* (require 'cus-load) clobbers match-data
@ 2010-02-14 5:13 Geoff Gole
2010-02-14 7:01 ` David Kastrup
2010-02-16 20:13 ` Glenn Morris
0 siblings, 2 replies; 8+ messages in thread
From: Geoff Gole @ 2010-02-14 5:13 UTC (permalink / raw)
To: emacs-devel
While trying to puzzle out bug 5533
<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5533>, I've found that
(require 'cus-load) will stomp on match data if the file is not
already loaded:
emacs -Q
(let ((md (match-data)))
(require 'cus-load)
(equal md (match-data)))
=> t
This is what causes the bug, but I can't figure out why it is
happening. cus-load.el is just a big list of (put ...) forms. Why is
it stomping on the match data?
Anyway, if anybody knows how to stop it doing that, that would fix bug
5533. Maybe require should save and restore the match data itself?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: (require 'cus-load) clobbers match-data
2010-02-14 5:13 (require 'cus-load) clobbers match-data Geoff Gole
@ 2010-02-14 7:01 ` David Kastrup
2010-02-14 7:49 ` Geoff Gole
2010-02-16 20:13 ` Glenn Morris
1 sibling, 1 reply; 8+ messages in thread
From: David Kastrup @ 2010-02-14 7:01 UTC (permalink / raw)
To: emacs-devel
Geoff Gole <geoffgole@gmail.com> writes:
> While trying to puzzle out bug 5533
> <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5533>, I've found that
> (require 'cus-load) will stomp on match data if the file is not
> already loaded:
>
> emacs -Q
> (let ((md (match-data)))
> (require 'cus-load)
> (equal md (match-data)))
> => t
>
> This is what causes the bug, but I can't figure out why it is
> happening. cus-load.el is just a big list of (put ...) forms. Why is
> it stomping on the match data?
>
> Anyway, if anybody knows how to stop it doing that, that would fix bug
> 5533. Maybe require should save and restore the match data itself?
Maybe. Things like hack-local-variables and similar affect match data.
Everything that can autoload in some manner should save match data, I
guess.
--
David Kastrup
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: (require 'cus-load) clobbers match-data
2010-02-14 5:13 (require 'cus-load) clobbers match-data Geoff Gole
2010-02-14 7:01 ` David Kastrup
@ 2010-02-16 20:13 ` Glenn Morris
2010-02-16 20:25 ` Davis Herring
1 sibling, 1 reply; 8+ messages in thread
From: Glenn Morris @ 2010-02-16 20:13 UTC (permalink / raw)
To: Geoff Gole; +Cc: emacs-devel
Geoff Gole wrote:
> While trying to puzzle out bug 5533
> <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5533>, I've found that
> (require 'cus-load) will stomp on match data if the file is not
> already loaded:
I'm not sure that 5533 can reasonably be classed as a bug. It seems a
strange way to do a search-replace - what's wrong with M-x query-replace?
In general, there should be no expectation that any operation in Emacs
will preserve the match-data (unless it explicitly says so).
> Maybe require should save and restore the match data itself?
This would be completely unnecessary in the vast majority of cases.
Since a require can run arbitrary code, there should be no expectation
that it preserves match-data.
The usual answer to "why doesn't FOO preserve the match-data" is "the
code calling FOO should take care to preserve the match-data if it
cares about it", rather than "FOO should always preserve the
match-data".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: (require 'cus-load) clobbers match-data
2010-02-16 20:13 ` Glenn Morris
@ 2010-02-16 20:25 ` Davis Herring
2010-02-16 21:11 ` Andreas Schwab
0 siblings, 1 reply; 8+ messages in thread
From: Davis Herring @ 2010-02-16 20:25 UTC (permalink / raw)
To: Glenn Morris; +Cc: Geoff Gole, emacs-devel
> In general, there should be no expectation that any operation in Emacs
> will preserve the match-data (unless it explicitly says so).
>
>> Maybe require should save and restore the match data itself?
>
> This would be completely unnecessary in the vast majority of cases.
> Since a require can run arbitrary code, there should be no expectation
> that it preserves match-data.
This may not have been the original point, but loading a library can be
the result of calling an autoloaded function, even one that advertises
that it preserves the match data. In that case it makes sense for `load'
(or something else in that sequence) to save it; loading a file is
(typically) already expensive compared to `save-match-data'.
Davis
--
This product is sold by volume, not by mass. If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: (require 'cus-load) clobbers match-data
2010-02-16 20:25 ` Davis Herring
@ 2010-02-16 21:11 ` Andreas Schwab
0 siblings, 0 replies; 8+ messages in thread
From: Andreas Schwab @ 2010-02-16 21:11 UTC (permalink / raw)
To: herring; +Cc: Geoff Gole, emacs-devel
"Davis Herring" <herring@lanl.gov> writes:
> This may not have been the original point, but loading a library can be
> the result of calling an autoloaded function
Autoloading already preserves match-data, so there is no bug here.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-02-16 21:11 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-14 5:13 (require 'cus-load) clobbers match-data Geoff Gole
2010-02-14 7:01 ` David Kastrup
2010-02-14 7:49 ` Geoff Gole
2010-02-14 8:00 ` David Kastrup
2010-02-14 8:33 ` Geoff Gole
2010-02-16 20:13 ` Glenn Morris
2010-02-16 20:25 ` Davis Herring
2010-02-16 21:11 ` Andreas Schwab
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.