From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel Mendler Newsgroups: gmane.emacs.bugs Subject: bug#55205: 28.1.50; completion--replace illegally mutates completion candidates Date: Sun, 1 May 2022 10:27:56 +0200 Message-ID: <4d1b8687-20f2-137a-2739-7bba28828991@daniel-mendler.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33818"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier To: 55205@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 01 10:29:15 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 1nl4x9-0008d8-6f for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 01 May 2022 10:29:15 +0200 Original-Received: from localhost ([::1]:60024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nl4x7-0000wR-PT for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 01 May 2022 04:29:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nl4ww-0000wB-NW for bug-gnu-emacs@gnu.org; Sun, 01 May 2022 04:29:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37329) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nl4ww-0004aN-Cm for bug-gnu-emacs@gnu.org; Sun, 01 May 2022 04:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nl4ww-000856-6e for bug-gnu-emacs@gnu.org; Sun, 01 May 2022 04:29:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Daniel Mendler Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 01 May 2022 08:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55205 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.165139370231009 (code B ref -1); Sun, 01 May 2022 08:29:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 1 May 2022 08:28:22 +0000 Original-Received: from localhost ([127.0.0.1]:59458 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nl4wH-000845-PY for submit@debbugs.gnu.org; Sun, 01 May 2022 04:28:22 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:40870) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nl4wH-00083z-3J for submit@debbugs.gnu.org; Sun, 01 May 2022 04:28:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nl4wG-0000vP-RM for bug-gnu-emacs@gnu.org; Sun, 01 May 2022 04:28:20 -0400 Original-Received: from server.qxqx.de ([2a01:4f8:121:346::180]:52655 helo=mail.qxqx.de) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nl4wE-0004WY-ET for bug-gnu-emacs@gnu.org; Sun, 01 May 2022 04:28:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de; s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:Subject:Cc:From:To :MIME-Version:Date:Message-ID:Sender:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=d2X/JJ/mrK6hEkQfHUbeW9ZsJPSGCdASTC38Dvi72l0=; b=d1GFbzBJP6DxJ9pmjM3HLCvz+W +Q2/ev3e0pXdCixVINR/1sjyLDjwkXCsQRP40SRbvDSPcRNV8yT6KeLlBtlfkbMUBdEOzKtwXLnWs e2FlRiLG5dCIXOyt7h9xZLU//aIk7RB85d8NchVKvRkDqdkqOGGna8BEcezriR4zOC7M=; Content-Language: en-US Received-SPF: pass client-ip=2a01:4f8:121:346::180; envelope-from=mail@daniel-mendler.de; helo=mail.qxqx.de X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:231095 Archived-At: The function completion--replace mutates the replacement string, it strips the text properties. The command minibuffer-force-complete calls (completion--replace base end (car all)) on the first candidate returned by completion-all-sorted-completions, which then affects the candidate strings passed to completing-read. The candidate strings passed to completing-read should be treated as constant and should not be mutated. There are two possibilities to fix this: 1. Copy the string (with concat or substring) before mutating it in completion--replace. This is the preferred solution and will make completion--replace safer to use. 2. Copy the candidate string just before passing it to completion--replace. This is the approach I take for example in my Corfu package and I will continue to do so for backward compatibility. Still, the pattern is error prone and copying the candidate string is easily forgotten, (completion--replace beg end (concat cand)). Original downstream issue: https://github.com/minad/consult/issues/566 In GNU Emacs 28.1.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars) of 2022-04-29 built on projects Repository revision: 3b6338c8c351cce721f2f1aa115cadc401179d5c Repository branch: emacs-28 Windowing system distributor 'The X.Org Foundation', version 11.0.12004000 System Description: Debian GNU/Linux 10 (buster)