[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#20690: 25.0.50; query-replace: incorrect history when replacing the
From: |
Juri Linkov |
Subject: |
bug#20690: 25.0.50; query-replace: incorrect history when replacing the NUL character. |
Date: |
Mon, 01 Jun 2015 23:39:45 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (x86_64-pc-linux-gnu) |
> ;; 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.
- bug#20690: 25.0.50; query-replace: incorrect history when replacing the NUL character.,
Juri Linkov <=