aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2007-04-14 19:33:06 +0000
committerGlenn Morris2007-04-14 19:33:06 +0000
commitd73bbb352c9c5a3f4df999f956c390f5f2777442 (patch)
tree8a3aaaee58b69d2ebbcf6fc414aa2243a4c7cea1
parent808409d6d7758ac9bedb756b361b0fe8f0b8c680 (diff)
downloademacs-d73bbb352c9c5a3f4df999f956c390f5f2777442.tar.gz
emacs-d73bbb352c9c5a3f4df999f956c390f5f2777442.zip
(PC-goto-end): New variable.
(partial-completion-mode) <choose-completion-string-functions>: Do not go to the end of the minibuffer if PC-goto-end is non-nil. (PC-do-completion): New optional fourth argument GOTO-END. Add a doc string. Set PC-goto-end for choose-completion. (PC-lisp-complete-symbol): Pass non-nil GOTO-END arg to PC-do-completion.
-rw-r--r--lisp/complete.el26
1 files changed, 21 insertions, 5 deletions
diff --git a/lisp/complete.el b/lisp/complete.el
index 1cdff0d9acd..b93202b2894 100644
--- a/lisp/complete.el
+++ b/lisp/complete.el
@@ -190,6 +190,10 @@ If nil, means use the colon-separated path in the variable $INCPATH instead."
190(defvar PC-do-completion-end nil 190(defvar PC-do-completion-end nil
191 "Internal variable used by `PC-do-completion'.") 191 "Internal variable used by `PC-do-completion'.")
192 192
193(defvar PC-goto-end nil
194 "Internal variable set in `PC-do-completion', used in
195`choose-completion-string-functions'.")
196
193;;;###autoload 197;;;###autoload
194(define-minor-mode partial-completion-mode 198(define-minor-mode partial-completion-mode
195 "Toggle Partial Completion mode. 199 "Toggle Partial Completion mode.
@@ -242,11 +246,16 @@ second TAB brings up the `*Completions*' buffer."
242 (if partial-completion-mode 'add-hook 'remove-hook) 246 (if partial-completion-mode 'add-hook 'remove-hook)
243 'choose-completion-string-functions 247 'choose-completion-string-functions
244 (lambda (choice buffer mini-p base-size) 248 (lambda (choice buffer mini-p base-size)
245 (if mini-p (goto-char (point-max)) 249 ;; When completing M-: (lisp- ) with point before the ), it is
250 ;; not appropriate to go to point-max (unlike the filename case).
251 (if (and (not PC-goto-end)
252 mini-p)
253 (goto-char (point-max))
246 ;; Need a similar hack for the non-minibuffer-case -- gm. 254 ;; Need a similar hack for the non-minibuffer-case -- gm.
247 (when PC-do-completion-end 255 (when PC-do-completion-end
248 (goto-char PC-do-completion-end) 256 (goto-char PC-do-completion-end)
249 (setq PC-do-completion-end nil))) 257 (setq PC-do-completion-end nil)))
258 (setq PC-goto-end nil)
250 nil)) 259 nil))
251 ;; Build the env-completion and mapping table. 260 ;; Build the env-completion and mapping table.
252 (when (and partial-completion-mode (null PC-env-vars-alist)) 261 (when (and partial-completion-mode (null PC-env-vars-alist))
@@ -417,7 +426,13 @@ of `minibuffer-completion-table' and the minibuffer contents.")
417 (let ((result (try-completion string alist predicate))) 426 (let ((result (try-completion string alist predicate)))
418 (if (eq result t) string result))) 427 (if (eq result t) string result)))
419 428
420(defun PC-do-completion (&optional mode beg end) 429;; TODO document MODE magic...
430(defun PC-do-completion (&optional mode beg end goto-end)
431 "Internal function to do the work of partial completion.
432Text to be completed lies between BEG and END. Normally when
433replacing text in the minibuffer, this function replaces up to
434point-max (as is appropriate for completing a file name). If
435GOTO-END is non-nil, however, it instead replaces up to END."
421 (or beg (setq beg (minibuffer-prompt-end))) 436 (or beg (setq beg (minibuffer-prompt-end)))
422 (or end (setq end (point-max))) 437 (or end (setq end (point-max)))
423 (let* ((table minibuffer-completion-table) 438 (let* ((table minibuffer-completion-table)
@@ -772,7 +787,8 @@ of `minibuffer-completion-table' and the minibuffer contents.")
772 (setq completion-base-size (if dirname 787 (setq completion-base-size (if dirname
773 dirlength 788 dirlength
774 (- beg prompt-end)) 789 (- beg prompt-end))
775 PC-do-completion-end end)))) 790 PC-do-completion-end end
791 PC-goto-end goto-end))))
776 (PC-temp-minibuffer-message " [Next char not unique]")) 792 (PC-temp-minibuffer-message " [Next char not unique]"))
777 nil))))) 793 nil)))))
778 794
@@ -886,11 +902,11 @@ or properties are considered."
886 ;; Alternatively alternatively, maybe end should be computed in 902 ;; Alternatively alternatively, maybe end should be computed in
887 ;; the same way as beg. That would change the behaviour though. 903 ;; the same way as beg. That would change the behaviour though.
888 (if (equal last-command 'PC-lisp-complete-symbol) 904 (if (equal last-command 'PC-lisp-complete-symbol)
889 (PC-do-completion nil beg PC-lisp-complete-end) 905 (PC-do-completion nil beg PC-lisp-complete-end t)
890 (if PC-lisp-complete-end 906 (if PC-lisp-complete-end
891 (move-marker PC-lisp-complete-end end) 907 (move-marker PC-lisp-complete-end end)
892 (setq PC-lisp-complete-end (copy-marker end t))) 908 (setq PC-lisp-complete-end (copy-marker end t)))
893 (PC-do-completion nil beg end)))) 909 (PC-do-completion nil beg end t))))
894 910
895(defun PC-complete-as-file-name () 911(defun PC-complete-as-file-name ()
896 "Perform completion on file names preceding point. 912 "Perform completion on file names preceding point.