# HG changeset patch # User Karl Heuer # Date 858120157 0 # Node ID d342009009c7ce98c80196d789f9423d43d77178 # Parent 1b3723c744f566e1864c79b8b9fa6b10a263f33f (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. diff -r 1b3723c744f5 -r d342009009c7 lisp/uniquify.el --- a/lisp/uniquify.el Tue Mar 11 22:32:22 1997 +0000 +++ b/lisp/uniquify.el Tue Mar 11 22:42:37 1997 +0000 @@ -1,6 +1,6 @@ ;;; uniquify.el --- unique buffer names dependent on file name -;; Copyright (c) 1989, 1995 Free Software Foundation, Inc. +;; Copyright (c) 1989, 1995, 1996, 1997 Free Software Foundation, Inc. ;; Author: Dick King ;; Maintainer: Michael Ernst @@ -34,13 +34,19 @@ ;; Makefile|zaphod, respectively (instead of Makefile and Makefile<2>). ;; Other buffer name styles are also available. -;; To use this file, just load it. +;; To use this file, just load it; or add (require 'uniquify) to your .emacs. ;; To disable it after loading, set variable uniquify-buffer-name-style to nil. ;; For other options, see "User-visible variables", below. ;; A version of uniquify.el that works under Emacs 18, Emacs 19, XEmacs, ;; and InfoDock is available from the maintainer. +;; Doesn't correctly handle buffer names created by M-x write-file in Emacs 18. +;; Doesn't work under NT when backslash is used as a path separator (forward +;; slash path separator works fine). To fix, check system-type against +;; 'windows-nt, write a routine that breaks paths down into components. +;; (Surprisingly, there isn't one built in.) + ;;; Change Log: ;; Originally by Dick King 15 May 86 @@ -59,13 +65,17 @@ ;; uniquify-buffer-name-style; add 'forward and 'post-forward-angle-brackets ;; styles; remove uniquify-reverse-dir-content-p; add ;; uniquify-trailing-separator-p. mernst 4 Aug 95 +;; Don't call expand-file-name on nil. mernst 7 Jan 96 +;; Check whether list-buffers-directory is bound. mernst 11 Oct 96 +;; Ignore non-file non-dired buffers. Colin Rafferty 3 Mar 97 ;; Valuable feedback was provided by ;; Paul Smith , ;; Alastair Burt , ;; Bob Weiner , ;; Albert L. Ting , -;; gyro@reasoning.com. +;; gyro@reasoning.com, +;; Bryan O'Sullivan . ;;; Code: @@ -172,11 +182,23 @@ ;; uniquify's version of buffer-file-name (defun uniquify-buffer-file-name (buffer) "Return name of file BUFFER is visiting, or nil if none. -Works on dired buffers as well as ordinary file-visiting buffers." +Works on dired buffers as well as ordinary file-visiting buffers, +but no others." (or (buffer-file-name buffer) + (and (featurep 'dired) (save-excursion (set-buffer buffer) - list-buffers-directory))) + (and + (eq major-mode 'dired-mode) ; do nothing if not a dired buffer + (if (boundp 'list-buffers-directory) ; XEmacs mightn't define this + list-buffers-directory + ;; don't use default-directory if dired-directory is nil + (and dired-directory + (expand-file-name + (directory-file-name + (if (consp dired-directory) + (car dired-directory) + dired-directory)))))))))) (defun uniquify-fix-list-filename-lessp (fixlist1 fixlist2) (uniquify-filename-lessp @@ -381,4 +403,3 @@ (add-hook 'kill-buffer-hook 'delay-uniquify-rationalize-file-buffer-names) ;;; uniquify.el ends here -