~/Dev/llvm-project/llvm/include/llvm/Support/Endian.h
buffer-name 是 Endian.h
,希望能傳遞一個函數自定義,多帶幾個path components,顯示爲 Support/Endian.h
我用 spacemacs 的。还要折腾下 spaceline 怎么改 buffer-id
先写成这样了
(spaceline-define-segment my-buffer-id
"Comment meow"
(let ((name buffer-file-name)
(f (lambda (s) (propertize s 'face 'mode-line-buffer-id))))
(if (and name (string-match-p "/llvm/" name))
(cond
((string-match "/include/clang-c/\\(.*\\)" name)
(concat "clang-c/" (funcall f (match-string 1 name))))
((and (string-match "/\\([a-z]*\\)/include/\\([a-z]*\\)/\\(.*\\)" name)
(string= (match-string 1 name) (match-string 2 name)))
(concat (substring (match-string 1 name) 0 1) "/" (funcall f (match-string 3 name))))
((string-match "/\\([a-z]*\\)/lib/\\(.*\\)" name)
(concat (substring (match-string 1 name) 0 1) "/" (funcall f (match-string 2 name))))
(t (funcall f (buffer-name))))
(funcall f (buffer-name)))))
;; Default additional-segments causes trouble.
;; Without this, the active window does not show buffer-id, weird.
;; (spaceline-spacemacs-theme nil)
(apply 'spaceline--theme
'((persp-name
workspace-number
window-number)
:fallback evil-state
:face highlight-face
:priority 0)
'((buffer-modified buffer-size my-buffer-id remote-host)
:priority 5))