aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2002-09-27 17:37:47 +0000
committerStefan Monnier2002-09-27 17:37:47 +0000
commit124e448b98102b036d24c43c1b4d55a26682084d (patch)
treed3bddb4a9828807418f3f8918157e4130901155e
parent184c3d811ac1d2df60b26c442c44eab2f3ff2d6e (diff)
downloademacs-124e448b98102b036d24c43c1b4d55a26682084d.tar.gz
emacs-124e448b98102b036d24c43c1b4d55a26682084d.zip
(uniquify-rationalize-file-buffer-names):
Add to kill-buffer-hook for buffers with conflict. (rename-buffer): Check kill-buffer-hook to see if there was a conflict. (uniquify-delay-rationalize-file-buffer-names): Remove useless check. (kill-buffer-hook): Don't change globally.
-rw-r--r--lisp/uniquify.el19
1 files changed, 12 insertions, 7 deletions
diff --git a/lisp/uniquify.el b/lisp/uniquify.el
index de5a2a231f2..27001fc17aa 100644
--- a/lisp/uniquify.el
+++ b/lisp/uniquify.el
@@ -184,7 +184,8 @@ contains the name of the directory which the buffer is visiting.")
184(defun uniquify-rationalize-file-buffer-names (&optional newbuffile newbuf) 184(defun uniquify-rationalize-file-buffer-names (&optional newbuffile newbuf)
185 "Make file buffer names unique by adding segments from file name. 185 "Make file buffer names unique by adding segments from file name.
186If `uniquify-min-dir-content' > 0, always pulls that many 186If `uniquify-min-dir-content' > 0, always pulls that many
187file name elements. Arguments cause only a subset of buffers to be renamed." 187file name elements.
188Arguments NEWBUFFILE and NEWBUF cause only a subset of buffers to be renamed."
188 (interactive) 189 (interactive)
189 (let (fix-list 190 (let (fix-list
190 uniquify-non-file-buffer-names 191 uniquify-non-file-buffer-names
@@ -208,6 +209,13 @@ file name elements. Arguments cause only a subset of buffers to be renamed."
208 rawname bfn uniquify-min-dir-content))) 209 rawname bfn uniquify-min-dir-content)))
209 (push (vector rawname bfn buffer proposed) fix-list) 210 (push (vector rawname bfn buffer proposed) fix-list)
210 (push bufname uniquify-non-file-buffer-names)))) 211 (push bufname uniquify-non-file-buffer-names))))
212 ;; Set up uniquify to re-rationalize after killing/renaming
213 ;; if there is a conflict.
214 (when (and uniquify-after-kill-buffer-p newbuffile (cdr fix-list))
215 (dolist (fix fix-list)
216 (with-current-buffer (uniquify-ref-buffer fix)
217 (add-hook 'kill-buffer-hook
218 'uniquify-delay-rationalize-file-buffer-names nil t))))
211 ;; selects buffers whose names may need changing, and others that 219 ;; selects buffers whose names may need changing, and others that
212 ;; may conflict, then bring conflicting names together 220 ;; may conflict, then bring conflicting names together
213 (uniquify-rationalize-a-list fix-list uniquify-min-dir-content))) 221 (uniquify-rationalize-a-list fix-list uniquify-min-dir-content)))
@@ -361,7 +369,8 @@ in `uniquify-list-buffers-directory-modes', otherwise returns nil."
361 ;; UNIQUE argument 369 ;; UNIQUE argument
362 (ad-get-arg 1)) 370 (ad-get-arg 1))
363 (progn 371 (progn
364 (if uniquify-after-kill-buffer-p 372 (if (memq 'uniquify-delay-rationalize-file-buffer-names
373 kill-buffer-hook)
365 ;; call with no argument; rationalize vs. old name as well as new 374 ;; call with no argument; rationalize vs. old name as well as new
366 (uniquify-rationalize-file-buffer-names) 375 (uniquify-rationalize-file-buffer-names)
367 ;; call with argument: rationalize vs. new name only 376 ;; call with argument: rationalize vs. new name only
@@ -389,9 +398,7 @@ in `uniquify-list-buffers-directory-modes', otherwise returns nil."
389 "Add `delayed-uniquify-rationalize-file-buffer-names' to `post-command-hook'. 398 "Add `delayed-uniquify-rationalize-file-buffer-names' to `post-command-hook'.
390For use on, eg, `kill-buffer-hook', to rationalize *after* buffer deletion." 399For use on, eg, `kill-buffer-hook', to rationalize *after* buffer deletion."
391 (if (and uniquify-buffer-name-style 400 (if (and uniquify-buffer-name-style
392 uniquify-after-kill-buffer-p 401 uniquify-after-kill-buffer-p)
393 ;; Rationalizing is costly, so don't do it for temp buffers.
394 (uniquify-buffer-file-name (current-buffer)))
395 (add-hook 'post-command-hook 402 (add-hook 'post-command-hook
396 'uniquify-delayed-rationalize-file-buffer-names))) 403 'uniquify-delayed-rationalize-file-buffer-names)))
397 404
@@ -402,6 +409,4 @@ See also `delay-rationalize-file-buffer-names' for hook setter."
402 (remove-hook 'post-command-hook 409 (remove-hook 'post-command-hook
403 'uniquify-delayed-rationalize-file-buffer-names)) 410 'uniquify-delayed-rationalize-file-buffer-names))
404 411
405(add-hook 'kill-buffer-hook 'uniquify-delay-rationalize-file-buffer-names)
406
407;;; uniquify.el ends here 412;;; uniquify.el ends here