GNU bug report logs - #7138
24.0.50; Markers lost with minibuffer completion

Previous Next

Package: emacs;

Reported by: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>

Date: Thu, 30 Sep 2010 15:40:04 UTC

Severity: normal

Found in version 24.0.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>
Subject: bug#7138: closed (Re: bug#7138: 24.0.50; Markers lost with
 minibuffer completion)
Date: Thu, 30 Sep 2010 23:12:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#7138: 24.0.50; Markers lost with minibuffer completion

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 7138 <at> debbugs.gnu.org.

-- 
7138: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7138
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>
Subject: Re: bug#7138: 24.0.50; Markers lost with minibuffer completion
Date: Fri, 01 Oct 2010 01:13:21 +0200
> 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

[Message part 3 (message/rfc822, inline)]
From: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.50; Markers lost with minibuffer completion
Date: Thu, 30 Sep 2010 11:42:24 -0400
[Message part 4 (text/plain, inline)]
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  <aaron.s.hawley <at> gmail.com>

	* 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.
[minibuffer-complete-replace-marks.diff (application/octet-stream, attachment)]

This bug report was last modified 14 years and 297 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.