3

I'm trying to activate semantic-mode for Python buffers only:

(use-package stickyfunc-enhance
  :init
  (require 'stickyfunc-enhance)
  (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)
        (semantic-mode 1)
      (semantic-mode -1)))
  (add-hook 'change-major-mode-hook #'me/enable-semantic-maybe))

But I get:

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!
2

You achieve that by customizing semantic-inhibit-functions. From the documentation (C-hvsemantic-inhibit-functionsRET

List of functions to call with no arguments before Semantic is setup. If any of these functions returns non-nil, the current buffer is not setup to use Semantic.

(defun my-inhibit-semantic-p ()
  (not (equal major-mode 'python-mode)))

(with-eval-after-load 'semantic
      (add-to-list 'semantic-inhibit-functions #'my-inhibit-semantic-p))
  • I had to remove the not on my-inhibit-semantic-p defun since in fact as the documentation for the semantic-inhibit-functions variable says: "If any of these functions returns non-nil, the current buffer is not setup to use Semantic." => so need to return true to inhibit. – teroi May 8 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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