1

By default the modeline like: enter image description here

Emacs displays Git-master when I am working in a directory that is under the Git version control system.Now I customize modeline in the file init-modeline.el like this:

(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"
        ") "
        ......
))

Then add (require 'init-modeline) to init.el.

Now emacs does not display git branch in the emacs modeline, so I add '(vc-mode vc-mode) to init-modeline.el like this:

    (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)
        ......
))

Now modeline shows like this:

enter image description here

It only shows -master.How can I show Git-master?

The value of variable vc-mode in init-mode buffer like:

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.
Alan
  • 1,691
  • 1
  • 16
  • 13
  • 1
    Show the value of variable `vc-mode` in your `..init.el` buffer. – artscan Feb 12 '15 at 05:12
  • Thanks,seem to not work – Alan Feb 12 '15 at 06:05
  • Well that's not useful. artscan was asking you to tell us the what value of the `vc-mode` variable is in your `init.el` buffer. If the value is `-master` then your mode line format is fine. If the value is `Git-master` then you'll want to establish why it gets truncated when displayed. – phils Feb 12 '15 at 07:22
  • Can you please type `C-h v` `vc-mode` `RET` in your `init.el` buffer and tell us what the value is? That's all we're asking for. – phils Feb 12 '15 at 10:20
  • 1
    So we can now see that `vc-mode` is just `" :master"`, which explains why `"Git"` doesn't appear (I see a value of `" Git:master"`, by comparison). I'm guessing that the `sml/vc-edited` face is responsible for displaying the `:` as `-` in your mode line. I presume that's some third-party thing, so that same library *might* be responsible for removing the `Git` prefix. I would try disabling it (whatever it is), and see if you get the prefix back again. – phils Feb 12 '15 at 21:23
  • @phils As you say, I disabled third-part mode about mode-line, and I get the prefix.Thank you. – Alan Feb 13 '15 at 02:52

0 Answers0