From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dima Kogan Newsgroups: gmane.emacs.bugs Subject: bug#19383: 25.0.50; query-replace-regexp becomes unusable when using lisp expressions for replacement Date: Mon, 15 Dec 2014 01:01:28 -0800 Message-ID: <871to1l193.fsf@secretsauce.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1418635261 3799 80.91.229.3 (15 Dec 2014 09:21:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 15 Dec 2014 09:21:01 +0000 (UTC) To: 19383@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Dec 15 10:20:55 2014 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 1Y0Rpm-0002KB-Qj for geb-bug-gnu-emacs@m.gmane.org; Mon, 15 Dec 2014 10:20:55 +0100 Original-Received: from localhost ([::1]:38647 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0Rpm-0007eH-4u for geb-bug-gnu-emacs@m.gmane.org; Mon, 15 Dec 2014 04:20:54 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50948) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0Rp4-0006gR-Lx for bug-gnu-emacs@gnu.org; Mon, 15 Dec 2014 04:20:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y0Rox-0008V2-Jc for bug-gnu-emacs@gnu.org; Mon, 15 Dec 2014 04:20:10 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:37070) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0Rox-0008UK-H1 for bug-gnu-emacs@gnu.org; Mon, 15 Dec 2014 04:20:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Y0Row-0005g1-KX for bug-gnu-emacs@gnu.org; Mon, 15 Dec 2014 04:20:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dima Kogan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 15 Dec 2014 09:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 19383 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.141863514321748 (code B ref -1); Mon, 15 Dec 2014 09:20:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Dec 2014 09:19:03 +0000 Original-Received: from localhost ([127.0.0.1]:46436 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y0Rny-0005eU-95 for submit@debbugs.gnu.org; Mon, 15 Dec 2014 04:19:02 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:48881) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y0Rnv-0005eA-Ny for submit@debbugs.gnu.org; Mon, 15 Dec 2014 04:19:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y0Rnj-0007yd-Sb for submit@debbugs.gnu.org; Mon, 15 Dec 2014 04:18:54 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:58683) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0Rnj-0007yV-Pc for submit@debbugs.gnu.org; Mon, 15 Dec 2014 04:18:47 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0Rnd-0004Ta-QO for bug-gnu-emacs@gnu.org; Mon, 15 Dec 2014 04:18:47 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y0RnY-0007rl-06 for bug-gnu-emacs@gnu.org; Mon, 15 Dec 2014 04:18:41 -0500 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:56469) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0RnX-0007qu-Sv for bug-gnu-emacs@gnu.org; Mon, 15 Dec 2014 04:18:35 -0500 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 3AE822070B for ; Mon, 15 Dec 2014 04:18:34 -0500 (EST) Original-Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Mon, 15 Dec 2014 04:18:34 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=x-sasl-enc:from:to:subject:date:message-id:mime-version :content-type; s=mesmtp; bh=L3jxshs8XQwkbcJjW99RNVfjqII=; b=mRQN 4GMUh6ShOXZeZGGt+iiu/X1Nhkh9tnIBVQlxbCHJkPzz2XQdZ+bdemo2kbiMll4R qmdUqI9+SZ5PKB9hasbDTqHbW8U/8sIDStq4puZPSm+tPDIZX2McwUS25glCCRRj 1Ic93QPTTOofI5L+jTZwxy/9HmEunkkGX3lemQo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:from:to:subject:date :message-id:mime-version:content-type; s=smtpout; bh=L3jxshs8XQw kbcJjW99RNVfjqII=; b=uGW6we7BJ9wEdYdTAekWwHGZn0ViKjDpU842iI5MgRm r3uMV1WbABr8l1+Hdt/5e8F+3VpWifRPBe/b+g9muxCIrDZBheJUGVM0u/06TSHn muhwbAxvKl7fISLy6Up5giSAsJNfGclu+/IQSj/4c3w0nUtZ8tgYRB0CvghTdiEg = X-Sasl-enc: oU5j5zgWPBuHFxRRjRoqlbT86bWm83fYetCW5nQL/xv9 1418635113 Original-Received: from shorty.local (unknown [76.91.145.213]) by mail.messagingengine.com (Postfix) with ESMTPA id E52536800EA for ; Mon, 15 Dec 2014 04:18:33 -0500 (EST) Original-Received: from dima by shorty.local with local (Exim 4.84) (envelope-from ) id 1Y0RnU-0001Qb-K4 for bug-gnu-emacs@gnu.org; Mon, 15 Dec 2014 01:18:32 -0800 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). 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:97346 Archived-At: Hi. I'm using a bleeding-edge emacs build, compiled from latest source as of Dec 14. There's a regression in query-replace-regexp where under some conditions it becomes unable to parse its history, and becomes unusable. Here's a recipe. Deviating from the exact steps can make the failure not occur, but I do see this in everyday use, so this isn't exactly a corner case. 1. Create a file called /tmp/dat. I don't think the contents are super important. I have 0001 0002 0003 0004 0005 0006 0007 0008 2. emacs -Q /tmp/dat 3. C-M-% ^. \,(concat \#&) Here we try to do a replacement, but there's an error: (concat ...) expects a string, but \#& is a number, and emacs complains. This is fine. 4. C-M-% SPC We run another replacement. We pull the previous one from the history, and manually remove the # to fix the complaint. \& is a string, as desired. We then replace the first match by presing SPC 5. M-% Error! After step 5, trying to M-% or C-M-% always fails with mapconcat: Wrong type argument: number-or-marker-p, replace-eval-replacement This is irreparable without dipping into lisp. Resetting the history fixes it for the session: (setq query-replace-defaults nil) When broken, the value of query-replace-defaults is (("" replace-eval-replacement replace-quote (concat (match-string 0))) ("^." . "\\,(concat \\#&)")) and the value of query-replace-history is ((replace-eval-replacement replace-quote (concat (match-string 0))) "" "\\,(concat \\#&)" "^.") The backtrace looks like this: Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p replace-eval-replacement) isearch-text-char-description(replace-eval-replacement) mapconcat(isearch-text-char-description (replace-eval-replacement replace-quote (concat (match-string 0))) "") query-replace-descr((replace-eval-replacement replace-quote (concat (match-string 0)))) #[(from-to) "\302@! \302A!Q\207" [from-to separator query-replace-descr] 4](("" replace-eval-replacement replace-quote (concat (match-string 0)))) mapcar(#[(from-to) "\302@! \302A!Q\207" [from-to separator query-replace-descr] 4] (("" replace-eval-replacement replace-quote (concat (match-string 0))) ("^." . "\\,(concat \\#&)"))) 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 (and transient-mark-mode mark-active) " in region" "")) nil))) (list (nth 0 common) (nth 1 common) (nth 2 common) (if (and transient-mark-mode mark-active) (region-beginning)) (if (and transient-mark-mode mark-active) (region-end)) (nth 3 common))) call-interactively(query-replace nil nil) command-execute(query-replace) The issue is that isearch-text-char-description expects a string argument, but it's getting bits of that s-expression; specifically 'replace-eval-replacement. I haven't looked further, and I don't know if this value of the history variables is wrong, or if their parsing is incorrect in some way. Thanks