From 08504243051574aafba44af494a15367076bcaa1 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Mon, 1 Jul 2024 10:37:35 +0200 Subject: [PATCH] feat: which-func only in prog mode --- init.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/init.el b/init.el index 934ae610acb4dc0ff2fd3d0b0fdd355c14c02a79..076eb8f8081ea62f6a2e0afedc279caa4dcc0089 100644 --- a/init.el +++ b/init.el @@ -765,7 +765,7 @@ (:eval (when buffer-read-only " RO")))) (vs-modeline-right '( - (:eval (when which-function-mode which-func-format)) + (:eval (when which-func-mode which-func-format)) (:eval (when which-function-mode " ")) (:eval (vs-modeline-input-method)) (:eval (when flymake-mode " ")) @@ -1138,7 +1138,15 @@ :custom (treesit-font-lock-level 4) :config - (which-function-mode 1)) + (which-function-mode 1) + + (defun my/which-func-try-to-enable () + (unless (or (not which-function-mode) + (local-variable-p 'which-func-mode)) + (setq which-func-mode (or (eq which-func-modes t) + (and (apply 'derived-mode-p which-func-modes) t))))) + + (advice-add 'which-func-try-to-enable :override #'my/which-func-try-to-enable)) ;; Nix (my-use-package nix-mode