Mercurial > emacs
comparison lisp/cedet/semantic/db-mode.el @ 104524:fbd55cc47b77
* cedet/ede/system.el (ede-upload-html-documentation)
(ede-upload-distribution, ede-edit-web-page)
(ede-web-browse-home): Autoload.
* cedet/ede/proj-elisp.el: Add autoload for
semantic-ede-proj-target-grammar.
* cedet/semantic.el (navigate-menu): Show menu items only if
semantic-mode is enabled.
* cedet/ede.el: Remove comments.
* cedet/cedet.el (cedet-menu-map): Minor doc fix.
* cedet/semantic/grammar.el:
* cedet/semantic/grammar-wy.el:
* cedet/semantic/ede-grammar.el: New files.
* cedet/semantic/db-mode.el (global-semanticdb-minor-mode): Define
using define-minor-mode, so that the usual mode variable exists.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 27 Sep 2009 21:35:46 +0000 |
parents | c65d65798b34 |
children | bbd7017a25d9 |
comparison
equal
deleted
inserted
replaced
104523:18ae68cd64bd | 104524:fbd55cc47b77 |
---|---|
34 ;; (defvar semanticdb-current-table nil | 34 ;; (defvar semanticdb-current-table nil |
35 ;; "For a given buffer, this is the currently active database table.") | 35 ;; "For a given buffer, this is the currently active database table.") |
36 ;; (make-variable-buffer-local 'semanticdb-current-table) | 36 ;; (make-variable-buffer-local 'semanticdb-current-table) |
37 | 37 |
38 (declare-function semantic-lex-spp-set-dynamic-table "semantic/lex-spp") | 38 (declare-function semantic-lex-spp-set-dynamic-table "semantic/lex-spp") |
39 | |
40 (defcustom semanticdb-global-mode nil | |
41 "*If non-nil enable the use of `semanticdb-minor-mode'." | |
42 :group 'semantic | |
43 :type 'boolean | |
44 :require 'semantic/db | |
45 :initialize 'custom-initialize-default | |
46 :set (lambda (sym val) | |
47 (global-semanticdb-minor-mode (if val 1 -1)) | |
48 (custom-set-default sym val))) | |
49 | |
50 (defcustom semanticdb-mode-hook nil | |
51 "Hook run whenever `global-semanticdb-minor-mode' is run. | |
52 Use `semanticdb-minor-mode-p' to determine if the mode has been turned | |
53 on or off." | |
54 :group 'semanticdb | |
55 :type 'hook) | |
56 | |
57 (semantic-varalias-obsolete 'semanticdb-mode-hooks | |
58 'semanticdb-mode-hook) | |
59 | 39 |
60 ;;; Start/Stop database use | 40 ;;; Start/Stop database use |
61 ;; | 41 ;; |
62 (defvar semanticdb-hooks | 42 (defvar semanticdb-hooks |
63 '((semanticdb-semantic-init-hook-fcn semantic-init-db-hook) | 43 '((semanticdb-semantic-init-hook-fcn semantic-init-db-hook) |
78 "Return non-nil if `semanticdb-minor-mode' is active." | 58 "Return non-nil if `semanticdb-minor-mode' is active." |
79 (member (car (car semanticdb-hooks)) | 59 (member (car (car semanticdb-hooks)) |
80 (symbol-value (car (cdr (car semanticdb-hooks)))))) | 60 (symbol-value (car (cdr (car semanticdb-hooks)))))) |
81 | 61 |
82 ;;;###autoload | 62 ;;;###autoload |
83 (defun global-semanticdb-minor-mode (&optional arg) | 63 (define-minor-mode global-semanticdb-minor-mode |
84 "Toggle the use of `semanticdb-minor-mode'. | 64 "Toggle Semantic DB mode. |
85 If ARG is positive, enable, if it is negative, disable. | 65 With ARG, turn Semantic DB mode on if ARG is positive, off otherwise. |
86 If ARG is nil, then toggle." | 66 |
87 (interactive "P") | 67 In Semantic DB mode, Semantic parsers store results in a |
88 (if (not arg) | 68 database, which can be saved for future Emacs sessions." |
89 (if (semanticdb-minor-mode-p) | 69 :global t |
90 (setq arg -1) | 70 :group 'semantic |
91 (setq arg 1))) | 71 (if global-semanticdb-minor-mode |
92 (let ((fn 'add-hook) | 72 ;; Enable |
93 (h semanticdb-hooks) | 73 (dolist (elt semanticdb-hooks) |
94 (changed nil)) | 74 (add-hook (cadr elt) (car elt))) |
95 (if (< arg 0) | 75 ;; Disable |
96 (setq changed semanticdb-global-mode | 76 (dolist (elt semanticdb-hooks) |
97 semanticdb-global-mode nil | 77 (add-hook (cadr elt) (car elt))))) |
98 fn 'remove-hook) | 78 |
99 (setq changed (not semanticdb-global-mode) | 79 (defvaralias 'semanticdb-mode-hook 'global-semanticdb-minor-mode-hook) |
100 semanticdb-global-mode t)) | 80 (defvaralias 'semanticdb-global-mode 'global-semanticdb-minor-mode) |
101 ;(message "ARG = %d" arg) | 81 (semantic-varalias-obsolete 'semanticdb-mode-hooks |
102 (when changed | 82 'global-semanticdb-minor-mode-hook) |
103 (while h | 83 |
104 (funcall fn (car (cdr (car h))) (car (car h))) | |
105 (setq h (cdr h))) | |
106 ;; Call a hook | |
107 (run-hooks 'semanticdb-mode-hook)) | |
108 )) | |
109 | 84 |
110 (defun semanticdb-toggle-global-mode () | 85 (defun semanticdb-toggle-global-mode () |
111 "Toggle use of the Semantic Database feature. | 86 "Toggle use of the Semantic Database feature. |
112 Update the environment of Semantic enabled buffers accordingly." | 87 Update the environment of Semantic enabled buffers accordingly." |
113 (interactive) | 88 (interactive) |