1 ;;; semantic-load.el --- Autoload definitions for Semantic
3 ;;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Eric M. Ludlam
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
6 ;; X-RCS: $Id: semantic-load.el,v 1.56 2007/05/31 02:25:55 zappo Exp $
8 ;; Semantic is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; This software is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU Emacs; see the file COPYING. If not, write to the
20 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
25 ;; Initialize semantic for all supported conditions.
30 (require 'semantic-fw)
32 ;;; Add parser and doc directories
34 (let ((dir (file-name-directory (locate-library "semantic"))))
35 (add-to-list 'load-path (expand-file-name "bovine" dir))
36 (add-to-list 'load-path (expand-file-name "wisent" dir))
37 (add-to-list 'Info-default-directory-list (expand-file-name "doc" dir))
40 ;;; Some speedbar major modes
41 (eval-after-load "speedbar"
43 (require 'semantic-cb)
44 (require 'semantic-ia-sb)))
46 ;;; Useful predefined setup
48 (defvar semantic-load-imenu-string "TAGS"
49 "String used in `semantic-load' startup for the Imenu menu item.")
51 (defvar semantic-load-turn-everything-on nil
52 "Non-nil means turn on all features in the semantic package.")
54 (defvar semantic-load-turn-useful-things-on nil
55 "Non-nil means turn on all `useful' features.
56 Sadly `useful' here means things Eric wants on as opposed to some
59 (defvar semantic-load-system-cache-loaded nil
60 "Non nil when the system caches have been loaded.
61 Prevent this load system from loading files in twice.")
63 (defun semantic-load-enable-minimum-features ()
64 "Enable the minimum number of semantic features for basic usage.
66 `semantic-idle-scheduler-mode' - Keeps a buffer's parse tree up to date.
67 `semanticdb-minor-mode' - Stores tags when a buffer is not in memory.
68 `semanticdb-load-system-caches' - Loads any systemdbs created earlier.
69 `semanticdb-load-ebrowse-caches' - Loads any ebrowse dbs created earlier."
72 (global-semantic-idle-scheduler-mode 1)
74 (global-semanticdb-minor-mode 1)
76 ;; Don't do the loads from semantic-load twice.
77 (when (null semantic-load-system-cache-loaded)
79 ;; This loads any created system databases which get linked into
80 ;; any searches performed.
81 (setq semantic-load-system-cache-loaded t)
82 (when (and (boundp 'semanticdb-default-system-save-directory)
83 (stringp semanticdb-default-system-save-directory)
84 (file-exists-p semanticdb-default-system-save-directory))
85 (semanticdb-load-system-caches))
87 ;; This loads any created ebrowse databases which get linked into
88 ;; any searches performed.
89 (when (and (not (featurep 'xemacs))
90 (boundp 'semanticdb-default-system-save-directory)
91 (stringp semanticdb-default-system-save-directory)
92 (file-exists-p semanticdb-default-system-save-directory))
93 (semanticdb-load-ebrowse-caches))
97 (defun semantic-load-enable-code-helpers ()
98 "Enable some semantic features that provide coding assistance.
99 This includes `semantic-load-enable-minimum-features' plus:
100 `imenu' - Lists Semantic generated tags in the menubar.
101 `semantic-idle-summary-mode' - Show a summary for the tag indicated by
102 code under point. (intellisense)
103 `senator-minor-mode' - Semantic Navigator, and global menu for all
105 `semantic-mru-bookmark-mode' - Provides a `switch-to-buffer' like
106 keybinding for tag names."
109 (semantic-load-enable-minimum-features)
111 (when (and (eq window-system 'x)
112 (locate-library "imenu"))
113 (add-hook 'semantic-init-hooks (lambda ()
115 (imenu-add-to-menubar
116 semantic-load-imenu-string)
119 (global-semantic-idle-summary-mode 1)
121 ;; Do this last. This allows other minor modes to get loaded
122 ;; in so they appear in the menu properly.
123 (global-senator-minor-mode 1)
127 (defun semantic-load-enable-gaudy-code-helpers ()
128 "Enable semantic features that provide gaudy coding assistance.
129 This includes `semantic-load-enable-code-helpers'.
130 `semantic-stickyfunc-mode' - Tracks current function in header-line
132 `semantic-idle-completions-mode' - Provide smart symbol completion
133 automatically at idle time.
134 `semantic-decoration-mode' - Decorate tags based on various attributes."
137 (global-semantic-decoration-mode 1)
139 (when (boundp 'header-line-format)
140 (global-semantic-stickyfunc-mode 1))
142 ;; Idle Completions mode is more annoying than useful
143 ;; when it keeps splitting the window to show you completions.
144 ;; Using speedbar for this would be better.
146 (when (and (featurep 'tooltip) tooltip-mode)
147 (global-semantic-idle-completions-mode 1))
150 (semantic-load-enable-code-helpers)
153 (semantic-alias-obsolete 'semantic-load-enable-guady-code-helpers
154 'semantic-load-enable-gaudy-code-helpers)
156 (defun semantic-load-enable-excessive-code-helpers ()
157 "Enable all semantic features that provide coding assistance.
158 This includes all features of `semantic-load-enable-code-helpers' plus:
159 `which-func-mode' - Display the current function in the mode line."
162 (semantic-load-enable-code-helpers)
164 (if (fboundp #'which-func-mode)
165 (add-hook 'semantic-init-hooks (lambda ()
166 (which-func-mode 1))))
169 (defun semantic-load-enable-semantic-debugging-helpers ()
170 "Enable all semantic features that assist with debugging semantic.
172 `semantic-highlight-edits-mode' - Highlight text that has been edited
173 since the last parse step.
174 `semantic-show-unmatched-syntax-mode' - Highlight lexical tokens which
176 `semantic-show-parser-state-mode' - Show the current buffer state via
177 small indicators in the mode line."
180 (global-semantic-highlight-edits-mode 1)
182 ;; This ought to be a code helper, but it is still
183 ;; a bit on the lame side. Opinions?
184 (global-semantic-show-unmatched-syntax-mode 1)
186 (global-semantic-show-parser-state-mode 1)
188 ;; This enables debug output from the incremental parser.
189 ;; Perhaps a mode for that dumps stuff in a `messages' like buffer
191 (setq semantic-edits-verbose-flag t)
195 ;; Old style variables. Use only if we are not in batch mode.
196 (when (not noninteractive)
198 (semantic-load-turn-everything-on
199 (semantic-load-enable-excessive-code-helpers))
200 (semantic-load-turn-useful-things-on
201 (semantic-load-enable-code-helpers))
204 (provide 'semantic-load)
206 ;;; semantic-load.el ends here