unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Document that failed search/match preserves match data
@ 2003-05-09 14:14 Stephen J. Turnbull
  2003-05-10 17:15 ` Richard Stallman
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen J. Turnbull @ 2003-05-09 14:14 UTC (permalink / raw)


Currently in both XEmacs and Emacs a failed search will preserve the
match data from the last successful search (this is true for XEmacs
from regression testing and verifying the code, and if I interpreted a
communication with Stefan Monnier correctly, it is true for Emacs).

However, until now the documentation for both Emacsen strongly implied
(to my mind) that any call to a search or match function would clobber
the match data.  As an experiment, in XEmacs I changed it to clear the
match data even on failure, and (as you would expect) got a bunch of
bug reports.  This led me to some elegant examples (the function
`w3-configuration-data' in "w3-cfg" is a good one, I think) which
depend on match failure preserving previous match data in an essential
way.  (Of course you could work around it but it would be real ugly.)

I propose that the docstrings and Info documentation for both Emacsen
be amended to reflect the (common) behavior of the implementations,
since it seems to be useful.  That is, we state that

"On success, a search or match sets the match data for the whole
expression and any matched subexpressions.  If the search or match
fails, the match data from the most recent successful search will be
preserved.  (You should not depend on the match data being preserved
in case of an error in the search function.)"[1]



Footnotes: 
[1]  In the case of XEmacs, I'm pretty sure that even on errors the
previous match data is preserved, but of course that's a little harder
to be sure of than with normal termination.



-- 
Institute of Policy and Planning Sciences     http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Document that failed search/match preserves match data
  2003-05-09 14:14 Document that failed search/match preserves match data Stephen J. Turnbull
@ 2003-05-10 17:15 ` Richard Stallman
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Stallman @ 2003-05-10 17:15 UTC (permalink / raw)
  Cc: emacs-devel

    "On success, a search or match sets the match data for the whole
    expression and any matched subexpressions.  If the search or match
    fails, the match data from the most recent successful search will be
    preserved.  (You should not depend on the match data being preserved
    in case of an error in the search function.)"[1]

That text looks good for the manual, except that I would interpret
"fails" as including the error case.  That is the first case that came
to my mind when I read those words--only after reading the last
sentence did I realize you must mean only when the search function
returns nil.

It would be better to say "when the function returns nil".

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-05-10 17:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-09 14:14 Document that failed search/match preserves match data Stephen J. Turnbull
2003-05-10 17:15 ` 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).