GNU bug report logs - #6808
24.0.50; Incomplete match highlighting with `query-replace-regexp'

Previous Next

Package: emacs;

Reported by: Tassilo Horn <tassilo <at> member.fsf.org>

Date: Fri, 6 Aug 2010 06:46:02 UTC

Severity: normal

Found in version 24.0.50

Done: Chong Yidong <cyd <at> stupidchicken.com>

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 6808 in the body.
You can then email your comments to 6808 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#6808; Package emacs. (Fri, 06 Aug 2010 06:46:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tassilo Horn <tassilo <at> member.fsf.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 06 Aug 2010 06:46:02 GMT) Full text and rfc822 format available.

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

From: Tassilo Horn <tassilo <at> member.fsf.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.50; Incomplete match highlighting with `query-replace-regexp'
Date: Fri, 06 Aug 2010 08:46:07 +0200
The matches to be replaced by `query-replace-regexp' aren't highlighted
completely, although the replacement is correct.

Here's a recipe:

1. emacs -Q
2. Create a buffer with contents:

 #1 153030 120 = 423988
 #2 152845 181 = 1500234
 #3 155160 247 = 767821
 #4 155160 310 = 11131347
 #5 155160 319 = 13979167

3. M-x query-replace-regexp RET [0-9]+ = RET RET

Result:

- The first match "120 =" is highlighted completely.
- All further matches have only the last number highlighted, e.g. "1 =",
  "7 =", ...
- Performing the replacement replaces the correct, complete match,
  e.g. "120 =", "181 =", "247 ="

`re-builder' doesn't have this issue.  It highlights the complete
matches.

For further info see thread on gmane.emacs.help starting with
<AANLkTikbQObpji8fDto_2Fnt4hCiN2U5JAp=NqXDYCTD <at> mail.gmail.com>: "Regex
is not being as "hungry" as it is supposed to"


In GNU Emacs 24.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 2.20.1)
 of 2010-08-05 on thinkpad
Windowing system distributor `The X.Org Foundation', version 11.0.10899905
configured using `configure  '--prefix=/usr' '--build=x86_64-pc-linux-gnu' '--host=x86_64-pc-linux-gnu' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share' '--sysconfdir=/etc' '--localstatedir=/var/lib' '--libdir=/usr/lib64' '--program-suffix=-emacs-24' '--infodir=/usr/share/info/emacs-24' '--with-crt-dir=/usr/lib64' '--without-compress-info' '--with-sound' '--with-x' '--without-gconf' '--without-toolkit-scroll-bars' '--with-gif' '--with-jpeg' '--with-png' '--with-rsvg' '--with-tiff' '--with-xpm' '--with-xft' '--with-libotf' '--with-m17n-flt' '--with-x-toolkit=gtk' '--without-hesiod' '--without-kerberos' '--without-kerberos5' '--with-gpm' '--with-dbus' 'build_alias=x86_64-pc-linux-gnu' 'host_alias=x86_64-pc-linux-gnu' 'CFLAGS=-march=native -O2 -pipe' 'LDFLAGS=-Wl,-O1 -Wl,--as-needed''

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: Message

Minor modes in effect:
  gnus-message-citation-mode: t
  diff-auto-refine-mode: t
  rcirc-track-minor-mode: t
  footnote-mode: t
  mml-mode: t
  global-auto-complete-mode: t
  auto-complete-mode: t
  yas/minor-mode: t
  recentf-mode: t
  window-number-meta-mode: t
  window-number-mode: t
  global-subword-mode: t
  subword-mode: t
  savehist-mode: t
  show-paren-mode: t
  command-frequency-autosave-mode: t
  command-frequency-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
  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:
