| 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)))) |
|---|
| 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)) |
|---|