Function: ghostel--buffer-identification
ghostel--buffer-identification is a natively compiled function defined
in ghostel.el.
Signature
(ghostel--buffer-identification FORMAT)
Documentation
Return a mode-line-buffer-identification value built from FORMAT.
See ghostel-buffer-identification-format for the specs.
%b stays a live mode-line construct.
A FORMAT with %t returns the plain buffer name while the terminal has no title.
Source Code
;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel--buffer-identification (format)
"Return a `mode-line-buffer-identification' value built from FORMAT.
See `ghostel-buffer-identification-format' for the specs.
%b stays a live mode-line construct.
A FORMAT with %t returns the plain buffer name while the terminal has no title."
(if (and (null ghostel-title)
;; Skip quoted percents so e.g. "50%%tests" is not read as a
;; title reference.
(string-match-p "%[ 0<>^_-]*[0-9]*\\(?:\\.[0-9]+\\)?t"
(string-replace "%%" "" format)))
(propertized-buffer-identification "%b")
(let* ((expanded
;; %b is passed through to the mode line, where `format-spec'
;; modifiers have no meaning; drop them so they cannot pad or
;; truncate the placeholder instead of the buffer name.
(format-spec (replace-regexp-in-string
"%[ 0<>^_-]*[0-9]*\\(?:\\.[0-9]+\\)?b" "%b" format)
`((?b . "\0")
(?t . ,(propertize (or ghostel-title "")
'help-echo ghostel-title))
(?d . ,(abbreviate-file-name
(directory-file-name default-directory))))
'ignore))
(name (propertized-buffer-identification "%b"))
(parts (split-string expanded "\0"))
(construct (list (string-replace "%" "%%" (car parts)))))
(dolist (part (cdr parts))
(push name construct)
(push (string-replace "%" "%%" part) construct))
(nreverse construct))))