有没有办法在 emacs 状态栏中显示当前分支、优点、缺点和作者?例如:
-UU-:**--F1 buildfile Top (84,16) (Ruby Paredit AC yas Fill) ---(git: master +2/-4 Jake Pearson
答案1
我想到了这个:
(defadvice vc-git-mode-line-string (after plus-minus (file) compile activate)
(setq ad-return-value
(concat ad-return-value
(let ((plus-minus (vc-git--run-command-string
file "diff" "--numstat" "--")))
(and plus-minus
(string-match "^\\([0-9]+\\)\t\\([0-9]+\\)\t" plus-minus)
(format " +%s-%s" (match-string 1 plus-minus) (match-string 2 plus-minus)))))))
将其放入Git:master +9-2
我的模式行中。
不确定你所说的作者是什么意思 - 是最新提交的作者吗?如果是这样,那么这似乎有效:
(defadvice vc-git-mode-line-string (after author (file) compile activate)
(setq ad-return-value
(concat ad-return-value
(let ((author
(vc-git--run-command-string file "log" "-n1" "--pretty=format:%an" "--")))
(when author
(concat " " author))))))
答案2
你有没有尝试过emacs-powerline?