1
1
;;; uniquify.el --- unique buffer names dependent on file name
3
3
;; Copyright (C) 1989, 1995, 1996, 1997, 2001, 2002, 2003,
4
;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4
;; 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
6
6
;; Author: Dick King <king@reasoning.com>
428
428
;;; Hooks from the rest of Emacs
430
(defun uniquify-maybe-rerationalize-w/o-cb ()
431
"Re-rationalize buffer names, ignoring current buffer."
432
(and (cdr uniquify-managed)
433
uniquify-buffer-name-style
434
(uniquify-rerationalize-w/o-cb uniquify-managed)))
430
436
;; Buffer deletion
431
437
;; Rerationalize after a buffer is killed, to reduce coinciding buffer names.
432
438
;; This mechanism uses `kill-buffer-hook', which runs *before* deletion, so
433
439
;; it calls `uniquify-rerationalize-w/o-cb' to rerationalize the buffer list
434
440
;; ignoring the current buffer (which is going to be deleted anyway).
435
(defun uniquify-maybe-rerationalize-w/o-cb ()
441
(defun uniquify-kill-buffer-function ()
436
442
"Re-rationalize buffer names, ignoring current buffer.
437
443
For use on `kill-buffer-hook'."
438
(if (and (cdr uniquify-managed)
439
uniquify-buffer-name-style
440
uniquify-after-kill-buffer-p)
441
(uniquify-rerationalize-w/o-cb uniquify-managed)))
444
(and uniquify-after-kill-buffer-p
445
(uniquify-maybe-rerationalize-w/o-cb)))
443
447
;; Ideally we'd like to add it buffer-locally, but that doesn't work
444
448
;; because kill-buffer-hook is not permanent-local :-(
445
(add-hook 'kill-buffer-hook 'uniquify-maybe-rerationalize-w/o-cb)
449
;; FIXME kill-buffer-hook _is_ permanent-local in 22+.
450
(add-hook 'kill-buffer-hook 'uniquify-kill-buffer-function)
447
452
;; The logical place to put all this code is in generate-new-buffer-name.
448
453
;; It's written in C, so we would add a generate-new-buffer-name-function