/[emacs]/emacs/lisp/simple.el
ViewVC logotype

Diff of /emacs/lisp/simple.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.547 by kfstorm, Sat Jun 1 00:00:29 2002 UTC revision 1.548 by kfstorm, Sat Jun 1 21:56:01 2002 UTC
# Line 3778  With prefix argument N, move N items (ne Line 3778  With prefix argument N, move N items (ne
3778      (delete-char len)))      (delete-char len)))
3779    
3780  (defvar choose-completion-string-functions nil  (defvar choose-completion-string-functions nil
3781    "List of functions which may override the standard `choose-completion-string'.    "Functions that may override the normal insertion of a completion choice.
3782  Each function in the list is called in turn with arguments CHOICE BUFFER BASE-SIZE  These functions are called in order with four arguments:
3783  like choose-completion-string.  If a function in the list returns non-nil, that  CHOICE - the string to insert in the buffer,
3784  function is supposed to have inserted the completion in the minibuffer.  BUFFER - the buffer in which the choice should be inserted,
3785  If all functions in the list return nil, use the default completion selection.")  MINI-P - non-nil iff BUFFER is a minibuffer,  and
3786    BASE-SIZE - the part of BUFFER which isn't part of completion.
3787    If a function in the list returns non-nil, that function is supposed
3788    to have inserted the CHOICE in the BUFFER, and possibly exited
3789    the minibuffer; no further functions will be called.")
3790    
3791  ;; Switch to BUFFER and insert the completion choice CHOICE.  ;; Switch to BUFFER and insert the completion choice CHOICE.
3792  ;; BASE-SIZE, if non-nil, says how many characters of BUFFER's text  ;; BASE-SIZE, if non-nil, says how many characters of BUFFER's text
# Line 3792  If all functions in the list return nil, Line 3796  If all functions in the list return nil,
3796  ;; unless it is reading a file name and CHOICE is a directory,  ;; unless it is reading a file name and CHOICE is a directory,
3797  ;; or completion-no-auto-exit is non-nil.  ;; or completion-no-auto-exit is non-nil.
3798  (defun choose-completion-string (choice &optional buffer base-size)  (defun choose-completion-string (choice &optional buffer base-size)
   (unless (run-hook-with-args-until-success  
            'choose-completion-string-functions choice buffer base-size)  
     (choose-completion-string1 choice buffer base-size)))  
   
 (defun choose-completion-string1 (choice &optional buffer base-size)  
3799    (let ((buffer (or buffer completion-reference-buffer))    (let ((buffer (or buffer completion-reference-buffer))
3800          (mini-p (string-match "\\` \\*Minibuf-[0-9]+\\*\\'" (buffer-name buffer))))          (mini-p (string-match "\\` \\*Minibuf-[0-9]+\\*\\'" (buffer-name buffer))))
3801      ;; If BUFFER is a minibuffer, barf unless it's the currently      ;; If BUFFER is a minibuffer, barf unless it's the currently
# Line 3806  If all functions in the list return nil, Line 3805  If all functions in the list return nil,
3805                   (not (equal buffer                   (not (equal buffer
3806                               (window-buffer (active-minibuffer-window))))))                               (window-buffer (active-minibuffer-window))))))
3807          (error "Minibuffer is not active for completion")          (error "Minibuffer is not active for completion")
3808        ;; Insert the completion into the buffer where completion was requested.        (unless (run-hook-with-args-until-success
3809        (set-buffer buffer)                 'choose-completion-string-functions choice buffer mini-p base-size)
3810        (if base-size          ;; Insert the completion into the buffer where completion was requested.
3811            (delete-region (+ base-size (if mini-p          (set-buffer buffer)
3812                                            (minibuffer-prompt-end)          (if base-size
3813                                          (point-min)))              (delete-region (+ base-size (if mini-p
3814                           (point))                                              (minibuffer-prompt-end)
3815          (choose-completion-delete-max-match choice))                                            (point-min)))
3816        (insert choice)                             (point))
3817        (remove-text-properties (- (point) (length choice)) (point)            (choose-completion-delete-max-match choice))
3818                                '(mouse-face nil))          (insert choice)
3819        ;; Update point in the window that BUFFER is showing in.          (remove-text-properties (- (point) (length choice)) (point)
3820        (let ((window (get-buffer-window buffer t)))                                  '(mouse-face nil))
3821          (set-window-point window (point)))          ;; Update point in the window that BUFFER is showing in.
3822        ;; If completing for the minibuffer, exit it with this choice.          (let ((window (get-buffer-window buffer t)))
3823        (and (not completion-no-auto-exit)            (set-window-point window (point)))
3824             (equal buffer (window-buffer (minibuffer-window)))          ;; If completing for the minibuffer, exit it with this choice.
3825             minibuffer-completion-table          (and (not completion-no-auto-exit)
3826             ;; If this is reading a file name, and the file name chosen               (equal buffer (window-buffer (minibuffer-window)))
3827             ;; is a directory, don't exit the minibuffer.               minibuffer-completion-table
3828             (if (and (eq minibuffer-completion-table 'read-file-name-internal)               ;; If this is reading a file name, and the file name chosen
3829                      (file-directory-p (field-string (point-max))))               ;; is a directory, don't exit the minibuffer.
3830                 (let ((mini (active-minibuffer-window)))               (if (and (eq minibuffer-completion-table 'read-file-name-internal)
3831                   (select-window mini)                        (file-directory-p (field-string (point-max))))
3832                   (when minibuffer-auto-raise                   (let ((mini (active-minibuffer-window)))
3833                     (raise-frame (window-frame mini))))                     (select-window mini)
3834               (exit-minibuffer))))))                     (when minibuffer-auto-raise
3835                         (raise-frame (window-frame mini))))
3836                   (exit-minibuffer)))))))
3837    
3838  (defun completion-list-mode ()  (defun completion-list-mode ()
3839    "Major mode for buffers showing lists of possible completions.    "Major mode for buffers showing lists of possible completions.

Legend:
Removed from v.1.547  
changed lines
  Added in v.1.548

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26