summaryrefslogtreecommitdiff
path: root/lisp/uniquify.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2002-09-27 17:37:47 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2002-09-27 17:37:47 +0000
commitc3ba6e1d7119a714cce37f2970061791ab328074 (patch)
tree671c04e7f336742f6965a9cbd47eb703f631a305 /lisp/uniquify.el
parent0b321ad6c7b4aa6a9c4b7d88d8f08ff2e32e174a (diff)
downloademacs-c3ba6e1d7119a714cce37f2970061791ab328074.tar.gz
(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.
Diffstat (limited to 'lisp/uniquify.el')
-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.")
(defun uniquify-rationalize-file-buffer-names (&optional newbuffile newbuf)
"Make file buffer names unique by adding segments from file name.
If `uniquify-min-dir-content' > 0, always pulls that many
-file name elements. Arguments cause only a subset of buffers to be renamed."
+file name elements.
+Arguments NEWBUFFILE and NEWBUF cause only a subset of buffers to be renamed."
(interactive)
(let (fix-list
uniquify-non-file-buffer-names
@@ -208,6 +209,13 @@ file name elements. Arguments cause only a subset of buffers to be renamed."
rawname bfn uniquify-min-dir-content)))
(push (vector rawname bfn buffer proposed) fix-list)
(push bufname uniquify-non-file-buffer-names))))
+ ;; Set up uniquify to re-rationalize after killing/renaming
+ ;; if there is a conflict.
+ (when (and uniquify-after-kill-buffer-p newbuffile (cdr fix-list))
+ (dolist (fix fix-list)
+ (with-current-buffer (uniquify-ref-buffer fix)
+ (add-hook 'kill-buffer-hook
+ 'uniquify-delay-rationalize-file-buffer-names nil t))))
;; selects buffers whose names may need changing, and others that
;; may conflict, then bring conflicting names together
(uniquify-rationalize-a-list fix-list uniquify-min-dir-content)))
@@ -361,7 +369,8 @@ in `uniquify-list-buffers-directory-modes', otherwise returns nil."
;; UNIQUE argument
(ad-get-arg 1))
(progn
- (if uniquify-after-kill-buffer-p
+ (if (memq 'uniquify-delay-rationalize-file-buffer-names
+ kill-buffer-hook)
;; call with no argument; rationalize vs. old name as well as new
(uniquify-rationalize-file-buffer-names)
;; call with argument: rationalize vs. new name only
@@ -389,9 +398,7 @@ in `uniquify-list-buffers-directory-modes', otherwise returns nil."
"Add `delayed-uniquify-rationalize-file-buffer-names' to `post-command-hook'.
For use on, eg, `kill-buffer-hook', to rationalize *after* buffer deletion."
(if (and uniquify-buffer-name-style
- uniquify-after-kill-buffer-p
- ;; Rationalizing is costly, so don't do it for temp buffers.
- (uniquify-buffer-file-name (current-buffer)))
+ uniquify-after-kill-buffer-p)
(add-hook 'post-command-hook
'uniquify-delayed-rationalize-file-buffer-names)))
@@ -402,6 +409,4 @@ See also `delay-rationalize-file-buffer-names' for hook setter."
(remove-hook 'post-command-hook
'uniquify-delayed-rationalize-file-buffer-names))
-(add-hook 'kill-buffer-hook 'uniquify-delay-rationalize-file-buffer-names)
-
;;; uniquify.el ends here