Function: uniquify--rename-buffer-advice
uniquify--rename-buffer-advice is a byte-compiled function defined in
uniquify.el.gz.
Signature
(uniquify--rename-buffer-advice NEWNAME &optional UNIQUE)
Documentation
Uniquify buffer names with parts of directory name.
Source Code
;; Defined in /usr/src/emacs/lisp/uniquify.el.gz
;; 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
;; that is that generate-new-buffer-name takes a potential buffer name as
;; its argument -- not other information, such as what file the buffer will
;; visit.
;; The below solution works because generate-new-buffer-name is called
;; only by rename-buffer (which, as of 19.29, is never called from C) and
;; generate-new-buffer, which is called only by Lisp functions
;; create-file-buffer and rename-uniquely. Rename-uniquely generally
;; isn't used for buffers visiting files, so it's sufficient to hook
;; rename-buffer and create-file-buffer. (Setting find-file-hook isn't
;; sufficient.)
;; (advice-add 'rename-buffer :around #'uniquify--rename-buffer-advice)
(defun uniquify--rename-buffer-advice (newname &optional unique)
;; BEWARE: This is called directly from `buffer.c'!
"Uniquify buffer names with parts of directory name."
(uniquify-maybe-rerationalize-w/o-cb)
(if (null unique)
;; Mark this buffer so it won't be renamed by uniquify.
(setq uniquify-managed nil)
(when uniquify-buffer-name-style
;; Rerationalize w.r.t the new name.
(uniquify-rationalize-file-buffer-names
newname
(uniquify-buffer-file-name (current-buffer))
(current-buffer)))))