summaryrefslogtreecommitdiff
path: root/lisp/shell.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2011-05-23 23:45:50 -0300
committerStefan Monnier <monnier@iro.umontreal.ca>2011-05-23 23:45:50 -0300
commita2a25d24350857dda87e28d6b2695cccc41bb32e (patch)
tree59bf876837e64b92932a52bf8ea8c526de285eb1 /lisp/shell.el
parent2df215b52612a739eedcc024e47b6a9fa720dfda (diff)
downloademacs-a2a25d24350857dda87e28d6b2695cccc41bb32e.tar.gz
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.el38
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."
(list
start end
(lambda (string pred action)
- (completion-table-with-terminator
- " " (lambda (string pred action)
- (if (string-match "/" string)
- (completion-file-name-table string pred action)
- (complete-with-action action completions string pred)))
- string pred action)))))
+ (if (string-match "/" string)
+ (completion-file-name-table string pred action)
+ (complete-with-action action completions string pred)))
+ :exit-function
+ (lambda (_string finished)
+ (when (memq finished '(sole finished))
+ (if (looking-at " ")
+ (goto-char (match-end 0))
+ (insert " ")))))))
;; (defun shell-dynamic-complete-as-command ()
;; "Dynamically complete at point as a command.
@@ -1150,18 +1153,17 @@ Returns non-nil if successful."
(substring x 0 (string-match "=" x)))
process-environment))
(suffix (case (char-before start) (?\{ "}") (?\( ")") (t ""))))
- (list
- start end
- (apply-partially
- #'completion-table-with-terminator
- (cons (lambda (comp)
- (concat comp
- suffix
- (if (file-directory-p
- (comint-directory (getenv comp)))
- "/")))
- "\\`a\\`")
- variables))))))
+ (list start end variables
+ :exit-function
+ (lambda (s finished)
+ (when (memq finished '(sole finished))
+ (let ((suf (concat suffix
+ (if (file-directory-p
+ (comint-directory (getenv s)))
+ "/"))))
+ (if (looking-at (regexp-quote suf))
+ (goto-char (match-end 0))
+ (insert suf))))))))))
(defun shell-c-a-p-replace-by-expanded-directory ()