summaryrefslogtreecommitdiff
path: root/lisp/uniquify.el
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2007-11-09 09:45:30 +0000
committerMiles Bader <miles@gnu.org>2007-11-09 09:45:30 +0000
commitc12ecb0af9679cc0e2fa0409931c34c035763469 (patch)
treebd118c7ebc571de0dab542f48ad0c1648c6ccf72 /lisp/uniquify.el
parente83d1fe87564d06d2fcbb4006dfd9133bc340aa8 (diff)
parent9d2185d10e3da9062672d96d3b59fcea31ff17ed (diff)
downloademacs-c12ecb0af9679cc0e2fa0409931c34c035763469.tar.gz
Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-923
Diffstat (limited to 'lisp/uniquify.el')
-rw-r--r--lisp/uniquify.el51
1 files changed, 35 insertions, 16 deletions
diff --git a/lisp/uniquify.el b/lisp/uniquify.el
index 254832ed700..492918c7f96 100644
--- a/lisp/uniquify.el
+++ b/lisp/uniquify.el
@@ -421,6 +421,23 @@ in `uniquify-list-buffers-directory-modes', otherwise returns nil."
;;; Hooks from the rest of Emacs
+;; 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 ()
+ "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)))
+
+;; 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)
+
;; 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
;; which, if non-nil, would be called instead of the C. One problem with
@@ -458,22 +475,24 @@ in `uniquify-list-buffers-directory-modes', otherwise returns nil."
(file-name-nondirectory filename)
(file-name-directory filename) ad-return-value))))
-;; 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 ()
- "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)))
-
-;; 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)
+;;; The End
+
+(defun uniquify-unload-function ()
+ "Unload the uniquify library."
+ (save-current-buffer
+ (let ((buffers nil))
+ (dolist (buf (buffer-list))
+ (set-buffer buf)
+ (when uniquify-managed
+ (push (cons buf (uniquify-item-base (car uniquify-managed))) buffers)))
+ (dolist (fun '(rename-buffer create-file-buffer))
+ (ad-remove-advice fun 'after (intern (concat (symbol-name fun) "-uniquify")))
+ (ad-update fun))
+ (dolist (buf buffers)
+ (set-buffer (car buf))
+ (rename-buffer (cdr buf) t))))
+ ;; continue standard uploading
+ nil)
(provide 'uniquify)