diff options
| -rw-r--r-- | lisp/help-fns.el | 7 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 51 |
2 files changed, 53 insertions, 5 deletions
diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 6be5cd4a501..03bbc979a9c 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el | |||
| @@ -176,8 +176,11 @@ with the current prefix. The files are chosen according to | |||
| 176 | completions)) | 176 | completions)) |
| 177 | 177 | ||
| 178 | (defun help--symbol-completion-table (string pred action) | 178 | (defun help--symbol-completion-table (string pred action) |
| 179 | (if (and completions-detailed (eq action 'metadata)) | 179 | (if (eq action 'metadata) |
| 180 | '(metadata (affixation-function . help--symbol-completion-table-affixation)) | 180 | `(metadata |
| 181 | ,@(when completions-detailed | ||
| 182 | '((affixation-function . help--symbol-completion-table-affixation))) | ||
| 183 | (category . symbol-help)) | ||
| 181 | (when help-enable-completion-autoload | 184 | (when help-enable-completion-autoload |
| 182 | (let ((prefixes (radix-tree-prefixes (help-definition-prefixes) string))) | 185 | (let ((prefixes (radix-tree-prefixes (help-definition-prefixes) string))) |
| 183 | (help--load-prefixes prefixes))) | 186 | (help--load-prefixes prefixes))) |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 1e1a6f852e8..48859585bc2 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -943,7 +943,12 @@ When completing \"foo\" the glob \"*f*o*o*\" is used, so that | |||
| 943 | completion-initials-try-completion completion-initials-all-completions | 943 | completion-initials-try-completion completion-initials-all-completions |
| 944 | "Completion of acronyms and initialisms. | 944 | "Completion of acronyms and initialisms. |
| 945 | E.g. can complete M-x lch to list-command-history | 945 | E.g. can complete M-x lch to list-command-history |
| 946 | and C-x C-f ~/sew to ~/src/emacs/work.")) | 946 | and C-x C-f ~/sew to ~/src/emacs/work.") |
| 947 | (shorthand | ||
| 948 | completion-shorthand-try-completion completion-shorthand-all-completions | ||
| 949 | "Completion of symbol shorthands setup in `read-symbol-shorthands'. | ||
| 950 | E.g. can complete \"x-foo\" to \"xavier-foo\" if the shorthand | ||
| 951 | ((\"x-\" . \"xavier-\")) is set up in the buffer of origin.")) | ||
| 947 | "List of available completion styles. | 952 | "List of available completion styles. |
| 948 | Each element has the form (NAME TRY-COMPLETION ALL-COMPLETIONS DOC): | 953 | Each element has the form (NAME TRY-COMPLETION ALL-COMPLETIONS DOC): |
| 949 | where NAME is the name that should be used in `completion-styles', | 954 | where NAME is the name that should be used in `completion-styles', |
| @@ -990,7 +995,8 @@ styles for specific categories, such as files, buffers, etc." | |||
| 990 | ;; e.g. one that does not anchor to bos. | 995 | ;; e.g. one that does not anchor to bos. |
| 991 | (project-file (styles . (substring))) | 996 | (project-file (styles . (substring))) |
| 992 | (xref-location (styles . (substring))) | 997 | (xref-location (styles . (substring))) |
| 993 | (info-menu (styles . (basic substring)))) | 998 | (info-menu (styles . (basic substring))) |
| 999 | (symbol-help (styles . (basic shorthand substring)))) | ||
| 994 | "Default settings for specific completion categories. | 1000 | "Default settings for specific completion categories. |
| 995 | Each entry has the shape (CATEGORY . ALIST) where ALIST is | 1001 | Each entry has the shape (CATEGORY . ALIST) where ALIST is |
| 996 | an association list that can specify properties such as: | 1002 | an association list that can specify properties such as: |
| @@ -1618,6 +1624,9 @@ DONT-CYCLE tells the function not to setup cycling." | |||
| 1618 | (defvar minibuffer--require-match nil | 1624 | (defvar minibuffer--require-match nil |
| 1619 | "Value of REQUIRE-MATCH passed to `completing-read'.") | 1625 | "Value of REQUIRE-MATCH passed to `completing-read'.") |
| 1620 | 1626 | ||
| 1627 | (defvar minibuffer--original-buffer nil | ||
| 1628 | "Buffer that was current when `completing-read' was called.") | ||
| 1629 | |||
| 1621 | (defun minibuffer-complete-and-exit () | 1630 | (defun minibuffer-complete-and-exit () |
| 1622 | "Exit if the minibuffer contains a valid completion. | 1631 | "Exit if the minibuffer contains a valid completion. |
| 1623 | Otherwise, try to complete the minibuffer contents. If | 1632 | Otherwise, try to complete the minibuffer contents. If |
| @@ -4080,6 +4089,40 @@ which is at the core of flex logic. The extra | |||
| 4080 | (let ((newstr (completion-initials-expand string table pred))) | 4089 | (let ((newstr (completion-initials-expand string table pred))) |
| 4081 | (when newstr | 4090 | (when newstr |
| 4082 | (completion-pcm-try-completion newstr table pred (length newstr))))) | 4091 | (completion-pcm-try-completion newstr table pred (length newstr))))) |
| 4092 | |||
| 4093 | ;; Shorthand completion | ||
| 4094 | ;; | ||
| 4095 | ;; Iff there is a (("x-" . "string-library-")) shorthand setup and | ||
| 4096 | ;; string-library-foo is in candidates, complete x-foo to it. | ||
| 4097 | |||
| 4098 | (defun completion-shorthand-try-completion (string table pred point) | ||
| 4099 | "Try completion with `read-symbol-shorthands' of original buffer." | ||
| 4100 | (cl-loop with expanded | ||
| 4101 | for (short . long) in | ||
| 4102 | (with-current-buffer minibuffer--original-buffer | ||
| 4103 | read-symbol-shorthands) | ||
| 4104 | for probe = | ||
| 4105 | (and (> point (length short)) | ||
| 4106 | (string-prefix-p short string) | ||
| 4107 | (try-completion (setq expanded | ||
| 4108 | (concat long | ||
| 4109 | (substring | ||
| 4110 | string | ||
| 4111 | (length short)))) | ||
| 4112 | table pred)) | ||
| 4113 | when probe | ||
| 4114 | do (message "Shorthand expansion") | ||
| 4115 | and return (cons expanded (max (length long) | ||
| 4116 | (+ (- point (length short)) | ||
| 4117 | (length long)))))) | ||
| 4118 | |||
| 4119 | (defun completion-shorthand-all-completions (string table pred _point) | ||
| 4120 | ;; no-op: For now, we don't want shorthands to list all the possible | ||
| 4121 | ;; locally active longhands. For the completion categories where | ||
| 4122 | ;; this style is active, it could hide other more interesting | ||
| 4123 | ;; matches from subsequent styles. | ||
| 4124 | nil) | ||
| 4125 | |||
| 4083 | 4126 | ||
| 4084 | (defvar completing-read-function #'completing-read-default | 4127 | (defvar completing-read-function #'completing-read-default |
| 4085 | "The function called by `completing-read' to do its work. | 4128 | "The function called by `completing-read' to do its work. |
| @@ -4111,6 +4154,7 @@ See `completing-read' for the meaning of the arguments." | |||
| 4111 | ;; in minibuffer-local-filename-completion-map can | 4154 | ;; in minibuffer-local-filename-completion-map can |
| 4112 | ;; override bindings in base-keymap. | 4155 | ;; override bindings in base-keymap. |
| 4113 | base-keymap))) | 4156 | base-keymap))) |
| 4157 | (buffer (current-buffer)) | ||
| 4114 | (result | 4158 | (result |
| 4115 | (minibuffer-with-setup-hook | 4159 | (minibuffer-with-setup-hook |
| 4116 | (lambda () | 4160 | (lambda () |
| @@ -4119,7 +4163,8 @@ See `completing-read' for the meaning of the arguments." | |||
| 4119 | ;; FIXME: Remove/rename this var, see the next one. | 4163 | ;; FIXME: Remove/rename this var, see the next one. |
| 4120 | (setq-local minibuffer-completion-confirm | 4164 | (setq-local minibuffer-completion-confirm |
| 4121 | (unless (eq require-match t) require-match)) | 4165 | (unless (eq require-match t) require-match)) |
| 4122 | (setq-local minibuffer--require-match require-match)) | 4166 | (setq-local minibuffer--require-match require-match) |
| 4167 | (setq-local minibuffer--original-buffer buffer)) | ||
| 4123 | (read-from-minibuffer prompt initial-input keymap | 4168 | (read-from-minibuffer prompt initial-input keymap |
| 4124 | nil hist def inherit-input-method)))) | 4169 | nil hist def inherit-input-method)))) |
| 4125 | (when (and (equal result "") def) | 4170 | (when (and (equal result "") def) |