unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#6808: 24.0.50; Incomplete match highlighting with `query-replace-regexp'
@ 2010-08-06  6:46 Tassilo Horn
  2010-08-06 13:13 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Tassilo Horn @ 2010-08-06  6:46 UTC (permalink / raw)
  To: 6808

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@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)





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

* bug#6808: 24.0.50; Incomplete match highlighting with `query-replace-regexp'
  2010-08-06  6:46 bug#6808: 24.0.50; Incomplete match highlighting with `query-replace-regexp' Tassilo Horn
@ 2010-08-06 13:13 ` Stefan Monnier
  2010-08-06 17:43   ` Tassilo Horn
  2010-08-07  0:01   ` Johan Bockgård
  0 siblings, 2 replies; 5+ messages in thread
From: Stefan Monnier @ 2010-08-06 13:13 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: 6808

> 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





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

* bug#6808: 24.0.50; Incomplete match highlighting with `query-replace-regexp'
  2010-08-06 13:13 ` Stefan Monnier
@ 2010-08-06 17:43   ` Tassilo Horn
  2010-08-07  0:01   ` Johan Bockgård
  1 sibling, 0 replies; 5+ messages in thread
From: Tassilo Horn @ 2010-08-06 17:43 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 6808

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





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

* bug#6808: 24.0.50; Incomplete match highlighting with `query-replace-regexp'
  2010-08-06 13:13 ` Stefan Monnier
  2010-08-06 17:43   ` Tassilo Horn
@ 2010-08-07  0:01   ` Johan Bockgård
  2010-08-08 20:56     ` Chong Yidong
  1 sibling, 1 reply; 5+ messages in thread
From: Johan Bockgård @ 2010-08-07  0:01 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Tassilo Horn, 6808

Stefan Monnier <monnier@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))






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

* bug#6808: 24.0.50; Incomplete match highlighting with `query-replace-regexp'
  2010-08-07  0:01   ` Johan Bockgård
@ 2010-08-08 20:56     ` Chong Yidong
  0 siblings, 0 replies; 5+ messages in thread
From: Chong Yidong @ 2010-08-08 20:56 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Tassilo Horn, 6808

Johan Bockgård <bojohan@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.





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

end of thread, other threads:[~2010-08-08 20:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-06  6:46 bug#6808: 24.0.50; Incomplete match highlighting with `query-replace-regexp' Tassilo Horn
2010-08-06 13:13 ` Stefan Monnier
2010-08-06 17:43   ` Tassilo Horn
2010-08-07  0:01   ` Johan Bockgård
2010-08-08 20:56     ` Chong Yidong

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).