[Top][All Lists]

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

Re: find-file-noselect needs save-match-data

From: Stefan Monnier
Subject: Re: find-file-noselect needs save-match-data
Date: Thu, 14 Jun 2007 12:22:43 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

> Excuse me but just another question: as Stefan said, 99% of
> non-trivial functions use regexps, does it mean that these 99%
> non-trivial functions shall not be put on the hooks that may be run
> between two regexp-sensitive functions/commands unless the putter
> saves match-data?

Normally, none of these functions will ever be put on a hook.
OTOH they may be called from other functions which are put on hooks.
It's the responsibility of *those* functions to use save-match-data.

Just like in the OP: find-file-noselect is not put on any hook.  It's some
other function from type-break which is put on a hook, so if there is a bug
it's in this other function, not in find-file-noselect.

> Btw, `post-command-hook' is the source of the original problem.

Indeed.  If the problem you posted is considered as a bug (I wouldn't
consider it as such), then a possible fix is the patch below:


--- orig/lisp/type-break.el
+++ mod/lisp/type-break.el
@@ -740,7 +740,7 @@
 (defun type-break-run-tb-post-command-hook ()
   (and type-break-mode
-       (run-hooks 'type-break-post-command-hook)))
+       (save-match-data (run-hooks 'type-break-post-command-hook))))
 (defun type-break-check ()
   "Ask to take a typing break if appropriate.
@@ -1274,5 +1274,5 @@
 (if type-break-mode
     (type-break-mode 1))
-;;; arch-tag: 943a2eb3-07e6-420b-993f-96e4796f5fd0
+;; arch-tag: 943a2eb3-07e6-420b-993f-96e4796f5fd0
 ;;; type-break.el ends here

reply via email to

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