<return> <return> <return> <return> <up> <up> <return> 
M-2 M-x q h C-g C-g <down> <down> <down> <down> <down> 
<down> C-SPC <down> <down> <down> <down> <down> M-w 
C-x b s c r <return> C-y <up> <up> <up> <up> <up> <up> 
M-x q u e <tab> - r <tab> <return> [ 0 - 9 ] + SPC 
= <return> " <backspace> <return> y y y y y C-x b C-g 
C-_ C-_ C-_ C-_ C-_ <down-mouse-1> <drag-mouse-1> <down-mouse-1> 
<mouse-movement> <mouse-movement> <drag-mouse-1> <down-mouse-1> 
<mouse-1> F C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k 
C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k 
C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k 
C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k 
C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k 
C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k 
C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k 
C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k 
C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k 
C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k C-k 
C-k C-k C-k <down> <down> <down> <down> <down> <down> 
<down> <return> D i t t o SPC w i t h h <backspace> 
SPC t h e SPC c u r r i n t <backspace> <backspace> 
<backspace> e n t SPC e m a c s SPC 2 4 SPC b z r . 
SPC t r u n <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> SPC t r u k n . <backspace> 
<backspace> <backspace> n k . M-x r e p o <tab> r t 
<tab> b <tab> <return>

Recent messages:
20100806T083715.509> End of message
Quit [2 times]
Mark set [3 times]
Replaced 5 occurrences
Quit
Undo! [5 times]
Mark set [2 times]
Auto-saving...done
byte-code: End of buffer [2 times]
Making completion list...

