[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rainbow-delimiters 9c4950a283 060/188: Properly tear down
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rainbow-delimiters 9c4950a283 060/188: Properly tear down the mode when changing major mode. |
Date: |
Sat, 1 Jan 2022 00:58:52 -0500 (EST) |
branch: elpa/rainbow-delimiters
commit 9c4950a28390300bf8003d4d20ee682e02eda608
Author: Fanael Linithien <fanael4@gmail.com>
Commit: Fanael Linithien <fanael4@gmail.com>
Properly tear down the mode when changing major mode.
Unpropertize is now run when changing major mode, so stale highlighting
will not carry on from the previous major mode.
---
rainbow-delimiters.el | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/rainbow-delimiters.el b/rainbow-delimiters.el
index 0ec8871d92..b8ded8a84a 100644
--- a/rainbow-delimiters.el
+++ b/rainbow-delimiters.el
@@ -581,22 +581,32 @@ Used by jit-lock for dynamic highlighting."
;;; Minor mode:
+(defun rainbow-delimiters-mode-turn-on ()
+ "Set up `rainbow-delimiters-mode'."
+ ;; 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)
+ (add-hook 'change-major-mode-hook 'rainbow-delimiters-mode-turn-off nil t)
+ (jit-lock-register 'rainbow-delimiters-propertize-region t)
+ ;; Create necessary syntax tables inheriting from current major-mode.
+ (set (make-local-variable 'rainbow-delimiters-syntax-table)
+ (rainbow-delimiters-make-syntax-table (syntax-table))))
+
+(defun rainbow-delimiters-mode-turn-off ()
+ "Tear down `rainbow-delimiters-mode'."
+ (kill-local-variable 'rainbow-delimiters-syntax-table)
+ (rainbow-delimiters-unpropertize-region (point-min) (point-max))
+ (jit-lock-unregister 'rainbow-delimiters-propertize-region)
+ (remove-hook 'change-major-mode-hook 'rainbow-delimiters-mode-turn-off t)
+ (remove-hook 'before-change-functions
'rainbow-delimiters-syntax-ppss-flush-cache t))
+
;;;###autoload
(define-minor-mode rainbow-delimiters-mode
"Highlight nested parentheses, brackets, and braces according to their
depth."
nil "" nil ; No modeline lighter - it's already obvious when the mode is on.
- (if (not rainbow-delimiters-mode)
- (progn
- (remove-hook 'before-change-functions
'rainbow-delimiters-syntax-ppss-flush-cache t)
- (jit-lock-unregister 'rainbow-delimiters-propertize-region)
- (rainbow-delimiters-unpropertize-region (point-min) (point-max)))
- ;; 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)
- (jit-lock-register 'rainbow-delimiters-propertize-region t)
- ;; Create necessary syntax tables inheriting from current major-mode.
- (set (make-local-variable 'rainbow-delimiters-syntax-table)
- (rainbow-delimiters-make-syntax-table (syntax-table)))))
+ (if rainbow-delimiters-mode
+ (rainbow-delimiters-mode-turn-on)
+ (rainbow-delimiters-mode-turn-off)))
;;;###autoload
(defun rainbow-delimiters-mode-enable ()
- [nongnu] elpa/rainbow-delimiters 0444666196 025/188: Note Bugfix of syntax-table problem in the 1.4 release notes., (continued)
- [nongnu] elpa/rainbow-delimiters 0444666196 025/188: Note Bugfix of syntax-table problem in the 1.4 release notes., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 8a8ee4e4e1 039/188: Merge branch 'master' of github.com:jlr/rainbow-delimiters, ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 493b514ae7 037/188: Color scheme for light backgrounds., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters d44ed19ade 030/188: Note that rainbow-delimiters-depth-1-face only gets applied to outermost delimiter pair. (Stylistically this is nice because it makes the outermost pair distinct.), ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 54855dcf52 062/188: Revert a part of 3dfd3fa9b that shouldn't be changed in the first place., ELPA Syncer, 2022/01/01
- [nongnu] elpa/rainbow-delimiters 4fc4352c0d 031/188: Release rainbow-delimiters.el version 1.3.3., ELPA Syncer, 2022/01/01
- [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 <=
- [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, 2022/01/01
- [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