# HG changeset patch # User Stefan Monnier # Date 1252034288 0 # Node ID 02b4657a3268681699f71f7f1f696f3028daa516 # Parent b255a4a2d4f54ac07324040f9ebbb79faa11276e (locate-file-completion-table): Make it provide boundary information, so partial-completion works better. diff -r b255a4a2d4f5 -r 02b4657a3268 lisp/ChangeLog --- a/lisp/ChangeLog Fri Sep 04 03:09:44 2009 +0000 +++ b/lisp/ChangeLog Fri Sep 04 03:18:08 2009 +0000 @@ -1,3 +1,8 @@ +2009-09-04 Stefan Monnier + + * files.el (locate-file-completion-table): Make it provide boundary + information, so partial-completion works better. + 2009-09-04 Leo (tiny change) * mail/footnote.el (Footnote-text-under-cursor): diff -r b255a4a2d4f5 -r 02b4657a3268 lisp/files.el --- a/lisp/files.el Fri Sep 04 03:09:44 2009 +0000 +++ b/lisp/files.el Fri Sep 04 03:18:08 2009 +0000 @@ -716,24 +716,34 @@ (defun locate-file-completion-table (dirs suffixes string pred action) "Do completion for file names passed to `locate-file'." - (if (file-name-absolute-p string) - (let ((read-file-name-predicate pred)) - (read-file-name-internal string nil action)) + (cond + ((file-name-absolute-p string) + (let ((read-file-name-predicate pred)) + (read-file-name-internal string nil action))) + ((eq (car-safe action) 'boundaries) + (let ((suffix (cdr action))) + (list* 'boundaries + (length (file-name-directory string)) + (let ((x (file-name-directory suffix))) + (if x (1- (length x)) (length suffix)))))) + (t (let ((names nil) (suffix (concat (regexp-opt suffixes t) "\\'")) - (string-dir (file-name-directory string))) + (string-dir (file-name-directory string)) + (string-file (file-name-nondirectory string))) (dolist (dir dirs) (unless dir (setq dir default-directory)) (if string-dir (setq dir (expand-file-name string-dir dir))) (when (file-directory-p dir) (dolist (file (file-name-all-completions - (file-name-nondirectory string) dir)) - (add-to-list 'names (if string-dir (concat string-dir file) file)) + string-file dir)) + (push file names) (when (string-match suffix file) (setq file (substring file 0 (match-beginning 0))) - (push (if string-dir (concat string-dir file) file) names))))) - (complete-with-action action names string pred)))) + (push file names))))) + (completion-table-with-context + string-dir names string-file pred action))))) (defun locate-file-completion (string path-and-suffixes action) "Do completion for file names passed to `locate-file'.