Load-path shadows:
~/repos/el/org-mode/lisp/org-xoxo hides /usr/share/emacs/24.0.50/lisp/org/org-xoxo
~/repos/el/org-mode/lisp/org-vm hides /usr/share/emacs/24.0.50/lisp/org/org-vm
~/repos/el/org-mode/lisp/org-w3m hides /usr/share/emacs/24.0.50/lisp/org/org-w3m
~/repos/el/org-mode/lisp/org-wl hides /usr/share/emacs/24.0.50/lisp/org/org-wl
~/repos/el/org-mode/lisp/org-table hides /usr/share/emacs/24.0.50/lisp/org/org-table
~/repos/el/org-mode/lisp/org-taskjuggler hides /usr/share/emacs/24.0.50/lisp/org/org-taskjuggler
~/repos/el/org-mode/lisp/org-timer hides /usr/share/emacs/24.0.50/lisp/org/org-timer
~/repos/el/org-mode/lisp/org-rmail hides /usr/share/emacs/24.0.50/lisp/org/org-rmail
~/repos/el/org-mode/lisp/org-remember hides /usr/share/emacs/24.0.50/lisp/org/org-remember
~/repos/el/org-mode/lisp/org-src hides /usr/share/emacs/24.0.50/lisp/org/org-src
~/repos/el/org-mode/lisp/org-publish hides /usr/share/emacs/24.0.50/lisp/org/org-publish
~/repos/el/org-mode/lisp/org-plot hides /usr/share/emacs/24.0.50/lisp/org/org-plot
~/repos/el/org-mode/lisp/org-protocol hides /usr/share/emacs/24.0.50/lisp/org/org-protocol
~/repos/el/org-mode/lisp/org-mouse hides /usr/share/emacs/24.0.50/lisp/org/org-mouse
~/repos/el/org-mode/lisp/org-mobile hides /usr/share/emacs/24.0.50/lisp/org/org-mobile
~/repos/el/org-mode/lisp/org-mks hides /usr/share/emacs/24.0.50/lisp/org/org-mks
~/repos/el/org-mode/lisp/org-mhe hides /usr/share/emacs/24.0.50/lisp/org/org-mhe
~/repos/el/org-mode/lisp/org-mew hides /usr/share/emacs/24.0.50/lisp/org/org-mew
~/repos/el/org-mode/lisp/org-mac-message hides /usr/share/emacs/24.0.50/lisp/org/org-mac-message
~/repos/el/org-mode/lisp/org-macs hides /usr/share/emacs/24.0.50/lisp/org/org-macs
~/repos/el/org-mode/lisp/org-latex hides /usr/share/emacs/24.0.50/lisp/org/org-latex
~/repos/el/org-mode/lisp/org-jsinfo hides /usr/share/emacs/24.0.50/lisp/org/org-jsinfo
~/repos/el/org-mode/lisp/org-list hides /usr/share/emacs/24.0.50/lisp/org/org-list
~/repos/el/org-mode/lisp/org-irc hides /usr/share/emacs/24.0.50/lisp/org/org-irc
~/repos/el/org-mode/lisp/org-inlinetask hides /usr/share/emacs/24.0.50/lisp/org/org-inlinetask
~/repos/el/org-mode/lisp/org-info hides /usr/share/emacs/24.0.50/lisp/org/org-info
~/repos/el/org-mode/lisp/org-install hides /usr/share/emacs/24.0.50/lisp/org/org-install
~/repos/el/org-mode/lisp/org-indent hides /usr/share/emacs/24.0.50/lisp/org/org-indent
~/repos/el/org-mode/lisp/org-html hides /usr/share/emacs/24.0.50/lisp/org/org-html
~/repos/el/org-mode/lisp/org-id hides /usr/share/emacs/24.0.50/lisp/org/org-id
~/repos/el/org-mode/lisp/org-icalendar hides /usr/share/emacs/24.0.50/lisp/org/org-icalendar
~/repos/el/org-mode/lisp/org-freemind hides /usr/share/emacs/24.0.50/lisp/org/org-freemind
~/repos/el/org-mode/lisp/org-gnus hides /usr/share/emacs/24.0.50/lisp/org/org-gnus
~/repos/el/org-mode/lisp/org-habit hides /usr/share/emacs/24.0.50/lisp/org/org-habit
~/repos/el/org-mode/lisp/org-feed hides /usr/share/emacs/24.0.50/lisp/org/org-feed
~/repos/el/org-mode/lisp/org hides /usr/share/emacs/24.0.50/lisp/org/org
~/repos/el/org-mode/lisp/org-footnote hides /usr/share/emacs/24.0.50/lisp/org/org-footnote
~/repos/el/org-mode/lisp/org-exp hides /usr/share/emacs/24.0.50/lisp/org/org-exp
~/repos/el/org-mode/lisp/org-faces hides /usr/share/emacs/24.0.50/lisp/org/org-faces
~/repos/el/org-mode/lisp/org-exp-blocks hides /usr/share/emacs/24.0.50/lisp/org/org-exp-blocks
~/repos/el/org-mode/lisp/org-docview hides /usr/share/emacs/24.0.50/lisp/org/org-docview
~/repos/el/org-mode/lisp/org-entities hides /usr/share/emacs/24.0.50/lisp/org/org-entities
~/repos/el/org-mode/lisp/org-datetree hides /usr/share/emacs/24.0.50/lisp/org/org-datetree
~/repos/el/org-mode/lisp/org-docbook hides /usr/share/emacs/24.0.50/lisp/org/org-docbook
~/repos/el/org-mode/lisp/org-ctags hides /usr/share/emacs/24.0.50/lisp/org/org-ctags
~/repos/el/org-mode/lisp/org-crypt hides /usr/share/emacs/24.0.50/lisp/org/org-crypt
~/repos/el/org-mode/lisp/org-colview hides /usr/share/emacs/24.0.50/lisp/org/org-colview
~/repos/el/org-mode/lisp/org-clock hides /usr/share/emacs/24.0.50/lisp/org/org-clock
~/repos/el/org-mode/lisp/org-compat hides /usr/share/emacs/24.0.50/lisp/org/org-compat
~/repos/el/org-mode/lisp/org-capture hides /usr/share/emacs/24.0.50/lisp/org/org-capture
~/repos/el/org-mode/lisp/org-bibtex hides /usr/share/emacs/24.0.50/lisp/org/org-bibtex
~/repos/el/org-mode/lisp/org-beamer hides /usr/share/emacs/24.0.50/lisp/org/org-beamer
~/repos/el/org-mode/lisp/org-bbdb hides /usr/share/emacs/24.0.50/lisp/org/org-bbdb
~/repos/el/org-mode/lisp/org-attach hides /usr/share/emacs/24.0.50/lisp/org/org-attach
~/repos/el/org-mode/lisp/org-agenda hides /usr/share/emacs/24.0.50/lisp/org/org-agenda
~/repos/el/org-mode/lisp/org-ascii hides /usr/share/emacs/24.0.50/lisp/org/org-ascii
~/repos/el/org-mode/lisp/org-archive hides /usr/share/emacs/24.0.50/lisp/org/org-archive
~/repos/el/org-mode/lisp/ob-tangle hides /usr/share/emacs/24.0.50/lisp/org/ob-tangle
~/repos/el/org-mode/lisp/ob-table hides /usr/share/emacs/24.0.50/lisp/org/ob-table
~/repos/el/org-mode/lisp/ob-sh hides /usr/share/emacs/24.0.50/lisp/org/ob-sh
~/repos/el/org-mode/lisp/ob-sqlite hides /usr/share/emacs/24.0.50/lisp/org/ob-sqlite
~/repos/el/org-mode/lisp/ob-sql hides /usr/share/emacs/24.0.50/lisp/org/ob-sql
~/repos/el/org-mode/lisp/ob-screen hides /usr/share/emacs/24.0.50/lisp/org/ob-screen
~/repos/el/org-mode/lisp/ob-ruby hides /usr/share/emacs/24.0.50/lisp/org/ob-ruby
~/repos/el/org-mode/lisp/ob-sass hides /usr/share/emacs/24.0.50/lisp/org/ob-sass
~/repos/el/org-mode/lisp/ob-R hides /usr/share/emacs/24.0.50/lisp/org/ob-R
~/repos/el/org-mode/lisp/ob-ref hides /usr/share/emacs/24.0.50/lisp/org/ob-ref
~/repos/el/org-mode/lisp/ob-python hides /usr/share/emacs/24.0.50/lisp/org/ob-python
~/repos/el/org-mode/lisp/ob-octave hides /usr/share/emacs/24.0.50/lisp/org/ob-octave
~/repos/el/org-mode/lisp/ob-perl hides /usr/share/emacs/24.0.50/lisp/org/ob-perl
~/repos/el/org-mode/lisp/ob-ocaml hides /usr/share/emacs/24.0.50/lisp/org/ob-ocaml
~/repos/el/org-mode/lisp/ob-mscgen hides /usr/share/emacs/24.0.50/lisp/org/ob-mscgen
~/repos/el/org-mode/lisp/ob-matlab hides /usr/share/emacs/24.0.50/lisp/org/ob-matlab
~/repos/el/org-mode/lisp/ob-lob hides /usr/share/emacs/24.0.50/lisp/org/ob-lob
~/repos/el/org-mode/lisp/ob-C hides /usr/share/emacs/24.0.50/lisp/org/ob-C
~/repos/el/org-mode/lisp/ob-latex hides /usr/share/emacs/24.0.50/lisp/org/ob-latex
~/repos/el/org-mode/lisp/ob-exp hides /usr/share/emacs/24.0.50/lisp/org/ob-exp
~/repos/el/org-mode/lisp/ob-keys hides /usr/share/emacs/24.0.50/lisp/org/ob-keys
~/repos/el/org-mode/lisp/ob-haskell hides /usr/share/emacs/24.0.50/lisp/org/ob-haskell
~/repos/el/org-mode/lisp/ob-gnuplot hides /usr/share/emacs/24.0.50/lisp/org/ob-gnuplot
~/repos/el/org-mode/lisp/ob-eval hides /usr/share/emacs/24.0.50/lisp/org/ob-eval
~/repos/el/org-mode/lisp/ob hides /usr/share/emacs/24.0.50/lisp/org/ob
~/repos/el/org-mode/lisp/ob-emacs-lisp hides /usr/share/emacs/24.0.50/lisp/org/ob-emacs-lisp
~/repos/el/org-mode/lisp/ob-dot hides /usr/share/emacs/24.0.50/lisp/org/ob-dot
~/repos/el/org-mode/lisp/ob-ditaa hides /usr/share/emacs/24.0.50/lisp/org/ob-ditaa
~/repos/el/org-mode/lisp/ob-comint hides /usr/share/emacs/24.0.50/lisp/org/ob-comint
~/repos/el/org-mode/lisp/ob-css hides /usr/share/emacs/24.0.50/lisp/org/ob-css
~/repos/el/org-mode/lisp/ob-clojure hides /usr/share/emacs/24.0.50/lisp/org/ob-clojure
~/repos/el/org-mode/lisp/ob-asymptote hides /usr/share/emacs/24.0.50/lisp/org/ob-asymptote

