unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Leo Liu <sdl.web@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 14395@debbugs.gnu.org
Subject: bug#14395: 24.3; [PATCH] new feature smie-highlight-matching-block
Date: Fri, 17 May 2013 09:30:34 +0800	[thread overview]
Message-ID: <m1mwrutmth.fsf@gmail.com> (raw)
In-Reply-To: <jwv7giybfvo.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Thu, 16 May 2013 20:40:39 -0400")

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
smie-highlight-matching-block-mode?

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 nil
   (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	other threads:[~2013-05-17  1:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-14  2:49 bug#14395: 24.3; [PATCH] new feature smie-highlight-matching-block Leo Liu
2013-05-14 16:02 ` Stefan Monnier
2013-05-15  7:13   ` Leo Liu
2013-05-16  2:31     ` Stefan Monnier
2013-05-16  3:27       ` Leo Liu
2013-05-16 13:24         ` Stefan Monnier
2013-05-16 16:06           ` Leo Liu
2013-05-16 17:51             ` Stefan Monnier
2013-05-16 23:09               ` Leo Liu
2013-05-17  0:40                 ` Stefan Monnier
2013-05-17  1:30                   ` Leo Liu [this message]
2013-05-22 18:50                     ` Stefan Monnier
2013-05-16  4:45       ` Glenn Morris
2013-05-16  5:33         ` Leo Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1mwrutmth.fsf@gmail.com \
    --to=sdl.web@gmail.com \
    --cc=14395@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).