Subject: Re: bug#7138: 24.0.50; Markers lost with minibuffer completion
From: Stefan Monnier <[email-masked]>
To: "Aaron S. Hawley" <[email-masked]>
Date: Fri, 01 Oct 2010 01:13:21 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> 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