[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rainbow-delimiters 49fb05303a 090/188: Use when/if instead
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rainbow-delimiters 49fb05303a 090/188: Use when/if instead of and/or+and. |
Date: |
Sat, 1 Jan 2022 00:58:55 -0500 (EST) |
branch: elpa/rainbow-delimiters
commit 49fb05303a349c0a595095714f0cb5398d5e9ec8
Author: Fanael Linithien <fanael4@gmail.com>
Commit: Fanael Linithien <fanael4@gmail.com>
Use when/if instead of and/or+and.
---
rainbow-delimiters.el | 75 +++++++++++++++++++++++++--------------------------
1 file changed, 37 insertions(+), 38 deletions(-)
diff --git a/rainbow-delimiters.el b/rainbow-delimiters.el
index 759d6bb401..7c08128798 100644
--- a/rainbow-delimiters.el
+++ b/rainbow-delimiters.el
@@ -259,17 +259,16 @@ For example: `rainbow-delimiters-depth-1-face'."
(intern-soft
(concat "rainbow-delimiters-depth-"
(number-to-string
- (or
- ;; Our nesting depth has a face defined for it.
- (and (<= depth rainbow-delimiters-max-face-count)
- depth)
- ;; Deeper than # of defined faces; cycle back through to
- ;; `rainbow-delimiters-outermost-only-face-count' + 1.
- ;; Return face # that corresponds to current nesting level.
- (+ 1 rainbow-delimiters-outermost-only-face-count
- (mod (- depth rainbow-delimiters-max-face-count 1)
- (- rainbow-delimiters-max-face-count
- rainbow-delimiters-outermost-only-face-count)))))
+ (if (<= depth rainbow-delimiters-max-face-count)
+ ;; Our nesting depth has a face defined for it.
+ depth
+ ;; Deeper than # of defined faces; cycle back through to
+ ;; `rainbow-delimiters-outermost-only-face-count' + 1.
+ ;; Return face # that corresponds to current nesting level.
+ (+ 1 rainbow-delimiters-outermost-only-face-count
+ (mod (- depth rainbow-delimiters-max-face-count 1)
+ (- rainbow-delimiters-max-face-count
+ rainbow-delimiters-outermost-only-face-count)))))
"-face")))
;;; Parse partial sexp cache
@@ -436,24 +435,24 @@ Returns t if char at loc meets one of the following
conditions:
(or
(nth 3 ppss) ; inside string?
(nth 4 ppss) ; inside comment?
- (and comment-start-skip ; starting a comment?
- (save-excursion
- (goto-char loc)
- (and
- ;; Fast path: if this test fails, it's not a comment, and we avoid a
- ;; costly `comment-search-forward' call.
- (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)))
- (and comment-start-pos (= loc comment-start-pos)))))))
- (and rainbow-delimiters-escaped-char-predicate
- (funcall rainbow-delimiters-escaped-char-predicate loc))))
+ (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)))))))
+ (when rainbow-delimiters-escaped-char-predicate
+ (funcall rainbow-delimiters-escaped-char-predicate loc))))
(defun rainbow-delimiters-apply-color (delim depth loc match)
"Apply color for DEPTH to DELIM at LOC following user settings.
@@ -462,13 +461,12 @@ DELIM is a string specifying delimiter type.
DEPTH is the delimiter depth, or corresponding face # if colors are repeating.
LOC is location of character (delimiter) to be colorized.
MATCH is nil iff it's a mismatched closing delimiter."
- (and
- ;; Ensure user has enabled highlighting of this delimiter type.
- (symbol-value (intern-soft
- (concat "rainbow-delimiters-highlight-" delim "s-p")))
- (rainbow-delimiters-propertize-delimiter loc
- depth
- match)))
+ ;; Ensure user has enabled highlighting of this delimiter type.
+ (when (symbol-value (intern-soft
+ (concat "rainbow-delimiters-highlight-" delim "s-p")))
+ (rainbow-delimiters-propertize-delimiter loc
+ depth
+ match)))
;;; Font-Lock functionality
@@ -529,8 +527,9 @@ Used by font-lock for dynamic highlighting."
delim-pos
(= (nth 1
closing-delim-info)
matching-opening-delim))
- (setq depth (or (and (<= depth 0) 0) ; unmatched delim
- (1- depth))))))))))))
+ (setq depth (if (<= depth 0)
+ 0 ; unmatched delim
+ (1- depth))))))))))))
;; We already fontified the delimiters, tell font-lock there's nothing more
;; to do.
nil)
- [nongnu] elpa/rainbow-delimiters aff2162d35 044/188: Merge pull request #13 from habib/master, (continued)
- [nongnu] elpa/rainbow-delimiters aff2162d35 044/188: Merge pull request #13 from habib/master, ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters d59a5a53b8 032/188: In emacs 24 it is possible to hook it to `prog-modes-hook`, so it is enabled for **all** programming modes., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters b78dd93407 048/188: Silence the byte compiler warnings., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 40c2aa5ce3 028/188: Update description and commentary at top of file., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 9c4950a283 060/188: Properly tear down the mode when changing major mode., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 75acc28109 063/188: Release version 1.3.7., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters a1cd80ee8d 073/188: Remove the changelog., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 0fa4723a9d 080/188: Add rainbow-delimiters-ignore-modes, ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters df4976a965 086/188: Release version 1.3.9., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters b85b86c0b4 088/188: Release version 1.3.10., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 49fb05303a 090/188: Use when/if instead of and/or+and.,
ELPA Syncer <=
- [nongnu] elpa/rainbow-delimiters 3a18183db3 092/188: Remove cider-repl-mode from rainbow-delimiters-ignore-modes., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 5a56248229 101/188: Pass the variable symbol to rainbow-delimiters-apply-color directly., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters e05dd60c12 100/188: Don't propertize if the syntax table is unset, ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters d4d8f74158 110/188: Use #' to quote function names., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 575620510f 111/188: Reindent after cf61a3aee6., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 0a4e4958ed 113/188: Add a missing or in rainbow-delimiters--char-ineligible-p., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 1473fbddce 116/188: Add a test suite., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 89574443f0 117/188: Fix the Emacs 24.3-specific test failure., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 30c6a4c1bc 118/188: Use the major mode's syntax table directly., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 406ee45e7c 126/188: Rewrite the installation and usage instructions., ELPA Syncer, 2022/01/01