如何在emacs模式中显示git分支?

时间:2015-02-12 03:52:08

标签: macos git emacs modeline

默认情况下,模式行如下: enter image description here

当我在Git版本控制系统下的目录中工作时,Emacs显示Git-master。现在我在文件init-modeline.el中自定义了这样的模式行:

(setq-default mode-line-format
    (list
        ;; the buffer name; the file name as a tool tip
        '(:eval (propertize "%b " 'face font-lock-keyword-face
        'help-echo (buffer-file-name)))

        ;; line and column
        "("
        "%02l" "," "%01c"
        ") "
        ......
))

然后将(require 'init-modeline)添加到init.el

现在,emacs不会在emacs模式中显示git分支,因此我将'(vc-mode vc-mode)添加到init-modeline.el,如下所示:

    (setq-default mode-line-format
    (list
        ;; the buffer name; the file name as a tool tip
        '(:eval (propertize "%b " 'face font-lock-keyword-face
        'help-echo (buffer-file-name)))

        ;; line and column
        "("
        "%02l" "," "%01c"
        ") "

        '(vc-mode vc-mode)
        ......
))

现在,modeline显示如下:

enter image description here

它只显示-master。如何显示Git-master

vc-mode缓冲区中变量init-mode的值,如:

vc-mode's value is #(" :master" 0 1
  (face sml/vc-edited)
  1 8
  (help-echo "Locally modified file under the Git version control system\nCurrent revision: master\nmouse-1: Version Control menu" face sml/vc-edited local-map
         (keymap
          (mode-line keymap
                     (down-mouse-1 menu-item "Version Control" vc-menu-map :filter vc-menu-map-filter)))
         mouse-face mode-line-highlight))

Local in buffer init.el; global value is nil

  Automatically becomes permanently buffer-local when set.
  This variable may be risky if used as a file-local variable.

0 个答案:

没有答案