diff options
| author | Stefan Monnier | 2000-11-21 20:42:39 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-11-21 20:42:39 +0000 |
| commit | f4eda05fe5461b7aa6c8d2442a4ee6656a2f8e41 (patch) | |
| tree | 5cf878ab546cd3b185d1a4b4c7420e2004f3dab0 | |
| parent | 77270fac616dd9a25743c95c7082489e5a669f35 (diff) | |
| download | emacs-f4eda05fe5461b7aa6c8d2442a4ee6656a2f8e41.tar.gz emacs-f4eda05fe5461b7aa6c8d2442a4ee6656a2f8e41.zip | |
(uniquify-list-buffers-directory-modes): New var.
(uniquify-buffer-file-name): Use it.
| -rw-r--r-- | lisp/uniquify.el | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lisp/uniquify.el b/lisp/uniquify.el index aa5faf0498c..e171de728a7 100644 --- a/lisp/uniquify.el +++ b/lisp/uniquify.el | |||
| @@ -72,6 +72,8 @@ | |||
| 72 | ;; Use directory-file-name; code cleanup. mernst 6 Sep 97 | 72 | ;; Use directory-file-name; code cleanup. mernst 6 Sep 97 |
| 73 | ;; Add uniquify-ignore-buffers-re. | 73 | ;; Add uniquify-ignore-buffers-re. |
| 74 | ;; Andre Srinivasan <andre@visigenic.com> 9 Sep 97 | 74 | ;; Andre Srinivasan <andre@visigenic.com> 9 Sep 97 |
| 75 | ;; Add uniquify-list-buffers-directory-modes | ||
| 76 | ;; Stefan Monnier <monnier@cs.yale.edu> 17 Nov 2000 | ||
| 75 | 77 | ||
| 76 | ;; Valuable feedback was provided by | 78 | ;; Valuable feedback was provided by |
| 77 | ;; Paul Smith <psmith@baynetworks.com>, | 79 | ;; Paul Smith <psmith@baynetworks.com>, |
| @@ -157,6 +159,10 @@ variable is ignored." | |||
| 157 | :type 'boolean | 159 | :type 'boolean |
| 158 | :group 'uniquify) | 160 | :group 'uniquify) |
| 159 | 161 | ||
| 162 | (defvar uniquify-list-buffers-directory-modes '(dired-mode cvs-mode) | ||
| 163 | "List of modes for which uniquify should obey `list-buffers-directory'. | ||
| 164 | That means that when `buffer-file-name' is set to nil, `list-buffers-directory' | ||
| 165 | contains the name of the directory which the buffer is visiting.") | ||
| 160 | 166 | ||
| 161 | ;;; Utilities | 167 | ;;; Utilities |
| 162 | 168 | ||
| @@ -186,7 +192,7 @@ variable is ignored." | |||
| 186 | ;;; Main entry point. | 192 | ;;; Main entry point. |
| 187 | 193 | ||
| 188 | (defun uniquify-rationalize-file-buffer-names (&optional newbuffile newbuf) | 194 | (defun uniquify-rationalize-file-buffer-names (&optional newbuffile newbuf) |
| 189 | "Makes file buffer names unique by adding segments from file name. | 195 | "Make file buffer names unique by adding segments from file name. |
| 190 | If `uniquify-min-dir-content' > 0, always pulls that many | 196 | If `uniquify-min-dir-content' > 0, always pulls that many |
| 191 | file name elements. Arguments cause only a subset of buffers to be renamed." | 197 | file name elements. Arguments cause only a subset of buffers to be renamed." |
| 192 | (interactive) | 198 | (interactive) |
| @@ -226,13 +232,12 @@ file name elements. Arguments cause only a subset of buffers to be renamed." | |||
| 226 | ;; uniquify's version of buffer-file-name; result never contains trailing slash | 232 | ;; uniquify's version of buffer-file-name; result never contains trailing slash |
| 227 | (defun uniquify-buffer-file-name (buffer) | 233 | (defun uniquify-buffer-file-name (buffer) |
| 228 | "Return name of file BUFFER is visiting, or nil if none. | 234 | "Return name of file BUFFER is visiting, or nil if none. |
| 229 | Works on dired buffers and ordinary file-visiting buffers, but no others." | 235 | Works on ordinary file-visiting buffers and buffers whose mode is mentioned |
| 236 | in `uniquify-list-buffers-directory-modes', otherwise returns nil." | ||
| 230 | (or (buffer-file-name buffer) | 237 | (or (buffer-file-name buffer) |
| 231 | (and (featurep 'dired) | 238 | (with-current-buffer buffer |
| 232 | (save-excursion | ||
| 233 | (set-buffer buffer) | ||
| 234 | (and | 239 | (and |
| 235 | (eq major-mode 'dired-mode) ; do nothing if not a dired buffer | 240 | (memq major-mode uniquify-list-buffers-directory-modes) |
| 236 | (if (boundp 'list-buffers-directory) ; XEmacs mightn't define this | 241 | (if (boundp 'list-buffers-directory) ; XEmacs mightn't define this |
| 237 | (and list-buffers-directory | 242 | (and list-buffers-directory |
| 238 | (directory-file-name list-buffers-directory)) | 243 | (directory-file-name list-buffers-directory)) |
| @@ -242,7 +247,7 @@ Works on dired buffers and ordinary file-visiting buffers, but no others." | |||
| 242 | (directory-file-name | 247 | (directory-file-name |
| 243 | (if (consp dired-directory) | 248 | (if (consp dired-directory) |
| 244 | (car dired-directory) | 249 | (car dired-directory) |
| 245 | dired-directory)))))))))) | 250 | dired-directory))))))))) |
| 246 | 251 | ||
| 247 | ;; This examines the filename components in reverse order. | 252 | ;; This examines the filename components in reverse order. |
| 248 | (defun uniquify-filename-lessp (s1 s2) | 253 | (defun uniquify-filename-lessp (s1 s2) |