diff options
| author | Leo Liu | 2011-03-21 22:55:00 +0800 |
|---|---|---|
| committer | Leo Liu | 2011-03-21 22:55:00 +0800 |
| commit | b16ac1ecabbcfc6dc22831ee457bee1f95a2f21f (patch) | |
| tree | 33d20cb97b1fd7ba630edf736fb56f42f8d9cf82 | |
| parent | 4e05e67e4cd0bc1b0a4ef3176a4d0d91c6b3738e (diff) | |
| download | emacs-b16ac1ecabbcfc6dc22831ee457bee1f95a2f21f.tar.gz emacs-b16ac1ecabbcfc6dc22831ee457bee1f95a2f21f.zip | |
Default read-file-name-function to a non-nil value
See discussion thread:
http://thread.gmane.org/gmane.emacs.devel/134000
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 20 |
2 files changed, 19 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d087982edee..7175df3f656 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2011-03-21 Leo Liu <sdl.web@gmail.com> | ||
| 2 | |||
| 3 | * minibuffer.el (read-file-name-function): Change default value. | ||
| 4 | (read-file-name--defaults): Rename from read-file-name-defaults. | ||
| 5 | (read-file-name-default): Rename from read-file-name. | ||
| 6 | (read-file-name): Call read-file-name-function. | ||
| 7 | |||
| 1 | 2011-03-21 Glenn Morris <rgm@gnu.org> | 8 | 2011-03-21 Glenn Morris <rgm@gnu.org> |
| 2 | 9 | ||
| 3 | * eshell/esh-opt.el (eshell-eval-using-options, eshell-process-args): | 10 | * eshell/esh-opt.el (eshell-eval-using-options, eshell-process-args): |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index fa36da01cd9..e541be9fdd9 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -1486,8 +1486,9 @@ except that it passes the file name through `substitute-in-file-name'." | |||
| 1486 | 'completion--file-name-table) | 1486 | 'completion--file-name-table) |
| 1487 | "Internal subroutine for `read-file-name'. Do not call this.") | 1487 | "Internal subroutine for `read-file-name'. Do not call this.") |
| 1488 | 1488 | ||
| 1489 | (defvar read-file-name-function nil | 1489 | (defvar read-file-name-function 'read-file-name-default |
| 1490 | "If this is non-nil, `read-file-name' does its work by calling this function.") | 1490 | "The function called by `read-file-name' to do its work. |
| 1491 | It should accept the same arguments as `read-file-name'.") | ||
| 1491 | 1492 | ||
| 1492 | (defcustom read-file-name-completion-ignore-case | 1493 | (defcustom read-file-name-completion-ignore-case |
| 1493 | (if (memq system-type '(ms-dos windows-nt darwin cygwin)) | 1494 | (if (memq system-type '(ms-dos windows-nt darwin cygwin)) |
| @@ -1525,7 +1526,7 @@ such as making the current buffer visit no file in the case of | |||
| 1525 | (declare-function x-file-dialog "xfns.c" | 1526 | (declare-function x-file-dialog "xfns.c" |
| 1526 | (prompt dir &optional default-filename mustmatch only-dir-p)) | 1527 | (prompt dir &optional default-filename mustmatch only-dir-p)) |
| 1527 | 1528 | ||
| 1528 | (defun read-file-name-defaults (&optional dir initial) | 1529 | (defun read-file-name--defaults (&optional dir initial) |
| 1529 | (let ((default | 1530 | (let ((default |
| 1530 | (cond | 1531 | (cond |
| 1531 | ;; With non-nil `initial', use `dir' as the first default. | 1532 | ;; With non-nil `initial', use `dir' as the first default. |
| @@ -1592,6 +1593,12 @@ treated as equivalent to nil. | |||
| 1592 | 1593 | ||
| 1593 | See also `read-file-name-completion-ignore-case' | 1594 | See also `read-file-name-completion-ignore-case' |
| 1594 | and `read-file-name-function'." | 1595 | and `read-file-name-function'." |
| 1596 | (funcall (or read-file-name-function #'read-file-name-default) | ||
| 1597 | prompt dir default-filename mustmatch initial predicate)) | ||
| 1598 | |||
| 1599 | (defun read-file-name-default (prompt &optional dir default-filename mustmatch initial predicate) | ||
| 1600 | "Default method for reading file names. | ||
| 1601 | See `read-file-name' for the meaning of the arguments." | ||
| 1595 | (unless dir (setq dir default-directory)) | 1602 | (unless dir (setq dir default-directory)) |
| 1596 | (unless (file-name-absolute-p dir) (setq dir (expand-file-name dir))) | 1603 | (unless (file-name-absolute-p dir) (setq dir (expand-file-name dir))) |
| 1597 | (unless default-filename | 1604 | (unless default-filename |
| @@ -1613,9 +1620,6 @@ and `read-file-name-function'." | |||
| 1613 | (minibuffer--double-dollars dir))) | 1620 | (minibuffer--double-dollars dir))) |
| 1614 | (initial (cons (minibuffer--double-dollars initial) 0))))) | 1621 | (initial (cons (minibuffer--double-dollars initial) 0))))) |
| 1615 | 1622 | ||
| 1616 | (if read-file-name-function | ||
| 1617 | (funcall read-file-name-function | ||
| 1618 | prompt dir default-filename mustmatch initial predicate) | ||
| 1619 | (let ((completion-ignore-case read-file-name-completion-ignore-case) | 1623 | (let ((completion-ignore-case read-file-name-completion-ignore-case) |
| 1620 | (minibuffer-completing-file-name t) | 1624 | (minibuffer-completing-file-name t) |
| 1621 | (pred (or predicate 'file-exists-p)) | 1625 | (pred (or predicate 'file-exists-p)) |
| @@ -1651,7 +1655,7 @@ and `read-file-name-function'." | |||
| 1651 | (lambda () | 1655 | (lambda () |
| 1652 | (with-current-buffer | 1656 | (with-current-buffer |
| 1653 | (window-buffer (minibuffer-selected-window)) | 1657 | (window-buffer (minibuffer-selected-window)) |
| 1654 | (read-file-name-defaults dir initial))))) | 1658 | (read-file-name--defaults dir initial))))) |
| 1655 | (completing-read prompt 'read-file-name-internal | 1659 | (completing-read prompt 'read-file-name-internal |
| 1656 | pred mustmatch insdef | 1660 | pred mustmatch insdef |
| 1657 | 'file-name-history default-filename))) | 1661 | 'file-name-history default-filename))) |
| @@ -1725,7 +1729,7 @@ and `read-file-name-function'." | |||
| 1725 | (if history-delete-duplicates | 1729 | (if history-delete-duplicates |
| 1726 | (delete val1 file-name-history) | 1730 | (delete val1 file-name-history) |
| 1727 | file-name-history))))))) | 1731 | file-name-history))))))) |
| 1728 | val))))) | 1732 | val)))) |
| 1729 | 1733 | ||
| 1730 | (defun internal-complete-buffer-except (&optional buffer) | 1734 | (defun internal-complete-buffer-except (&optional buffer) |
| 1731 | "Perform completion on all buffers excluding BUFFER. | 1735 | "Perform completion on all buffers excluding BUFFER. |