reftex -- Update and prettify package-info.in provides.
[packages] / xemacs-packages / semantic / semantic-load.el
1 ;;; semantic-load.el --- Autoload definitions for Semantic
2
3 ;;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Eric M. Ludlam
4
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 $
7
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)
11 ;; any later version.
12
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.
17
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.
22
23 ;;; Commentary:
24 ;;
25 ;; Initialize semantic for all supported conditions.
26
27 ;;; Code:
28 ;;
29
30 (require 'semantic-fw)
31
32 ;;; Add parser and doc directories
33 ;;
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))
38   )
39
40 ;;; Some speedbar major modes
41 (eval-after-load "speedbar"
42   '(progn
43      (require 'semantic-cb)
44      (require 'semantic-ia-sb)))
45 \f
46 ;;; Useful predefined setup
47 ;;
48 (defvar semantic-load-imenu-string "TAGS"
49   "String used in `semantic-load' startup for the Imenu menu item.")
50
51 (defvar semantic-load-turn-everything-on nil
52   "Non-nil means turn on all features in the semantic package.")
53
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
57 other criteria.")
58
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.")
62
63 (defun semantic-load-enable-minimum-features ()
64   "Enable the minimum number of semantic features for basic usage.
65 This includes:
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."
70   (interactive)
71
72   (global-semantic-idle-scheduler-mode 1)
73
74   (global-semanticdb-minor-mode 1)
75
76   ;; Don't do the loads from semantic-load twice.
77   (when (null semantic-load-system-cache-loaded)
78
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))
86
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))
94     )
95   )
96
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
104                          features semantic.
105   `semantic-mru-bookmark-mode' - Provides a `switch-to-buffer' like
106                        keybinding for tag names."
107   (interactive)
108
109   (semantic-load-enable-minimum-features)
110
111   (when (and (eq window-system 'x)
112              (locate-library "imenu"))
113     (add-hook 'semantic-init-hooks (lambda ()
114                                      (condition-case nil
115                                          (imenu-add-to-menubar
116                                           semantic-load-imenu-string)
117                                        (error nil)))))
118
119   (global-semantic-idle-summary-mode 1)
120
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)
124
125   )
126
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
131                                (when available).
132   `semantic-idle-completions-mode' - Provide smart symbol completion
133                                  automatically at idle time.
134   `semantic-decoration-mode' - Decorate tags based on various attributes."
135   (interactive)
136
137   (global-semantic-decoration-mode 1)
138
139   (when (boundp 'header-line-format)
140     (global-semantic-stickyfunc-mode 1))
141
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.
145   (condition-case nil
146       (when (and (featurep 'tooltip) tooltip-mode)
147         (global-semantic-idle-completions-mode 1))
148     (error nil))
149
150   (semantic-load-enable-code-helpers)
151   )
152
153 (semantic-alias-obsolete 'semantic-load-enable-guady-code-helpers
154                          'semantic-load-enable-gaudy-code-helpers)
155
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."
160   (interactive)
161
162   (semantic-load-enable-code-helpers)
163
164   (if (fboundp #'which-func-mode)
165       (add-hook 'semantic-init-hooks (lambda ()
166                                        (which-func-mode 1))))
167   )
168
169 (defun semantic-load-enable-semantic-debugging-helpers ()
170   "Enable all semantic features that assist with debugging semantic.
171 These modes include:
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
175                             failed to be parsed.
176   `semantic-show-parser-state-mode' - Show the current buffer state via
177                             small indicators in the mode line."
178   (interactive)
179
180   (global-semantic-highlight-edits-mode 1)
181
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)
185
186   (global-semantic-show-parser-state-mode 1)
187
188   ;; This enables debug output from the incremental parser.
189   ;; Perhaps a mode for that dumps stuff in a `messages' like buffer
190   ;; would be better?
191   (setq semantic-edits-verbose-flag t)
192
193   )
194
195 ;; Old style variables.  Use only if we are not in batch mode.
196 (when (not noninteractive)
197   (cond
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))
202    ))
203
204 (provide 'semantic-load)
205
206 ;;; semantic-load.el ends here