Function: semantic-mode

semantic-mode is an autoloaded, interactive and byte-compiled function defined in semantic.el.gz.

Signature

(semantic-mode &optional ARG)

Documentation

Toggle parser features (Semantic mode).

In Semantic mode, Emacs parses the buffers you visit for their semantic content. This information is used by a variety of auxiliary minor modes, listed in semantic-default-submodes; all the minor modes in this list are also enabled when you enable Semantic mode.

C-c , , semantic-force-refresh
C-c , <down> senator-transpose-tags-down
C-c , <up> senator-transpose-tags-up
C-c , C-w senator-kill-tag
C-c , C-y senator-yank-tag
C-c , G semantic-symref
C-c , J semantic-complete-jump
C-c , M-w senator-copy-tag
C-c , SPC semantic-complete-analyze-inline
C-c , g semantic-symref-symbol
C-c , j semantic-complete-jump-local
C-c , l semantic-analyze-possible-completions
C-c , m semantic-complete-jump-local-members
C-c , n senator-next-tag
C-c , p senator-previous-tag
C-c , r senator-copy-tag-to-register
C-c , u senator-go-to-up-reference

This is a global minor mode. If called interactively, toggle the Semantic mode mode. If the prefix argument is positive, enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is toggle. Enable the mode if ARG is nil, omitted, or is a positive number. Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer, evaluate (default-value \=semantic-mode)'.

The mode's hook is called both when the mode is enabled and when it is disabled.

Probably introduced at or before Emacs version 23.2.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic.el.gz
;;;###autoload
(define-minor-mode semantic-mode
  "Toggle parser features (Semantic mode).

In Semantic mode, Emacs parses the buffers you visit for their
semantic content.  This information is used by a variety of
auxiliary minor modes, listed in `semantic-default-submodes';
all the minor modes in this list are also enabled when you enable
Semantic mode.

\\{semantic-mode-map}"
  :global t
  :group 'semantic
  (if semantic-mode
      ;; Turn on Semantic mode
      (progn
	;; Enable all the global auxiliary minor modes in
	;; `semantic-submode-list'.
	(dolist (mode semantic-submode-list)
	  (and (memq mode semantic-default-submodes)
	       (fboundp mode)
	       (funcall mode 1)))
	(unless semantic-load-system-cache-loaded
	  (setq semantic-load-system-cache-loaded t)
	  (when (and (boundp 'semanticdb-default-system-save-directory)
		     (stringp semanticdb-default-system-save-directory)
		     (file-exists-p semanticdb-default-system-save-directory))
	    (require 'semantic/db-ebrowse)
	    (semanticdb-load-ebrowse-caches)))
	(add-hook 'mode-local-init-hook #'semantic-new-buffer-fcn)
	;; Add semantic-ia-complete-symbol to
	;; completion-at-point-functions, so that it is run from
	;; M-TAB.
	;;
	;; Note: The first entry added is the last entry run, so the
	;;       most specific entry should be last.
	(add-hook 'completion-at-point-functions
		  #'semantic-analyze-nolongprefix-completion-at-point-function)
	(add-hook 'completion-at-point-functions
		  #'semantic-analyze-notc-completion-at-point-function)
	(add-hook 'completion-at-point-functions
		  #'semantic-analyze-completion-at-point-function)

	(if (bound-and-true-p global-ede-mode)
	    (define-key cedet-menu-map [cedet-menu-separator] '("--")))
	(dolist (b (buffer-list))
	  (with-current-buffer b
	    (semantic-new-buffer-fcn))))
    ;; Disable Semantic features.  Removing everything Semantic has
    ;; introduced in the buffer is pretty much futile, but we have to
    ;; clean the hooks and delete Semantic-related overlays, so that
    ;; Semantic can be re-activated cleanly.
    (remove-hook 'mode-local-init-hook #'semantic-new-buffer-fcn)
    (remove-hook 'completion-at-point-functions
		 #'semantic-analyze-completion-at-point-function)
    (remove-hook 'completion-at-point-functions
		 #'semantic-analyze-notc-completion-at-point-function)
    (remove-hook 'completion-at-point-functions
		 #'semantic-analyze-nolongprefix-completion-at-point-function)

    (remove-hook 'after-change-functions
		 #'semantic-change-function)
    (define-key cedet-menu-map [cedet-menu-separator] nil)
    (define-key cedet-menu-map [semantic-options-separator] nil)
    ;; FIXME: handle semanticdb-load-ebrowse-caches
    (dolist (mode semantic-submode-list)
      (if (and (boundp mode) (symbol-value mode))
	  (funcall mode -1)))
    ;; Unlink buffer and clear cache
    (semantic--tag-unlink-cache-from-buffer)
    (setq semantic--buffer-cache nil)
    ;; Make sure we run the setup function if Semantic gets
    ;; re-activated.
    (setq semantic-new-buffer-fcn-was-run nil)
    ;; restore the original `imenu-create-index-function'
    (dolist (b (buffer-list))
      (with-current-buffer b
        (unless (eq semantic--create-index-function-origin
                    imenu-create-index-function)
          (setq imenu-create-index-function
                (or semantic--create-index-function-origin
                    (default-value 'imenu-create-index-function))))))))