diff options
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 48 |
2 files changed, 49 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 62dde5840ad..ad3d029edd7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2009-08-19 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * minibuffer.el (minibuffer-hide-completions): New function. | ||
| 4 | (completion--do-completion): Use it. | ||
| 5 | (completions-annotations): New face. | ||
| 6 | (completion--insert-strings): Use it. | ||
| 7 | (completion-pcm--delim-wild-regex): Add docstring. | ||
| 8 | (completion-pcm--string->pattern): Add support for 0-width delimiters | ||
| 9 | in completion-pcm--delim-wild-regex. | ||
| 10 | |||
| 1 | 2009-08-18 Stefan Monnier <monnier@iro.umontreal.ca> | 11 | 2009-08-18 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 12 | ||
| 3 | * international/ucs-normalize.el (ucs-normalize-hfs-nfd-post-read-conversion): | 13 | * international/ucs-normalize.el (ucs-normalize-hfs-nfd-post-read-conversion): |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index dc43b361566..e8862eba6d1 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -388,8 +388,10 @@ E = after completion we now have an Exact match. | |||
| 388 | (- (point) beg)))) | 388 | (- (point) beg)))) |
| 389 | (cond | 389 | (cond |
| 390 | ((null comp) | 390 | ((null comp) |
| 391 | (minibuffer-hide-completions) | ||
| 391 | (ding) (minibuffer-message "No match") (minibuffer--bitset nil nil nil)) | 392 | (ding) (minibuffer-message "No match") (minibuffer--bitset nil nil nil)) |
| 392 | ((eq t comp) | 393 | ((eq t comp) |
| 394 | (minibuffer-hide-completions) | ||
| 393 | (goto-char (field-end)) | 395 | (goto-char (field-end)) |
| 394 | (minibuffer--bitset nil nil t)) ;Exact and unique match. | 396 | (minibuffer--bitset nil nil t)) ;Exact and unique match. |
| 395 | (t | 397 | (t |
| @@ -422,7 +424,11 @@ E = after completion we now have an Exact match. | |||
| 422 | (let ((exact (test-completion completion | 424 | (let ((exact (test-completion completion |
| 423 | minibuffer-completion-table | 425 | minibuffer-completion-table |
| 424 | minibuffer-completion-predicate))) | 426 | minibuffer-completion-predicate))) |
| 425 | (unless completed | 427 | (if completed |
| 428 | ;; We could also decide to refresh the completions, | ||
| 429 | ;; if they're displayed (and assuming there are | ||
| 430 | ;; completions left). | ||
| 431 | (minibuffer-hide-completions) | ||
| 426 | ;; Show the completion table, if requested. | 432 | ;; Show the completion table, if requested. |
| 427 | (cond | 433 | (cond |
| 428 | ((not exact) | 434 | ((not exact) |
| @@ -431,9 +437,9 @@ E = after completion we now have an Exact match. | |||
| 431 | (t completion-auto-help)) | 437 | (t completion-auto-help)) |
| 432 | (minibuffer-completion-help) | 438 | (minibuffer-completion-help) |
| 433 | (minibuffer-message "Next char not unique"))) | 439 | (minibuffer-message "Next char not unique"))) |
| 434 | ;; If the last exact completion and this one were the same, | 440 | ;; If the last exact completion and this one were the same, it |
| 435 | ;; it means we've already given a "Complete but not unique" | 441 | ;; means we've already given a "Next char not unique" message |
| 436 | ;; message and the user's hit TAB again, so now we give him help. | 442 | ;; and the user's hit TAB again, so now we give him help. |
| 437 | ((eq this-command last-command) | 443 | ((eq this-command last-command) |
| 438 | (if completion-auto-help (minibuffer-completion-help))))) | 444 | (if completion-auto-help (minibuffer-completion-help))))) |
| 439 | 445 | ||
| @@ -701,6 +707,9 @@ Return nil if there is no valid completion, else t." | |||
| 701 | t) | 707 | t) |
| 702 | (t t))) | 708 | (t t))) |
| 703 | 709 | ||
| 710 | (defface completions-annotations '((t :inherit italic)) | ||
| 711 | "Face to use for annotations in the *Completions* buffer.") | ||
| 712 | |||
| 704 | (defun completion--insert-strings (strings) | 713 | (defun completion--insert-strings (strings) |
| 705 | "Insert a list of STRINGS into the current buffer. | 714 | "Insert a list of STRINGS into the current buffer. |
| 706 | Uses columns to keep the listing readable but compact. | 715 | Uses columns to keep the listing readable but compact. |
| @@ -752,8 +761,9 @@ It also eliminates runs of equal strings." | |||
| 752 | 'mouse-face 'highlight) | 761 | 'mouse-face 'highlight) |
| 753 | (put-text-property (point) (progn (insert (car str)) (point)) | 762 | (put-text-property (point) (progn (insert (car str)) (point)) |
| 754 | 'mouse-face 'highlight) | 763 | 'mouse-face 'highlight) |
| 755 | (put-text-property (point) (progn (insert (cadr str)) (point)) | 764 | (add-text-properties (point) (progn (insert (cadr str)) (point)) |
| 756 | 'mouse-face nil)) | 765 | '(mouse-face nil |
| 766 | face completions-annotations))) | ||
| 757 | ;; Next column to align to. | 767 | ;; Next column to align to. |
| 758 | (setq column (+ column | 768 | (setq column (+ column |
| 759 | ;; Round up to a whole number of columns. | 769 | ;; Round up to a whole number of columns. |
| @@ -898,6 +908,13 @@ the completions buffer." | |||
| 898 | (if completions "Sole completion" "No completions"))) | 908 | (if completions "Sole completion" "No completions"))) |
| 899 | nil)) | 909 | nil)) |
| 900 | 910 | ||
| 911 | (defun minibuffer-hide-completions () | ||
| 912 | "Get rid of an out-of-date *Completions* buffer." | ||
| 913 | ;; FIXME: We could/should use minibuffer-scroll-window here, but it | ||
| 914 | ;; can also point to the minibuffer-parent-window, so it's a bit tricky. | ||
| 915 | (let ((win (get-buffer-window "*Completions*" 0))) | ||
| 916 | (if win (with-selected-window win (bury-buffer))))) | ||
| 917 | |||
| 901 | (defun exit-minibuffer () | 918 | (defun exit-minibuffer () |
| 902 | "Terminate this minibuffer argument." | 919 | "Terminate this minibuffer argument." |
| 903 | (interactive) | 920 | (interactive) |
| @@ -1351,7 +1368,13 @@ Return the new suffix." | |||
| 1351 | 1368 | ||
| 1352 | ;;; Partial-completion-mode style completion. | 1369 | ;;; Partial-completion-mode style completion. |
| 1353 | 1370 | ||
| 1354 | (defvar completion-pcm--delim-wild-regex nil) | 1371 | (defvar completion-pcm--delim-wild-regex nil |
| 1372 | "Regular expression matching delimiters controlling the partial-completion. | ||
| 1373 | Typically, this regular expression simply matches a delimiter, meaning | ||
| 1374 | that completion can add something at (match-beginning 0), but if it has | ||
| 1375 | a submatch 1, then completion can add something at (match-end 1). | ||
| 1376 | This is used when the delimiter needs to be of size zero (e.g. the transition | ||
| 1377 | from lowercase to uppercase characters).") | ||
| 1355 | 1378 | ||
| 1356 | (defun completion-pcm--prepare-delim-re (delims) | 1379 | (defun completion-pcm--prepare-delim-re (delims) |
| 1357 | (setq completion-pcm--delim-wild-regex (concat "[" delims "*]"))) | 1380 | (setq completion-pcm--delim-wild-regex (concat "[" delims "*]"))) |
| @@ -1395,13 +1418,20 @@ or a symbol chosen among `any', `star', `point'." | |||
| 1395 | (p 0) | 1418 | (p 0) |
| 1396 | (p0 0)) | 1419 | (p0 0)) |
| 1397 | 1420 | ||
| 1398 | (while (and (setq p (string-match-p completion-pcm--delim-wild-regex | 1421 | (while (and (setq p (string-match completion-pcm--delim-wild-regex |
| 1399 | string p)) | 1422 | string p)) |
| 1400 | ;; If the char was added by minibuffer-complete-word, then | 1423 | ;; If the char was added by minibuffer-complete-word, then |
| 1401 | ;; don't treat it as a delimiter, otherwise "M-x SPC" | 1424 | ;; don't treat it as a delimiter, otherwise "M-x SPC" |
| 1402 | ;; ends up inserting a "-" rather than listing | 1425 | ;; ends up inserting a "-" rather than listing |
| 1403 | ;; all completions. | 1426 | ;; all completions. |
| 1404 | (not (get-text-property p 'completion-try-word string))) | 1427 | (not (get-text-property p 'completion-try-word string))) |
| 1428 | ;; Usually, completion-pcm--delim-wild-regex matches a delimiter, | ||
| 1429 | ;; meaning that something can be added *before* it, but it can also | ||
| 1430 | ;; match a prefix and postfix, in which case something can be added | ||
| 1431 | ;; in-between (e.g. match [[:lower:]][[:upper:]]). | ||
| 1432 | ;; This is determined by the presence of a submatch-1 which delimits | ||
| 1433 | ;; the prefix. | ||
| 1434 | (if (match-end 1) (setq p (match-end 1))) | ||
| 1405 | (push (substring string p0 p) pattern) | 1435 | (push (substring string p0 p) pattern) |
| 1406 | (if (eq (aref string p) ?*) | 1436 | (if (eq (aref string p) ?*) |
| 1407 | (progn | 1437 | (progn |