GNU bug report logs - #5689
looking-back-p

Previous Next

Package: emacs;

Reported by: Devon Sean McCullough <Emacs-hacker <at> Jovi.Net>

Date: Sat, 6 Mar 2010 19:45:02 UTC

Severity: wishlist

Tags: wontfix

Done: Lars 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 5689 in the body.
You can then email your comments to 5689 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 owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5689; Package emacs. (Sat, 06 Mar 2010 19:45:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Devon Sean McCullough <Emacs-hacker <at> Jovi.Net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 06 Mar 2010 19:45:02 GMT) Full text and rfc822 format available.

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

From: Devon Sean McCullough <Emacs-hacker <at> Jovi.Net>
To: emacs-pretest-bug <at> gnu.org
Subject: looking-back-p
Date: Sat, 6 Mar 2010 13:29:46 -0500 (EST)
Please include the missing looking-back-p
either as a subst like looking-at-p and string-match-p

--- lisp/subr.el.~1.667.~	2009-11-24 22:59:23.000000000 -0500
+++ lisp/subr.el	2010-03-06 12:52:30.000000000 -0500
@@ -2984,6 +2984,12 @@
   (let ((inhibit-changing-match-data t))
     (looking-at regexp)))
 
+(defsubst looking-back-p (regexp &optional limit greedy)
+  "\
+Same as `looking-back' except this saves the match data."
+  (save-match-data
+    (looking-back regexp limit greedy)))
+
 (defsubst string-match-p (regexp string &optional start)
   "\
 Same as `string-match' except this function does not change the match data."

or as a macro like

--- lisp/subr.el.~1.667.~	2009-11-24 22:59:23.000000000 -0500
+++ lisp/subr.el	2010-03-06 13:18:53.000000000 -0500
@@ -2984,6 +2984,14 @@
   (let ((inhibit-changing-match-data t))
     (looking-at regexp)))
 
+(defmacro looking-back-p (&rest args)
+  "\
+Same as `looking-back' except this saves the match data.
+
+\(fn REGEXP &optional LIMIT GREEDY)"
+  `(save-match-data
+     (looking-back .,args)))
+
 (defsubst string-match-p (regexp string &optional start)
   "\
 Same as `string-match' except this function does not change the match data."



Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5689; Package emacs. (Sat, 06 Mar 2010 21:23:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Devon Sean McCullough <Emacs-hacker <at> Jovi.Net>
Cc: 5689 <at> debbugs.gnu.org
Subject: Re: bug#5689: looking-back-p
Date: Sat, 06 Mar 2010 16:21:54 -0500
> Please include the missing looking-back-p

looking-back is a function that people should generally try to avoid,
because it's very costly and its behavior is not always as people
might expect.  So if anything, I'd rename it to
do-something-like-looking-at-but-going-backward and would definitely
refrain from providing a "-p" alternative that would make it sound like
"it's more lightweight" even tho it's actually even worse (tho
unnoticeably so).



        Stefan






Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5689; Package emacs. (Sun, 07 Mar 2010 12:16:02 GMT) Full text and rfc822 format available.

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

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: Devon Sean McCullough <Emacs-hacker <at> Jovi.Net>
Cc: 5689 <at> debbugs.gnu.org
Subject: Re: bug#5689: looking-back-p
Date: Sun, 07 Mar 2010 13:17:03 +0100
Devon Sean McCullough wrote:
> Please include the missing looking-back-p
> either as a subst like looking-at-p and string-match-p
> 
> --- lisp/subr.el.~1.667.~	2009-11-24 22:59:23.000000000 -0500
> +++ lisp/subr.el	2010-03-06 12:52:30.000000000 -0500
> @@ -2984,6 +2984,12 @@
>    (let ((inhibit-changing-match-data t))
>      (looking-at regexp)))
>  
> +(defsubst looking-back-p (regexp &optional limit greedy)
> +  "\
> +Same as `looking-back' except this saves the match data."
> +  (save-match-data
> +    (looking-back regexp limit greedy)))
> +
>  (defsubst string-match-p (regexp string &optional start)
>    "\
>  Same as `string-match' except this function does not change the match data."
> 
> or as a macro like
> 
> --- lisp/subr.el.~1.667.~	2009-11-24 22:59:23.000000000 -0500
> +++ lisp/subr.el	2010-03-06 13:18:53.000000000 -0500
> @@ -2984,6 +2984,14 @@
>    (let ((inhibit-changing-match-data t))
>      (looking-at regexp)))
>  
> +(defmacro looking-back-p (&rest args)
> +  "\
> +Same as `looking-back' except this saves the match data.
> +
> +\(fn REGEXP &optional LIMIT GREEDY)"
> +  `(save-match-data
> +     (looking-back .,args)))
> +
>  (defsubst string-match-p (regexp string &optional start)
>    "\
>  Same as `string-match' except this function does not change the match data."
> 
> 
> 
> 


Hi Devon,

thanks a lot.

As a change usually has pros and cons, just my personal
view:

`save-match-data' changes the way of execution, I'd
like to see it expressingly.

Think code is pretty good readable as it's now.

Andreas





Severity set to 'wishlist' from 'normal' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Mon, 08 Mar 2010 19:31:02 GMT) Full text and rfc822 format available.

Added tag(s) wontfix. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Mon, 08 Mar 2010 19:31:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 5689 <at> debbugs.gnu.org and Devon Sean McCullough <Emacs-hacker <at> Jovi.Net> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 01 Feb 2014 07:30:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 01 Mar 2014 12:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 273 days ago.

Previous Next


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