[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rainbow-delimiters f5679e9040 120/188: Simplify two ifs by
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rainbow-delimiters f5679e9040 120/188: Simplify two ifs by using max in their stead. |
Date: |
Sat, 1 Jan 2022 00:58:58 -0500 (EST) |
branch: elpa/rainbow-delimiters
commit f5679e904033e0b5dcac0eb3160e324213cd2cd1
Author: Fanael Linithien <fanael4@gmail.com>
Commit: Fanael Linithien <fanael4@gmail.com>
Simplify two ifs by using max in their stead.
---
rainbow-delimiters.el | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/rainbow-delimiters.el b/rainbow-delimiters.el
index a223516677..efaad948d8 100644
--- a/rainbow-delimiters.el
+++ b/rainbow-delimiters.el
@@ -287,15 +287,6 @@ to work around a bug."
(rainbow-delimiters--syntax-ppss-run (car nearest-before) pos (cdr
nearest-before))
(rainbow-delimiters--syntax-ppss-run (point-min) pos nil))))))
-;;; Nesting level
-
-(defun rainbow-delimiters--depth (ppss)
- "Return # of nested levels of delimiters at parse state PPSS."
- (let ((depth (car ppss)))
- (if (>= depth 0)
- depth
- 0))) ; Ignore negative depths created by unmatched closing parens.
-
;;; Text properties
(defun rainbow-delimiters--propertize-delimiter (loc depth match)
@@ -391,7 +382,8 @@ Used by font-lock for dynamic highlighting."
;; Point can be anywhere in buffer; determine the nesting depth at point.
(let* ((last-ppss-pos (point))
(ppss (rainbow-delimiters--syntax-ppss last-ppss-pos))
- (depth (rainbow-delimiters--depth ppss)))
+ ;; Ignore negative depths created by unmatched closing delimiters.
+ (depth (max 0 (nth 0 ppss))))
(while (and (< (point) end)
(re-search-forward rainbow-delimiters--delim-regex end t))
(let* ((delim-pos (match-beginning 0))
@@ -412,9 +404,9 @@ Used by font-lock for dynamic highlighting."
delim-pos
(eq (cdr delim-syntax)
matching-opening-delim))
- (setq depth (if (<= depth 0)
- 0 ; unmatched delim
- (1- depth))))))))))
+ ;; Don't let `depth' go negative, even if there's an unmatched
+ ;; delimiter.
+ (setq depth (max 0 (1- depth))))))))))
;; We already fontified the delimiters, tell font-lock there's nothing more
;; to do.
nil)
- [nongnu] elpa/rainbow-delimiters 29e7bfd8e4 098/188: Remove global-rainbow-delimiters-mode from installation instructions., (continued)
- [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, 2022/01/01
- [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 <=
- [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
- [nongnu] elpa/rainbow-delimiters df63c842a3 131/188: Update the customization instructions., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 845e681fae 135/188: Use lexical-binding., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters d723eb0a8c 134/188: In the C++ template syntax test, remove some text properties., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 039e9345c5 136/188: Document why there's no Emacs 24 requirement., ELPA Syncer, 2022/01/01