From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#55205: 28.1.50; completion--replace illegally mutates completion candidates Date: Sun, 01 May 2022 13:07:31 -0400 Message-ID: References: <4d1b8687-20f2-137a-2739-7bba28828991@daniel-mendler.de> <87wnf5mpt4.fsf@gnus.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25775"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Daniel Mendler , 55205@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 01 19:08:28 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nlD3a-0006Vt-P9 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 01 May 2022 19:08:26 +0200 Original-Received: from localhost ([::1]:42642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nlD3Z-0005Mt-KP for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 01 May 2022 13:08:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlD3M-0005KB-EB for bug-gnu-emacs@gnu.org; Sun, 01 May 2022 13:08:12 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40177) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nlD3C-0000i2-G4 for bug-gnu-emacs@gnu.org; Sun, 01 May 2022 13:08:11 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nlD3C-0007wZ-8e for bug-gnu-emacs@gnu.org; Sun, 01 May 2022 13:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 01 May 2022 17:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55205 X-GNU-PR-Package: emacs Original-Received: via spool by 55205-submit@debbugs.gnu.org id=B55205.165142486230505 (code B ref 55205); Sun, 01 May 2022 17:08:02 +0000 Original-Received: (at 55205) by debbugs.gnu.org; 1 May 2022 17:07:42 +0000 Original-Received: from localhost ([127.0.0.1]:34074 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nlD2s-0007vx-By for submit@debbugs.gnu.org; Sun, 01 May 2022 13:07:42 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:16296) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nlD2q-0007vk-Nj for 55205@debbugs.gnu.org; Sun, 01 May 2022 13:07:41 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 2EC9A80009; Sun, 1 May 2022 13:07:35 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id CF8D680539; Sun, 1 May 2022 13:07:33 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1651424853; bh=gCvuCiBXRDDMWwJhT462ZTH4Nf25Bh9rrN3xYbnr26w=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Z6g1zu/1W/d9LRwjGrIBdxhQZnQDTd9332+RdGuPeCggRkVzzXJXvxqqvPdP08EjV VsFAX7J3cBvA/fr+vaX2HbePBRt5NaTE1vLqQnQqCC0AaRlZPxNVheUbxWIZnUGEzG kpdUTsxkwdwnCSF+S9UsErwfMlEDsyPgCouz6q8QTwXioxnEbYS03JA9aMKLudAsxw /Zx1Fywk6XvI7Es78bPOHl5Wy6f3kxsuULeFRKbVCYAey9bha5tC4RTpf2j8l8YDcl T1gI6j9XgywGIE6TZApEHYPZymOxS7Muzb03xscL0lxCSXUYeg1ciUmRHnvbdGGY3C 1XO0mq4X2kpcw== Original-Received: from pastel (unknown [45.72.221.51]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 8D7701204BD; Sun, 1 May 2022 13:07:33 -0400 (EDT) In-Reply-To: <87wnf5mpt4.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 01 May 2022 13:53:59 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:231172 Archived-At: Lars Ingebrigtsen [2022-05-01 13:53:59] wrote: > Daniel Mendler writes: >> The function completion--replace mutates the replacement string, it >> strips the text properties. > I don't think that's, strictly speaking, illegal. :-) [ Notice the smiley. ] > Anyway, I agree that it's unfortunate that completion destructively > modifies the strings it's handed, and this has been discussed > extensively over the years (and there's probably several bug reports > open about that, although I can't find them now). > > I don't remember why we're doing that, but I seem to vaguely recall that > there's a reason... Anybody? I'm pretty sure there's a reason, and I'm pretty sure this reason is "sloppiness". I blame the author of commit 1d00653d9e (and the author of commit 14486c44 might be considered as an accessory to the crime). > We should (at least) document this in all the relevant functions. I think it's much better to fix the bug, so I just pushed the patch below to `master`. I think it's safe enough for `emacs-28`, but I can't claim it's "obviously safe", the way I could about that same `copy-sequence` in `cl-generic.el`. Stefan commit 788694d026b401715330576633a98542623978ff (HEAD -> main, origin/master, origin/HEAD) Author: Stefan Monnier Date: Sun May 1 13:04:44 2022 -0400 * lisp/minibuffer.el (completion--replace): Fix bug#55205 diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index ef71b4e6be6..fb473cf71b0 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1140,6 +1140,7 @@ completion--replace ;; The properties on `newtext' include things like the ;; `completions-first-difference' face, which we don't want to ;; include upon insertion. + (setq newtext (copy-sequence newtext)) ;Don't modify the arg by side-effect. (if minibuffer-allow-text-properties ;; If we're preserving properties, then just remove the faces ;; and other properties added by the completion machinery.