From unknown Mon Aug 18 19:30:10 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#7138 <7138@debbugs.gnu.org> To: bug#7138 <7138@debbugs.gnu.org> Subject: Status: 24.0.50; Markers lost with minibuffer completion Reply-To: bug#7138 <7138@debbugs.gnu.org> Date: Tue, 19 Aug 2025 02:30:10 +0000 retitle 7138 24.0.50; Markers lost with minibuffer completion reassign 7138 emacs submitter 7138 "Aaron S. Hawley" severity 7138 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 30 11:39:47 2010 Received: (at submit) by debbugs.gnu.org; 30 Sep 2010 15:39:47 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P1LEZ-0001Vx-HA for submit@debbugs.gnu.org; Thu, 30 Sep 2010 11:39:47 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P1LEY-0001Vs-O9 for submit@debbugs.gnu.org; Thu, 30 Sep 2010 11:39:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P1LHN-0008Ov-22 for submit@debbugs.gnu.org; Thu, 30 Sep 2010 11:42:42 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID,T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:35637) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P1LHM-0008Om-VL for submit@debbugs.gnu.org; Thu, 30 Sep 2010 11:42:41 -0400 Received: from [140.186.70.92] (port=40423 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P1LHG-00071u-Iu for bug-gnu-emacs@gnu.org; Thu, 30 Sep 2010 11:42:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P1LH8-0008KY-8J for bug-gnu-emacs@gnu.org; Thu, 30 Sep 2010 11:42:34 -0400 Received: from mail-iw0-f169.google.com ([209.85.214.169]:59556) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P1LH8-0008KE-5G for bug-gnu-emacs@gnu.org; Thu, 30 Sep 2010 11:42:26 -0400 Received: by iwn33 with SMTP id 33so4025529iwn.0 for ; Thu, 30 Sep 2010 08:42:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=CyyeyKXkt0NhcZyKcZeMgLyj5KboCfnL/gSeEjAUV+g=; b=PMnpS0Rzp/neOpLPVTdnw11hwGvdTjIu/3gjqyLA7vdU6YPE8hkgepycN5prV46/C7 crEjRHyY7KPlcZ+rZbpyKwjSkc3X5JZ5X8uPZbCiEJZHOcZx2TSRxeKpQ5aoxHP2mmtE m9YE1R9jecpzo8oy61og2rHk/TxyRZYnFvq3A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=u6uwf0MlhTA59oN+ZbVGhhKx65STrOzjUEz/HY5SZvCNl4e4UCo2R8UQargTMshmYk PR0kqj7y68r9Wx/mr1nVcxg7vZoyFVCyA6GOK4mtg2uQhJ5L/S8bXGgCj3q/B9Zm1OCR DexkhHeeq17t/hTr0/7DQUlPH27/EN8mKUKos= MIME-Version: 1.0 Received: by 10.231.191.74 with SMTP id dl10mr3888101ibb.157.1285861344668; Thu, 30 Sep 2010 08:42:24 -0700 (PDT) Received: by 10.231.184.69 with HTTP; Thu, 30 Sep 2010 08:42:24 -0700 (PDT) Date: Thu, 30 Sep 2010 11:42:24 -0400 Message-ID: Subject: 24.0.50; Markers lost with minibuffer completion From: "Aaron S. Hawley" To: bug-gnu-emacs@gnu.org Content-Type: multipart/mixed; boundary=0016367d6298aded7104917becd1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -4.3 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 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: -4.8 (----) --0016367d6298aded7104917becd1 Content-Type: text/plain; charset=ISO-8859-1 In GNU Emacs 24.0.50.1 (i386-mingw-nt6.1.7600) of 2010-09-20 on 3249CTO Windowing system distributor `Microsoft Corp.', version 6.1.7600 configured using `configure --with-gcc (4.4) --no-opt --cflags -Ic:/imagesupport/include' I've found that setting markers with C-SPC in the minibuffer for C-x C-f and then completing some file name with TAB, the markers will be deleted and so C-u C-SPC won't work. This is a corner case of completion and markers, but seems like it should be done right. I have proposed a patch. The comment in the function I changed suggests that marks should be preserved. That doesn't seem to be the case at all. 2010-09-30 Aaron S. Hawley * minibuffer.el (completion--replace): Try to preserve markers by only replacing the changed text. --- minibuffer.el 2010-09-21 14:10:35.139030100 -0400 +++ minibuffer.el 2010-09-30 08:48:11.327387800 -0400 @@ -490,6 +490,13 @@ ;; to keep markers "at the right place" and be robust in the face of ;; after-change-functions that may themselves modify the buffer. (goto-char beg) - (insert newtext) - (delete-region (point) (+ (point) (- end beg)))) + (let ((pos (compare-strings (buffer-substring-no-properties beg end) + 0 (- end beg) + newtext 0 (length newtext)))) + (if (numberp pos) + (setq pos (1- (abs pos))) + (setq pos 0)) + (forward-char pos) + (delete-region (point) end) + (insert (substring newtext pos)))) -- In general, we reserve the right to have a poor memory--the computer, however, is supposed to remember! Poor computer. -- Guy Lewis Steele Jr. --0016367d6298aded7104917becd1 Content-Type: application/octet-stream; name="minibuffer-complete-replace-marks.diff" Content-Disposition: attachment; filename="minibuffer-complete-replace-marks.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: file0 MjAxMC0wOS0zMCAgQWFyb24gUy4gSGF3bGV5ICA8YWFyb24ucy5oYXdsZXlAZ21haWwuY29tPgoK CSogbWluaWJ1ZmZlci5lbCAoY29tcGxldGlvbi0tcmVwbGFjZSk6IFRyeSB0byBwcmVzZXJ2ZSBt YXJrZXJzIGJ5Cglvbmx5IHJlcGxhY2luZyB0aGUgY2hhbmdlZCB0ZXh0LgoKLS0tIG1pbmlidWZm ZXIuZWwJMjAxMC0wOS0yMSAxNDoxMDozNS4xMzkwMzAxMDAgLTA0MDAKKysrIG1pbmlidWZmZXIu ZWwJMjAxMC0wOS0zMCAwODo0ODoxMS4zMjczODc4MDAgLTA0MDAKQEAgLTQ5MCw2ICs0OTAsMTMg QEAKICAgOzsgdG8ga2VlcCBtYXJrZXJzICJhdCB0aGUgcmlnaHQgcGxhY2UiIGFuZCBiZSByb2J1 c3QgaW4gdGhlIGZhY2Ugb2YKICAgOzsgYWZ0ZXItY2hhbmdlLWZ1bmN0aW9ucyB0aGF0IG1heSB0 aGVtc2VsdmVzIG1vZGlmeSB0aGUgYnVmZmVyLgogICAoZ290by1jaGFyIGJlZykKLSAgKGluc2Vy dCBuZXd0ZXh0KQotICAoZGVsZXRlLXJlZ2lvbiAocG9pbnQpICgrIChwb2ludCkgKC0gZW5kIGJl ZykpKSkKKyAgKGxldCAoKHBvcyAoY29tcGFyZS1zdHJpbmdzIChidWZmZXItc3Vic3RyaW5nLW5v LXByb3BlcnRpZXMgYmVnIGVuZCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDAgKC0g ZW5kIGJlZykKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld3RleHQgMCAobGVuZ3Ro IG5ld3RleHQpKSkpCisgICAgKGlmIChudW1iZXJwIHBvcykKKyAgICAgICAgKHNldHEgcG9zICgx LSAoYWJzIHBvcykpKQorICAgICAgKHNldHEgcG9zIDApKQorICAgIChmb3J3YXJkLWNoYXIgcG9z KQorICAgIChkZWxldGUtcmVnaW9uIChwb2ludCkgZW5kKQorICAgIChpbnNlcnQgKHN1YnN0cmlu ZyBuZXd0ZXh0IHBvcykpKSkKIAo= --0016367d6298aded7104917becd1-- From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 30 19:11:10 2010 Received: (at 7138-done) by debbugs.gnu.org; 30 Sep 2010 23:11:11 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P1SHN-0006lZ-Tf for submit@debbugs.gnu.org; Thu, 30 Sep 2010 19:11:10 -0400 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P1SGa-0006js-PH for 7138-done@debbugs.gnu.org; Thu, 30 Sep 2010 19:10:21 -0400 Received: from dyn.83-228-153-173.dsl.vtx.ch ([83.228.153.173]:11467 helo=ceviche.home) by fencepost.gnu.org with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1P1SJR-0000b0-Cr; Thu, 30 Sep 2010 19:13:17 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 3747C6611D; Fri, 1 Oct 2010 01:13:21 +0200 (CEST) From: Stefan Monnier To: "Aaron S. Hawley" Subject: Re: bug#7138: 24.0.50; Markers lost with minibuffer completion Message-ID: References: Date: Fri, 01 Oct 2010 01:13:21 +0200 In-Reply-To: (Aaron S. Hawley's message of "Thu, 30 Sep 2010 11:42:24 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -5.2 (-----) X-Debbugs-Envelope-To: 7138-done X-Mailman-Approved-At: Thu, 30 Sep 2010 19:11:08 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 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: -5.2 (-----) > I've found that setting markers with C-SPC in the minibuffer for C-x > C-f and then completing some file name with TAB, the markers will be > deleted and so C-u C-SPC won't work. This is a corner case of > completion and markers, but seems like it should be done right. I > have proposed a patch. Looks pretty good, thank you. > The comment in the function I changed suggests that marks should be > preserved. That doesn't seem to be the case at all. It is talking about surrounding markers, not markers within the replaced text. Your patch changes the code to "delete first and insert afterwards", which is not as good w.r.t preserving surrounding markers (because after the delete, the markers that were after and before the deleted text end up together and the subsequent insert can't tell which to push to which side). > + (if (numberp pos) > + (setq pos (1- (abs pos))) > + (setq pos 0)) Aka (setq pos (if (numberp pos) (1- (abs pos)) 0)) In any case, I've installed in the emacs-23 branch a slightly different change, which additionally tries to find a common suffix. Thanks, Stefan From unknown Mon Aug 18 19:30:10 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 29 Oct 2010 11:24:04 +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