aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog23
-rw-r--r--lisp/cedet/semantic/decorate/mode.el3
-rw-r--r--lisp/cedet/semantic/idle.el9
-rw-r--r--lisp/cedet/semantic/mru-bookmark.el3
-rw-r--r--lisp/cedet/semantic/util-modes.el114
5 files changed, 84 insertions, 68 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3ffd1345472..86b73ddd292 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,28 @@
12010-05-02 Stefan Monnier <monnier@iro.umontreal.ca> 12010-05-02 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 Use a mode-line spec rather than a static string in Semantic.
4 * cedet/semantic/util-modes.el:
5 (semantic-minor-modes-format): New var to replace...
6 (semantic-minor-modes-status): Remove.
7 (semantic-mode-line-update): Construct a mode-line spec rather than
8 a static string so that mouse buttons can be used on individual minor
9 modes and so that semantic-mode-line-update only needs to be called
10 when global settings are changed.
11 (semantic-add-minor-mode, semantic-toggle-minor-mode-globally):
12 Call semantic-mode-line-update.
13 (semantic-toggle-minor-mode-globally): Don't assume mode is on
14 minor-mode-alist, check semantic-minor-mode-alist as well.
15 (semantic-stickyfunc-mode, semantic-show-parser-state-auto-marker)
16 (semantic-show-parser-state-marker, semantic-show-parser-state-mode)
17 (semantic-show-unmatched-syntax-mode, semantic-highlight-edits-mode):
18 * cedet/semantic/mru-bookmark.el (semantic-mru-bookmark-mode):
19 * cedet/semantic/idle.el (semantic-idle-scheduler-mode)
20 (define-semantic-idle-service, semantic-idle-summary-mode):
21 * cedet/semantic/decorate/mode.el (semantic-decoration-mode):
22 Don't call semantic-mode-line-update any more.
23
242010-05-02 Stefan Monnier <monnier@iro.umontreal.ca>
25
3 Use define-minor-mode in CEDET where applicable. 26 Use define-minor-mode in CEDET where applicable.
4 27
5 * cedet/srecode/mode.el (srecode-minor-mode,global-srecode-minor-mode): 28 * cedet/srecode/mode.el (srecode-minor-mode,global-srecode-minor-mode):
diff --git a/lisp/cedet/semantic/decorate/mode.el b/lisp/cedet/semantic/decorate/mode.el
index 2f24e678753..3c7549c6d0c 100644
--- a/lisp/cedet/semantic/decorate/mode.el
+++ b/lisp/cedet/semantic/decorate/mode.el
@@ -277,8 +277,7 @@ minor mode is enabled."
277 (remove-hook 'semantic-after-partial-cache-change-hook 277 (remove-hook 'semantic-after-partial-cache-change-hook
278 'semantic-decorate-tags-after-partial-reparse t) 278 'semantic-decorate-tags-after-partial-reparse t)
279 (remove-hook 'semantic-after-toplevel-cache-change-hook 279 (remove-hook 'semantic-after-toplevel-cache-change-hook
280 'semantic-decorate-tags-after-full-reparse t)) 280 'semantic-decorate-tags-after-full-reparse t)))
281 (semantic-mode-line-update))
282 281
283(semantic-add-minor-mode 'semantic-decoration-mode 282(semantic-add-minor-mode 'semantic-decoration-mode
284 "") 283 "")
diff --git a/lisp/cedet/semantic/idle.el b/lisp/cedet/semantic/idle.el
index c3b337161c8..a2db3b549d6 100644
--- a/lisp/cedet/semantic/idle.el
+++ b/lisp/cedet/semantic/idle.el
@@ -177,8 +177,7 @@ minor mode is enabled."
177 (setq semantic-idle-scheduler-mode nil) 177 (setq semantic-idle-scheduler-mode nil)
178 (error "Buffer %s was not set up idle time scheduling" 178 (error "Buffer %s was not set up idle time scheduling"
179 (buffer-name))) 179 (buffer-name)))
180 (semantic-idle-scheduler-setup-timers))) 180 (semantic-idle-scheduler-setup-timers))))
181 (semantic-mode-line-update))
182 181
183(semantic-add-minor-mode 'semantic-idle-scheduler-mode 182(semantic-add-minor-mode 'semantic-idle-scheduler-mode
184 "ARP") 183 "ARP")
@@ -589,8 +588,7 @@ turned on in every Semantic-supported buffer.")
589 ;; Enable the mode mode 588 ;; Enable the mode mode
590 (semantic-idle-scheduler-add #',func)) 589 (semantic-idle-scheduler-add #',func))
591 ;; Disable the mode mode 590 ;; Disable the mode mode
592 (semantic-idle-scheduler-remove #',func)) 591 (semantic-idle-scheduler-remove #',func)))
593 (semantic-mode-line-update))
594 592
595 (semantic-add-minor-mode ',mode 593 (semantic-add-minor-mode ',mode
596 "") ; idle schedulers are quiet? 594 "") ; idle schedulers are quiet?
@@ -758,8 +756,7 @@ of the lexical token at point whenever Emacs is idle."
758 (add-hook 'pre-command-hook 'semantic-idle-summary-refresh-echo-area t)) 756 (add-hook 'pre-command-hook 'semantic-idle-summary-refresh-echo-area t))
759 ;; Disable the mode 757 ;; Disable the mode
760 (semantic-idle-scheduler-remove 'semantic-idle-summary-idle-function) 758 (semantic-idle-scheduler-remove 'semantic-idle-summary-idle-function)
761 (remove-hook 'pre-command-hook 'semantic-idle-summary-refresh-echo-area t)) 759 (remove-hook 'pre-command-hook 'semantic-idle-summary-refresh-echo-area t)))
762 (semantic-mode-line-update))
763 760
764(defun semantic-idle-summary-refresh-echo-area () 761(defun semantic-idle-summary-refresh-echo-area ()
765 (and semantic-idle-summary-mode 762 (and semantic-idle-summary-mode
diff --git a/lisp/cedet/semantic/mru-bookmark.el b/lisp/cedet/semantic/mru-bookmark.el
index b69d2f69a01..12e0cb9f834 100644
--- a/lisp/cedet/semantic/mru-bookmark.el
+++ b/lisp/cedet/semantic/mru-bookmark.el
@@ -288,8 +288,7 @@ minor mode is enabled."
288 (remove-hook 'semantic-edits-new-change-hooks 288 (remove-hook 'semantic-edits-new-change-hooks
289 'semantic-mru-bookmark-change-hook-fcn t) 289 'semantic-mru-bookmark-change-hook-fcn t)
290 (remove-hook 'semantic-edits-move-change-hooks 290 (remove-hook 'semantic-edits-move-change-hooks
291 'semantic-mru-bookmark-change-hook-fcn t)) 291 'semantic-mru-bookmark-change-hook-fcn t)))
292 (semantic-mode-line-update))
293 292
294(semantic-add-minor-mode 'semantic-mru-bookmark-mode 293(semantic-add-minor-mode 'semantic-mru-bookmark-mode
295 "k") 294 "k")
diff --git a/lisp/cedet/semantic/util-modes.el b/lisp/cedet/semantic/util-modes.el
index 85d02df2638..9f53dffea98 100644
--- a/lisp/cedet/semantic/util-modes.el
+++ b/lisp/cedet/semantic/util-modes.el
@@ -28,6 +28,10 @@
28;; 28;;
29 29
30;;; Code: 30;;; Code:
31
32;; FIXME: compiling util-modes.el seems to require loading util-modes.el,
33;; so if the previous compilation generated a file that fails to load,
34;; recompiling fails to fix the problem.
31(require 'semantic) 35(require 'semantic)
32 36
33;;; Group for all semantic enhancing modes 37;;; Group for all semantic enhancing modes
@@ -49,8 +53,7 @@ line."
49 :set (lambda (sym val) 53 :set (lambda (sym val)
50 (set-default sym val) 54 (set-default sym val)
51 ;; Update status of all Semantic enabled buffers 55 ;; Update status of all Semantic enabled buffers
52 (semantic-map-buffers 56 (semantic-mode-line-update)))
53 #'semantic-mode-line-update)))
54 57
55(defcustom semantic-mode-line-prefix 58(defcustom semantic-mode-line-prefix
56 (propertize "S" 'face 'bold) 59 (propertize "S" 'face 'bold)
@@ -60,52 +63,54 @@ line."
60 :require 'semantic/util-modes 63 :require 'semantic/util-modes
61 :initialize 'custom-initialize-default) 64 :initialize 'custom-initialize-default)
62 65
63(defvar semantic-minor-modes-status nil 66(defvar semantic-minor-modes-format nil
64 "String showing Semantic minor modes which are locally enabled. 67 "Mode line format showing Semantic minor modes which are locally enabled.
65It is displayed in the mode line.") 68It is displayed in the mode line.")
66(make-variable-buffer-local 'semantic-minor-modes-status) 69(put 'semantic-minor-modes-format 'risky-local-variable t)
67 70
68(defvar semantic-minor-mode-alist nil 71(defvar semantic-minor-mode-alist nil
69 "Alist saying how to show Semantic minor modes in the mode line. 72 "Alist saying how to show Semantic minor modes in the mode line.
70Like variable `minor-mode-alist'.") 73Like variable `minor-mode-alist'.")
71 74
72(defun semantic-mode-line-update () 75(defun semantic-mode-line-update ()
73 "Update display of Semantic minor modes in the mode line. 76 "Update mode line format of Semantic minor modes.
74Only minor modes that are locally enabled are shown in the mode line." 77Only minor modes that are locally enabled are shown in the mode line."
75 (setq semantic-minor-modes-status nil) 78 (setq semantic-minor-modes-format nil)
76 (if semantic-update-mode-line 79 (dolist (x semantic-minor-mode-alist)
77 (let ((ml semantic-minor-mode-alist) 80 (setq minor-mode-alist (delq (assq (car x) minor-mode-alist)
78 mm ms see) 81 minor-mode-alist)))
79 (while ml 82 (when semantic-update-mode-line
80 (setq mm (car ml) 83 (let ((locals '()))
81 ms (cadr mm) 84 ;; Select the minor modes that aren't enabled globally and who
82 mm (car mm) 85 ;; have a non-empty "name".
83 ml (cdr ml)) 86 (dolist (x semantic-minor-mode-alist)
84 (when (and (symbol-value mm) 87 (unless (or (memq (car x) semantic-init-hook)
85 ;; Only show local minor mode status 88 (not (string-match "^[ ]*\\(.+\\)" (cadr x))))
86 (not (memq mm semantic-init-hook))) 89 (push (list (car x) (concat "/" (match-string 1 (cadr x)))) locals)))
87 (and ms 90 ;; Then build the format spec.
88 (symbolp ms) 91 (when locals
89 (setq ms (symbol-value ms))) 92 (let ((prefix (if (string-match "^[ ]*\\(.+\\)"
90 (and (stringp ms) 93 semantic-mode-line-prefix)
91 (not (member ms see)) ;; Don't duplicate same status 94 (match-string 1 semantic-mode-line-prefix)
92 (setq see (cons ms see) 95 "S")))
93 ms (if (string-match "^[ ]*\\(.+\\)" ms) 96 (setq semantic-minor-modes-format
94 (match-string 1 ms))) 97 `((:eval (if (or ,@(mapcar 'car locals))
95 (setq semantic-minor-modes-status 98 ,(concat " " prefix)))))
96 (if semantic-minor-modes-status 99 ;; It would be easier to just put `locals' inside
97 (concat semantic-minor-modes-status "/" ms) 100 ;; semantic-minor-modes-format, but then things like
98 ms))))) 101 ;; mode-line-minor-mode-help can't find the right major mode
99 (if semantic-minor-modes-status 102 ;; any more. So instead, we carefully put the minor modes
100 (setq semantic-minor-modes-status 103 ;; in minor-mode-alist.
101 (concat 104 (let* ((elem (or (assq 'semantic-minor-modes-format
102 " " 105 minor-mode-alist)
103 (if (string-match "^[ ]*\\(.+\\)" 106 ;; FIXME: This entry is meaningless for
104 semantic-mode-line-prefix) 107 ;; mode-line-minor-mode-help.
105 (match-string 1 semantic-mode-line-prefix) 108 '(semantic-minor-modes-format
106 "S") 109 semantic-minor-modes-format)))
107 "/" 110 (tail (or (memq elem minor-mode-alist)
108 semantic-minor-modes-status)))))) 111 (setq minor-mode-alist
112 (cons elem minor-mode-alist)))))
113 (setcdr tail (nconc locals (cdr tail)))))))))
109 114
110(defun semantic-desktop-ignore-this-minor-mode (buffer) 115(defun semantic-desktop-ignore-this-minor-mode (buffer)
111 "Installed as a minor-mode initializer for Desktop mode. 116 "Installed as a minor-mode initializer for Desktop mode.
@@ -121,25 +126,20 @@ It is also an interactive function to toggle the mode.
121NAME specifies what will appear in the mode line when the minor mode 126NAME specifies what will appear in the mode line when the minor mode
122is active. NAME should be either a string starting with a space, or a 127is active. NAME should be either a string starting with a space, or a
123symbol whose value is such a string." 128symbol whose value is such a string."
124 ;; Add a dymmy semantic minor mode to display the status
125 (or (assq 'semantic-minor-modes-status minor-mode-alist)
126 (setq minor-mode-alist (cons (list 'semantic-minor-modes-status
127 'semantic-minor-modes-status)
128 minor-mode-alist)))
129 ;; Record how to display this minor mode in the mode line 129 ;; Record how to display this minor mode in the mode line
130 (let ((mm (assq toggle semantic-minor-mode-alist))) 130 (let ((mm (assq toggle semantic-minor-mode-alist)))
131 (if mm 131 (if mm
132 (setcdr mm (list name)) 132 (setcdr mm (list name))
133 (setq semantic-minor-mode-alist (cons (list toggle name) 133 (setq semantic-minor-mode-alist (cons (list toggle name)
134 semantic-minor-mode-alist)))) 134 semantic-minor-mode-alist))))
135 (semantic-mode-line-update)
135 136
136 ;; Semantic minor modes don't work w/ Desktop restore. 137 ;; Semantic minor modes don't work w/ Desktop restore.
137 ;; This line will disable this minor mode from being restored 138 ;; This line will disable this minor mode from being restored
138 ;; by Desktop. 139 ;; by Desktop.
139 (when (boundp 'desktop-minor-mode-handlers) 140 (when (boundp 'desktop-minor-mode-handlers)
140 (add-to-list 'desktop-minor-mode-handlers 141 (add-to-list 'desktop-minor-mode-handlers
141 (cons toggle 'semantic-desktop-ignore-this-minor-mode))) 142 (cons toggle 'semantic-desktop-ignore-this-minor-mode))))
142 )
143 143
144(defun semantic-toggle-minor-mode-globally (mode &optional arg) 144(defun semantic-toggle-minor-mode-globally (mode &optional arg)
145 "Toggle minor mode MODE in every Semantic enabled buffer. 145 "Toggle minor mode MODE in every Semantic enabled buffer.
@@ -148,7 +148,8 @@ If ARG is positive, enable, if it is negative, disable.
148MODE must be a valid minor mode defined in `minor-mode-alist' and must be 148MODE must be a valid minor mode defined in `minor-mode-alist' and must be
149too an interactive function used to toggle the mode." 149too an interactive function used to toggle the mode."
150 ;; FIXME: All callers should pass a -1 or +1 argument. 150 ;; FIXME: All callers should pass a -1 or +1 argument.
151 (or (and (fboundp mode) (assq mode minor-mode-alist)) 151 (or (and (fboundp mode) (or (assq mode minor-mode-alist) ;Needed?
152 (assq mode semantic-minor-mode-alist)))
152 (error "Semantic minor mode %s not found" mode)) 153 (error "Semantic minor mode %s not found" mode))
153 ;; Add or remove the MODE toggle function from `semantic-init-hook'. 154 ;; Add or remove the MODE toggle function from `semantic-init-hook'.
154 (cond 155 (cond
@@ -159,6 +160,8 @@ too an interactive function used to toggle the mode."
159 ;; Otherwise just check MODE state 160 ;; Otherwise just check MODE state
160 (t 161 (t
161 (error "semantic-toggle-minor-mode-globally: arg should be -1 or 1"))) 162 (error "semantic-toggle-minor-mode-globally: arg should be -1 or 1")))
163 ;; Update the minor mode format.
164 (semantic-mode-line-update)
162 ;; Then turn MODE on or off in every Semantic enabled buffer. 165 ;; Then turn MODE on or off in every Semantic enabled buffer.
163 (semantic-map-buffers #'(lambda () (funcall mode arg)))) 166 (semantic-map-buffers #'(lambda () (funcall mode arg))))
164 167
@@ -224,8 +227,7 @@ minor mode is enabled."
224 'semantic-highlight-edits-new-change-hook-fcn nil t)) 227 'semantic-highlight-edits-new-change-hook-fcn nil t))
225 ;; Remove hooks 228 ;; Remove hooks
226 (remove-hook 'semantic-edits-new-change-hooks 229 (remove-hook 'semantic-edits-new-change-hooks
227 'semantic-highlight-edits-new-change-hook-fcn t)) 230 'semantic-highlight-edits-new-change-hook-fcn t)))
228 (semantic-mode-line-update))
229 231
230(semantic-add-minor-mode 'semantic-highlight-edits-mode 232(semantic-add-minor-mode 'semantic-highlight-edits-mode
231 "e") 233 "e")
@@ -390,8 +392,7 @@ minor mode is enabled.
390 (remove-hook 'semantic-pre-clean-token-hooks 392 (remove-hook 'semantic-pre-clean-token-hooks
391 'semantic-clean-token-of-unmatched-syntax t) 393 'semantic-clean-token-of-unmatched-syntax t)
392 ;; Cleanup unmatched-syntax highlighting 394 ;; Cleanup unmatched-syntax highlighting
393 (semantic-clean-unmatched-syntax-in-buffer)) 395 (semantic-clean-unmatched-syntax-in-buffer)))
394 (semantic-mode-line-update))
395 396
396(semantic-add-minor-mode 'semantic-show-unmatched-syntax-mode 397(semantic-add-minor-mode 'semantic-show-unmatched-syntax-mode
397 "u") 398 "u")
@@ -508,8 +509,7 @@ minor mode is enabled."
508 (remove-hook 'semantic-before-idle-scheduler-reparse-hook 509 (remove-hook 'semantic-before-idle-scheduler-reparse-hook
509 'semantic-show-parser-state-auto-marker t) 510 'semantic-show-parser-state-auto-marker t)
510 (remove-hook 'semantic-after-idle-scheduler-reparse-hook 511 (remove-hook 'semantic-after-idle-scheduler-reparse-hook
511 'semantic-show-parser-state-marker t)) 512 'semantic-show-parser-state-marker t)))
512 (semantic-mode-line-update))
513 513
514(semantic-add-minor-mode 'semantic-show-parser-state-mode 514(semantic-add-minor-mode 'semantic-show-parser-state-mode
515 "") 515 "")
@@ -539,7 +539,7 @@ in many situations."
539 (t 539 (t
540 "-"))) 540 "-")))
541 ;;(message "Setup mode line indicator to [%s]" semantic-show-parser-state-string) 541 ;;(message "Setup mode line indicator to [%s]" semantic-show-parser-state-string)
542 (semantic-mode-line-update)) 542 )
543 543
544(defun semantic-show-parser-state-auto-marker () 544(defun semantic-show-parser-state-auto-marker ()
545 "Hook function run before an autoparse. 545 "Hook function run before an autoparse.
@@ -547,7 +547,6 @@ Set up `semantic-show-parser-state-marker' to show `@'
547to indicate a parse in progress." 547to indicate a parse in progress."
548 (unless (semantic-parse-tree-up-to-date-p) 548 (unless (semantic-parse-tree-up-to-date-p)
549 (setq semantic-show-parser-state-string "@") 549 (setq semantic-show-parser-state-string "@")
550 (semantic-mode-line-update)
551 ;; For testing. 550 ;; For testing.
552 ;;(sit-for 1) 551 ;;(sit-for 1)
553 )) 552 ))
@@ -737,8 +736,7 @@ minor mode is enabled."
737 (kill-local-variable 'header-line-format) 736 (kill-local-variable 'header-line-format)
738 (when (local-variable-p 'semantic-stickyfunc-old-hlf (current-buffer)) 737 (when (local-variable-p 'semantic-stickyfunc-old-hlf (current-buffer))
739 (setq header-line-format semantic-stickyfunc-old-hlf) 738 (setq header-line-format semantic-stickyfunc-old-hlf)
740 (kill-local-variable 'semantic-stickyfunc-old-hlf)))) 739 (kill-local-variable 'semantic-stickyfunc-old-hlf)))))
741 (semantic-mode-line-update))
742 740
743(defvar semantic-stickyfunc-sticky-classes 741(defvar semantic-stickyfunc-sticky-classes
744 '(function type) 742 '(function type)