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

>>> +(define-minor-mode smie-highlight-matching-block-mode nil
>> Please provide a docstring.
> Is the automatically-provided docstring good enough?

Oh, right, I guess it is, sorry I forgot that I tried to make
define-minor-mode DTRT.

> +(define-minor-mode smie-highlight-matching-block-mode nil :global t
> +  (when (timerp smie--highlight-matching-block-timer)
> +    (cancel-timer smie--highlight-matching-block-timer))
> +  (if smie-highlight-matching-block-mode
> +      (setq smie--highlight-matching-block-timer
> +            (run-with-idle-timer 0.2 t #'smie-highlight-matching-block))
> +    (when (timerp smie--highlight-matching-block-timer)
> +      (cancel-timer smie--highlight-matching-block-timer))
> +    (setq smie--highlight-matching-block-timer nil)))

No, need to "cancel" twice when disabling the mode.

> -      (add-hook 'post-self-insert-hook
> -                #'smie-blink-matching-open 'append 'local)
> +      (if smie-highlight-matching-block-mode
> +          (remove-hook 'post-self-insert-hook
> +                       #'smie-blink-matching-open 'local)
> +        (add-hook 'post-self-insert-hook
> +                  #'smie-blink-matching-open 'append 'local))

I think the `remove-hook' should be done within the body of the
smie-highlight-matching-block-mode minor mode rather than here.
In here, you just need to wrap the add-hook within a test of
smie-highlight-matching-block-mode.

BTW.  Is there a non-SMIE version of "highlight-matching-block-mode",
which does it for parentheses?  If yes, maybe 
smie-highlight-matching-block-mode should integrate into it.

One more thought, maybe you were right that futzing around with
add/remove-hook is too complicated and it's easier to check a variable.
But then maybe smie-highlight-matching-block-mode should set
blink-matching-paren to nil (which brings us back to whether there's
a global highlight-matching-block-mode working not just for modes using
SMIE).


        Stefan





  reply	other threads:[~2013-05-16 13:24 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 [this message]
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
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=jwvli7fdq55.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=14395@debbugs.gnu.org \
    --cc=sdl.web@gmail.com \
    /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).