Mercurial > emacs
comparison lisp/simple.el @ 103201:0f518b180240
(completion-setup-function):
Only modify the default-directory in *Completions* (bug#3250).
Take partial-completion into account when setting default-directory.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 11 May 2009 15:35:44 +0000 |
parents | ce405af23a6e |
children | 5cf7afafabf1 |
comparison
equal
deleted
inserted
replaced
103200:1bf70050c13e | 103201:0f518b180240 |
---|---|
5849 | 5849 |
5850 ;; This function goes in completion-setup-hook, so that it is called | 5850 ;; This function goes in completion-setup-hook, so that it is called |
5851 ;; after the text of the completion list buffer is written. | 5851 ;; after the text of the completion list buffer is written. |
5852 (defun completion-setup-function () | 5852 (defun completion-setup-function () |
5853 (let* ((mainbuf (current-buffer)) | 5853 (let* ((mainbuf (current-buffer)) |
5854 (mbuf-contents (minibuffer-completion-contents)) | 5854 (base-dir |
5855 common-string-length) | 5855 ;; When reading a file name in the minibuffer, |
5856 ;; When reading a file name in the minibuffer, | 5856 ;; try and find the right default-directory to set in the |
5857 ;; set default-directory in the minibuffer | 5857 ;; completion list buffer. |
5858 ;; so it will get copied into the completion list buffer. | 5858 ;; FIXME: Why do we do that, actually? --Stef |
5859 (if minibuffer-completing-file-name | 5859 (if minibuffer-completing-file-name |
5860 (with-current-buffer mainbuf | 5860 (file-name-as-directory |
5861 (setq default-directory | 5861 (expand-file-name |
5862 (file-name-directory (expand-file-name mbuf-contents))))) | 5862 (substring (minibuffer-completion-contents) |
5863 0 (or completion-base-size 0))))))) | |
5863 (with-current-buffer standard-output | 5864 (with-current-buffer standard-output |
5864 (let ((base-size completion-base-size)) ;Read before killing localvars. | 5865 (let ((base-size completion-base-size)) ;Read before killing localvars. |
5865 (completion-list-mode) | 5866 (completion-list-mode) |
5866 (set (make-local-variable 'completion-base-size) base-size)) | 5867 (set (make-local-variable 'completion-base-size) base-size)) |
5867 (set (make-local-variable 'completion-reference-buffer) mainbuf) | 5868 (set (make-local-variable 'completion-reference-buffer) mainbuf) |
5869 (if base-dir (setq default-directory base-dir)) | |
5868 (unless completion-base-size | 5870 (unless completion-base-size |
5869 ;; This shouldn't be needed any more, but further analysis is needed | 5871 ;; This shouldn't be needed any more, but further analysis is needed |
5870 ;; to make sure it's the case. | 5872 ;; to make sure it's the case. |
5871 (setq completion-base-size | 5873 (setq completion-base-size |
5872 (cond | 5874 (cond |