diff options
| author | Glenn Morris | 2011-02-19 12:36:54 -0800 |
|---|---|---|
| committer | Glenn Morris | 2011-02-19 12:36:54 -0800 |
| commit | bea584fae3e985332d15a05fd08b3c322a965c75 (patch) | |
| tree | 2dfa2fb4a6b3c362970b1aa45f8d270f6e1f7412 | |
| parent | 615d868ee6add5d37db574d266f0d166c2f16bb8 (diff) | |
| download | emacs-bea584fae3e985332d15a05fd08b3c322a965c75.tar.gz emacs-bea584fae3e985332d15a05fd08b3c322a965c75.zip | |
Merge dired-x's dired-find-buffer-nocreate into dired.el.
* lisp/dired-x.el (dired-find-buffer-nocreate): Merge into dired.el.
* lisp/dired.el (dired-find-buffer-nocreate): Merge dired-x version.
* doc/misc/dired-x.texi (Technical Details):
No longer redefines dired-find-buffer-nocreate.
| -rw-r--r-- | doc/misc/ChangeLog | 4 | ||||
| -rw-r--r-- | doc/misc/dired-x.texi | 22 | ||||
| -rw-r--r-- | lisp/ChangeLog | 3 | ||||
| -rw-r--r-- | lisp/dired-x.el | 32 | ||||
| -rw-r--r-- | lisp/dired.el | 55 |
5 files changed, 56 insertions, 60 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index 164fdc4ed65..8906c53aeed 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog | |||
| @@ -51,8 +51,8 @@ | |||
| 51 | 2011-02-19 Glenn Morris <rgm@gnu.org> | 51 | 2011-02-19 Glenn Morris <rgm@gnu.org> |
| 52 | 52 | ||
| 53 | * dired-x.texi (Technical Details): No longer redefines dired-add-entry, | 53 | * dired-x.texi (Technical Details): No longer redefines dired-add-entry, |
| 54 | dired-initial-position, dired-clean-up-after-deletion, or | 54 | dired-initial-position, dired-clean-up-after-deletion, |
| 55 | dired-read-shell-command. | 55 | dired-read-shell-command, or dired-find-buffer-nocreate. |
| 56 | 56 | ||
| 57 | 2011-02-18 Glenn Morris <rgm@gnu.org> | 57 | 2011-02-18 Glenn Morris <rgm@gnu.org> |
| 58 | 58 | ||
diff --git a/doc/misc/dired-x.texi b/doc/misc/dired-x.texi index c4e474f0943..003046d5a7c 100644 --- a/doc/misc/dired-x.texi +++ b/doc/misc/dired-x.texi | |||
| @@ -174,19 +174,19 @@ Point}). | |||
| 174 | 174 | ||
| 175 | @node Technical Details, , Features, Introduction | 175 | @node Technical Details, , Features, Introduction |
| 176 | @section Technical Details | 176 | @section Technical Details |
| 177 | @cindex Redefined functions | 177 | @cindex Modified functions |
| 178 | @cindex @file{dired-aux.el} | 178 | @cindex @file{dired-aux.el} |
| 179 | 179 | ||
| 180 | When loaded this code @emph{redefines} the standard @file{dired.el} | 180 | When @file{dired-x.el} is loaded, some standard Dired functions from |
| 181 | function @code{dired-find-buffer-nocreate}. In addition, once | 181 | @file{dired.el} and @file{dired-aux.el} offer additional features. |
| 182 | @file{dired-x.el} is loaded, the following Dired functions offer | 182 | @code{dired-add-entry} obeys Dired Omit mode (@pxref{Omitting Files in |
| 183 | additional features. @code{dired-add-entry} obeys Dired Omit mode | 183 | Dired}), if it is active. @code{dired-find-buffer-nocreate} and |
| 184 | (@pxref{Omitting Files in Dired}), if it is active. | 184 | @code{dired-initial-position} respect the value of |
| 185 | @code{dired-initial-position} obeys @code{dired-find-subdir} | 185 | @code{dired-find-subdir} (@pxref{Miscellaneous Commands}). |
| 186 | (@pxref{Miscellaneous Commands}). @code{dired-clean-up-after-deletion} | 186 | @code{dired-clean-up-after-deletion} respects the value of |
| 187 | respects the value of @code{dired-clean-up-buffers-too}. | 187 | @code{dired-clean-up-buffers-too}. @code{dired-read-shell-command} uses |
| 188 | @code{dired-read-shell-command} uses @code{dired-guess-shell-command} | 188 | @code{dired-guess-shell-command} (@pxref{Shell Command Guessing}) to |
| 189 | (@pxref{Shell Command Guessing}) to offer a smarter default command. | 189 | offer a smarter default command. |
| 190 | 190 | ||
| 191 | @node Installation, Omitting Files in Dired, Introduction, Top | 191 | @node Installation, Omitting Files in Dired, Introduction, Top |
| 192 | @chapter Installation | 192 | @chapter Installation |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 840f96bfcf1..16f1c7dbe5e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -22,6 +22,9 @@ | |||
| 22 | 22 | ||
| 23 | 2011-02-19 Glenn Morris <rgm@gnu.org> | 23 | 2011-02-19 Glenn Morris <rgm@gnu.org> |
| 24 | 24 | ||
| 25 | * dired-x.el (dired-find-buffer-nocreate): Merge into dired.el. | ||
| 26 | * dired.el (dired-find-buffer-nocreate): Merge dired-x version. | ||
| 27 | |||
| 25 | * dired-x.el (dired-read-shell-command): Merge into dired-aux's version. | 28 | * dired-x.el (dired-read-shell-command): Merge into dired-aux's version. |
| 26 | * dired-aux.el (dired-read-shell-command): Merge dired-x's version. | 29 | * dired-aux.el (dired-read-shell-command): Merge dired-x's version. |
| 27 | 30 | ||
diff --git a/lisp/dired-x.el b/lisp/dired-x.el index 042fbe0b085..ff051f65fe9 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el | |||
| @@ -42,13 +42,12 @@ | |||
| 42 | ;; ;; (dired-omit-mode 1) | 42 | ;; ;; (dired-omit-mode 1) |
| 43 | ;; )) | 43 | ;; )) |
| 44 | ;; | 44 | ;; |
| 45 | ;; At load time dired-x.el will install itself, redefine some functions, and | 45 | ;; At load time dired-x.el will install itself and bind some dired keys. |
| 46 | ;; bind some dired keys. | 46 | ;; Some dired.el and dired-aux.el functions have extra features if |
| 47 | ;; dired-x is loaded. | ||
| 47 | 48 | ||
| 48 | ;; User customization: M-x customize-group RET dired-x RET. | 49 | ;; User customization: M-x customize-group RET dired-x RET. |
| 49 | 50 | ||
| 50 | ;; When loaded this code redefines dired.el's dired-find-buffer-nocreate. | ||
| 51 | |||
| 52 | ;; *Please* see the `dired-x' info pages for more details. | 51 | ;; *Please* see the `dired-x' info pages for more details. |
| 53 | 52 | ||
| 54 | 53 | ||
| @@ -1306,31 +1305,6 @@ Otherwise obeys the value of `dired-vm-read-only-folders'." | |||
| 1306 | 1305 | ||
| 1307 | ;;; MISCELLANEOUS INTERNAL FUNCTIONS. | 1306 | ;;; MISCELLANEOUS INTERNAL FUNCTIONS. |
| 1308 | 1307 | ||
| 1309 | (declare-function dired-old-find-buffer-nocreate "dired-x") | ||
| 1310 | |||
| 1311 | (or (fboundp 'dired-old-find-buffer-nocreate) | ||
| 1312 | (fset 'dired-old-find-buffer-nocreate | ||
| 1313 | (symbol-function 'dired-find-buffer-nocreate))) | ||
| 1314 | |||
| 1315 | ;; REDEFINE. | ||
| 1316 | ;; Redefines dired.el's version of `dired-find-buffer-nocreate' | ||
| 1317 | (defun dired-find-buffer-nocreate (dirname &optional mode) | ||
| 1318 | (if (and dired-find-subdir | ||
| 1319 | ;; don't try to find a wildcard as a subdirectory | ||
| 1320 | (string-equal dirname (file-name-directory dirname))) | ||
| 1321 | (let* ((cur-buf (current-buffer)) | ||
| 1322 | (buffers (nreverse | ||
| 1323 | (dired-buffers-for-dir (expand-file-name dirname)))) | ||
| 1324 | (cur-buf-matches (and (memq cur-buf buffers) | ||
| 1325 | ;; wildcards must match, too: | ||
| 1326 | (equal dired-directory dirname)))) | ||
| 1327 | ;; We don't want to switch to the same buffer--- | ||
| 1328 | (setq buffers (delq cur-buf buffers));;need setq with delq | ||
| 1329 | (or (car (sort buffers #'dired-buffer-more-recently-used-p)) | ||
| 1330 | ;; ---unless it's the only possibility: | ||
| 1331 | (and cur-buf-matches cur-buf))) | ||
| 1332 | (dired-old-find-buffer-nocreate dirname mode))) | ||
| 1333 | |||
| 1334 | ;; This should be a builtin | 1308 | ;; This should be a builtin |
| 1335 | (defun dired-buffer-more-recently-used-p (buffer1 buffer2) | 1309 | (defun dired-buffer-more-recently-used-p (buffer1 buffer2) |
| 1336 | "Return t if BUFFER1 is more recently used than BUFFER2. | 1310 | "Return t if BUFFER1 is more recently used than BUFFER2. |
diff --git a/lisp/dired.el b/lisp/dired.el index c5174561faf..1834fe3eeb3 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -847,28 +847,47 @@ periodically reverts at specified time intervals." | |||
| 847 | ;; killed buffer, it is removed from this list. | 847 | ;; killed buffer, it is removed from this list. |
| 848 | "Alist of expanded directories and their associated dired buffers.") | 848 | "Alist of expanded directories and their associated dired buffers.") |
| 849 | 849 | ||
| 850 | (defvar dired-find-subdir) | ||
| 851 | |||
| 852 | ;; FIXME add a doc-string, and document dired-x extensions. | ||
| 850 | (defun dired-find-buffer-nocreate (dirname &optional mode) | 853 | (defun dired-find-buffer-nocreate (dirname &optional mode) |
| 851 | ;; This differs from dired-buffers-for-dir in that it does not consider | 854 | ;; This differs from dired-buffers-for-dir in that it does not consider |
| 852 | ;; subdirs of default-directory and searches for the first match only. | 855 | ;; subdirs of default-directory and searches for the first match only. |
| 853 | ;; Also, the major mode must be MODE. | 856 | ;; Also, the major mode must be MODE. |
| 854 | (setq dirname (expand-file-name dirname)) | 857 | (if (and (featurep 'dired-x) |
| 855 | (let (found (blist dired-buffers)) ; was (buffer-list) | 858 | dired-find-subdir |
| 856 | (or mode (setq mode 'dired-mode)) | 859 | ;; Don't try to find a wildcard as a subdirectory. |
| 857 | (while blist | 860 | (string-equal dirname (file-name-directory dirname))) |
| 858 | (if (null (buffer-name (cdr (car blist)))) | 861 | (let* ((cur-buf (current-buffer)) |
| 859 | (setq blist (cdr blist)) | 862 | (buffers (nreverse |
| 860 | (with-current-buffer (cdr (car blist)) | 863 | (dired-buffers-for-dir (expand-file-name dirname)))) |
| 861 | (if (and (eq major-mode mode) | 864 | (cur-buf-matches (and (memq cur-buf buffers) |
| 862 | dired-directory ;; nil during find-alternate-file | 865 | ;; Wildcards must match, too: |
| 863 | (equal dirname | 866 | (equal dired-directory dirname)))) |
| 864 | (expand-file-name | 867 | ;; We don't want to switch to the same buffer--- |
| 865 | (if (consp dired-directory) | 868 | (setq buffers (delq cur-buf buffers)) |
| 866 | (car dired-directory) | 869 | (or (car (sort buffers #'dired-buffer-more-recently-used-p)) |
| 867 | dired-directory)))) | 870 | ;; ---unless it's the only possibility: |
| 868 | (setq found (cdr (car blist)) | 871 | (and cur-buf-matches cur-buf))) |
| 869 | blist nil) | 872 | ;; No dired-x, or dired-find-subdir nil. |
| 870 | (setq blist (cdr blist)))))) | 873 | (setq dirname (expand-file-name dirname)) |
| 871 | found)) | 874 | (let (found (blist dired-buffers)) ; was (buffer-list) |
| 875 | (or mode (setq mode 'dired-mode)) | ||
| 876 | (while blist | ||
| 877 | (if (null (buffer-name (cdr (car blist)))) | ||
| 878 | (setq blist (cdr blist)) | ||
| 879 | (with-current-buffer (cdr (car blist)) | ||
| 880 | (if (and (eq major-mode mode) | ||
| 881 | dired-directory ;; nil during find-alternate-file | ||
| 882 | (equal dirname | ||
| 883 | (expand-file-name | ||
| 884 | (if (consp dired-directory) | ||
| 885 | (car dired-directory) | ||
| 886 | dired-directory)))) | ||
| 887 | (setq found (cdr (car blist)) | ||
| 888 | blist nil) | ||
| 889 | (setq blist (cdr blist)))))) | ||
| 890 | found))) | ||
| 872 | 891 | ||
| 873 | 892 | ||
| 874 | ;; Read in a new dired buffer | 893 | ;; Read in a new dired buffer |