From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#20690: 25.0.50; query-replace: incorrect history when replacing the NUL character. Date: Mon, 01 Jun 2015 23:39:45 +0300 Organization: LINKOV.NET Message-ID: <871thvcgdq.fsf@mail.linkov.net> References: <86d21jzsft.fsf@members.fsf.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1433191347 18134 80.91.229.3 (1 Jun 2015 20:42:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 1 Jun 2015 20:42:27 +0000 (UTC) Cc: 20690@debbugs.gnu.org To: Nicolas Richard Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jun 01 22:42:13 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YzWXE-0006of-9R for geb-bug-gnu-emacs@m.gmane.org; Mon, 01 Jun 2015 22:42:12 +0200 Original-Received: from localhost ([::1]:54322 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzWXD-0002rA-PS for geb-bug-gnu-emacs@m.gmane.org; Mon, 01 Jun 2015 16:42:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzWXA-0002oN-0N for bug-gnu-emacs@gnu.org; Mon, 01 Jun 2015 16:42:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YzWX4-0003Jj-Tp for bug-gnu-emacs@gnu.org; Mon, 01 Jun 2015 16:42:07 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54684) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzWX4-0003Jd-QJ for bug-gnu-emacs@gnu.org; Mon, 01 Jun 2015 16:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YzWX4-0001EK-9o for bug-gnu-emacs@gnu.org; Mon, 01 Jun 2015 16:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 01 Jun 2015 20:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20690 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 20690-submit@debbugs.gnu.org id=B20690.14331912994699 (code B ref 20690); Mon, 01 Jun 2015 20:42:02 +0000 Original-Received: (at 20690) by debbugs.gnu.org; 1 Jun 2015 20:41:39 +0000 Original-Received: from localhost ([127.0.0.1]:36426 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YzWWg-0001Dj-8T for submit@debbugs.gnu.org; Mon, 01 Jun 2015 16:41:38 -0400 Original-Received: from sub3.mail.dreamhost.com ([69.163.253.7]:47437 helo=homiemail-a11.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YzWWe-0001Da-6m for 20690@debbugs.gnu.org; Mon, 01 Jun 2015 16:41:37 -0400 Original-Received: from homiemail-a11.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a11.g.dreamhost.com (Postfix) with ESMTP id 494496E07F; Mon, 1 Jun 2015 13:41:34 -0700 (PDT) Original-Received: from localhost.linkov.net (m213-100-241-26.cust.tele2.ee [213.100.241.26]) (Authenticated sender: jurta@jurta.org) by homiemail-a11.g.dreamhost.com (Postfix) with ESMTPA id 4B2006E07E; Mon, 1 Jun 2015 13:41:33 -0700 (PDT) In-Reply-To: <86d21jzsft.fsf@members.fsf.org> (Nicolas Richard's message of "Fri, 29 May 2015 10:41:42 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:103456 Archived-At: > ;; We do a query-replace to remove NUL characters and replace them by > ;; an empty string: > M-% [query-replace] > C-q [quoted-insert] > 0 [exit-minibuffer] > [exit-minibuffer] > ;; now we try to do it again, by relying on the history > M-% [query-replace] > [previous-line-or-history-element] > [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.