GNU bug report logs -
#11025
23.1; re-search-backward does not find the right beginning of the regexp
Previous Next
Reported by: Jack Duthen <duthen.mac.01 <at> gmail.com>
Date: Fri, 16 Mar 2012 16:50:02 UTC
Severity: minor
Tags: notabug
Merged with 9681,
24801
Found in versions 23.1, 25.1
Done: npostavs <at> users.sourceforge.net
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 11025 in the body.
You can then email your comments to 11025 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11025
; Package
emacs
.
(Fri, 16 Mar 2012 16:50:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Jack Duthen <duthen.mac.01 <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 16 Mar 2012 16:50:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
--text follows this line--
Hello,
I'm editing a ".el" file, in emacs-lisp-mode,
and I use the standard value of `comment-start-skip':
;;; (insert comment-start-skip)
"\(\(^\|[^\\
]\)\(\\\\\)*\);+ *" <-- I added the quotes here
;;; Test #1
;;; (progn (beginning-of-line) (looking-at comment-start-skip))
;;; Move the point at the end of the previous line and type C-x C-e
;;; It moves the point at the beginning of the line and returns T. Ok.
;;; (progn (previous-line) (re-search-forward comment-start-skip))
;;; Move the point at the end of the previous line and type C-x C-e
;;; It moves the point on the first "(". Ok.
;;; Thus the string "^;;; " matches the regexp `comment-start-skip'.
;;; (re-search-backward comment-start-skip)
;;; Move the point at the end of the previous line and type C-x C-e
;;; It moves the point just one character AFTER the first semicolon.
;;; I would expect it to move the point at the beginning of the line
;;; since, as shown previously, it matches the regexp and this match
;;; includes the match actually found.
;;; Test #2
; (setq re1 (concat comment-start-skip "--+\n" comment-start-skip " [^ ].*\n"))
; (setq re (concat "\\(" re1 "\\)+"))
; Move the point at the end of the next line and type C-x C-e to see the match
; (progn (forward-char) (and (looking-at re) (re-search-forward re)))
; ----------
; this yes
; ----------
; this no
; ----------
;
; (re-search-backward re)
; Move the point at the end of the previous line and type C-x C-e
; The point moves to the beginning of the line before "this no".
; => Bug
In GNU Emacs 23.1.1 (i686-pc-linux-gnu, GTK+ Version 2.22.0)
of 2011-03-04 on roseapple, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.10900000
configured using `configure '--build=i686-linux-gnu'
'--host=i686-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib'
'--libexecdir=/usr/lib' '--localstatedir=/var/lib'
'--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes'
'--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.1/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.1/leim'
'--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars'
'build_alias=i686-linux-gnu' 'host_alias=i686-linux-gnu'
'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS=''
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: fr_FR.utf8
value of $XMODIFIERS: nil
locale-coding-system: utf-8-unix
default-enable-multibyte-characters: t
Major mode: Emacs-Lisp
Minor modes in effect:
which-function-mode: t
diff-auto-refine-mode: t
eldoc-mode: t
show-paren-mode: t
recentf-mode: t
desktop-save-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:
<menu-bar> <help-menu> <send-emacs-bug-report>
Recent messages:
/usr/bin/mail is not an executable. Setting mail-interactive to t.
)jack(
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11025
; Package
emacs
.
(Fri, 16 Mar 2012 17:01:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 11025 <at> debbugs.gnu.org (full text, mbox):
Oops! It's a feature, not a bug...
Sorry for the noise.
I just found the same problem addressed in bug#9681.
I understood the current behavior of re-search-backward.
see my reply.
sincerely
)jack(
---------- Forwarded message ----------
From: Jack Duthen <duthen.mac.01 <at> gmail.com>
Date: 2012/3/16
Subject: Re: bug#9681: Broken behaviour of re-search-backward (.+
matching only a single character)
To: bug-gnu-emacs <at> gnu.org
On Thu, Oct 06, 2011 at 08:57:09AM -0400, Stefan Monnier wrote:
> re-search-* stops at the first character position that has a match.
> And then it chooses the longest match at that position.
Stepan wrote:
> So, again: it definitely needs better documentation,
> and IMO it also needs fixing.
Hi!
For my own imenu-prev-index-position-function, I needed
a backward regexp search which would match something like ".+"
the way one (like Stepan) can expect rather than the way it actually
does (as described by Stefan).
So, I just wrote a function to do that.
The way it handles the COUNT variable is not as good as one could want
but, as I almost never use it, I don't care.
It's not very efficient but, since I can't notice the time it takes
when used in the "*rescan" menu and since I can't imagine a better algorithm,
it's ok for me.
(defun jd-re-search-backward (regexp &optional bound noerror count)
(let ((orig-point (point)) bom)
(when (re-search-backward regexp bound noerror count)
(setq bom (point)) ; should not be useful
(goto-char (point-min))
(while (re-search-forward regexp orig-point 'noerror)
;; remember the last beginning of match
(setq bom (match-beginning 0)))
(goto-char bom)
;; set match data (erased by the last failing search) and return T
(looking-at regexp))))
HTH
)jack(
Forcibly Merged 9681 11025.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Fri, 16 Mar 2012 17:49:02 GMT)
Full text and
rfc822 format available.
Forcibly Merged 9681 11025 24801.
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Sat, 29 Oct 2016 01:19:01 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
24801 <at> debbugs.gnu.org and Drew Adams <drew.adams <at> oracle.com>
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Sat, 29 Oct 2016 01:19: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, 26 Nov 2016 12:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 8 years and 208 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.