Mercurial > emacs
comparison lisp/files.el @ 105697:136cf2d23c90
* minibuffer.el (completion-table-with-terminator): Properly implement
boundaries, in case `terminator' appears in the suffix.
(completion--embedded-envvar-table): Don't return boundaries if
there's no valid completion. Simplify.
(completion-file-name-table): New completion table extracted from
completion--file-name-table.
(completion--file-name-table): Use it.
(read-file-name-predicate): Declare obsolete.
(read-file-name): Use the pred arg i.s.o read-file-name-predicate.
* vc-bzr.el (vc-bzr-revision-completion-table): Use the new
completion-file-name-table, and use the `pred' argument.
* files.el (locate-file-completion-table): Use the `pred' arg rather
than read-file-name-predicate.
(abbreviate-file-name): Use \` rather than ^ for BOS.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 21 Oct 2009 20:03:57 +0000 |
parents | 196c2ded63f5 |
children | 26d5ef08acf0 |
comparison
equal
deleted
inserted
replaced
105696:56d1856a3ea9 | 105697:136cf2d23c90 |
---|---|
726 | 726 |
727 (defun locate-file-completion-table (dirs suffixes string pred action) | 727 (defun locate-file-completion-table (dirs suffixes string pred action) |
728 "Do completion for file names passed to `locate-file'." | 728 "Do completion for file names passed to `locate-file'." |
729 (cond | 729 (cond |
730 ((file-name-absolute-p string) | 730 ((file-name-absolute-p string) |
731 (let ((read-file-name-predicate pred)) | 731 ;; FIXME: maybe we should use completion-file-name-table instead, |
732 (read-file-name-internal string nil action))) | 732 ;; tho at least for `load', the arg is passed through |
733 ;; substitute-in-file-name for historical reasons. | |
734 (read-file-name-internal string pred action)) | |
733 ((eq (car-safe action) 'boundaries) | 735 ((eq (car-safe action) 'boundaries) |
734 (let ((suffix (cdr action))) | 736 (let ((suffix (cdr action))) |
735 (list* 'boundaries | 737 (list* 'boundaries |
736 (length (file-name-directory string)) | 738 (length (file-name-directory string)) |
737 (let ((x (file-name-directory suffix))) | 739 (let ((x (file-name-directory suffix))) |
1601 ;; We include a slash at the end, to avoid spurious matches | 1603 ;; We include a slash at the end, to avoid spurious matches |
1602 ;; such as `/usr/foobar' when the home dir is `/usr/foo'. | 1604 ;; such as `/usr/foobar' when the home dir is `/usr/foo'. |
1603 (or abbreviated-home-dir | 1605 (or abbreviated-home-dir |
1604 (setq abbreviated-home-dir | 1606 (setq abbreviated-home-dir |
1605 (let ((abbreviated-home-dir "$foo")) | 1607 (let ((abbreviated-home-dir "$foo")) |
1606 (concat "^" (abbreviate-file-name (expand-file-name "~")) | 1608 (concat "\\`" (abbreviate-file-name (expand-file-name "~")) |
1607 "\\(/\\|\\'\\)")))) | 1609 "\\(/\\|\\'\\)")))) |
1608 | 1610 |
1609 ;; If FILENAME starts with the abbreviated homedir, | 1611 ;; If FILENAME starts with the abbreviated homedir, |
1610 ;; make it start with `~' instead. | 1612 ;; make it start with `~' instead. |
1611 (if (and (string-match abbreviated-home-dir filename) | 1613 (if (and (string-match abbreviated-home-dir filename) |
1612 ;; If the home dir is just /, don't change it. | 1614 ;; If the home dir is just /, don't change it. |
1613 (not (and (= (match-end 0) 1) | 1615 (not (and (= (match-end 0) 1) |
1614 (= (aref filename 0) ?/))) | 1616 (= (aref filename 0) ?/))) |
1615 ;; MS-DOS root directories can come with a drive letter; | 1617 ;; MS-DOS root directories can come with a drive letter; |
1616 ;; Novell Netware allows drive letters beyond `Z:'. | 1618 ;; Novell Netware allows drive letters beyond `Z:'. |
1617 (not (and (or (eq system-type 'ms-dos) | 1619 (not (and (memq system-type '(ms-dos windows-nt cygwin)) |
1618 (eq system-type 'cygwin) | |
1619 (eq system-type 'windows-nt)) | |
1620 (save-match-data | 1620 (save-match-data |
1621 (string-match "^[a-zA-`]:/$" filename))))) | 1621 (string-match "^[a-zA-`]:/$" filename))))) |
1622 (setq filename | 1622 (setq filename |
1623 (concat "~" | 1623 (concat "~" |
1624 (match-string 1 filename) | 1624 (match-string 1 filename) |
1641 (truename (abbreviate-file-name (file-truename filename)))) | 1641 (truename (abbreviate-file-name (file-truename filename)))) |
1642 (or (let ((buf (get-file-buffer filename))) | 1642 (or (let ((buf (get-file-buffer filename))) |
1643 (when (and buf (funcall predicate buf)) buf)) | 1643 (when (and buf (funcall predicate buf)) buf)) |
1644 (let ((list (buffer-list)) found) | 1644 (let ((list (buffer-list)) found) |
1645 (while (and (not found) list) | 1645 (while (and (not found) list) |
1646 (save-excursion | 1646 (with-current-buffer (car list) |
1647 (set-buffer (car list)) | |
1648 (if (and buffer-file-name | 1647 (if (and buffer-file-name |
1649 (string= buffer-file-truename truename) | 1648 (string= buffer-file-truename truename) |
1650 (funcall predicate (current-buffer))) | 1649 (funcall predicate (current-buffer))) |
1651 (setq found (car list)))) | 1650 (setq found (car list)))) |
1652 (setq list (cdr list))) | 1651 (setq list (cdr list))) |
4832 (throw 'found t))))) | 4831 (throw 'found t))))) |
4833 (yes-or-no-p (format "Revert buffer from file %s? " | 4832 (yes-or-no-p (format "Revert buffer from file %s? " |
4834 file-name))) | 4833 file-name))) |
4835 (run-hooks 'before-revert-hook) | 4834 (run-hooks 'before-revert-hook) |
4836 ;; If file was backed up but has changed since, | 4835 ;; If file was backed up but has changed since, |
4837 ;; we shd make another backup. | 4836 ;; we should make another backup. |
4838 (and (not auto-save-p) | 4837 (and (not auto-save-p) |
4839 (not (verify-visited-file-modtime (current-buffer))) | 4838 (not (verify-visited-file-modtime (current-buffer))) |
4840 (setq buffer-backed-up nil)) | 4839 (setq buffer-backed-up nil)) |
4841 ;; Effectively copy the after-revert-hook status, | 4840 ;; Effectively copy the after-revert-hook status, |
4842 ;; since after-find-file will clobber it. | 4841 ;; since after-find-file will clobber it. |