X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/26e06f4464c58704889bdc536edc25b73e8c0179..562dd5e9532d75d18843a37a1e42a1f4398d4823:/lisp/uniquify.el diff --git a/lisp/uniquify.el b/lisp/uniquify.el index 7acd650642..3153e143ba 100644 --- a/lisp/uniquify.el +++ b/lisp/uniquify.el @@ -1,12 +1,12 @@ -;;; uniquify.el --- unique buffer names dependent on file name +;;; uniquify.el --- unique buffer names dependent on file name -*- lexical-binding: t -*- -;; Copyright (C) 1989, 1995, 1996, 1997, 2001, 2002, 2003, -;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +;; Copyright (C) 1989, 1995-1997, 2001-2011 Free Software Foundation, Inc. ;; Author: Dick King ;; Maintainer: FSF ;; Keywords: files ;; Created: 15 May 86 +;; Package: emacs ;; This file is part of GNU Emacs. @@ -89,7 +89,7 @@ (defgroup uniquify nil "Unique buffer names dependent on file name." - :group 'applications) + :group 'files) (defcustom uniquify-buffer-name-style nil @@ -427,22 +427,27 @@ in `uniquify-list-buffers-directory-modes', otherwise returns nil." ;;; Hooks from the rest of Emacs +(defun uniquify-maybe-rerationalize-w/o-cb () + "Re-rationalize buffer names, ignoring current buffer." + (and (cdr uniquify-managed) + uniquify-buffer-name-style + (uniquify-rerationalize-w/o-cb uniquify-managed))) + ;; Buffer deletion ;; Rerationalize after a buffer is killed, to reduce coinciding buffer names. ;; This mechanism uses `kill-buffer-hook', which runs *before* deletion, so ;; it calls `uniquify-rerationalize-w/o-cb' to rerationalize the buffer list ;; ignoring the current buffer (which is going to be deleted anyway). -(defun uniquify-maybe-rerationalize-w/o-cb () +(defun uniquify-kill-buffer-function () "Re-rationalize buffer names, ignoring current buffer. For use on `kill-buffer-hook'." - (if (and (cdr uniquify-managed) - uniquify-buffer-name-style - uniquify-after-kill-buffer-p) - (uniquify-rerationalize-w/o-cb uniquify-managed))) + (and uniquify-after-kill-buffer-p + (uniquify-maybe-rerationalize-w/o-cb))) ;; Ideally we'd like to add it buffer-locally, but that doesn't work ;; because kill-buffer-hook is not permanent-local :-( -(add-hook 'kill-buffer-hook 'uniquify-maybe-rerationalize-w/o-cb) +;; FIXME kill-buffer-hook _is_ permanent-local in 22+. +(add-hook 'kill-buffer-hook 'uniquify-kill-buffer-function) ;; The logical place to put all this code is in generate-new-buffer-name. ;; It's written in C, so we would add a generate-new-buffer-name-function @@ -502,5 +507,4 @@ For use on `kill-buffer-hook'." (provide 'uniquify) -;; arch-tag: e763faa3-56c9-4903-8eb8-26e1c45a0065 ;;; uniquify.el ends here