From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Barzilay <eli@barzilay.org>
Cc: 4219@emacsbugs.donarmstrong.com
Subject: bug#4219: 23.1; case insensitive + partial completions
Date: Sun, 13 Sep 2009 23:35:12 -0400 [thread overview]
Message-ID: <jwveiqafbhk.fsf-monnier+emacsbugreports@gnu.org> (raw)
In-Reply-To: <E1MeKC5-0005QA-Hq@barzilay.org> (Eli Barzilay's message of "Thu, 20 Aug 2009 22:49:33 -0400")
>>>>> "Eli" == Eli Barzilay <eli@barzilay.org> writes:
> Start with a default Emacs, and
> (setq read-file-name-completion-ignore-case t)
> (setq completion-styles '(partial-completion))
> Now go to a directory that has two files called
> INSTALL
> install-sh
> Hit `C-x C-f ins TAB' -- it will be completed to "insTALL".
I think the patch below will help out. You may still get such
inconsistent results in different parts of a completion (e.g. completing
"fo-ba" against "FOO-BAR" and "foo-bar" may return "FOO-bar"), but at
least the above case should be handled better.
Stefan
--- minibuffer.el.~1.83.~ 2009-09-02 20:35:02.000000000 -0400
+++ minibuffer.el 2009-09-13 23:31:10.000000000 -0400
@@ -1670,28 +1670,32 @@
(unless (string-match re str)
(error "Internal error: %s doesn't match %s" str re))
(let ((chopped ())
- (i 1))
- (while (match-beginning i)
- (push (match-string i str) chopped)
+ (last 0)
+ (i 1)
+ next)
+ (while (setq next (match-end i))
+ (push (substring str last next) chopped)
+ (setq last next)
(setq i (1+ i)))
;; Add the text corresponding to the implicit trailing `any'.
- (push (substring str (match-end 0)) chopped)
+ (push (substring str last) chopped)
(push (nreverse chopped) ccs))))
;; Then for each of those non-constant elements, extract the
;; commonality between them.
- (let ((res ()))
- ;; Make the implicit `any' explicit. We could make it explicit
+ (let ((res ())
+ (fixed ""))
+ ;; Make the implicit trailing `any' explicit. We could make it explicit
;; everywhere, but it would slow down regexp-matching a little bit.
(dolist (elem (append pattern '(any)))
(if (stringp elem)
- (push elem res)
+ (setq fixed (concat fixed elem))
(let ((comps ()))
(dolist (cc (prog1 ccs (setq ccs nil)))
(push (car cc) comps)
(push (cdr cc) ccs))
- (let* ((prefix (try-completion "" comps))
- (unique (or (and (eq prefix t) (setq prefix ""))
+ (let* ((prefix (try-completion fixed comps))
+ (unique (or (and (eq prefix t) (setq prefix fixed))
(eq t (try-completion prefix comps)))))
(unless (equal prefix "") (push prefix res))
;; If there's only one completion, `elem' is not useful
@@ -1700,7 +1704,8 @@
;; `any' into a `star' because the surrounding context has
;; changed such that string->pattern wouldn't add an `any'
;; here any more.
- (unless unique (push elem res))))))
+ (unless unique (push elem res))
+ (setq fixed "")))))
;; We return it in reverse order.
res)))))
next prev parent reply other threads:[~2009-09-14 3:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-21 2:49 bug#4219: 23.1; case insensitive + partial completions Eli Barzilay
2009-09-14 3:35 ` Stefan Monnier [this message]
2009-09-14 5:55 ` Eli Barzilay
-- strict thread matches above, loose matches on Subject: below --
2009-09-12 1:23 Chong Yidong
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwveiqafbhk.fsf-monnier+emacsbugreports@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=4219@emacsbugs.donarmstrong.com \
--cc=eli@barzilay.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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).