~ubuntu-branches/ubuntu/karmic/emacs-snapshot/karmic

« back to all changes in this revision

Viewing changes to lisp/uniquify.el

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-04-05 09:14:30 UTC
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: james.westby@ubuntu.com-20090405091430-nw07lynn2arotjbe
Tags: upstream-20090320
ImportĀ upstreamĀ versionĀ 20090320

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
;;; uniquify.el --- unique buffer names dependent on file name
2
2
 
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.
5
5
 
6
6
;; Author: Dick King <king@reasoning.com>
7
7
;; Maintainer: FSF
427
427
 
428
428
;;; Hooks from the rest of Emacs
429
429
 
 
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)))
 
435
 
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)))
442
446
 
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)
446
451
 
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