Mercurial > emacs
comparison lisp/minibuffer.el @ 102958:ca1d2b3eaecc
(completion--try-word-completion): Don't disable
`partial-completion' any more. Mark the added char instead.
(completion-pcm--string->pattern): Notice chars added by
completion--try-word-completion and treat them specially.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 14 Apr 2009 02:02:30 +0000 |
parents | ac174f1dba45 |
children | 9fb3df55079f |
comparison
equal
deleted
inserted
replaced
102957:b145ec03f378 | 102958:ca1d2b3eaecc |
---|---|
605 comp | 605 comp |
606 | 606 |
607 ;; If completion finds next char not unique, | 607 ;; If completion finds next char not unique, |
608 ;; consider adding a space or a hyphen. | 608 ;; consider adding a space or a hyphen. |
609 (when (= (length string) (length (car comp))) | 609 (when (= (length string) (length (car comp))) |
610 (let ((exts '(" " "-")) | 610 ;; Mark the added char with the `completion-word' property, so it |
611 ;; can be handled specially by completion styles such as | |
612 ;; partial-completion. | |
613 ;; We used to remove `partial-completion' from completion-styles | |
614 ;; instead, but it was too blunt, leading to situations where SPC | |
615 ;; was the only insertable char at point but minibuffer-complete-word | |
616 ;; refused inserting it. | |
617 (let ((exts (mapcar (lambda (str) (propertize str 'completion-try-word t)) | |
618 '(" " "-"))) | |
611 (before (substring string 0 point)) | 619 (before (substring string 0 point)) |
612 (after (substring string point)) | 620 (after (substring string point)) |
613 ;; Disable partial-completion for this. | |
614 (completion-styles | |
615 (or (remove 'partial-completion completion-styles) | |
616 completion-styles)) | |
617 tem) | 621 tem) |
618 (while (and exts (not (consp tem))) | 622 (while (and exts (not (consp tem))) |
619 (setq tem (completion-try-completion | 623 (setq tem (completion-try-completion |
620 (concat before (pop exts) after) | 624 (concat before (pop exts) after) |
621 table predicate (1+ point)))) | 625 table predicate (1+ point)))) |
1379 (completion-pcm--string->pattern suffix))) | 1383 (completion-pcm--string->pattern suffix))) |
1380 (let ((pattern nil) | 1384 (let ((pattern nil) |
1381 (p 0) | 1385 (p 0) |
1382 (p0 0)) | 1386 (p0 0)) |
1383 | 1387 |
1384 (while (setq p (string-match-p completion-pcm--delim-wild-regex string p)) | 1388 (while (and (setq p (string-match-p completion-pcm--delim-wild-regex |
1389 string p)) | |
1390 ;; If the char was added by minibuffer-complete-word, then | |
1391 ;; don't treat it as a delimiter, otherwise "M-x SPC" | |
1392 ;; ends up inserting a "-" rather than listing | |
1393 ;; all completions. | |
1394 (not (get-text-property p 'completion-try-word string))) | |
1385 (push (substring string p0 p) pattern) | 1395 (push (substring string p0 p) pattern) |
1386 (if (eq (aref string p) ?*) | 1396 (if (eq (aref string p) ?*) |
1387 (progn | 1397 (progn |
1388 (push 'star pattern) | 1398 (push 'star pattern) |
1389 (setq p0 (1+ p))) | 1399 (setq p0 (1+ p))) |