Features:
(shadow emacsbug flow-fill xgit-dvc xgit xgit-annotate dvc-annotate
xgit-log tla smerge-mode dvc-state dvc-config dvc-diff dvc-fileinfo diff
tla-gnus dvc-gnus dvc-cmenu dvc-about dvc-version dvc-revlist sort
gnus-cite ansi-color gnus-bcklg gnus-async gnus-ml newcomment bzr-core
tla-core tla-autoconf tla-defs dvc-log vc vc-dispatcher dvc-unified
dvc-tips ediff-merg ediff-diff ediff-wind ediff-help ediff-util
ediff-mult ediff-init ediff xdarcs-core xgit-core xhg-core xmtn-minimal
qp smiley rcirc-late-fix gnus-topic parse-time nnml netrc nndraft nnmh
bbdb-gnus bbdb-snarf mail-extr bbdb-com nnnil gnus-agent gnus-srvr
gnus-score score-mode nnvirtual gnus-msg gnus-art mm-uu mml2015
epg-config mm-view smime password-cache dig nntp gnus-cache gnus-sum
nnoo gnus-group gnus-undo nnmail mail-source format-spec gnus-start
gnus-spec gnus-int gnus-range gnus-win package greqlscript-mode
greql-mode tg-mode generic th-latex paredit dvc-autoloads dvc-core
dvc-lisp dvc-buffers dvc-ui dvc-register dvc-utils dvc-emacs ewoc
dvc-defs dvc-site magit diff-mode log-edit pcvs-util add-log wtf
cus-edit cus-start cus-load rdictcc rcirc org-beamer solar cal-dst
holidays hol-loaddefs appt diary-lib diary-loaddefs vc-git hl-line
org-w3m org-irc org-jsinfo org-infojs org-html org-exp ob-exp
org-exp-blocks org-info org-gnus org-docview org-bibtex org-bbdb
org-protocol org-attach org-id org-agenda org ob-emacs-lisp ob-keys
ob-comint ob-tangle ob-ref ob-lob ob-table ob org-footnote org-src
org-list org-faces org-compat org-entities org-macs time-date
org-install cal-menu calendar cal-loaddefs dired-x dired-aux pcomplete
em-term term disp-table ehelp electric esh-var esh-io esh-cmd esh-ext
esh-proc esh-arg eldoc esh-groups eshell esh-util esh-module esh-mode
highlight-symbol hi-lock th-boxquote boxquote rect footnote smtpmail
ecomplete message idna sendmail rfc822 mml mml-sec mm-decode mm-bodies
mm-encode mailabbrev gmm-utils mailheader info edit-server server
auto-complete-config auto-complete popup yasnippet dropdown-list
help-mode view noutline outline browse-kill-ring derived recentf
tree-widget sr-speedbar speedbar sb-image ezimage dframe assoc
anything-config warnings compile comint ring semantic/util-modes
semantic/util semantic semantic/tag semantic/lex semantic/fw eieio
byte-opt bytecomp byte-compile mode-local cedet imenu w3m-bookmark w3m
browse-url doc-view jka-compr image-mode w3m-hist w3m-fb w3m-ems w3m-ccl
ccl w3m-favicon w3m-image w3m-proc w3m-util bookmark pp easymenu rx ffap
thingatpt anything window-number uniquify subword saveplace savehist
paren th-private lusty-explorer dired cl cl-19 edmacro kmacro advice
help-fns advice-preload th-common mm-url gnus gnus-ems nnheader
mail-utils wid-edit url-http tls url url-proxy url-privacy url-expand
url-methods url-history mailcap url-auth mail-parse rfc2231 rfc2047
rfc2045 ietf-drums url-cookie url-util url-parse auth-source gnus-util
url-gw url-vars mm-util mail-prsvr windmove command-frequency easy-mmode
site-gentoo w3m-load preview-latex bbdb-autoloads bbdb regexp-opt
timezone tex-site auto-loads tooltip ediff-hook vc-hooks lisp-float-type
mwheel x-win x-dnd tool-bar dnd fontset image fringe lisp-mode register
page menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button
minibuffer faces cus-face files text-properties overlay md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind dynamic-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6808; Package emacs. (Fri, 06 Aug 2010 13:14:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Tassilo Horn <tassilo <at> member.fsf.org>
Cc: 6808 <at> debbugs.gnu.org
Subject: Re: bug#6808: 24.0.50;
	Incomplete match highlighting with `query-replace-regexp'
Date: Fri, 06 Aug 2010 15:13:55 +0200
> The matches to be replaced by `query-replace-regexp' aren't highlighted
> completely, although the replacement is correct.

> Here's a recipe:

> 1. emacs -Q
> 2. Create a buffer with contents:

>  #1 153030 120 = 423988
>  #2 152845 181 = 1500234
>  #3 155160 247 = 767821
>  #4 155160 310 = 11131347
>  #5 155160 319 = 13979167

> 3. M-x query-replace-regexp RET [0-9]+ = RET RET

> Result:

> - The first match "120 =" is highlighted completely.
> - All further matches have only the last number highlighted, e.g. "1 =",
>   "7 =", ...
> - Performing the replacement replaces the correct, complete match,
>   e.g. "120 =", "181 =", "247 ="

I'd guess that those incorrect matches are search with
re-search-backward rather than re-search-forward.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6808; Package emacs. (Fri, 06 Aug 2010 17:44:02 GMT) Full text and rfc822 format available.

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

From: Tassilo Horn <tassilo <at> member.fsf.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 6808 <at> debbugs.gnu.org
Subject: Re: bug#6808: 24.0.50;
	Incomplete match highlighting with `query-replace-regexp'
Date: Fri, 6 Aug 2010 19:43:47 +0200
On Friday 06 August 2010 15:13:55 Stefan Monnier wrote:
> > The matches to be replaced by `query-replace-regexp' aren't highlighted
> > completely, although the replacement is correct.
> 
> > Here's a recipe:
> 
> > 1. emacs -Q
> > 2. Create a buffer with contents:
> 
> >  #1 153030 120 = 423988
> >  #2 152845 181 = 1500234
> >  #3 155160 247 = 767821
> >  #4 155160 310 = 11131347
> >  #5 155160 319 = 13979167
> 
> > 3. M-x query-replace-regexp RET [0-9]+ = RET RET
> 
> > Result:
> 
> > - The first match "120 =" is highlighted completely.
> > - All further matches have only the last number highlighted, e.g. "1 =",
> >   "7 =", ...
> > - Performing the replacement replaces the correct, complete match,
> >   e.g. "120 =", "181 =", "247 ="
> 
> I'd guess that those incorrect matches are search with
> re-search-backward rather than re-search-forward.

To check your guess, I adviced that subr:

(defadvice re-search-backward (before rsb-called activate)
  (message "re-search-backward was called"))

Indeed, with that example above, for the 5 replacements that subr is
called 25 times.

I tried the same in an emacs without -Q, and although I had that
incorrect highlighting at first, after typing the advice and evaling it,
out of sudden it highlighted correctly...

Another thing that is a bit strange (but it doesn't qualify as a bug) is
that if you have point in the middle of the example, also matches before
point are highlighted, although you won't reach them.

Bye,
Tassilo




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6808; Package emacs. (Sat, 07 Aug 2010 00:02:02 GMT) Full text and rfc822 format available.

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

From: Johan Bockgård <bojohan <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Tassilo Horn <tassilo <at> member.fsf.org>, 6808 <at> debbugs.gnu.org
Subject: Re: bug#6808: 24.0.50;
	Incomplete match highlighting with `query-replace-regexp'
Date: Sat, 07 Aug 2010 02:01:24 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>> The matches to be replaced by `query-replace-regexp' aren't highlighted
>> completely, although the replacement is correct.

[...]

> I'd guess that those incorrect matches are search with
> re-search-backward rather than re-search-forward.

Yes. replace-highlight does not update isearch-forward, so you get this
behavior if the previous isearch was a backward search (or in emacs -Q).

The following patch fixes this and two other problems:

* There is no lazy highlighting during replacement if the previous
  isearch set isearch-error (invalid regexp).

* A search that is started with C-s uses forward search for highlighting
  and one that is started with C-r uses backward search, but the
  highlighting is not updated if one switches direction in the middle
  (C-s followed by C-r or vice versa).



diff --git a/lisp/isearch.el b/lisp/isearch.el
index 89d50d6..1fe604d 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -2581,6 +2581,7 @@ since they have special meaning in a regexp."
 (defvar isearch-lazy-highlight-case-fold-search nil)
 (defvar isearch-lazy-highlight-regexp nil)
 (defvar isearch-lazy-highlight-space-regexp nil)
+(defvar isearch-lazy-highlight-forward nil)
 
 (defun lazy-highlight-cleanup (&optional force)
   "Stop lazy highlighting and remove extra highlighting from current buffer.
@@ -2620,7 +2621,9 @@ by other Emacs features."
                  (not (= (window-start)
                          isearch-lazy-highlight-window-start))
                  (not (= (window-end)   ; Window may have been split/joined.
-                         isearch-lazy-highlight-window-end))))
+                         isearch-lazy-highlight-window-end))
+		 (not (eq isearch-forward
+			  isearch-lazy-highlight-forward))))
     ;; something important did indeed change
     (lazy-highlight-cleanup t) ;kill old loop & remove overlays
     (when (not isearch-error)
@@ -2635,7 +2638,8 @@ by other Emacs features."
 	    isearch-lazy-highlight-case-fold-search isearch-case-fold-search
 	    isearch-lazy-highlight-regexp	isearch-regexp
             isearch-lazy-highlight-wrapped      nil
-	    isearch-lazy-highlight-space-regexp search-whitespace-regexp)
+	    isearch-lazy-highlight-space-regexp search-whitespace-regexp
+	    isearch-lazy-highlight-forward      isearch-forward)
       (unless (equal isearch-string "")
 	(setq isearch-lazy-highlight-timer
 	      (run-with-idle-timer lazy-highlight-initial-delay nil
@@ -2651,7 +2655,8 @@ Attempt to do the search exactly the way the pending Isearch would."
 	    (search-invisible nil)	; don't match invisible text
 	    (retry t)
 	    (success nil)
-	    (bound (if isearch-forward
+	    (isearch-forward isearch-lazy-highlight-forward)
+	    (bound (if isearch-lazy-highlight-forward
 		       (min (or isearch-lazy-highlight-end-limit (point-max))
 			    (if isearch-lazy-highlight-wrapped
 				isearch-lazy-highlight-start
@@ -2687,7 +2692,7 @@ Attempt to do the search exactly the way the pending Isearch would."
 	    (select-window isearch-lazy-highlight-window))
 	(save-excursion
 	  (save-match-data
-	    (goto-char (if isearch-forward
+	    (goto-char (if isearch-lazy-highlight-forward
 			   isearch-lazy-highlight-end
 			 isearch-lazy-highlight-start))
 	    (while looping
@@ -2700,7 +2705,7 @@ Attempt to do the search exactly the way the pending Isearch would."
 		    (let ((mb (match-beginning 0))
 			  (me (match-end 0)))
 		      (if (= mb me)	;zero-length match
-			  (if isearch-forward
+			  (if isearch-lazy-highlight-forward
 			      (if (= mb (if isearch-lazy-highlight-wrapped
 					    isearch-lazy-highlight-start
 					  (window-end)))
@@ -2720,7 +2725,7 @@ Attempt to do the search exactly the way the pending Isearch would."
 			  (overlay-put ov 'priority 1000)
 			  (overlay-put ov 'face lazy-highlight-face)
 			  (overlay-put ov 'window (selected-window))))
-		      (if isearch-forward
+		      (if isearch-lazy-highlight-forward
 			  (setq isearch-lazy-highlight-end (point))
 			(setq isearch-lazy-highlight-start (point)))))
 
@@ -2730,7 +2735,7 @@ Attempt to do the search exactly the way the pending Isearch would."
 			(setq looping nil
 			      nomore  t)
 		      (setq isearch-lazy-highlight-wrapped t)
-		      (if isearch-forward
+		      (if isearch-lazy-highlight-forward
 			  (progn
 			    (setq isearch-lazy-highlight-end (window-start))
 			    (goto-char (max (or isearch-lazy-highlight-start-limit (point-min))
diff --git a/lisp/replace.el b/lisp/replace.el
index d73692c..01d971f 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1979,7 +1979,9 @@ make, or the user didn't cancel the call."
       (let ((isearch-string string)
 	    (isearch-regexp regexp)
 	    (search-whitespace-regexp nil)
-	    (isearch-case-fold-search case-fold))
+	    (isearch-case-fold-search case-fold)
+	    (isearch-forward t)
+	    (isearch-error nil))
 	;; Set isearch-word to nil because word-replace is regexp-based,
 	;; so `isearch-search-fun' should not use `word-search-forward'.
 	(if (and isearch-word isearch-regexp) (setq isearch-word nil))





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6808; Package emacs. (Sun, 08 Aug 2010 20:56:02 GMT) Full text and rfc822 format available.

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

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Tassilo Horn <tassilo <at> member.fsf.org>, 6808 <at> debbugs.gnu.org
Subject: Re: bug#6808: 24.0.50;
	Incomplete match highlighting with `query-replace-regexp'
Date: Sun, 08 Aug 2010 16:56:06 -0400
Johan Bockgård <bojohan <at> gnu.org> writes:

> Yes. replace-highlight does not update isearch-forward, so you get this
> behavior if the previous isearch was a backward search (or in emacs -Q).
>
> The following patch fixes this and two other problems:
>
> * There is no lazy highlighting during replacement if the previous
>   isearch set isearch-error (invalid regexp).
>
> * A search that is started with C-s uses forward search for highlighting
>   and one that is started with C-r uses backward search, but the
>   highlighting is not updated if one switches direction in the middle
>   (C-s followed by C-r or vice versa).

Thanks.  I've checked it into the branch.




bug closed, send any further explanations to Tassilo Horn <tassilo <at> member.fsf.org> Request was from Chong Yidong <cyd <at> stupidchicken.com> to control <at> debbugs.gnu.org. (Sun, 08 Aug 2010 20:56: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. (Mon, 06 Sep 2010 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 347 days ago.

Previous Next


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