From unknown Mon Jun 23 02:21:11 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#13805 <13805@debbugs.gnu.org> To: bug#13805 <13805@debbugs.gnu.org> Subject: Status: query-replace-regexp has conflicting interactive defaults Reply-To: bug#13805 <13805@debbugs.gnu.org> Date: Mon, 23 Jun 2025 09:21:11 +0000 retitle 13805 query-replace-regexp has conflicting interactive defaults reassign 13805 emacs submitter 13805 Richard Copley severity 13805 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 24 15:41:49 2013 Received: (at submit) by debbugs.gnu.org; 24 Feb 2013 20:41:49 +0000 Received: from localhost ([127.0.0.1]:48058 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U9iOK-0006Cq-SX for submit@debbugs.gnu.org; Sun, 24 Feb 2013 15:41:49 -0500 Received: from eggs.gnu.org ([208.118.235.92]:44404) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U9iOH-0006Ch-TZ for submit@debbugs.gnu.org; Sun, 24 Feb 2013 15:41:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U9iLA-00087e-UN for submit@debbugs.gnu.org; Sun, 24 Feb 2013 15:38:35 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-102.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, USER_IN_WHITELIST autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:44460) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9iLA-00087Z-Ot for submit@debbugs.gnu.org; Sun, 24 Feb 2013 15:38:32 -0500 Received: from eggs.gnu.org ([208.118.235.92]:54900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9iL6-0006v1-KX for bug-gnu-emacs@gnu.org; Sun, 24 Feb 2013 15:38:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U9iL0-00085D-8o for bug-gnu-emacs@gnu.org; Sun, 24 Feb 2013 15:38:28 -0500 Received: from mail-ee0-f41.google.com ([74.125.83.41]:53378) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9iL0-00084x-16 for bug-gnu-emacs@gnu.org; Sun, 24 Feb 2013 15:38:22 -0500 Received: by mail-ee0-f41.google.com with SMTP id c13so1091744eek.28 for ; Sun, 24 Feb 2013 12:38:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=r8o0ApQ8lFwcP+JfjHSpWILuplVf6iOLo6etMrq5jzc=; b=rcIbS1GpmHrBPhCChicVaqY8EPROFIYNDiq4RM85t/tnKn3rV08FV1eRPJ9G9vPImq 9yDHEGBuixyDDkR20liHzdhxFJ7y2ZPpaX8m8DC61hrph0TAPKfBnx9eS8DMbTIf2KWG s6Y96S5Po0H+T8Nfbi+VKtkAm6lciOmChwJ7CLxl77hTJr5LzTmnaXxFqYfWHPU0yxP9 Bzj4emKS8T6V7xDuRiOtIgbB5mahGezgY49rTKN2Mtl8UwbFenQAJoJbVgjs+8QotOcO Q7XQmEonVyL/Wmc0dINPSxhqbSWdvX/0vVyUSMwufClr1mgs1ocUhA/37Wv8uvIfBUD8 9xZw== MIME-Version: 1.0 X-Received: by 10.14.210.132 with SMTP id u4mr31434429eeo.19.1361738300605; Sun, 24 Feb 2013 12:38:20 -0800 (PST) Received: by 10.14.96.11 with HTTP; Sun, 24 Feb 2013 12:38:20 -0800 (PST) Date: Sun, 24 Feb 2013 20:38:20 +0000 Message-ID: Subject: query-replace-regexp has conflicting interactive defaults From: Richard Copley To: "bug-gnu-emacs@gnu.org" Content-Type: text/plain; charset=ISO-8859-1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -6.1 (------) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) `query-replace-regexp' offers to repeat the last replacement, but then goes off and does something exciting and new instead. IMHO replace-regexp and friends should not default their argument using the thing at point, because the user doesn't have control of point: it is by definition at one end of the region to be searched. That means the default is useful only in exceptional cases, and just a distraction otherwise. >From `emacs -Q': M-% . RET ! RET ;; To put a replacement into the history. M-b ;; To place point before the word "buffer" in *scratch*. C-M-% ;; Prompts "Query replace regexp (default . -> !): ". RET ;; Prompts "Query replace regexp \_ with: ". RET ! ;; Replaces "buffer" with "". In GNU Emacs 24.3.50.1 (i386-mingw-nt6.2.9200) of 2013-02-24 on MACHINE Bzr revision: 111868 rgm@gnu.org-20130224194517-l50airg5zdb6y0cr Windowing system distributor `Microsoft Corp.', version 6.2.9200 Configured using: `configure --with-gcc (4.7) --cflags -I c:/gnuwin32/include --ldflags -L c:/gnuwin32/lib' Important settings: value of $LANG: ENG locale-coding-system: cp1252 default enable-multibyte-characters: t Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: M-% . ! M-b C-M-% ? ! M-x r e p o r t - e m a c s - b u g Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Mark set Replaced 0 occurrences Mark set Replaced 1 occurrence Load-path shadows: None found. Features: (shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel dos-w32 ls-lisp w32-common-fns disp-table w32-win w32-vars tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process w32notify w32 multi-tty emacs) From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 24 19:13:09 2013 Received: (at 13805) by debbugs.gnu.org; 25 Feb 2013 00:13:10 +0000 Received: from localhost ([127.0.0.1]:48334 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U9lgr-0002xF-FK for submit@debbugs.gnu.org; Sun, 24 Feb 2013 19:13:09 -0500 Received: from ps18281.dreamhost.com ([69.163.218.105]:54357 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U9lgn-0002x4-VH for 13805@debbugs.gnu.org; Sun, 24 Feb 2013 19:13:07 -0500 Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 4E311258B92902; Sun, 24 Feb 2013 16:11:28 -0800 (PST) From: Juri Linkov To: Richard Copley Subject: Re: bug#13805: query-replace-regexp has conflicting interactive defaults Organization: JURTA References: Date: Mon, 25 Feb 2013 02:03:37 +0200 In-Reply-To: (Richard Copley's message of "Sun, 24 Feb 2013 20:38:20 +0000") Message-ID: <87k3pxntt2.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 13805 Cc: 13805@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) > From `emacs -Q': > M-% . RET ! RET ;; To put a replacement into the history. > M-b ;; To place point before the word "buffer" in *scratch*. > C-M-% ;; Prompts "Query replace regexp (default . -> !): ". > RET ;; Prompts "Query replace regexp \_ with: ". > RET ! ;; Replaces "buffer" with "". The default logic was broken a week ago in revno:111803. This patch should restore the previous correct behavior: === modified file 'lisp/replace.el' --- lisp/replace.el 2013-02-22 17:13:05 +0000 +++ lisp/replace.el 2013-02-25 00:01:21 +0000 @@ -592,7 +592,8 @@ (defun read-regexp (prompt &optional def Non-nil HISTORY is a symbol to use for the history list. If HISTORY is nil, `regexp-history' is used." - (let* ((defaults + (let* ((default (if (consp defaults) (car defaults) defaults)) + (defaults (append (if (listp defaults) defaults (list defaults)) (list @@ -610,7 +611,6 @@ (defun read-regexp (prompt &optional def (car (symbol-value query-replace-from-history-variable))))) (defaults (delete-dups (delq nil (delete "" defaults)))) - (default (car defaults)) ;; Do not automatically add default to the history for empty input. (history-add-new-input nil) (input (read-from-minibuffer To avoid similar confusion in the future, I propose to improve the terminology and give the variables proper names, i.e. to rename the variable `defaults' to `suggestions' (a list of values available via `M-n') as opposed to the variable `default' (a single value used when the user accepts empty input). This patch could be applied over the above patch: === modified file 'lisp/replace.el' --- lisp/replace.el 2013-02-25 00:01:21 +0000 +++ lisp/replace.el 2013-02-25 00:02:12 +0000 @@ -593,7 +593,7 @@ Non-nil HISTORY is a symbol to use for the history list. If HISTORY is nil, `regexp-history' is used." (let* ((default (if (consp defaults) (car defaults) defaults)) - (defaults + (suggestions (append (if (listp defaults) defaults (list defaults)) (list @@ -610,7 +610,7 @@ (regexp-quote (or (car search-ring) "")) (car (symbol-value query-replace-from-history-variable))))) - (defaults (delete-dups (delq nil (delete "" defaults)))) + (suggestions (delete-dups (delq nil (delete "" suggestions)))) ;; Do not automatically add default to the history for empty input. (history-add-new-input nil) (input (read-from-minibuffer @@ -621,7 +621,7 @@ (query-replace-descr default))) (t (format "%s: " prompt))) - nil nil nil (or history 'regexp-history) defaults t))) + nil nil nil (or history 'regexp-history) suggestions t))) (if (equal input "") (or default input) (prog1 input From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 25 16:01:04 2013 Received: (at 13805-done) by debbugs.gnu.org; 25 Feb 2013 21:01:04 +0000 Received: from localhost ([127.0.0.1]:50064 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UA5AW-0003NI-7v for submit@debbugs.gnu.org; Mon, 25 Feb 2013 16:01:04 -0500 Received: from ps18281.dreamhost.com ([69.163.218.105]:54892 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UA5AT-0003Ms-AM for 13805-done@debbugs.gnu.org; Mon, 25 Feb 2013 16:01:02 -0500 Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 04319258B92900; Mon, 25 Feb 2013 12:59:17 -0800 (PST) From: Juri Linkov To: Richard Copley Subject: Re: bug#13805: query-replace-regexp has conflicting interactive defaults Organization: JURTA References: <87k3pxntt2.fsf@mail.jurta.org> Date: Mon, 25 Feb 2013 22:58:09 +0200 In-Reply-To: <87k3pxntt2.fsf@mail.jurta.org> (Juri Linkov's message of "Mon, 25 Feb 2013 02:03:37 +0200") Message-ID: <871uc4xg9q.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13805-done Cc: 13805-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.0 (/) >> From `emacs -Q': >> M-% . RET ! RET ;; To put a replacement into the history. >> M-b ;; To place point before the word "buffer" in *scratch*. >> C-M-% ;; Prompts "Query replace regexp (default . -> !): ". >> RET ;; Prompts "Query replace regexp \_ with: ". >> RET ! ;; Replaces "buffer" with "". > > The default logic was broken a week ago in revno:111803. > This patch should restore the previous correct behavior: This is fixed now, thanks for the bug report. From unknown Mon Jun 23 02:21:11 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 26 Mar 2013 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator