* timers and match-data
@ 2005-05-31 1:40 Luc Teirlinck
2005-05-31 3:18 ` Luc Teirlinck
2005-05-31 17:47 ` Richard Stallman
0 siblings, 2 replies; 3+ messages in thread
From: Luc Teirlinck @ 2005-05-31 1:40 UTC (permalink / raw)
(elisp)Saving Match Data contains:
Emacs automatically saves and restores the match data when it runs
process filter functions (*note Filter Functions::) and process
sentinels (*note Sentinels::).
But this apparently does not apply to timers.
This leads to very concrete problems. If one autoreverts the Buffer
Menu, if Buffer-menu-use-header-line is t, enable-local-variables is
'ask and one does `C-h n' and waits too long before answering `y' to
the y-or-n-p question,, the NEWS does not get put in Outline Mode,
because of a Local Variables error, due to the fact that autoreverting
the Buffer Menu changed the match data.
To avoid such problems, either:
1. Every function that waits for input or otherwise allows for timers
to run should save and restore the match data.
2. We should make timers automatically save and restore match data.
3. Any individual timer function that potentially could alter the
match data should save and restore the match data.
Which one?
If (3), I could make autorevert use save-match-data. If (1), the
patch below to files.el solves the `C-h n' problem.
===File ~/files-diff========================================
*** files.el 20 May 2005 21:47:22 -0500 1.772
--- files.el 30 May 2005 19:26:40 -0500
***************
*** 2172,2181 ****
(save-excursion
(beginning-of-line)
(set-window-start (selected-window) (point)))
! (y-or-n-p (format string
! (if buffer-file-name
! (file-name-nondirectory buffer-file-name)
! (concat "buffer " (buffer-name)))))))))
(defun hack-local-variables-prop-line (&optional mode-only)
"Set local variables specified in the -*- line.
--- 2172,2182 ----
(save-excursion
(beginning-of-line)
(set-window-start (selected-window) (point)))
! (save-match-data
! (y-or-n-p (format string
! (if buffer-file-name
! (file-name-nondirectory buffer-file-name)
! (concat "buffer " (buffer-name))))))))))
(defun hack-local-variables-prop-line (&optional mode-only)
"Set local variables specified in the -*- line.
============================================================
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: timers and match-data
2005-05-31 1:40 timers and match-data Luc Teirlinck
@ 2005-05-31 3:18 ` Luc Teirlinck
2005-05-31 17:47 ` Richard Stallman
1 sibling, 0 replies; 3+ messages in thread
From: Luc Teirlinck @ 2005-05-31 3:18 UTC (permalink / raw)
>From my prior message:
1. Every function that waits for input or otherwise allows for timers
to run should save and restore the match data.
This is probably not unreasonable, as every function that asks a
minibuffer question already needs to store the match data for other
reasons anyway: the user could mess it up in tons of ways.
Sincerely,
Luc.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: timers and match-data
2005-05-31 1:40 timers and match-data Luc Teirlinck
2005-05-31 3:18 ` Luc Teirlinck
@ 2005-05-31 17:47 ` Richard Stallman
1 sibling, 0 replies; 3+ messages in thread
From: Richard Stallman @ 2005-05-31 17:47 UTC (permalink / raw)
Cc: emacs-devel
To avoid such problems, either:
1. Every function that waits for input or otherwise allows for timers
to run should save and restore the match data.
2. We should make timers automatically save and restore match data.
3. Any individual timer function that potentially could alter the
match data should save and restore the match data.
Which one?
Currently, #3 is the way it is supposed to work.
However, converting to #2 might be an improvement.
It would be cleaner, but it might be less efficient;
surely most timer functions are rather small and don't
alter the match data.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-05-31 17:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-31 1:40 timers and match-data Luc Teirlinck
2005-05-31 3:18 ` Luc Teirlinck
2005-05-31 17:47 ` Richard Stallman
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).