diff options
Diffstat (limited to 'lisp/pcomplete.el')
-rw-r--r-- | lisp/pcomplete.el | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el index b3367dc4c74..369285a565d 100644 --- a/lisp/pcomplete.el +++ b/lisp/pcomplete.el @@ -444,12 +444,14 @@ in the same way as TABLE completes strings of the form (concat S2 S)." ;; I don't think such commands are usable before first setting up buffer-local ;; variables to parse args, so there's no point autoloading it. ;; ;;;###autoload -(defun pcomplete-std-complete () +(defun pcomplete-completions-at-point () "Provide standard completion using pcomplete's completion tables. Same as `pcomplete' but using the standard completion UI." - (interactive) ;; FIXME: it only completes the text before point, whereas the ;; standard UI may also consider text after point. + ;; FIXME: the `pcomplete' UI may be used internally during + ;; pcomplete-completions and then throw to `pcompleted', thus + ;; imposing the pcomplete UI over the standard UI. (catch 'pcompleted (let* ((pcomplete-stub) pcomplete-seen pcomplete-norm-func @@ -516,7 +518,7 @@ Same as `pcomplete' but using the standard completion UI." (directory-file-name f)) pcomplete-seen)))))) - (completion-in-region + (list beg (point) ;; Add a space at the end of completion. Use a terminator-regexp ;; that never matches since the terminator cannot appear @@ -527,7 +529,14 @@ Same as `pcomplete' but using the standard completion UI." (cons pcomplete-termination-string "\\`a\\`") table)) - pred)))) + :predicate pred)))) + + ;; I don't think such commands are usable before first setting up buffer-local + ;; variables to parse args, so there's no point autoloading it. + ;; ;;;###autoload +(defun pcomplete-std-complete () + (let ((completion-at-point-functions '(pcomplete-completions-at-point))) + (completion-at-point))) ;;; Pcomplete's native UI. @@ -544,7 +553,7 @@ completion functions list (it should occur fairly early in the list)." pcomplete-expand-and-complete pcomplete-reverse))) (progn - (delete-backward-char pcomplete-last-completion-length) + (delete-char (- pcomplete-last-completion-length)) (if (eq this-command 'pcomplete-reverse) (progn (push (car (last pcomplete-current-completions)) @@ -607,7 +616,7 @@ This will modify the current buffer." (pcomplete) (when (and pcomplete-current-completions (> (length pcomplete-current-completions) 0)) ;?? - (delete-backward-char pcomplete-last-completion-length) + (delete-char (- pcomplete-last-completion-length)) (while pcomplete-current-completions (unless (pcomplete-insert-entry "" (car pcomplete-current-completions) t @@ -630,7 +639,7 @@ This will modify the current buffer." (when (and pcomplete-cycle-completions pcomplete-current-completions (eq last-command 'pcomplete-argument)) - (delete-backward-char pcomplete-last-completion-length) + (delete-char (- pcomplete-last-completion-length)) (setq pcomplete-current-completions nil pcomplete-last-completion-raw nil)) (let ((pcomplete-show-list t)) @@ -1113,7 +1122,7 @@ generate the completions list. This means that the hook (defmacro pcomplete-here* (&optional form stub form-only) "An alternate form which does not participate in argument paring." (declare (debug t)) - `(pcomplete-here (lambda () ,form) ,stub t ,form-only)) + `(pcomplete-here ,form ,stub t ,form-only)) ;; display support @@ -1198,7 +1207,7 @@ Returns non-nil if a space was appended at the end." ;; FIXME: Here we presume that quoting `stub' gives us the exact ;; text in the buffer before point, which is not guaranteed; ;; e.g. it is not the case in eshell when completing ${FOO}tm[TAB]. - (delete-backward-char (length (pcomplete-quote-argument stub))) + (delete-char (- (length (pcomplete-quote-argument stub)))) ;; if there is already a backslash present to handle the first ;; character, don't bother quoting it (when (eq (char-before) ?\\) |