diff options
| author | Stefan Monnier | 2011-05-23 23:45:50 -0300 |
|---|---|---|
| committer | Stefan Monnier | 2011-05-23 23:45:50 -0300 |
| commit | a2a25d24350857dda87e28d6b2695cccc41bb32e (patch) | |
| tree | 59bf876837e64b92932a52bf8ea8c526de285eb1 /lisp/shell.el | |
| parent | 2df215b52612a739eedcc024e47b6a9fa720dfda (diff) | |
| download | emacs-a2a25d24350857dda87e28d6b2695cccc41bb32e.tar.gz emacs-a2a25d24350857dda87e28d6b2695cccc41bb32e.zip | |
Add an :exit-function for completion-at-point.
* lisp/minibuffer.el (completion--done): New fun.
(completion--do-completion): Use it. New arg `expect-exact'.
(minibuffer-complete, minibuffer-complete-word): Don't output message,
since completion--do-completion does it for us now.
(minibuffer-force-complete): Use completion--done and
completion--replace. Handle sole-completion case with more care.
(minibuffer-complete-and-exit): Use new `expect-exact' arg.
(completion-extra-properties): New var.
(completion-annotate-function): Make obsolete.
(minibuffer-completion-help): Adjust accordingly.
Use completion-list-insert-choice-function.
(completion-at-point, completion-help-at-point):
Bind completion-extra-properties.
(completion-pcm-word-delimiters): Add | (for uniquify, for example).
* lisp/simple.el (completion-list-insert-choice-function): New var.
(completion-setup-function): Preserve it.
(choose-completion): Pay attention to it, shuffle the code a bit.
(choose-completion-string): New arg `insert-function'.
* lisp/textmodes/bibtex.el: Convert to lexical binding.
(bibtex-mode-map): Use completion-at-point.
(bibtex-mode): Use define-derived-mode&completion-at-point-functions.
(bibtex-completion-at-point-function): New fun, from bibtex-complete.
(bibtex-complete): Define as obsolete alias.
(bibtex-complete-internal): Remove.
(bibtex-format-entry): Remove unused sub-group in regexp.
* lisp/shell.el (shell--command-completion-data)
(shell-environment-variable-completion):
* lisp/pcomplete.el (pcomplete-completions-at-point):
* lisp/comint.el (comint--complete-file-name-data): Use :exit-function
instead of completion-table-with-terminator so it also works for
choose-completion.
Diffstat (limited to 'lisp/shell.el')
| -rw-r--r-- | lisp/shell.el | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/lisp/shell.el b/lisp/shell.el index cba50038bc0..53455944ee6 100644 --- a/lisp/shell.el +++ b/lisp/shell.el | |||
| @@ -1074,12 +1074,15 @@ Returns t if successful." | |||
| 1074 | (list | 1074 | (list |
| 1075 | start end | 1075 | start end |
| 1076 | (lambda (string pred action) | 1076 | (lambda (string pred action) |
| 1077 | (completion-table-with-terminator | 1077 | (if (string-match "/" string) |
| 1078 | " " (lambda (string pred action) | 1078 | (completion-file-name-table string pred action) |
| 1079 | (if (string-match "/" string) | 1079 | (complete-with-action action completions string pred))) |
| 1080 | (completion-file-name-table string pred action) | 1080 | :exit-function |
| 1081 | (complete-with-action action completions string pred))) | 1081 | (lambda (_string finished) |
| 1082 | string pred action))))) | 1082 | (when (memq finished '(sole finished)) |
| 1083 | (if (looking-at " ") | ||
| 1084 | (goto-char (match-end 0)) | ||
| 1085 | (insert " "))))))) | ||
| 1083 | 1086 | ||
| 1084 | ;; (defun shell-dynamic-complete-as-command () | 1087 | ;; (defun shell-dynamic-complete-as-command () |
| 1085 | ;; "Dynamically complete at point as a command. | 1088 | ;; "Dynamically complete at point as a command. |
| @@ -1150,18 +1153,17 @@ Returns non-nil if successful." | |||
| 1150 | (substring x 0 (string-match "=" x))) | 1153 | (substring x 0 (string-match "=" x))) |
| 1151 | process-environment)) | 1154 | process-environment)) |
| 1152 | (suffix (case (char-before start) (?\{ "}") (?\( ")") (t "")))) | 1155 | (suffix (case (char-before start) (?\{ "}") (?\( ")") (t "")))) |
| 1153 | (list | 1156 | (list start end variables |
| 1154 | start end | 1157 | :exit-function |
| 1155 | (apply-partially | 1158 | (lambda (s finished) |
| 1156 | #'completion-table-with-terminator | 1159 | (when (memq finished '(sole finished)) |
| 1157 | (cons (lambda (comp) | 1160 | (let ((suf (concat suffix |
| 1158 | (concat comp | 1161 | (if (file-directory-p |
| 1159 | suffix | 1162 | (comint-directory (getenv s))) |
| 1160 | (if (file-directory-p | 1163 | "/")))) |
| 1161 | (comint-directory (getenv comp))) | 1164 | (if (looking-at (regexp-quote suf)) |
| 1162 | "/"))) | 1165 | (goto-char (match-end 0)) |
| 1163 | "\\`a\\`") | 1166 | (insert suf)))))))))) |
| 1164 | variables)))))) | ||
| 1165 | 1167 | ||
| 1166 | 1168 | ||
| 1167 | (defun shell-c-a-p-replace-by-expanded-directory () | 1169 | (defun shell-c-a-p-replace-by-expanded-directory () |