Show
Ignore:
Timestamp:
05/03/06 18:37:43 (3 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk

    • Property svn:ignore changed from
      bin
      to
      bin
      site-lisp
  • trunk/lisp/complete.el

    r4058 r4073  
    142142 
    143143  
    144 (defvar PC-old-read-file-name-internal nil) 
    145  
    146144(defun PC-bindings (bind) 
    147145  (let ((completion-map minibuffer-local-completion-map) 
     
    220218         (add-hook 'find-file-not-found-functions 'PC-look-for-include-file))) 
    221219  ;; ... with some underhand redefining. 
    222   (cond ((and (not partial-completion-mode) 
    223               (functionp PC-old-read-file-name-internal)) 
    224          (fset 'read-file-name-internal PC-old-read-file-name-internal)) 
    225         ((and (not PC-disable-includes) (not PC-old-read-file-name-internal)) 
    226          (setq PC-old-read-file-name-internal 
    227                (symbol-function 'read-file-name-internal)) 
    228          (fset 'read-file-name-internal 
    229                'PC-read-include-file-name-internal))) 
    230     (when (and partial-completion-mode (null PC-env-vars-alist)) 
    231       (setq PC-env-vars-alist 
    232             (mapcar (lambda (string) 
    233                       (let ((d (string-match "=" string))) 
    234                         (cons (concat "$" (substring string 0 d)) 
    235                               (and d (substring string (1+ d)))))) 
    236                     process-environment)))) 
     220  (cond ((not partial-completion-mode) 
     221         (ad-disable-advice 'read-file-name-internal 'around 'PC-include-file) 
     222         (ad-activate 'read-file-name-internal)) 
     223        ((not PC-disable-includes) 
     224         (ad-enable-advice 'read-file-name-internal 'around 'PC-include-file) 
     225         (ad-activate 'read-file-name-internal))) 
     226  ;; Adjust the completion selection in *Completion* buffers to the way 
     227  ;; we work.  The default minibuffer completion code only completes the 
     228  ;; text before point and leaves the text after point alone (new in 
     229  ;; Emacs-22).  In contrast we use the whole text and we even sometimes 
     230  ;; move point to a place before EOB, to indicate the first position where 
     231  ;; there's a difference, so when the user uses choose-completion, we have 
     232  ;; to trick choose-completion into replacing the whole minibuffer text 
     233  ;; rather than only the text before point.  --Stef 
     234  (funcall 
     235   (if partial-completion-mode 'add-hook 'remove-hook) 
     236   'choose-completion-string-functions 
     237   (lambda (&rest x) (goto-char (point-max)) nil)) 
     238  ;; Build the env-completion and mapping table. 
     239  (when (and partial-completion-mode (null PC-env-vars-alist)) 
     240    (setq PC-env-vars-alist 
     241          (mapcar (lambda (string) 
     242                    (let ((d (string-match "=" string))) 
     243                      (cons (concat "$" (substring string 0 d)) 
     244                            (and d (substring string (1+ d)))))) 
     245                  process-environment)))) 
    237246 
    238247  
     
    931940        compressed)))) 
    932941 
    933 (defun PC-read-include-file-name-internal (string dir action) 
    934   (if (string-match "<\\([^\"<>]*\\)>?$" string) 
    935       (let* ((name (substring string (match-beginning 1) (match-end 1))) 
     942(defadvice read-file-name-internal (around PC-include-file disable) 
     943  (if (string-match "<\\([^\"<>]*\\)>?\\'" (ad-get-arg 0)) 
     944      (let* ((string (ad-get-arg 0)) 
     945             (action (ad-get-arg 2)) 
     946             (name (substring string (match-beginning 1) (match-end 1))) 
    936947             (str2 (substring string (match-beginning 0))) 
    937948             (completion-table 
    938               (mapcar (function (lambda (x) (list (format "<%s>" x)))) 
     949              (mapcar (lambda (x) (format "<%s>" x)) 
    939950                      (PC-include-file-all-completions 
    940951                       name (PC-include-file-path))))) 
    941         (cond 
    942          ((not completion-table) nil) 
    943          ((eq action nil) (try-completion str2 completion-table nil)) 
    944          ((eq action t) (all-completions str2 completion-table nil)) 
    945          ((eq action 'lambda) (test-completion str2 completion-table nil)))) 
    946     (funcall PC-old-read-file-name-internal string dir action))) 
     952        (setq ad-return-value 
     953              (cond 
     954               ((not completion-table) nil) 
     955               ((eq action 'lambda) (test-completion str2 completion-table nil)) 
     956               ((eq action nil) (try-completion str2 completion-table nil)) 
     957               ((eq action t) (all-completions str2 completion-table nil))))) 
     958    ad-do-it)) 
    947959  
    948960