[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rainbow-delimiters 2cde18809f 112/188: Use the syntax tabl
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rainbow-delimiters 2cde18809f 112/188: Use the syntax table to determine if a delimiters starts a comment. |
Date: |
Sat, 1 Jan 2022 00:58:57 -0500 (EST) |
branch: elpa/rainbow-delimiters
commit 2cde18809f7bb9d5c75a0b6bf893c81c2875d98e
Author: Fanael Linithien <fanael4@gmail.com>
Commit: Fanael Linithien <fanael4@gmail.com>
Use the syntax table to determine if a delimiters starts a comment.
Gets rid of the ugly comment-start-skip/comment-search-forward hack.
---
rainbow-delimiters.el | 31 ++++++++++++-------------------
1 file changed, 12 insertions(+), 19 deletions(-)
diff --git a/rainbow-delimiters.el b/rainbow-delimiters.el
index de1a38ca3b..092fd11803 100644
--- a/rainbow-delimiters.el
+++ b/rainbow-delimiters.el
@@ -89,7 +89,6 @@
;; - Intelligent support for other languages: Ruby, LaTeX tags, et al.
;;; Code:
-(require 'newcomment)
;;; Customize interface:
@@ -411,22 +410,18 @@ Returns t if char at loc meets one of the following
conditions:
(or
(nth 3 ppss) ; inside string?
(nth 4 ppss) ; inside comment?
- (when comment-start-skip ; starting a comment?
- (save-excursion
- (goto-char loc)
- ;; Fast path: if this test fails, it's not a comment, and we avoid a
- ;; costly `comment-search-forward' call.
- (when (let ((inhibit-changing-match-data t))
- (looking-at comment-start-skip))
- ;; Some major modes set `comment-start-skip' to not exactly what we
- ;; expect, catching more than actual comments. Use
- ;; `comment-search-forward' to see if it's really a comment.
- ;; NOTE: is lookahead of five characters enough for all languages? I
- ;; hope there's no language with 6-character comment delimiters.
- (save-match-data
- (let ((comment-start-pos (comment-search-forward (min (+ 5 loc)
(point-max)) t)))
- (when comment-start-pos
- (= loc comment-start-pos)))))))
+ (let ((loc-syntax (car (syntax-after loc)))) ; starting a comment?
+ ;; Note: no need to consider single-char openers, they're already handled
+ ;; by looking at ppss.
+ (cond
+ ;; Two character opener, LOC at the first character?
+ ((/= 0 (logand #x10000 loc-syntax))
+ (/= 0 (logand #x20000 (car (syntax-after (1+ loc))))))
+ ;; Two character opener, LOC at the second character?
+ ((/= 0 (logand #x20000 loc-syntax))
+ (/= 0 (logand #x10000 (or (car (syntax-after (1- loc))) 0))))
+ (t
+ nil)))
(when rainbow-delimiters-escaped-char-predicate
(funcall rainbow-delimiters-escaped-char-predicate loc))))
@@ -524,8 +519,6 @@ Used by font-lock for dynamic highlighting."
(defun rainbow-delimiters--mode-turn-on ()
"Set up `rainbow-delimiters-mode'."
- ;; Necessary for our use of `comment-search-forward'.
- (comment-normalize-vars t)
;; Flush the ppss cache now in case there's something left in there.
(setq rainbow-delimiters--parse-partial-sexp-cache nil)
(add-hook 'before-change-functions
#'rainbow-delimiters--syntax-ppss-flush-cache t t)
- [nongnu] elpa/rainbow-delimiters 3d425a85d3 094/188: Don't enable in Completion List Mode, (continued)
- [nongnu] elpa/rainbow-delimiters 3d425a85d3 094/188: Don't enable in Completion List Mode, ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters ecacb319d3 093/188: Wrap the font-lock-fontify-buffer call with with-no-warnings., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 6cdf1f1c14 096/188: Merge pull request #38 from lunaryorn/patch-1, ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters e2a67de8e7 097/188: Deprecate global-rainbow-delimiters-mode., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 29e7bfd8e4 098/188: Remove global-rainbow-delimiters-mode from installation instructions., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 4cc4d38479 099/188: Remove global-rainbow-delimiters-mode., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters d35b992378 106/188: Don't error when highlighting an unmatched closing delimiter., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters e48b7bf746 104/188: Merge pull request #41 from jlr/no-global, ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters f2404ef0bf 108/188: Remove dead code., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters cf61a3aee6 109/188: Use double hyphen to indicate internal symbols., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 2cde18809f 112/188: Use the syntax table to determine if a delimiters starts a comment.,
ELPA Syncer <=
- [nongnu] elpa/rainbow-delimiters 513bb785eb 114/188: Update authorship, package metadata, and URLs., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 4699fd94c8 115/188: Release version 1.3.13., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters ed5dd72f79 119/188: Restore the ability to disable the highlighting of selected delimiters., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters f5679e9040 120/188: Simplify two ifs by using max in their stead., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters b32fedb455 121/188: Remove an unneeded condition., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters d8de0c6954 122/188: Kill rainbow-delimiters--parse-partial-sexp-cache when turning off., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters f50a4ae177 123/188: Use `syntax-ppss` instead of our own implementation., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 50551159a7 124/188: Move rainbow-delimiters--mode-turn-{on, off} back into rainbow-delimiters-mode., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 44bd65920e 127/188: Remove the TODO list from rainbow-delimiters.el., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 25ceded842 128/188: Add MELPA and build status badges to the readme., ELPA Syncer, 2022/01/01