aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/simple.el75
2 files changed, 47 insertions, 37 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f4e0bf2553a..53152a2a8a0 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12002-06-02 Kim F. Storm <storm@cua.dk>
2
3 * simple.el: Reworked 2001-06-01 change.
4 (choose-completion-string1): Merged back into choose-completion-string.
5 (choose-completion-string): Run choose-completion-string-functions
6 after checking for proper minibuffer window. Added mini-p arg to
7 the hook functions. Insert choice if all hook functions return nil.
8 (choose-completion-string-functions): Doc update.
9
12002-06-01 Sam Steingold <sds@gnu.org> 102002-06-01 Sam Steingold <sds@gnu.org>
2 11
3 * files.el (auto-mode-alist): Strip trailing ".in" from the file 12 * files.el (auto-mode-alist): Strip trailing ".in" from the file
diff --git a/lisp/simple.el b/lisp/simple.el
index 5115fbef72f..9fc3144fb26 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -3778,11 +3778,15 @@ With prefix argument N, move N items (negative N means move backward)."
3778 (delete-char len))) 3778 (delete-char len)))
3779 3779
3780(defvar choose-completion-string-functions nil 3780(defvar choose-completion-string-functions nil
3781 "List of functions which may override the standard `choose-completion-string'. 3781 "Functions that may override the normal insertion of a completion choice.
3782Each function in the list is called in turn with arguments CHOICE BUFFER BASE-SIZE 3782These functions are called in order with four arguments:
3783like choose-completion-string. If a function in the list returns non-nil, that 3783CHOICE - the string to insert in the buffer,
3784function is supposed to have inserted the completion in the minibuffer. 3784BUFFER - the buffer in which the choice should be inserted,
3785If all functions in the list return nil, use the default completion selection.") 3785MINI-P - non-nil iff BUFFER is a minibuffer, and
3786BASE-SIZE - the part of BUFFER which isn't part of completion.
3787If a function in the list returns non-nil, that function is supposed
3788to have inserted the CHOICE in the BUFFER, and possibly exited
3789the minibuffer; no further functions will be called.")
3786 3790
3787;; Switch to BUFFER and insert the completion choice CHOICE. 3791;; Switch to BUFFER and insert the completion choice CHOICE.
3788;; BASE-SIZE, if non-nil, says how many characters of BUFFER's text 3792;; BASE-SIZE, if non-nil, says how many characters of BUFFER's text
@@ -3792,11 +3796,6 @@ If all functions in the list return nil, use the default completion selection.")
3792;; unless it is reading a file name and CHOICE is a directory, 3796;; unless it is reading a file name and CHOICE is a directory,
3793;; or completion-no-auto-exit is non-nil. 3797;; or completion-no-auto-exit is non-nil.
3794(defun choose-completion-string (choice &optional buffer base-size) 3798(defun choose-completion-string (choice &optional buffer base-size)
3795 (unless (run-hook-with-args-until-success
3796 'choose-completion-string-functions choice buffer base-size)
3797 (choose-completion-string1 choice buffer base-size)))
3798
3799(defun choose-completion-string1 (choice &optional buffer base-size)
3800 (let ((buffer (or buffer completion-reference-buffer)) 3799 (let ((buffer (or buffer completion-reference-buffer))
3801 (mini-p (string-match "\\` \\*Minibuf-[0-9]+\\*\\'" (buffer-name buffer)))) 3800 (mini-p (string-match "\\` \\*Minibuf-[0-9]+\\*\\'" (buffer-name buffer))))
3802 ;; If BUFFER is a minibuffer, barf unless it's the currently 3801 ;; If BUFFER is a minibuffer, barf unless it's the currently
@@ -3806,33 +3805,35 @@ If all functions in the list return nil, use the default completion selection.")
3806 (not (equal buffer 3805 (not (equal buffer
3807 (window-buffer (active-minibuffer-window)))))) 3806 (window-buffer (active-minibuffer-window))))))
3808 (error "Minibuffer is not active for completion") 3807 (error "Minibuffer is not active for completion")
3809 ;; Insert the completion into the buffer where completion was requested. 3808 (unless (run-hook-with-args-until-success
3810 (set-buffer buffer) 3809 'choose-completion-string-functions choice buffer mini-p base-size)
3811 (if base-size 3810 ;; Insert the completion into the buffer where completion was requested.
3812 (delete-region (+ base-size (if mini-p 3811 (set-buffer buffer)
3813 (minibuffer-prompt-end) 3812 (if base-size
3814 (point-min))) 3813 (delete-region (+ base-size (if mini-p
3815 (point)) 3814 (minibuffer-prompt-end)
3816 (choose-completion-delete-max-match choice)) 3815 (point-min)))
3817 (insert choice) 3816 (point))
3818 (remove-text-properties (- (point) (length choice)) (point) 3817 (choose-completion-delete-max-match choice))
3819 '(mouse-face nil)) 3818 (insert choice)
3820 ;; Update point in the window that BUFFER is showing in. 3819 (remove-text-properties (- (point) (length choice)) (point)
3821 (let ((window (get-buffer-window buffer t))) 3820 '(mouse-face nil))
3822 (set-window-point window (point))) 3821 ;; Update point in the window that BUFFER is showing in.
3823 ;; If completing for the minibuffer, exit it with this choice. 3822 (let ((window (get-buffer-window buffer t)))
3824 (and (not completion-no-auto-exit) 3823 (set-window-point window (point)))
3825 (equal buffer (window-buffer (minibuffer-window))) 3824 ;; If completing for the minibuffer, exit it with this choice.
3826 minibuffer-completion-table 3825 (and (not completion-no-auto-exit)
3827 ;; If this is reading a file name, and the file name chosen 3826 (equal buffer (window-buffer (minibuffer-window)))
3828 ;; is a directory, don't exit the minibuffer. 3827 minibuffer-completion-table
3829 (if (and (eq minibuffer-completion-table 'read-file-name-internal) 3828 ;; If this is reading a file name, and the file name chosen
3830 (file-directory-p (field-string (point-max)))) 3829 ;; is a directory, don't exit the minibuffer.
3831 (let ((mini (active-minibuffer-window))) 3830 (if (and (eq minibuffer-completion-table 'read-file-name-internal)
3832 (select-window mini) 3831 (file-directory-p (field-string (point-max))))
3833 (when minibuffer-auto-raise 3832 (let ((mini (active-minibuffer-window)))
3834 (raise-frame (window-frame mini)))) 3833 (select-window mini)
3835 (exit-minibuffer)))))) 3834 (when minibuffer-auto-raise
3835 (raise-frame (window-frame mini))))
3836 (exit-minibuffer)))))))
3836 3837
3837(defun completion-list-mode () 3838(defun completion-list-mode ()
3838 "Major mode for buffers showing lists of possible completions. 3839 "Major mode for buffers showing lists of possible completions.