comparison lisp/uniquify.el @ 48833:df00563bf991

(uniquify-rationalize-file-buffer-names, rename-buffer) (uniquify-delay-rationalize-file-buffer-names, kill-buffer-hook): Undo 2002/09/27 change, because kill-buffer-hook is not permanent-local.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 13 Dec 2002 19:52:35 +0000
parents 9925c06ca5fb
children 2fb36b4b42f5 d7ddb3e565de
comparison
equal deleted inserted replaced
48832:351ae4e51f08 48833:df00563bf991
207 (equal rawname newbuffile-nd)) 207 (equal rawname newbuffile-nd))
208 (setq proposed (uniquify-get-proposed-name 208 (setq proposed (uniquify-get-proposed-name
209 rawname bfn uniquify-min-dir-content))) 209 rawname bfn uniquify-min-dir-content)))
210 (push (vector rawname bfn buffer proposed) fix-list) 210 (push (vector rawname bfn buffer proposed) fix-list)
211 (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))))
219 ;; selects buffers whose names may need changing, and others that 212 ;; selects buffers whose names may need changing, and others that
220 ;; may conflict, then bring conflicting names together 213 ;; may conflict, then bring conflicting names together
221 (uniquify-rationalize-a-list fix-list uniquify-min-dir-content))) 214 (uniquify-rationalize-a-list fix-list uniquify-min-dir-content)))
222 215
223 ;; uniquify's version of buffer-file-name; result never contains trailing slash 216 ;; uniquify's version of buffer-file-name; result never contains trailing slash
366 "Uniquify buffer names with parts of directory name." 359 "Uniquify buffer names with parts of directory name."
367 (if (and uniquify-buffer-name-style 360 (if (and uniquify-buffer-name-style
368 ;; UNIQUE argument 361 ;; UNIQUE argument
369 (ad-get-arg 1)) 362 (ad-get-arg 1))
370 (progn 363 (progn
371 (if (memq 'uniquify-delay-rationalize-file-buffer-names 364 (if uniquify-after-kill-buffer-p
372 kill-buffer-hook)
373 ;; call with no argument; rationalize vs. old name as well as new 365 ;; call with no argument; rationalize vs. old name as well as new
374 (uniquify-rationalize-file-buffer-names) 366 (uniquify-rationalize-file-buffer-names)
375 ;; call with argument: rationalize vs. new name only 367 ;; call with argument: rationalize vs. new name only
376 (uniquify-rationalize-file-buffer-names 368 (uniquify-rationalize-file-buffer-names
377 (uniquify-buffer-file-name (current-buffer)) (current-buffer))) 369 (uniquify-buffer-file-name (current-buffer)) (current-buffer)))
395 387
396 (defun uniquify-delay-rationalize-file-buffer-names () 388 (defun uniquify-delay-rationalize-file-buffer-names ()
397 "Add `delayed-uniquify-rationalize-file-buffer-names' to `post-command-hook'. 389 "Add `delayed-uniquify-rationalize-file-buffer-names' to `post-command-hook'.
398 For use on, eg, `kill-buffer-hook', to rationalize *after* buffer deletion." 390 For use on, eg, `kill-buffer-hook', to rationalize *after* buffer deletion."
399 (if (and uniquify-buffer-name-style 391 (if (and uniquify-buffer-name-style
400 uniquify-after-kill-buffer-p) 392 uniquify-after-kill-buffer-p
393 ;; Rationalizing is costly, so don't do it for temp buffers.
394 (uniquify-buffer-file-name (current-buffer)))
401 (add-hook 'post-command-hook 395 (add-hook 'post-command-hook
402 'uniquify-delayed-rationalize-file-buffer-names))) 396 'uniquify-delayed-rationalize-file-buffer-names)))
403 397
404 (defun uniquify-delayed-rationalize-file-buffer-names () 398 (defun uniquify-delayed-rationalize-file-buffer-names ()
405 "Rerationalize buffer names and remove self from `post-command-hook'. 399 "Rerationalize buffer names and remove self from `post-command-hook'.
406 See also `delay-rationalize-file-buffer-names' for hook setter." 400 See also `delay-rationalize-file-buffer-names' for hook setter."
407 (uniquify-rationalize-file-buffer-names) 401 (uniquify-rationalize-file-buffer-names)
408 (remove-hook 'post-command-hook 402 (remove-hook 'post-command-hook
409 'uniquify-delayed-rationalize-file-buffer-names)) 403 'uniquify-delayed-rationalize-file-buffer-names))
410 404
405 (add-hook 'kill-buffer-hook 'uniquify-delay-rationalize-file-buffer-names)
406
411 ;;; uniquify.el ends here 407 ;;; uniquify.el ends here