[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: Stefan Monnier
Subject: bug#14395: 24.3; [PATCH] new feature smie-highlight-matching-block
Date: Thu, 16 May 2013 09:24:08 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

>>> +(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

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


reply via email to

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