Cache expensive computations in spacemacs/title-prepare

This commit is contained in:
Dieter Komendera 2018-10-09 12:18:43 +02:00 committed by Boris Buliga
parent 4929f62a70
commit 2d7737cd3e
No known key found for this signature in database
GPG Key ID: 027328150F064FA8
1 changed files with 16 additions and 8 deletions

View File

@ -681,14 +681,22 @@ If ARG is non nil then Ask questions to the user before installing the dotfile."
%n -- prints Narrow if appropriate
%z -- prints mnemonics of buffer, terminal, and keyboard coding systems
%Z -- like %z, but including the end-of-line format"
(let* ((fs (format-spec-make
?a (when (string-match-p "%a" title-format)
(abbreviate-file-name (or (buffer-file-name)
(buffer-name))))
?t (if (and (string-match-p "%t" title-format)
(fboundp 'projectile-project-name))
(projectile-project-name)
"-")
(let* ((project-name (when (string-match-p "%t" title-format)
(if (boundp 'spacemacs--buffer-project-name)
spacemacs--buffer-project-name
(set (make-local-variable 'spacemacs--buffer-project-name)
(if (fboundp 'projectile-project-name)
(projectile-project-name)
"-")))))
(abbreviated-file-name (when (string-match-p "%a" title-format)
(if (boundp 'spacemacs--buffer-abbreviated-filename)
spacemacs--buffer-abbreviated-filename
(set (make-local-variable 'spacemacs--buffer-abbreviated-filename)
(abbreviate-file-name (or (buffer-file-name)
(buffer-name)))))))
(fs (format-spec-make
?a abbreviated-file-name
?t project-name
?S system-name
?I invocation-name
?U (or (getenv "USER") "")