0

I modified my mode-line, but now which-function-mode stopped working: nothing is displayed. Code:

(setq mode-line-position
      (list '(:eval (propertize "L%l " 'face nil 'help-echo "Line number"))
            '(:eval (propertize "C%C " 'face nil 'help-echo "Column number"))
            (list -3 (propertize "%P" 'face nil 'help-echo "Position in buffer"))
            '(:eval (when (buffer-file-name)
                      (propertize "  %I" 'face 'font-lock-variable-name-face
                                  'help-echo "Buffer size")))))

(setq mode-line-modified
      (list '(:eval (propertize "%*" 'face nil 'help-echo
                                "Buffer read-only and modification indicator"))
            '(:eval (propertize "%+" 'face nil 'help-echo
                                "Buffer read-only and modification indicator"))))

(setq mode-line-buffer-identification
      (list '(:eval (propertize "%12b" 'face 'mode-line-buffer-id
                                'help-echo default-directory))))

(setq-default mode-line-format
              (list "%e"
                    mode-line-position "  "
                    mode-line-modified "  "
                    mode-line-buffer-identification "  "
                    mode-line-modes "  "
                    mode-line-misc-info
                    ))

(which-function-mode)

which-function-mode uses mode-line-misc-info, which I did not modify. Its value is

((which-function-mode
  (which-func-mode
   (#1="" which-func-format " ")))
 (global-mode-string
  (#1# global-mode-string " ")))

Why isn't it showing anything then? (Nothing is displayed if Emacs is started with this code as ~/.emacs.)

1 Answer 1

0

Don't evaluate list when you set mode-line-format. Use ' instead of list:

(setq-default mode-line-format
              '("%e"
                mode-line-position "  "
                mode-line-modified "  "
                mode-line-buffer-identification "  "
                mode-line-modes "  "
                mode-line-misc-info
                ))

At the moment you set mode-line-format there are no which-function-mode related code in the mode-line-misc-info.

See Quoting.

1
  • That's it, thank you, it works now.
    – GrB
    Commented Nov 12, 2019 at 4:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.