GNU bug report logs - #2499
doc fix for searching.texi

Previous Next

Package: emacs;

Reported by: tcr <at> freebits.de

Date: Fri, 27 Feb 2009 15:50:02 UTC

Severity: minor

Tags: fixed, notabug, patch

Fixed in version 24.1

Done: Lars Magne Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 2499 in the body.
You can then email your comments to 2499 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#2499; Package emacs. (Fri, 27 Feb 2009 15:50:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to tcr <at> freebits.de:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Fri, 27 Feb 2009 15:50:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: tcr <at> freebits.de
To: emacs-pretest-bug <at> gnu.org
Subject: 23.0.91;  syntax-ppss / beginning-of-defun not saving match data
Date: Fri, 27 Feb 2009 16:42:52 +0100
`beginning-of-defun' (and `syntax-ppss' as it invokes the former by
the variable `syntax-begin-function') does not save match data.

The issue also applies to 23.0.60.1, and 22.1.1.

Test case:

  (let ((buffer-sexpr "(defun *HERE*"))
  (with-temp-buffer
    (lisp-mode)
    (insert buffer-sexpr)
    (search-backward "*HERE*")
    (let ((old (match-data)))
      (progn (beginning-of-defun))
      (equal old (match-data)))))

               ==> nil

There are several possible options now:

  (i) `beginning-of-defun' is allowed to not save match data. If so,
      please document it.

  (ii) If (i) is true, still consider whether `syntax-ppss' is allowed
       to not save match data, too. Perhaps it should rather funcall
       `syntax-begin-function' wrapped in a `save-match-data'.
       Whatever the decision, please document it.

Thank you!


In GNU Emacs 23.0.91.1 (i686-pc-linux-gnu, GTK+ Version 2.12.9)
 of 2009-02-27 on thaleron
Windowing system distributor `The X.Org Foundation', version 11.0.10400090
configured using `configure  '--prefix=/home/tcr/software/emacs-cvs' '--with-x-toolkit=gtk' '--without-gpm' '--with-x' '--without-xpm' '--enable-asserts' 'CFLAGS=-g''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  eldoc-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<down> <return> C-x b * <backspace> <return> C-y C-M-x 
C-j <up> <up> <up> <right> <right> <right> <right> 
<right> <right> <right> M-d s a v e - m a t c h - d 
a t a C-e <down> C-j <up> <up> <right> <right> <right> 
<right> <right> <right> <right> <up> C-M-k r <backspace> 
p r o g n M-x r e p o r t - e m a c s - b u g <ret
urn>

Recent messages:
Loading /home/tcr/.emacs.d/config/lisp-config.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set
nil

-- 
Diese Nachricht wurde auf Viren und andere gefaerliche Inhalte untersucht
und ist - aktuelle Virenscanner vorausgesetzt - sauber.
Freebits E-Mail Virus Scanner





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#2499; Package emacs. (Sat, 28 Feb 2009 04:55:06 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sat, 28 Feb 2009 04:55:06 GMT) Full text and rfc822 format available.

Message #10 received at 2499 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: tcr <at> freebits.de
Cc: 2499 <at> debbugs.gnu.org
Subject: Re: bug#2499: 23.0.91; syntax-ppss / beginning-of-defun not saving match data
Date: Fri, 27 Feb 2009 23:50:32 -0500
>   (i) `beginning-of-defun' is allowed to not save match data. If so,
>       please document it.

99.9% of the functions are allowed to not save match data.  We do not
bother to document it.  We should document the functions that are not
allowed to do it, OTOH.


        Stefan





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#2499; Package emacs. (Sat, 28 Feb 2009 17:00:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Tobias C. Rittweiler" <tcr <at> freebits.de>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sat, 28 Feb 2009 17:00:04 GMT) Full text and rfc822 format available.

Message #15 received at 2499 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Tobias C. Rittweiler" <tcr <at> freebits.de>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 2499 <at> debbugs.gnu.org
Subject: Re: bug#2499: 23.0.91; syntax-ppss / beginning-of-defun not saving match data
Date: Sat, 28 Feb 2009 17:56:14 +0100
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> >   (i) `beginning-of-defun' is allowed to not save match data. If so,
> >       please document it.
>
> 99.9% of the functions are allowed to not save match data.  

