X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/e7e7e168835c79bff058b8cd400b9762c7468f87..b0c9a334c2f0eb881eff47f590997e746cc3bdb3:/lisp/uniquify.el diff --git a/lisp/uniquify.el b/lisp/uniquify.el index b2da797116..cc08ab7083 100644 --- a/lisp/uniquify.el +++ b/lisp/uniquify.el @@ -1,6 +1,7 @@ ;;; uniquify.el --- unique buffer names dependent on file name -;; Copyright (c) 1989,95,96,97,2001,2003 Free Software Foundation, Inc. +;; Copyright (C) 1989, 1995, 1996, 1997, 2001, 2002, 2003, +;; 2004, 2005 Free Software Foundation, Inc. ;; Author: Dick King ;; Maintainer: FSF @@ -21,8 +22,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Commentary: @@ -89,7 +90,7 @@ ;;; User-visible variables (defgroup uniquify nil - "Unique buffer names dependent on file name" + "Unique buffer names dependent on file name." :group 'applications) @@ -109,17 +110,20 @@ would have the following buffer names in the various styles: (const post-forward) (const post-forward-angle-brackets) (const :tag "standard Emacs behavior (nil)" nil)) - :require 'uniquify) + :require 'uniquify + :group 'uniquify) (defcustom uniquify-after-kill-buffer-p t "If non-nil, rerationalize buffer names after a buffer has been killed." - :type 'boolean) + :type 'boolean + :group 'uniquify) (defcustom uniquify-ask-about-buffer-names-p nil "*If non-nil, permit user to choose names for buffers with same base file. If the user chooses to name a buffer, uniquification is preempted and no other buffer names are changed." - :type 'boolean) + :type 'boolean + :group 'uniquify) ;; The default value matches certain Gnus buffers. (defcustom uniquify-ignore-buffers-re nil @@ -127,11 +131,13 @@ other buffer names are changed." For instance, set this to \"^draft-[0-9]+$\" to avoid having uniquify rename draft buffers even if `uniquify-after-kill-buffer-p' is non-nil and the visited file name isn't the same as that of the buffer." - :type '(choice (const :tag "Uniquify all buffers" nil) regexp)) + :type '(choice (const :tag "Uniquify all buffers" nil) regexp) + :group 'uniquify) (defcustom uniquify-min-dir-content 0 "*Minimum number of directory name components included in buffer name." - :type 'integer) + :type 'integer + :group 'uniquify) (defcustom uniquify-separator nil "*String separator for buffer name components. @@ -139,14 +145,16 @@ When `uniquify-buffer-name-style' is `post-forward', separates base file name from directory part in buffer names (default \"|\"). When `uniquify-buffer-name-style' is `reverse', separates all file name components (default \"\\\")." - :type '(choice (const nil) string)) + :type '(choice (const nil) string) + :group 'uniquify) (defcustom uniquify-trailing-separator-p nil "*If non-nil, add a file name separator to dired buffer names. If `uniquify-buffer-name-style' is `forward', add the separator at the end; if it is `reverse', add the separator at the beginning; otherwise, this variable is ignored." - :type 'boolean) + :type 'boolean + :group 'uniquify) (defcustom uniquify-strip-common-suffix ;; Using it when uniquify-min-dir-content>0 doesn't make much sense. @@ -155,7 +163,8 @@ variable is ignored." E.g. if you open /a1/b/c/d and /a2/b/c/d, the buffer names will say \"d|a1\" and \"d|a2\" instead of \"d|a1/b/c\" and \"d|a2/b/c\". This can be handy when you have deep parallel hierarchies." - :type 'boolean) + :type 'boolean + :group 'uniquify) (defvar uniquify-list-buffers-directory-modes '(dired-mode cvs-mode) "List of modes for which uniquify should obey `list-buffers-directory'. @@ -187,9 +196,16 @@ It actually holds the list of `uniquify-item's corresponding to the conflict.") If `uniquify-min-dir-content' > 0, always pulls that many file name elements. Arguments BASE, DIRNAME, and NEWBUF specify the new buffer that causes -this rationaliztion." - (if (null dirname) - (with-current-buffer newbuf (setq uniquify-managed nil)) +this rationalization." + (interactive + (list (if uniquify-managed + (uniquify-item-base (car uniquify-managed)) (buffer-name)) + (uniquify-buffer-file-name (current-buffer)) + (current-buffer))) + ;; Make sure we don't get confused by outdated uniquify-managed info in + ;; this buffer. + (with-current-buffer newbuf (setq uniquify-managed nil)) + (when dirname (setq dirname (expand-file-name (directory-file-name dirname))) (let ((fix-list (list (uniquify-make-item base dirname newbuf))) items) @@ -457,5 +473,5 @@ For use on `kill-buffer-hook'." (provide 'uniquify) -;;; arch-tag: e763faa3-56c9-4903-8eb8-26e1c45a0065 +;; arch-tag: e763faa3-56c9-4903-8eb8-26e1c45a0065 ;;; uniquify.el ends here