0

I was looking around in foreign but public init.el files and setup a which-function-mode that use the headline instead of the modeline for it's content.

I couldn't find a use-package example for that and I am still not clear with lisp code. The which-function-mode now is used in nearly every buffer. But I want it only for pyhton (emacs in build).

How do I have to modify the use-package to achieve this goal?

;; =========
;; Which Function Mode
;; =========
(use-package which-func
  :config
  (add-hook 'prog-mode-hook
        (lambda()
          (which-func-mode)))
  ;; replace nothing found symbol "???"
  (setq which-func-unknown "∅")
  ;; add to headline
  (setq-default header-line-format
        '((which-func-mode ("" which-func-format " "))))
  ;; remove from modeline
  (setq mode-line-misc-info
    (delete '(which-function-mode (which-func-mode
                       ("" which-func-format " ")))
       mode-line-misc-info))
)

1 Answer 1

1

If you want it only for python, just change prog-mode-hook to python-mode-hook

(use-package which-func
  :config
  (add-hook 'python-mode-hook 'which-func-mode)
  ;; replace nothing found symbol "???"
  (setq which-func-unknown "∅")
  ;; add to headline
  (setq-default header-line-format
                '((which-func-mode ("" which-func-format " "))))
  ;; remove from modeline
  (setq mode-line-misc-info
        (delete '(which-function-mode (which-func-mode
                                       ("" which-func-format " ")))
                mode-line-misc-info)))
2

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.