Oh, I didn't know that! I thought the policy was the other way
around. (Perhaps 34.6, The Match Data, should make this policy more
explicit. If so, and you say so, I'll prepare a patch.)


> We do not bother to document it.  We should document the functions
> that are not allowed to do it, OTOH.

I think it's still worth to think about making `syntax-ppss' saving the
match data as this function may easily be implicitly invoked by
something deep down.

Thank you for your prompt reply!,

  -T.

-- 
Diese Nachricht wurde auf Viren und andere gefaerliche Inhalte untersucht
und ist - aktuelle Virenscanner vorausgesetzt - sauber.
Freebits E-Mail Virus Scanner





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#2499; Package emacs. (Sat, 28 Feb 2009 22:15:08 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sat, 28 Feb 2009 22:15:09 GMT) Full text and rfc822 format available.

Message #20 received at 2499 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: "Tobias C. Rittweiler" <tcr <at> freebits.de>
Cc: 2499 <at> debbugs.gnu.org
Subject: Re: bug#2499: 23.0.91; syntax-ppss / beginning-of-defun not saving match data
Date: Sat, 28 Feb 2009 17:09:29 -0500
>> >   (i) `beginning-of-defun' is allowed to not save match data. If so,
>> >       please document it.
>> 99.9% of the functions are allowed to not save match data.  
> Oh, I didn't know that! I thought the policy was the other way
> around. (Perhaps 34.6, The Match Data, should make this policy more
> explicit. If so, and you say so, I'll prepare a patch.)

Patch welcome.

>> We do not bother to document it.  We should document the functions
>> that are not allowed to do it, OTOH.
> I think it's still worth to think about making `syntax-ppss' saving the
> match data as this function may easily be implicitly invoked by
> something deep down.

Basically any function that does a non-trivial amount of work should be
expected to affect the match-data.  I.e. it's the responsability of the
match-data user to make sure she reads the match-data soon after the
regexp match took place, rather than responsability of all other
functions to preserve the match-data.


        Stefan




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#2499; Package emacs. (Tue, 03 Mar 2009 21:10:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Tobias C. Rittweiler" <tcr <at> freebits.de>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Tue, 03 Mar 2009 21:10:04 GMT) Full text and rfc822 format available.

Message #25 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Tobias C. Rittweiler" <tcr <at> freebits.de>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#2499: 23.0.91; syntax-ppss / beginning-of-defun not saving match data
Date: Tue, 03 Mar 2009 21:50:45 +0100
[Message part 1 (text/plain, inline)]
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> > > >   (i) `beginning-of-defun' is allowed to not save match data. If so,
> > > >       please document it.
> > >
> > > 99.9% of the functions are allowed to not save match data.  
> >
> > Oh, I didn't know that! I thought the policy was the other way
> > around. (Perhaps 34.6, The Match Data, should make this policy more
> > explicit. If so, and you say so, I'll prepare a patch.)
>
> Patch welcome.

Attached.

  -T.

[match-data-lispref.diff (text/x-diff, inline)]
Index: doc/lispref/searching.texi
===================================================================
RCS file: /sources/emacs/emacs/doc/lispref/searching.texi,v
retrieving revision 1.11
diff -u -r1.11 searching.texi
--- doc/lispref/searching.texi	8 Jan 2009 05:29:01 -0000	1.11
+++ doc/lispref/searching.texi	3 Mar 2009 20:48:30 -0000
@@ -1204,6 +1204,12 @@
 can't avoid another intervening search, you must save and restore the
 match data around it, to prevent it from being overwritten.
 
+  Notice that all functions are allowed to overwrite the match data
+unless they're explicitly documented not to do so. A consequence is that
+functions that are run implictly in the background (@pxref{Timers}, and
+@ref{Idle Timers}) should likely save and restore the match data
+explicitly.
+
 @menu
 * Replacing Match::	  Replacing a substring that was matched.
 * Simple Match Data::     Accessing single items of match data,

Tags added: notabug Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Wed, 04 Mar 2009 01:15:05 GMT) Full text and rfc822 format available.

Severity set to `minor' from `normal' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Wed, 04 Mar 2009 01:15:05 GMT) Full text and rfc822 format available.

Added tag(s) patch. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 20 Jan 2010 01:41:02 GMT) Full text and rfc822 format available.

Changed bug title to 'doc fix for searching.texi' from '23.0.91; syntax-ppss / beginning-of-defun not saving match data' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Mon, 07 Mar 2011 01:56:02 GMT) Full text and rfc822 format available.

Added tag(s) fixed. Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 03 Jul 2011 18:47:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 24.1, send any further explanations to 2499 <at> debbugs.gnu.org and tcr <at> freebits.de Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 03 Jul 2011 18:47:02 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#2499; Package emacs. (Sun, 03 Jul 2011 18:56:01 GMT) Full text and rfc822 format available.

Message #40 received at 2499 <at> debbugs.gnu.org (full text, mbox):

From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: "Tobias C. Rittweiler" <tcr <at> freebits.de>
Cc: 2499 <at> debbugs.gnu.org
Subject: Re: bug#2499: 23.0.91;
	syntax-ppss / beginning-of-defun not saving match data
Date: Sun, 03 Jul 2011 20:45:36 +0200
"Tobias C. Rittweiler" <tcr <at> freebits.de> writes:

>> Patch welcome.
>
> Attached.

I've now applied your patch to Emacs 24.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 01 Aug 2011 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 281 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.