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!
Mathieu Marques
  • 1,953
  • 1
  • 13
  • 30

1 Answers1

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))
Iqbal Ansari
  • 7,468
  • 1
  • 28
  • 31
  • 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 08 '19 at 13:38