diff options
| author | Stefan Monnier | 2009-09-04 03:18:08 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2009-09-04 03:18:08 +0000 |
| commit | df1204818a023bdde46e36c8cfd878cf0937fab7 (patch) | |
| tree | 52841a521233340b87918ea3c4abb38fc9312cd2 | |
| parent | c0bc6d79eab4c5e38e8eb84558d160f1eb8ed22d (diff) | |
| download | emacs-df1204818a023bdde46e36c8cfd878cf0937fab7.tar.gz emacs-df1204818a023bdde46e36c8cfd878cf0937fab7.zip | |
(locate-file-completion-table): Make it provide boundary
information, so partial-completion works better.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/files.el | 26 |
2 files changed, 23 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7882d1b1b04..64af8363417 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2009-09-04 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * files.el (locate-file-completion-table): Make it provide boundary | ||
| 4 | information, so partial-completion works better. | ||
| 5 | |||
| 1 | 2009-09-04 Leo <sdl.web@gmail.com> (tiny change) | 6 | 2009-09-04 Leo <sdl.web@gmail.com> (tiny change) |
| 2 | 7 | ||
| 3 | * mail/footnote.el (Footnote-text-under-cursor): | 8 | * mail/footnote.el (Footnote-text-under-cursor): |
diff --git a/lisp/files.el b/lisp/files.el index 42eee8e609d..9f22a60dc00 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -716,24 +716,34 @@ one or more of those symbols." | |||
| 716 | 716 | ||
| 717 | (defun locate-file-completion-table (dirs suffixes string pred action) | 717 | (defun locate-file-completion-table (dirs suffixes string pred action) |
| 718 | "Do completion for file names passed to `locate-file'." | 718 | "Do completion for file names passed to `locate-file'." |
| 719 | (if (file-name-absolute-p string) | 719 | (cond |
| 720 | (let ((read-file-name-predicate pred)) | 720 | ((file-name-absolute-p string) |
| 721 | (read-file-name-internal string nil action)) | 721 | (let ((read-file-name-predicate pred)) |
| 722 | (read-file-name-internal string nil action))) | ||
| 723 | ((eq (car-safe action) 'boundaries) | ||
| 724 | (let ((suffix (cdr action))) | ||
| 725 | (list* 'boundaries | ||
| 726 | (length (file-name-directory string)) | ||
| 727 | (let ((x (file-name-directory suffix))) | ||
| 728 | (if x (1- (length x)) (length suffix)))))) | ||
| 729 | (t | ||
| 722 | (let ((names nil) | 730 | (let ((names nil) |
| 723 | (suffix (concat (regexp-opt suffixes t) "\\'")) | 731 | (suffix (concat (regexp-opt suffixes t) "\\'")) |
| 724 | (string-dir (file-name-directory string))) | 732 | (string-dir (file-name-directory string)) |
| 733 | (string-file (file-name-nondirectory string))) | ||
| 725 | (dolist (dir dirs) | 734 | (dolist (dir dirs) |
| 726 | (unless dir | 735 | (unless dir |
| 727 | (setq dir default-directory)) | 736 | (setq dir default-directory)) |
| 728 | (if string-dir (setq dir (expand-file-name string-dir dir))) | 737 | (if string-dir (setq dir (expand-file-name string-dir dir))) |
| 729 | (when (file-directory-p dir) | 738 | (when (file-directory-p dir) |
| 730 | (dolist (file (file-name-all-completions | 739 | (dolist (file (file-name-all-completions |
| 731 | (file-name-nondirectory string) dir)) | 740 | string-file dir)) |
| 732 | (add-to-list 'names (if string-dir (concat string-dir file) file)) | 741 | (push file names) |
| 733 | (when (string-match suffix file) | 742 | (when (string-match suffix file) |
| 734 | (setq file (substring file 0 (match-beginning 0))) | 743 | (setq file (substring file 0 (match-beginning 0))) |
| 735 | (push (if string-dir (concat string-dir file) file) names))))) | 744 | (push file names))))) |
| 736 | (complete-with-action action names string pred)))) | 745 | (completion-table-with-context |
| 746 | string-dir names string-file pred action))))) | ||
| 737 | 747 | ||
| 738 | (defun locate-file-completion (string path-and-suffixes action) | 748 | (defun locate-file-completion (string path-and-suffixes action) |
| 739 | "Do completion for file names passed to `locate-file'. | 749 | "Do completion for file names passed to `locate-file'. |