[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#14395: 24.3; [PATCH] new feature smie-highlight-matching-block

From: Leo Liu
Subject: bug#14395: 24.3; [PATCH] new feature smie-highlight-matching-block
Date: Fri, 17 May 2013 09:30:34 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (OS X 10.8.3)

On 2013-05-17 08:40 +0800, Stefan Monnier wrote:
> But in terms of functionality, your minor mode provides a behavior
> comparable to show-paren-mode, I think.

I agree.

> So maybe the better thing to do now is to try and see how to integrate
> so that it "just works" for people who use show-paren-mode.  Just like
> smie-blink-matching-open makes blink-matching-paren "just work".

Would it be OK if we let show-paren-mode turn on

I just realised that it doesn't clean up the overlays when
smie-highlight-matching-block-mode is turned off.

Should I install something like this? An alternative fix might be not to
make smie--highlight-matching-block-overlay buffer-local which is easier
to clean up.

diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el
index 21134578..3e78b76b 100644
--- a/lisp/emacs-lisp/smie.el
+++ b/lisp/emacs-lisp/smie.el
@@ -1095,10 +1095,17 @@ (define-minor-mode smie-highlight-matching-block-mode 
   (when (timerp smie--highlight-matching-block-timer)
     (cancel-timer smie--highlight-matching-block-timer))
   (setq smie--highlight-matching-block-timer nil)
-  (when smie-highlight-matching-block-mode
-    (remove-hook 'post-self-insert-hook #'smie-blink-matching-open 'local)
-    (setq smie--highlight-matching-block-timer
-          (run-with-idle-timer 0.2 t #'smie-highlight-matching-block))))
+  (if smie-highlight-matching-block-mode
+      (progn
+        (remove-hook 'post-self-insert-hook #'smie-blink-matching-open 'local)
+        (setq smie--highlight-matching-block-timer
+              (run-with-idle-timer 0.2 t #'smie-highlight-matching-block)))
+    ;; Clean up.
+    (dolist (b (buffer-list))
+      (with-current-buffer b
+        (when (overlayp smie--highlight-matching-block-overlay)
+          (delete-overlay smie--highlight-matching-block-overlay)
+          (kill-local-variable smie--highlight-matching-block-overlay))))))
 ;;; The indentation engine.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]