From Semantic docs:
2.3.1 Don't parse certain buffers
You can inhibit parsing using the semantic-inhibit-functions variable.
— Variable: semantic-inhibit-functions List of functions to call with
no arguments before semantic sets up a buffer. If any of these
functions returns non-nil, the current buffer is not setup to use
Semantic.
You could have this inhibit parsing in very large files, or files
which cause particular problems to semantic.
Proper usage example:
;; Disable Semantic's source referencing in lisp buffers.
(add-hook 'semantic-inhibit-functions
(lambda () (member major-mode '(emacs-lisp-mode))))
This adds it to the list (instead of overwriting the list), and ensures that it only runs after semantic has been loaded.
You must use with-eval-after-load
, since the semantic package may not be loaded when your user config initializes. And in that case, you would get an error saying that the semantic-inhibit-functions variable doesn't exist, and your override wouldn't be applied.
This fixes those issues and is better than @Tom's and @Dmitry's answers.
Oh and I highly recommend blocking emacs-lisp-mode, because otherwise Semantic will try parsing the entire source code tree of the running Emacs instance whenever autocompletion is triggered, which will freeze Emacs if you have a lot of packages.