diff options
| author | Stefan Monnier | 2011-06-20 16:16:20 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2011-06-20 16:16:20 -0400 |
| commit | 4cb3bfa09c6838a579fcf3dab9b7ea1135a2fb4b (patch) | |
| tree | f01721f8e9c776ae2d4d16e32ea022a39a29abed | |
| parent | 0c7efc0884bf7fc60ce768398d361772185ff622 (diff) | |
| download | emacs-4cb3bfa09c6838a579fcf3dab9b7ea1135a2fb4b.tar.gz emacs-4cb3bfa09c6838a579fcf3dab9b7ea1135a2fb4b.zip | |
* lisp/minibuffer.el (completion-metadata): Prepend the alist with `metadata'.
(completion-try-completion, completion-all-completions): Compute the
metadata argument if it's missing; make it optional.
Fixes: debbugs:8795
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 17 |
2 files changed, 16 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 957c751750b..ceab0a14fcf 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | 2011-06-20 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2011-06-20 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * minibuffer.el (completion-metadata): Prepend the alist with `metadata'. | ||
| 4 | (completion-try-completion, completion-all-completions): Compute the | ||
| 5 | metadata argument if it's missing; make it optional (bug#8795). | ||
| 6 | |||
| 3 | * wid-edit.el: Use lexical scoping and move towards completion-at-point. | 7 | * wid-edit.el: Use lexical scoping and move towards completion-at-point. |
| 4 | (widget-complete): Use new :completion-function property. | 8 | (widget-complete): Use new :completion-function property. |
| 5 | (widget-completions-at-point): New function. | 9 | (widget-completions-at-point): New function. |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 03e8225f0c5..a7ffc8d061a 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -135,7 +135,8 @@ The metadata of a completion table should be constant between two boundaries." | |||
| 135 | (let ((metadata (if (functionp table) | 135 | (let ((metadata (if (functionp table) |
| 136 | (funcall table string pred 'metadata)))) | 136 | (funcall table string pred 'metadata)))) |
| 137 | (if (eq (car-safe metadata) 'metadata) | 137 | (if (eq (car-safe metadata) 'metadata) |
| 138 | (cdr metadata)))) | 138 | metadata |
| 139 | '(metadata)))) | ||
| 139 | 140 | ||
| 140 | (defun completion--field-metadata (field-start) | 141 | (defun completion--field-metadata (field-start) |
| 141 | (completion-metadata (buffer-substring-no-properties field-start (point)) | 142 | (completion-metadata (buffer-substring-no-properties field-start (point)) |
| @@ -513,7 +514,7 @@ an association list that can specify properties such as: | |||
| 513 | (delete-dups (append (cdr over) (copy-sequence completion-styles))) | 514 | (delete-dups (append (cdr over) (copy-sequence completion-styles))) |
| 514 | completion-styles))) | 515 | completion-styles))) |
| 515 | 516 | ||
| 516 | (defun completion-try-completion (string table pred point metadata) | 517 | (defun completion-try-completion (string table pred point &optional metadata) |
| 517 | "Try to complete STRING using completion table TABLE. | 518 | "Try to complete STRING using completion table TABLE. |
| 518 | Only the elements of table that satisfy predicate PRED are considered. | 519 | Only the elements of table that satisfy predicate PRED are considered. |
| 519 | POINT is the position of point within STRING. | 520 | POINT is the position of point within STRING. |
| @@ -524,9 +525,12 @@ a new position for point." | |||
| 524 | (completion--some (lambda (style) | 525 | (completion--some (lambda (style) |
| 525 | (funcall (nth 1 (assq style completion-styles-alist)) | 526 | (funcall (nth 1 (assq style completion-styles-alist)) |
| 526 | string table pred point)) | 527 | string table pred point)) |
| 527 | (completion--styles metadata))) | 528 | (completion--styles (or metadata |
| 529 | (completion-metadata | ||
| 530 | (substring string 0 point) | ||
| 531 | table pred))))) | ||
| 528 | 532 | ||
| 529 | (defun completion-all-completions (string table pred point metadata) | 533 | (defun completion-all-completions (string table pred point &optional metadata) |
| 530 | "List the possible completions of STRING in completion table TABLE. | 534 | "List the possible completions of STRING in completion table TABLE. |
| 531 | Only the elements of table that satisfy predicate PRED are considered. | 535 | Only the elements of table that satisfy predicate PRED are considered. |
| 532 | POINT is the position of point within STRING. | 536 | POINT is the position of point within STRING. |
| @@ -537,7 +541,10 @@ in the last `cdr'." | |||
| 537 | (completion--some (lambda (style) | 541 | (completion--some (lambda (style) |
| 538 | (funcall (nth 2 (assq style completion-styles-alist)) | 542 | (funcall (nth 2 (assq style completion-styles-alist)) |
| 539 | string table pred point)) | 543 | string table pred point)) |
| 540 | (completion--styles metadata))) | 544 | (completion--styles (or metadata |
| 545 | (completion-metadata | ||
| 546 | (substring string 0 point) | ||
| 547 | table pred))))) | ||
| 541 | 548 | ||
| 542 | (defun minibuffer--bitset (modified completions exact) | 549 | (defun minibuffer--bitset (modified completions exact) |
| 543 | (logior (if modified 4 0) | 550 | (logior (if modified 4 0) |