all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Aaron S. Hawley" <aaron.s.hawley@gmail.com>
To: 7138@debbugs.gnu.org
Subject: bug#7138: 24.0.50; Markers lost with minibuffer completion
Date: Thu, 30 Sep 2010 11:42:24 -0400	[thread overview]
Message-ID: <AANLkTinZ_FCKQfT+T6UKnqTGW5C631Znnn6z1F1CR09M@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1667 bytes --]

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@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.

[-- Attachment #2: minibuffer-complete-replace-marks.diff --]
[-- Type: application/octet-stream, Size: 875 bytes --]

2010-09-30  Aaron S. Hawley  <aaron.s.hawley@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))))
 

             reply	other threads:[~2010-09-30 15:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-30 15:42 Aaron S. Hawley [this message]
2010-09-30 23:13 ` bug#7138: 24.0.50; Markers lost with minibuffer completion Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTinZ_FCKQfT+T6UKnqTGW5C631Znnn6z1F1CR09M@mail.gmail.com \
    --to=aaron.s.hawley@gmail.com \
    --cc=7138@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.