diff options
Diffstat (limited to 'lisp/minibuffer.el')
| -rw-r--r-- | lisp/minibuffer.el | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 10c7e64df7e..2dc340e08c7 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -3736,22 +3736,39 @@ the minibuffer was activated, and execute the forms." | |||
| 3736 | ;; not a completion-table feature. | 3736 | ;; not a completion-table feature. |
| 3737 | ;; - The methods should not be affected by `completion-regexp-list'. | 3737 | ;; - The methods should not be affected by `completion-regexp-list'. |
| 3738 | 3738 | ||
| 3739 | ;; TODO: | ||
| 3740 | ;; - Async support (maybe via a `completion-table-fetch-async' method) | ||
| 3741 | ;; - Support try-completion filtering (maybe by having fetch-matches | ||
| 3742 | ;; return a filtering function to be applied for try-completion). | ||
| 3743 | |||
| 3744 | (defun completion-table--call-method (table methodname args) | ||
| 3745 | (if (functionp table) | ||
| 3746 | (funcall table methodname args) | ||
| 3747 | (signal 'wrong-number-of-arguments nil))) | ||
| 3748 | |||
| 3739 | (cl-defgeneric completion-table-test (table string) | 3749 | (cl-defgeneric completion-table-test (table string) |
| 3740 | (condition-case nil | 3750 | (condition-case nil |
| 3741 | (if (functionp table) | 3751 | (completion-table--call-method table 'test (list string)) |
| 3742 | (funcall table 'test (list string)) | ||
| 3743 | (with-suppressed-warnings ((callargs car)) (car))) | ||
| 3744 | (wrong-number-of-arguments | 3752 | (wrong-number-of-arguments |
| 3745 | (test-completion string table)))) | 3753 | (test-completion string table)))) |
| 3746 | 3754 | ||
| 3747 | (cl-defgeneric completion-table-category (table string) | 3755 | (cl-defgeneric completion-table-category (table string) |
| 3756 | "Return a description of the kind of completion taking place. | ||
| 3757 | Return value should be either nil or of the form (CATEGORY . ALIST) where | ||
| 3758 | CATEGORY should be a symbol (such as ‘buffer’ and ‘file’, used when | ||
| 3759 | completing buffer and file names, respectively). | ||
| 3760 | ALIST specifies the default settings to use for that category among: | ||
| 3761 | - ‘styles’: the list of ‘completion-styles’ to use for that category. | ||
| 3762 | - ‘cycle’: the ‘completion-cycle-threshold’ to use for that category." | ||
| 3748 | (condition-case nil | 3763 | (condition-case nil |
| 3749 | (if (functionp table) | 3764 | (completion-table--call-method table 'category (list string)) |
| 3750 | (funcall table 'category ()) | ||
| 3751 | (with-suppressed-warnings ((callargs car)) (car))) | ||
| 3752 | (wrong-number-of-arguments | 3765 | (wrong-number-of-arguments |
| 3753 | (let ((md (completion-metadata string table nil))) | 3766 | (let ((category |
| 3754 | (alist-get 'category md))))) | 3767 | (let ((md (completion-metadata string table nil))) |
| 3768 | (alist-get 'category md)))) | ||
| 3769 | (when category | ||
| 3770 | (cons category | ||
| 3771 | (alist-get category completion-category-defaults))))))) | ||
| 3755 | 3772 | ||
| 3756 | (cl-defgeneric completion-table-boundaries (table string point) | 3773 | (cl-defgeneric completion-table-boundaries (table string point) |
| 3757 | ;; FIXME: We should return an additional information to indicate | 3774 | ;; FIXME: We should return an additional information to indicate |
| @@ -3781,9 +3798,7 @@ E.g. for simple completion tables, the result is always (0 . (length STRING)) | |||
| 3781 | and for file names the result is the positions delimited by | 3798 | and for file names the result is the positions delimited by |
| 3782 | the closest directory separators." | 3799 | the closest directory separators." |
| 3783 | (condition-case nil | 3800 | (condition-case nil |
| 3784 | (if (functionp table) | 3801 | (completion-table--call-method table 'boundaries (list string point)) |
| 3785 | (funcall table 'boundaries (list string point)) | ||
| 3786 | (with-suppressed-warnings ((callargs car)) (car))) | ||
| 3787 | (wrong-number-of-arguments | 3802 | (wrong-number-of-arguments |
| 3788 | (pcase-let ((`(,prepos . ,postpos) | 3803 | (pcase-let ((`(,prepos . ,postpos) |
| 3789 | (completion-boundaries (substring string 0 point) table nil | 3804 | (completion-boundaries (substring string 0 point) table nil |
| @@ -3805,9 +3820,8 @@ Return either a list of strings or an alist whose `car's are strings." | |||
| 3805 | (let ((len (length pre))) | 3820 | (let ((len (length pre))) |
| 3806 | (equal (completion-table-boundaries table pre len) (cons len len)))) | 3821 | (equal (completion-table-boundaries table pre len) (cons len len)))) |
| 3807 | (condition-case nil | 3822 | (condition-case nil |
| 3808 | (if (functionp table) | 3823 | (completion-table--call-method |
| 3809 | (funcall table 'fetch-matches (list pre pattern session)) | 3824 | table 'fetch-matches (list pre pattern session)) |
| 3810 | (with-suppressed-warnings ((callargs car)) (car))) | ||
| 3811 | (wrong-number-of-arguments | 3825 | (wrong-number-of-arguments |
| 3812 | (let ((completion-regexp-list nil)) | 3826 | (let ((completion-regexp-list nil)) |
| 3813 | (all-completions (concat pre pattern) table))))) | 3827 | (all-completions (concat pre pattern) table))))) |