From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard Copley Newsgroups: gmane.emacs.bugs Subject: bug#23127: 25.0.92; Assertion failure when editing history in query-replace in cc-mode Date: Tue, 29 Mar 2016 00:24:20 +0100 Message-ID: References: <20160328220210.57301.qmail@mail.muc.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1459207523 6623 80.91.229.3 (28 Mar 2016 23:25:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 28 Mar 2016 23:25:23 +0000 (UTC) Cc: 23127@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Mar 29 01:25:14 2016 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 1akgX4-0003fm-14 for geb-bug-gnu-emacs@m.gmane.org; Tue, 29 Mar 2016 01:25:14 +0200 Original-Received: from localhost ([::1]:43456 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akgWz-0007gr-Vj for geb-bug-gnu-emacs@m.gmane.org; Mon, 28 Mar 2016 19:25:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38163) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akgWv-0007cA-HY for bug-gnu-emacs@gnu.org; Mon, 28 Mar 2016 19:25:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1akgWs-0001iv-AY for bug-gnu-emacs@gnu.org; Mon, 28 Mar 2016 19:25:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:45452) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akgWs-0001id-72 for bug-gnu-emacs@gnu.org; Mon, 28 Mar 2016 19:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1akgWs-0008IS-1h for bug-gnu-emacs@gnu.org; Mon, 28 Mar 2016 19:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Richard Copley Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Mar 2016 23:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23127 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23127-submit@debbugs.gnu.org id=B23127.145920749931881 (code B ref 23127); Mon, 28 Mar 2016 23:25:02 +0000 Original-Received: (at 23127) by debbugs.gnu.org; 28 Mar 2016 23:24:59 +0000 Original-Received: from localhost ([127.0.0.1]:42579 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1akgWp-0008I9-3x for submit@debbugs.gnu.org; Mon, 28 Mar 2016 19:24:59 -0400 Original-Received: from mail-vk0-f43.google.com ([209.85.213.43]:33695) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1akgWl-0008Hs-R6 for 23127@debbugs.gnu.org; Mon, 28 Mar 2016 19:24:57 -0400 Original-Received: by mail-vk0-f43.google.com with SMTP id k1so175705206vkb.0 for <23127@debbugs.gnu.org>; Mon, 28 Mar 2016 16:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=oGjDrgBvnQxM/oqNLUmLZ1KhD4aMpr02QHM20soCymQ=; b=edSR9YUSBvgs6HrF2W7Or/jjrgP/dUNTqGjlrPKRLLJLERYnBhTnLZITE/a7q5k2+p XqbxCaSqD9BcDXFL+wiTp0pE5l6B6HvsuSHjG8ixM9TjosrMOR7jZ+cCcrn5XJv6ahFx wP2uNbAdPWI1i+8Olaprgp/K5xhfaE+Ykda6PtP/YDR70N6/kLkdj8ys/ObXw0yI0005 SWu1M712v0SDf06mGtkP15/Ph8SD8ew1LUecOALCfsuAcCVUqQysX/+/fELeNDcSM+Hr oie3lj+ACl+h26pRtC+Wjlqq6ZNWZdBBA2++PckdcNjEifF5ndtTl9CBLLylg3tuOFvg lsMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=oGjDrgBvnQxM/oqNLUmLZ1KhD4aMpr02QHM20soCymQ=; b=cvVCDMG4/S1TroQx1F00VteWDD9XbZBUIF7LcV4uXAsIPTpv+ERPyaEaUAyXmRTGqF 3c267rvYZPvUvhzWtSvFn/4WyTD6LEpq+9cBnS3hqK7jvdmS/nINNAT/UvzFDZnjz/Tq Nr+eroEN2ypxTASypXIsFSCye5dP2hTDS1ReHlLZrSUtaenSSMWU5BTwkD87TXPBzeGM rBmFhchC53Skd3TvhbeVxmYxkNU9vWTxSe+AvtaKn/QiqAy+jdRoReCpmj+IersCGQnm sY45eC8QbredqxXInY0DAxJKxDMTfTJ//4I6WVIbSNiGuZ1zmd2iSikiTdeypcecan2U VtCQ== X-Gm-Message-State: AD7BkJLDJA7an+XLu3h2xW7q66vQ5IiZp6+Y4UHZDHvhTJzidOY5PXed4v34h7eHnjCBEU64RidKuO0qcgVrXA== X-Received: by 10.31.49.137 with SMTP id x131mr16349973vkx.0.1459207490324; Mon, 28 Mar 2016 16:24:50 -0700 (PDT) Original-Received: by 10.159.35.105 with HTTP; Mon, 28 Mar 2016 16:24:20 -0700 (PDT) In-Reply-To: <20160328220210.57301.qmail@mail.muc.de> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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:115677 Archived-At: On 28 March 2016 at 23:02, Alan Mackenzie wrote: > Hello, Richard. > > In article you wrote: >> In cc-mode, while doing query-replace, edit a previous replacement in >> the minibuffer, and insert characters after the " =E2=86=92 " separator.= The >> subsequent emacs-lisp chokes on the text properties of the resulting >> string, with an assertion failure. > >> Recipe starting from 'emacs -Q': > >> M-x c-mode RET >> M-< >> C-% a RET b RET ! >> M-< >> C-% M-p C-e c RET > >> =3D=3D> error "cl--assertion-failed: Assertion failed: (not >> (text-property-any (1+ split-pos) length (quote separator) t string))" > >> The callstack looks like this (except that here I've replaced a NUL with= "^@"): > >> Debugger entered: ((cl-assertion-failed (not (text-property-any (1+ >> split-pos) length (quote separator) t string)) nil)) >> cl--assertion-failed((not (text-property-any (1+ split-pos) length >> (quote separator) t string))) >> query-replace--split-string(#("a^@c" 1 2 (display #(" =E2=86=92 " 0 3 = (face >> minibuffer-prompt)) separator t) 2 3 (separator t))) >> query-replace-read-from("Query replace" nil) >> query-replace-read-args("Query replace" nil) >> (let ((common (query-replace-read-args (concat "Query replace" (if >> current-prefix-arg (if (eq current-prefix-arg ...) " backward" " >> word") "") (if (use-region-p) " in region" "")) nil))) (list (nth 0 >> common) (nth 1 common) (nth 2 common) (if (use-region-p) >> (region-beginning)) (if (use-region-p) (region-end)) (nth 3 common) >> (if (use-region-p) (region-noncontiguous-p)))) >> call-interactively(query-replace nil nil) >> command-execute(query-replace) > >> As you can see, the "c" inherited the separator property, and >> query-replace--split-string choked on that. >> It doesn't happen in all modes. It does happen in c-mode and c++-mode. > > Thanks for such a high quality bug report. The cause was a critical > variable being buffer local in C Mode and C++ Mode. This buffer local > binding was not available in `read-from-minibuffer', with the result that > the `separator' text property got spread to the newly inserted 'c'. > > The following patch should fix the bug. Would you please try it out and > confirm that the bug is indeed fixed, or report what's still wrong. > Thanks! > >> In GNU Emacs 25.0.92.1 (x86_64-w64-mingw32) >> of 2016-03-21 built on MACHINE >> Repository revision: 76ef52267cf887e3e1aa6d25b3b16dd0601dd459 >> Windowing system distributor 'Microsoft Corp.', version 10.0.10586 >> Configured using: >> 'configure --prefix /c/emacs/emacs-20160321-102640 >> --without-imagemagick --disable-dependency-tracking >> --enable-locallisppath=3D%emacs_dir%/../site-lisp 'CFLAGS=3D-Og -g -ggd= b'' > > > > diff --git a/lisp/replace.el b/lisp/replace.el > index 428be3c..412f827 100644 > --- a/lisp/replace.el > +++ b/lisp/replace.el > @@ -167,8 +167,6 @@ query-replace-read-from > ;; unavailable while preparing to dump. > (custom-reevaluate-setting 'query-replace-from-to-separator) > (let* ((history-add-new-input nil) > - (text-property-default-nonsticky > - (cons '(separator . t) text-property-default-nonsticky)) > (separator > (when query-replace-from-to-separator > (propertize "\0" > @@ -195,9 +193,16 @@ query-replace-read-from > (save-excursion > (if regexp-flag > (read-regexp prompt nil 'query-replace-from-to-history) > - (read-from-minibuffer > - prompt nil nil nil 'query-replace-from-to-history > - (car (if regexp-flag regexp-search-ring search-ring)) t)= ))) > + ;; The `with-current-buffer' ensures that the binding > + ;; for `text-property-default-nonsticky' isn't a > + ;; buffer local binding in the current buffer, which > + ;; `read-from-minibuffer' wouldn't see. > + (with-current-buffer (window-buffer (minibuffer-window)) > + (let ((text-property-default-nonsticky > + (cons '(separator . t) text-property-default-no= nsticky))) > + (read-from-minibuffer > + prompt nil nil nil 'query-replace-from-to-history > + (car (if regexp-flag regexp-search-ring search-ring= )) t)))))) > (to)) > (if (and (zerop (length from)) query-replace-defaults) > (cons (caar query-replace-defaults) Thanks very much Alan. I tested your patch and noticed that it fixes query-replace but not query-replace-regexp. I won't submit a new patch because I don't have the paperwork (sorry), but I reckon you just need to move the "(with-current-buffer (...) (let (...) ...))" construct outside the "(if regexp-flag ...)". With that change it works fine for me.