I've seen this question a lot. But none of the replies fixed my issue: the minor mode stays on in others modes.
So far, I have tried:
(use-package stickyfunc-enhance
:config
;; (add-to-list 'semantic-default-submodes 'global-semantic-stickyfunc-mode)
;; (defun turn-on-semantic () (semantic-mode 1) (require 'stickyfunc-enhance))
;; (add-hook 'python-mode-hook 'turn-on-semantic)
(add-hook 'python-mode-hook
(lambda ()
(add-to-list 'semantic-default-submodes 'global-semantic-stickyfunc-mode)
(semantic-mode 1)
(require 'stickyfunc-enhance))))
My issue with those 2 approaches is that semantic-mode
will stay on in all major modes once I visited a Python buffer.
How can I turn off semantic-mode
in all other modes? Do I have to manually turn it off on prog-mode-hook
?
Trying kaushalmodi's solution:
(use-package stickyfunc-enhance
:init
(add-to-list 'semantic-default-submodes 'global-semantic-stickyfunc-mode)
:config
(defun me/enable-semantic-maybe ()
"Maybe enable `semantic-mode'."
(if (derived-mode-p 'python-mode)
(lambda ()
(semantic-mode 1)
(require 'stickyfunc-enhance))
(semantic-mode -1)))
(add-hook 'change-major-mode-hook #'me/enable-semantic-maybe))
Yields me:
Making python-shell-interpreter local to *Python Internal [792caf12c778150badeeede64c068cee]* while let-bound!
Making python-shell-interpreter-args local to *Python Internal [792caf12c778150badeeede64c068cee]* while let-bound!