Subject: bug#1315: uniquify-buffer-name bug on save

From: Glenn Morris <[email-masked]>
Date: Thu, 13 Nov 2008 04:09:22 -0500

Please try this (lightly tested) patch against CVS trunk:

*** uniquify.el.~1.75.~	2008-07-01 20:02:50.000000000 -0700
--- uniquify.el	2008-11-13 00:57:08.000000000 -0800
***************
*** 427,448 ****
  
  ;;; 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
--- 427,452 ----
  
  ;;; 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-kill-buffer-function ()
    "Re-rationalize buffer names, ignoring current buffer.
  For use on `kill-buffer-hook'."
!   (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-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