GNU bug report logs - #20690
25.0.50; query-replace: incorrect history when replacing the NUL character.

Previous Next

Package: emacs;

Reported by: Nicolas Richard <youngfrog <at> members.fsf.org>

Date: Fri, 29 May 2015 08:48:02 UTC

Severity: normal

Found in version 25.0.50

Done: Nicolas Richard <youngfrog <at> members.fsf.org>

Bug is archived. No further changes may be made.

Full log


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

From: Juri Linkov <juri <at> linkov.net>
To: Nicolas Richard <youngfrog <at> members.fsf.org>
Cc: 20690 <at> debbugs.gnu.org
Subject: Re: bug#20690: 25.0.50;
 query-replace: incorrect history when replacing the NUL character.
Date: Mon, 01 Jun 2015 23:39:45 +0300
> ;; We do a query-replace to remove NUL characters and replace them by
> ;; an empty string:
>  M-% [query-replace]
>  C-q [quoted-insert]
>  0 <return> <return> [exit-minibuffer]
>  <return> [exit-minibuffer]
> ;; now we try to do it again, by relying on the history
>  M-% [query-replace]
>  <up> [previous-line-or-history-element]
>  <return> [exit-minibuffer]
> ;; At this point, emacs asks what to replace "two NUL chars" with,
> ;; instead of removing NULs like the previous query-replace did.
>
> I suggest the following changes :

Thank you for the fix!  I noticed that besides fixing the NUL character problem
your patch also changes the behaviour when there are no NUL characters, i.e.:

> +(defun query-replace--split-string (string)
> +  "Split string STRING at a character with property `separator'"
> +  (let* ((length (length string))
> +         (split-pos (text-property-any 0 length 'separator t string)))
> +    (if (not split-pos)
> +        string
           ======
This used to be (substring-no-properties string)

> -	(let* ((to (if (and (string-match separator from)
> -			    (get-text-property (match-beginning 0) 'separator from))
> -		       (substring-no-properties from (match-end 0))))
> -	       (from (if to (substring-no-properties from 0 (match-beginning 0))
> -		       (substring-no-properties from))))
                        =======================
Like you can see here above that stripes properties from the from string.




This bug report was last modified 9 years and 337 days ago.

Previous Next


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