diff options
| author | Karl Heuer | 1997-03-11 22:42:37 +0000 |
|---|---|---|
| committer | Karl Heuer | 1997-03-11 22:42:37 +0000 |
| commit | bc2e0aaed9a742ca006a6416371c6fa7fb034048 (patch) | |
| tree | ade4bdda55a45fc0b5a8beef83793c8eeda64ff8 | |
| parent | 42875c6da8beaeaffbd0f37825032ee6cc4a039e (diff) | |
| download | emacs-bc2e0aaed9a742ca006a6416371c6fa7fb034048.tar.gz emacs-bc2e0aaed9a742ca006a6416371c6fa7fb034048.zip | |
(uniquify-buffer-file-name): Don't call
expand-file-name on nil. Check whether list-buffers-directory is
bound. Ignore non-file non-dired buffers.
| -rw-r--r-- | lisp/uniquify.el | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/lisp/uniquify.el b/lisp/uniquify.el index 0152721dad0..5d2f2107228 100644 --- a/lisp/uniquify.el +++ b/lisp/uniquify.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; uniquify.el --- unique buffer names dependent on file name | 1 | ;;; uniquify.el --- unique buffer names dependent on file name |
| 2 | 2 | ||
| 3 | ;; Copyright (c) 1989, 1995 Free Software Foundation, Inc. | 3 | ;; Copyright (c) 1989, 1995, 1996, 1997 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Dick King <king@reasoning.com> | 5 | ;; Author: Dick King <king@reasoning.com> |
| 6 | ;; Maintainer: Michael Ernst <mernst@theory.lcs.mit.edu> | 6 | ;; Maintainer: Michael Ernst <mernst@theory.lcs.mit.edu> |
| @@ -34,13 +34,19 @@ | |||
| 34 | ;; Makefile|zaphod, respectively (instead of Makefile and Makefile<2>). | 34 | ;; Makefile|zaphod, respectively (instead of Makefile and Makefile<2>). |
| 35 | ;; Other buffer name styles are also available. | 35 | ;; Other buffer name styles are also available. |
| 36 | 36 | ||
| 37 | ;; To use this file, just load it. | 37 | ;; To use this file, just load it; or add (require 'uniquify) to your .emacs. |
| 38 | ;; To disable it after loading, set variable uniquify-buffer-name-style to nil. | 38 | ;; To disable it after loading, set variable uniquify-buffer-name-style to nil. |
| 39 | ;; For other options, see "User-visible variables", below. | 39 | ;; For other options, see "User-visible variables", below. |
| 40 | 40 | ||
| 41 | ;; A version of uniquify.el that works under Emacs 18, Emacs 19, XEmacs, | 41 | ;; A version of uniquify.el that works under Emacs 18, Emacs 19, XEmacs, |
| 42 | ;; and InfoDock is available from the maintainer. | 42 | ;; and InfoDock is available from the maintainer. |
| 43 | 43 | ||
| 44 | ;; Doesn't correctly handle buffer names created by M-x write-file in Emacs 18. | ||
| 45 | ;; Doesn't work under NT when backslash is used as a path separator (forward | ||
| 46 | ;; slash path separator works fine). To fix, check system-type against | ||
| 47 | ;; 'windows-nt, write a routine that breaks paths down into components. | ||
| 48 | ;; (Surprisingly, there isn't one built in.) | ||
| 49 | |||
| 44 | ;;; Change Log: | 50 | ;;; Change Log: |
| 45 | 51 | ||
| 46 | ;; Originally by Dick King <king@reasoning.com> 15 May 86 | 52 | ;; Originally by Dick King <king@reasoning.com> 15 May 86 |
| @@ -59,13 +65,17 @@ | |||
| 59 | ;; uniquify-buffer-name-style; add 'forward and 'post-forward-angle-brackets | 65 | ;; uniquify-buffer-name-style; add 'forward and 'post-forward-angle-brackets |
| 60 | ;; styles; remove uniquify-reverse-dir-content-p; add | 66 | ;; styles; remove uniquify-reverse-dir-content-p; add |
| 61 | ;; uniquify-trailing-separator-p. mernst 4 Aug 95 | 67 | ;; uniquify-trailing-separator-p. mernst 4 Aug 95 |
| 68 | ;; Don't call expand-file-name on nil. mernst 7 Jan 96 | ||
| 69 | ;; Check whether list-buffers-directory is bound. mernst 11 Oct 96 | ||
| 70 | ;; Ignore non-file non-dired buffers. Colin Rafferty <craffert@ml.com> 3 Mar 97 | ||
| 62 | 71 | ||
| 63 | ;; Valuable feedback was provided by | 72 | ;; Valuable feedback was provided by |
| 64 | ;; Paul Smith <psmith@baynetworks.com>, | 73 | ;; Paul Smith <psmith@baynetworks.com>, |
| 65 | ;; Alastair Burt <burt@dfki.uni-kl.de>, | 74 | ;; Alastair Burt <burt@dfki.uni-kl.de>, |
| 66 | ;; Bob Weiner <weiner@footloose.sps.mot.com>, | 75 | ;; Bob Weiner <weiner@footloose.sps.mot.com>, |
| 67 | ;; Albert L. Ting <alt@vlibs.com>, | 76 | ;; Albert L. Ting <alt@vlibs.com>, |
| 68 | ;; gyro@reasoning.com. | 77 | ;; gyro@reasoning.com, |
| 78 | ;; Bryan O'Sullivan <bos@eng.sun.com>. | ||
| 69 | 79 | ||
| 70 | 80 | ||
| 71 | ;;; Code: | 81 | ;;; Code: |
| @@ -172,11 +182,23 @@ file name elements. Arguments cause only a subset of buffers to be renamed." | |||
| 172 | ;; uniquify's version of buffer-file-name | 182 | ;; uniquify's version of buffer-file-name |
| 173 | (defun uniquify-buffer-file-name (buffer) | 183 | (defun uniquify-buffer-file-name (buffer) |
| 174 | "Return name of file BUFFER is visiting, or nil if none. | 184 | "Return name of file BUFFER is visiting, or nil if none. |
| 175 | Works on dired buffers as well as ordinary file-visiting buffers." | 185 | Works on dired buffers as well as ordinary file-visiting buffers, |
| 186 | but no others." | ||
| 176 | (or (buffer-file-name buffer) | 187 | (or (buffer-file-name buffer) |
| 188 | (and (featurep 'dired) | ||
| 177 | (save-excursion | 189 | (save-excursion |
| 178 | (set-buffer buffer) | 190 | (set-buffer buffer) |
| 179 | list-buffers-directory))) | 191 | (and |
| 192 | (eq major-mode 'dired-mode) ; do nothing if not a dired buffer | ||
| 193 | (if (boundp 'list-buffers-directory) ; XEmacs mightn't define this | ||
| 194 | list-buffers-directory | ||
| 195 | ;; don't use default-directory if dired-directory is nil | ||
| 196 | (and dired-directory | ||
| 197 | (expand-file-name | ||
| 198 | (directory-file-name | ||
| 199 | (if (consp dired-directory) | ||
| 200 | (car dired-directory) | ||
| 201 | dired-directory)))))))))) | ||
| 180 | 202 | ||
| 181 | (defun uniquify-fix-list-filename-lessp (fixlist1 fixlist2) | 203 | (defun uniquify-fix-list-filename-lessp (fixlist1 fixlist2) |
| 182 | (uniquify-filename-lessp | 204 | (uniquify-filename-lessp |
| @@ -381,4 +403,3 @@ See also `delay-rationalize-file-buffer-names' for hook setter." | |||
| 381 | (add-hook 'kill-buffer-hook 'delay-uniquify-rationalize-file-buffer-names) | 403 | (add-hook 'kill-buffer-hook 'delay-uniquify-rationalize-file-buffer-names) |
| 382 | 404 | ||
| 383 | ;;; uniquify.el ends here | 405 | ;;; uniquify.el ends here |
| 384 | |||