emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/uniquify.el,v


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/uniquify.el,v
Date: Fri, 09 Nov 2007 09:45:35 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Miles Bader <miles>     07/11/09 09:45:31

Index: lisp/uniquify.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/uniquify.el,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- lisp/uniquify.el    30 Oct 2007 23:28:12 -0000      1.66
+++ lisp/uniquify.el    9 Nov 2007 09:45:22 -0000       1.67
@@ -421,6 +421,23 @@
 
 ;;; 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 @@
         (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)))
+;;; The End
 
-;; 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)
+(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)
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]