diff options
| author | Stefan Monnier | 2010-05-01 23:38:19 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2010-05-01 23:38:19 -0400 |
| commit | cb7f3653c838dd1ce01d80e725b4679b79bba256 (patch) | |
| tree | a2f1adb1602ce93b783b452ed03491f18cf3bbe2 | |
| parent | a5a1e2ef820c01bec5a35e0fa5bac7a46894c9e7 (diff) | |
| download | emacs-cb7f3653c838dd1ce01d80e725b4679b79bba256.tar.gz emacs-cb7f3653c838dd1ce01d80e725b4679b79bba256.zip | |
Use define-minor-mode in CEDET where applicable.
* cedet/srecode/mode.el (srecode-minor-mode,global-srecode-minor-mode):
Use define-minor-mode.
* cedet/semantic/util-modes.el (semantic-add-minor-mode):
Remove unused arg `keymap' and code redundant with define-minor-mode.
(semantic-toggle-minor-mode-globally): Only handle arg -1 and 1.
(semantic-stickyfunc-mode, global-semantic-show-unmatched-syntax-mode)
(semantic-highlight-func-mode, global-semantic-show-parser-state-mode)
(global-semantic-highlight-edits-mode, semantic-highlight-edits-mode)
(semantic-show-unmatched-syntax-mode, semantic-show-parser-state-mode)
(global-semantic-stickyfunc-mode, global-semantic-highlight-func-mode):
Use define-minor-mode.
(semantic-stickyfunc-mode-setup, semantic-highlight-edits-mode-setup)
(semantic-show-unmatched-syntax-mode-setup)
(semantic-show-parser-state-mode-setup)
(semantic-highlight-func-mode-setup): Inline into sole caller.
* cedet/semantic/mru-bookmark.el (global-semantic-mru-bookmark-mode)
(semantic-mru-bookmark-mode): Use define-minor-mode.
(semantic-mru-bookmark-mode-setup): Inline into sole caller.
* cedet/semantic/idle.el (define-semantic-idle-service):
Use define-minor-mode and inline setup function into its sole caller.
(semantic-idle-scheduler-mode-setup)
(semantic-idle-summary-mode-setup): Inline into sole caller.
(global-semantic-idle-scheduler-mode, semantic-idle-scheduler-mode):
Use define-minor-mode.
* cedet/semantic/decorate/mode.el (global-semantic-decoration-mode)
(semantic-decoration-mode): Use define-minor-mode.
(semantic-decoration-mode-setup): Inline into sole caller.
* cedet/ede/dired.el (ede-dired-minor-mode): Initialize in declaration.
(ede-dired-minor-mode): Use define-minor-mode and derived-mode-p.
(ede-dired-add-to-target): Use dolist.
| -rw-r--r-- | lisp/ChangeLog | 47 | ||||
| -rw-r--r-- | lisp/cedet/ede/dired.el | 98 | ||||
| -rw-r--r-- | lisp/cedet/semantic/decorate/mode.el | 87 | ||||
| -rw-r--r-- | lisp/cedet/semantic/idle.el | 162 | ||||
| -rw-r--r-- | lisp/cedet/semantic/mru-bookmark.el | 84 | ||||
| -rw-r--r-- | lisp/cedet/semantic/util-modes.el | 501 | ||||
| -rw-r--r-- | lisp/cedet/srecode/mode.el | 49 |
7 files changed, 313 insertions, 715 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 170d22a106b..3ffd1345472 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,43 @@ | |||
| 1 | 2010-05-02 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | Use define-minor-mode in CEDET where applicable. | ||
| 4 | |||
| 5 | * cedet/srecode/mode.el (srecode-minor-mode,global-srecode-minor-mode): | ||
| 6 | Use define-minor-mode. | ||
| 7 | |||
| 8 | * cedet/semantic/util-modes.el (semantic-add-minor-mode): | ||
| 9 | Remove unused arg `keymap' and code redundant with define-minor-mode. | ||
| 10 | (semantic-toggle-minor-mode-globally): Only handle arg -1 and 1. | ||
| 11 | (semantic-stickyfunc-mode, global-semantic-show-unmatched-syntax-mode) | ||
| 12 | (semantic-highlight-func-mode, global-semantic-show-parser-state-mode) | ||
| 13 | (global-semantic-highlight-edits-mode, semantic-highlight-edits-mode) | ||
| 14 | (semantic-show-unmatched-syntax-mode, semantic-show-parser-state-mode) | ||
| 15 | (global-semantic-stickyfunc-mode, global-semantic-highlight-func-mode): | ||
| 16 | Use define-minor-mode. | ||
| 17 | (semantic-stickyfunc-mode-setup, semantic-highlight-edits-mode-setup) | ||
| 18 | (semantic-show-unmatched-syntax-mode-setup) | ||
| 19 | (semantic-show-parser-state-mode-setup) | ||
| 20 | (semantic-highlight-func-mode-setup): Inline into sole caller. | ||
| 21 | |||
| 22 | * cedet/semantic/mru-bookmark.el (global-semantic-mru-bookmark-mode) | ||
| 23 | (semantic-mru-bookmark-mode): Use define-minor-mode. | ||
| 24 | (semantic-mru-bookmark-mode-setup): Inline into sole caller. | ||
| 25 | |||
| 26 | * cedet/semantic/idle.el (define-semantic-idle-service): | ||
| 27 | Use define-minor-mode and inline setup function into its sole caller. | ||
| 28 | (semantic-idle-scheduler-mode-setup) | ||
| 29 | (semantic-idle-summary-mode-setup): Inline into sole caller. | ||
| 30 | (global-semantic-idle-scheduler-mode, semantic-idle-scheduler-mode): | ||
| 31 | Use define-minor-mode. | ||
| 32 | |||
| 33 | * cedet/semantic/decorate/mode.el (global-semantic-decoration-mode) | ||
| 34 | (semantic-decoration-mode): Use define-minor-mode. | ||
| 35 | (semantic-decoration-mode-setup): Inline into sole caller. | ||
| 36 | |||
| 37 | * cedet/ede/dired.el (ede-dired-minor-mode): Initialize in declaration. | ||
| 38 | (ede-dired-minor-mode): Use define-minor-mode and derived-mode-p. | ||
| 39 | (ede-dired-add-to-target): Use dolist. | ||
| 40 | |||
| 1 | 2010-05-01 Toru TSUNEYOSHI <t_tuneyosi@hotmail.com> | 41 | 2010-05-01 Toru TSUNEYOSHI <t_tuneyosi@hotmail.com> |
| 2 | Michael Albinus <michael.albinus@gmx.de> | 42 | Michael Albinus <michael.albinus@gmx.de> |
| 3 | 43 | ||
| @@ -8,8 +48,8 @@ | |||
| 8 | (tramp-inline-compress-commands): New defconst. | 48 | (tramp-inline-compress-commands): New defconst. |
| 9 | (tramp-find-inline-compress, tramp-get-inline-compress) | 49 | (tramp-find-inline-compress, tramp-get-inline-compress) |
| 10 | (tramp-get-inline-coding): New defuns. | 50 | (tramp-get-inline-coding): New defuns. |
| 11 | (tramp-get-remote-coding, tramp-get-local-coding): Removed, | 51 | (tramp-get-remote-coding, tramp-get-local-coding): Remove, |
| 12 | replaced by `tramp-get-inline-coding'. | 52 | replace by `tramp-get-inline-coding'. |
| 13 | (tramp-handle-file-local-copy, tramp-handle-write-region) | 53 | (tramp-handle-file-local-copy, tramp-handle-write-region) |
| 14 | (tramp-method-out-of-band-p): Use `tramp-get-inline-coding'. | 54 | (tramp-method-out-of-band-p): Use `tramp-get-inline-coding'. |
| 15 | 55 | ||
| @@ -41,8 +81,7 @@ | |||
| 41 | 81 | ||
| 42 | 2010-04-30 Chong Yidong <cyd@stupidchicken.com> | 82 | 2010-04-30 Chong Yidong <cyd@stupidchicken.com> |
| 43 | 83 | ||
| 44 | * minibuffer.el (tags-completion-at-point-function): Fix return | 84 | * minibuffer.el (tags-completion-at-point-function): Fix return value. |
| 45 | value. | ||
| 46 | 85 | ||
| 47 | 2010-04-30 Eli Zaretskii <eliz@gnu.org> | 86 | 2010-04-30 Eli Zaretskii <eliz@gnu.org> |
| 48 | 87 | ||
diff --git a/lisp/cedet/ede/dired.el b/lisp/cedet/ede/dired.el index ede30287723..82784740615 100644 --- a/lisp/cedet/ede/dired.el +++ b/lisp/cedet/ede/dired.el | |||
| @@ -27,57 +27,46 @@ | |||
| 27 | ;; This provides a dired interface to EDE, allowing users to modify | 27 | ;; This provides a dired interface to EDE, allowing users to modify |
| 28 | ;; their project file by adding files (or whatever) directly from a | 28 | ;; their project file by adding files (or whatever) directly from a |
| 29 | ;; dired buffer. | 29 | ;; dired buffer. |
| 30 | 30 | (eval-when-compile (require 'cl)) | |
| 31 | (require 'easymenu) | 31 | (require 'easymenu) |
| 32 | (require 'dired) | 32 | (require 'dired) |
| 33 | (require 'ede) | 33 | (require 'ede) |
| 34 | 34 | ||
| 35 | ;;; Code: | 35 | ;;; Code: |
| 36 | (defvar ede-dired-minor-mode nil | 36 | (defvar ede-dired-keymap |
| 37 | "Non-nil when in ede dired minor mode.") | 37 | (let ((map (make-sparse-keymap))) |
| 38 | (make-variable-buffer-local 'ede-dired-minor-mode) | 38 | (define-key map ".a" 'ede-dired-add-to-target) |
| 39 | 39 | (define-key map ".t" 'ede-new-target) | |
| 40 | (defvar ede-dired-keymap nil | 40 | (define-key map ".s" 'ede-speedbar) |
| 41 | (define-key map ".C" 'ede-compile-project) | ||
| 42 | (define-key map ".d" 'ede-make-dist) | ||
| 43 | |||
| 44 | (easy-menu-define | ||
| 45 | ede-dired-menu map "EDE Dired Minor Mode Menu" | ||
| 46 | '("Project" | ||
| 47 | [ "Add files to target" ede-dired-add-to-target (ede-current-project) ] | ||
| 48 | ( "Build" :filter ede-build-forms-menu) | ||
| 49 | "-" | ||
| 50 | [ "Create Project" ede-new (not (ede-current-project)) ] | ||
| 51 | [ "Create Target" ede-new-target (ede-current-project) ] | ||
| 52 | "-" | ||
| 53 | ( "Customize Project" :filter ede-customize-forms-menu ) | ||
| 54 | [ "View Project Tree" ede-speedbar (ede-current-project) ] | ||
| 55 | )) | ||
| 56 | map) | ||
| 41 | "Keymap used for ede dired minor mode.") | 57 | "Keymap used for ede dired minor mode.") |
| 42 | 58 | ||
| 43 | (if ede-dired-keymap | 59 | (define-minor-mode ede-dired-minor-mode |
| 44 | nil | ||
| 45 | (setq ede-dired-keymap (make-sparse-keymap)) | ||
| 46 | (define-key ede-dired-keymap ".a" 'ede-dired-add-to-target) | ||
| 47 | (define-key ede-dired-keymap ".t" 'ede-new-target) | ||
| 48 | (define-key ede-dired-keymap ".s" 'ede-speedbar) | ||
| 49 | (define-key ede-dired-keymap ".C" 'ede-compile-project) | ||
| 50 | (define-key ede-dired-keymap ".d" 'ede-make-dist) | ||
| 51 | |||
| 52 | (easy-menu-define | ||
| 53 | ede-dired-menu ede-dired-keymap "EDE Dired Minor Mode Menu" | ||
| 54 | '("Project" | ||
| 55 | [ "Add files to target" ede-dired-add-to-target (ede-current-project) ] | ||
| 56 | ( "Build" :filter ede-build-forms-menu) | ||
| 57 | "-" | ||
| 58 | [ "Create Project" ede-new (not (ede-current-project)) ] | ||
| 59 | [ "Create Target" ede-new-target (ede-current-project) ] | ||
| 60 | "-" | ||
| 61 | ( "Customize Project" :filter ede-customize-forms-menu ) | ||
| 62 | [ "View Project Tree" ede-speedbar (ede-current-project) ] | ||
| 63 | )) | ||
| 64 | ) | ||
| 65 | |||
| 66 | (defun ede-dired-minor-mode (&optional arg) | ||
| 67 | "A minor mode that should only be activated in DIRED buffers. | 60 | "A minor mode that should only be activated in DIRED buffers. |
| 68 | If ARG is nil, toggle, if it is a positive number, force on, if | 61 | If ARG is nil or a positive number, force on, if |
| 69 | negative, force off." | 62 | negative, force off." |
| 70 | (interactive "P") | 63 | :lighter " EDE" :keymap ede-dired-keymap |
| 71 | (if (not (or (eq major-mode 'dired-mode) | 64 | (unless (derived-mode-p 'dired-mode) |
| 72 | (eq major-mode 'vc-dired-mode))) | 65 | (setq ede-dired-minor-mode nil) |
| 73 | (error "Not in DIRED mode")) | 66 | (error "Not in DIRED mode")) |
| 74 | (setq ede-dired-minor-mode | 67 | (unless (or (ede-directory-project-p default-directory) |
| 75 | (not (or (and (null arg) ede-dired-minor-mode) | 68 | (interactive-p)) |
| 76 | (<= (prefix-numeric-value arg) 0)))) | 69 | (setq ede-dired-minor-mode nil))) |
| 77 | (if (and (not (ede-directory-project-p default-directory)) | ||
| 78 | (not (interactive-p))) | ||
| 79 | (setq ede-dired-minor-mode nil)) | ||
| 80 | ) | ||
| 81 | 70 | ||
| 82 | (defun ede-dired-add-to-target (target) | 71 | (defun ede-dired-add-to-target (target) |
| 83 | "Add a file, or all marked files into a TARGET." | 72 | "Add a file, or all marked files into a TARGET." |
| @@ -85,24 +74,13 @@ negative, force off." | |||
| 85 | (let ((ede-object (ede-current-project))) | 74 | (let ((ede-object (ede-current-project))) |
| 86 | (ede-invoke-method 'project-interactive-select-target | 75 | (ede-invoke-method 'project-interactive-select-target |
| 87 | "Add files to Target: ")))) | 76 | "Add files to Target: ")))) |
| 88 | (let ((files (dired-get-marked-files t))) | 77 | (dolist (file (dired-get-marked-files t)) |
| 89 | (while files | 78 | (project-add-file target file) |
| 90 | (project-add-file target (car files)) | 79 | ;; Find the buffer for this files, and set it's ede-object |
| 91 | ;; Find the buffer for this files, and set it's ede-object | 80 | (if (get-file-buffer file) |
| 92 | (if (get-file-buffer (car files)) | 81 | (with-current-buffer (get-file-buffer file) |
| 93 | (with-current-buffer (get-file-buffer (car files)) | 82 | (setq ede-object nil) |
| 94 | (setq ede-object nil) | 83 | (setq ede-object (ede-buffer-object (current-buffer))))))) |
| 95 | (setq ede-object (ede-buffer-object (current-buffer))))) | ||
| 96 | ;; Increment. | ||
| 97 | (setq files (cdr files))))) | ||
| 98 | |||
| 99 | ;; Minor mode management. | ||
| 100 | (add-to-list 'minor-mode-alist '(ede-dired-minor-mode " EDE")) | ||
| 101 | (let ((a (assoc 'ede-dired-minor-mode minor-mode-map-alist))) | ||
| 102 | (if a | ||
| 103 | (setcdr a ede-dired-keymap) | ||
| 104 | (add-to-list 'minor-mode-map-alist (cons 'ede-dired-minor-mode | ||
| 105 | ede-dired-keymap)))) | ||
| 106 | 84 | ||
| 107 | (provide 'ede/dired) | 85 | (provide 'ede/dired) |
| 108 | 86 | ||
diff --git a/lisp/cedet/semantic/decorate/mode.el b/lisp/cedet/semantic/decorate/mode.el index c5dee1676b6..2f24e678753 100644 --- a/lisp/cedet/semantic/decorate/mode.el +++ b/lisp/cedet/semantic/decorate/mode.el | |||
| @@ -224,46 +224,34 @@ Flush functions from `semantic-decorate-pending-decoration-hook'." | |||
| 224 | ;; Generic mode for handling basic highlighting and decorations. | 224 | ;; Generic mode for handling basic highlighting and decorations. |
| 225 | ;; | 225 | ;; |
| 226 | 226 | ||
| 227 | (defcustom global-semantic-decoration-mode nil | ||
| 228 | "*If non-nil, enable global use of command `semantic-decoration-mode'. | ||
| 229 | When this mode is activated, decorations specified by | ||
| 230 | `semantic-decoration-styles'." | ||
| 231 | :group 'semantic | ||
| 232 | :group 'semantic-modes | ||
| 233 | :type 'boolean | ||
| 234 | :require 'semantic/decorate/mode | ||
| 235 | :initialize 'custom-initialize-default | ||
| 236 | :set (lambda (sym val) | ||
| 237 | (global-semantic-decoration-mode (if val 1 -1)))) | ||
| 238 | |||
| 239 | ;;;###autoload | 227 | ;;;###autoload |
| 240 | (defun global-semantic-decoration-mode (&optional arg) | 228 | (define-minor-mode global-semantic-decoration-mode |
| 241 | "Toggle global use of option `semantic-decoration-mode'. | 229 | "Toggle global use of option `semantic-decoration-mode'. |
| 242 | Decoration mode turns on all active decorations as specified | 230 | Decoration mode turns on all active decorations as specified |
| 243 | by `semantic-decoration-styles'. | 231 | by `semantic-decoration-styles'." |
| 244 | If ARG is positive, enable, if it is negative, disable. | 232 | :global t :group 'semantic :group 'semantic-modes |
| 245 | If ARG is nil, then toggle." | 233 | ;; Not needed because it's autoloaded instead. |
| 246 | (interactive "P") | 234 | ;; :require 'semantic/decorate/mode |
| 247 | (setq global-semantic-decoration-mode | 235 | (semantic-toggle-minor-mode-globally |
| 248 | (semantic-toggle-minor-mode-globally | 236 | 'semantic-decoration-mode (if global-semantic-decoration-mode 1 -1))) |
| 249 | 'semantic-decoration-mode arg))) | ||
| 250 | 237 | ||
| 251 | (defcustom semantic-decoration-mode-hook nil | 238 | (defcustom semantic-decoration-mode-hook nil |
| 252 | "Hook run at the end of function `semantic-decoration-mode'." | 239 | "Hook run at the end of function `semantic-decoration-mode'." |
| 253 | :group 'semantic | 240 | :group 'semantic |
| 254 | :type 'hook) | 241 | :type 'hook) |
| 255 | 242 | ||
| 256 | ;;;;###autoload | 243 | (define-minor-mode semantic-decoration-mode |
| 257 | (defvar semantic-decoration-mode nil | 244 | "Minor mode for decorating tags. |
| 258 | "Non-nil if command `semantic-decoration-mode' is enabled. | 245 | Decorations are specified in `semantic-decoration-styles'. |
| 259 | Use the command `semantic-decoration-mode' to change this variable.") | 246 | You can define new decoration styles with |
| 260 | (make-variable-buffer-local 'semantic-decoration-mode) | 247 | `define-semantic-decoration-style'. |
| 261 | 248 | With prefix argument ARG, turn on if positive, otherwise off. The | |
| 262 | (defun semantic-decoration-mode-setup () | 249 | minor mode can be turned on only if semantic feature is available and |
| 263 | "Setup the `semantic-decoration-mode' minor mode. | 250 | the current buffer was set up for parsing. Return non-nil if the |
| 264 | The minor mode can be turned on only if the semantic feature is available | ||
| 265 | and the current buffer was set up for parsing. Return non-nil if the | ||
| 266 | minor mode is enabled." | 251 | minor mode is enabled." |
| 252 | ;; | ||
| 253 | ;;\\{semantic-decoration-map}" | ||
| 254 | nil nil nil | ||
| 267 | (if semantic-decoration-mode | 255 | (if semantic-decoration-mode |
| 268 | (if (not (and (featurep 'semantic) (semantic-active-p))) | 256 | (if (not (and (featurep 'semantic) (semantic-active-p))) |
| 269 | (progn | 257 | (progn |
| @@ -280,8 +268,7 @@ minor mode is enabled." | |||
| 280 | 'semantic-decorate-tags-after-full-reparse nil t) | 268 | 'semantic-decorate-tags-after-full-reparse nil t) |
| 281 | ;; Add decorations to available tags. The above hooks ensure | 269 | ;; Add decorations to available tags. The above hooks ensure |
| 282 | ;; that new tags will be decorated when they become available. | 270 | ;; that new tags will be decorated when they become available. |
| 283 | (semantic-decorate-add-decorations (semantic-fetch-available-tags)) | 271 | (semantic-decorate-add-decorations (semantic-fetch-available-tags))) |
| 284 | ) | ||
| 285 | ;; Remove decorations from available tags. | 272 | ;; Remove decorations from available tags. |
| 286 | (semantic-decorate-clear-decorations (semantic-fetch-available-tags)) | 273 | (semantic-decorate-clear-decorations (semantic-fetch-available-tags)) |
| 287 | ;; Cleanup any leftover crap too. | 274 | ;; Cleanup any leftover crap too. |
| @@ -290,41 +277,11 @@ minor mode is enabled." | |||
| 290 | (remove-hook 'semantic-after-partial-cache-change-hook | 277 | (remove-hook 'semantic-after-partial-cache-change-hook |
| 291 | 'semantic-decorate-tags-after-partial-reparse t) | 278 | 'semantic-decorate-tags-after-partial-reparse t) |
| 292 | (remove-hook 'semantic-after-toplevel-cache-change-hook | 279 | (remove-hook 'semantic-after-toplevel-cache-change-hook |
| 293 | 'semantic-decorate-tags-after-full-reparse t) | 280 | 'semantic-decorate-tags-after-full-reparse t)) |
| 294 | ) | 281 | (semantic-mode-line-update)) |
| 295 | semantic-decoration-mode) | ||
| 296 | |||
| 297 | (defun semantic-decoration-mode (&optional arg) | ||
| 298 | "Minor mode for decorating tags. | ||
| 299 | Decorations are specified in `semantic-decoration-styles'. | ||
| 300 | You can define new decoration styles with | ||
| 301 | `define-semantic-decoration-style'. | ||
| 302 | With prefix argument ARG, turn on if positive, otherwise off. The | ||
| 303 | minor mode can be turned on only if semantic feature is available and | ||
| 304 | the current buffer was set up for parsing. Return non-nil if the | ||
| 305 | minor mode is enabled." | ||
| 306 | ;; | ||
| 307 | ;;\\{semantic-decoration-map}" | ||
| 308 | (interactive | ||
| 309 | (list (or current-prefix-arg | ||
| 310 | (if semantic-decoration-mode 0 1)))) | ||
| 311 | (setq semantic-decoration-mode | ||
| 312 | (if arg | ||
| 313 | (> | ||
| 314 | (prefix-numeric-value arg) | ||
| 315 | 0) | ||
| 316 | (not semantic-decoration-mode))) | ||
| 317 | (semantic-decoration-mode-setup) | ||
| 318 | (run-hooks 'semantic-decoration-mode-hook) | ||
| 319 | (if (called-interactively-p 'interactive) | ||
| 320 | (message "decoration-mode minor mode %sabled" | ||
| 321 | (if semantic-decoration-mode "en" "dis"))) | ||
| 322 | (semantic-mode-line-update) | ||
| 323 | semantic-decoration-mode) | ||
| 324 | 282 | ||
| 325 | (semantic-add-minor-mode 'semantic-decoration-mode | 283 | (semantic-add-minor-mode 'semantic-decoration-mode |
| 326 | "" | 284 | "") |
| 327 | nil) | ||
| 328 | 285 | ||
| 329 | (defun semantic-decorate-tags-after-full-reparse (tag-list) | 286 | (defun semantic-decorate-tags-after-full-reparse (tag-list) |
| 330 | "Add decorations after a complete reparse of the current buffer. | 287 | "Add decorations after a complete reparse of the current buffer. |
diff --git a/lisp/cedet/semantic/idle.el b/lisp/cedet/semantic/idle.el index ba7a49757a5..c3b337161c8 100644 --- a/lisp/cedet/semantic/idle.el +++ b/lisp/cedet/semantic/idle.el | |||
| @@ -128,16 +128,6 @@ unlikely the user would be ready to type again right away." | |||
| 128 | ;; The minor mode portion of this code just sets up the minor mode | 128 | ;; The minor mode portion of this code just sets up the minor mode |
| 129 | ;; which does the initial scheduling of the idle timers. | 129 | ;; which does the initial scheduling of the idle timers. |
| 130 | ;; | 130 | ;; |
| 131 | ;;;###autoload | ||
| 132 | (defcustom global-semantic-idle-scheduler-mode nil | ||
| 133 | "*If non-nil, enable global use of idle-scheduler mode." | ||
| 134 | :group 'semantic | ||
| 135 | :group 'semantic-modes | ||
| 136 | :type 'boolean | ||
| 137 | :require 'semantic/idle | ||
| 138 | :initialize 'custom-initialize-default | ||
| 139 | :set (lambda (sym val) | ||
| 140 | (global-semantic-idle-scheduler-mode (if val 1 -1)))) | ||
| 141 | 131 | ||
| 142 | (defcustom semantic-idle-scheduler-mode-hook nil | 132 | (defcustom semantic-idle-scheduler-mode-hook nil |
| 143 | "Hook run at the end of the function `semantic-idle-scheduler-mode'." | 133 | "Hook run at the end of the function `semantic-idle-scheduler-mode'." |
| @@ -167,24 +157,8 @@ exceeds the `semantic-idle-scheduler-max-buffer-size' threshold." | |||
| 167 | (or (<= semantic-idle-scheduler-max-buffer-size 0) | 157 | (or (<= semantic-idle-scheduler-max-buffer-size 0) |
| 168 | (< (buffer-size) semantic-idle-scheduler-max-buffer-size)))) | 158 | (< (buffer-size) semantic-idle-scheduler-max-buffer-size)))) |
| 169 | 159 | ||
| 170 | (defun semantic-idle-scheduler-mode-setup () | ||
| 171 | "Setup option `semantic-idle-scheduler-mode'. | ||
| 172 | The minor mode can be turned on only if semantic feature is available | ||
| 173 | and the current buffer was set up for parsing. When minor mode is | ||
| 174 | enabled parse the current buffer if needed. Return non-nil if the | ||
| 175 | minor mode is enabled." | ||
| 176 | (if semantic-idle-scheduler-mode | ||
| 177 | (if (not (and (featurep 'semantic) (semantic-active-p))) | ||
| 178 | (progn | ||
| 179 | ;; Disable minor mode if semantic stuff not available | ||
| 180 | (setq semantic-idle-scheduler-mode nil) | ||
| 181 | (error "Buffer %s was not set up idle time scheduling" | ||
| 182 | (buffer-name))) | ||
| 183 | (semantic-idle-scheduler-setup-timers))) | ||
| 184 | semantic-idle-scheduler-mode) | ||
| 185 | |||
| 186 | ;;;###autoload | 160 | ;;;###autoload |
| 187 | (defun semantic-idle-scheduler-mode (&optional arg) | 161 | (define-minor-mode semantic-idle-scheduler-mode |
| 188 | "Minor mode to auto parse buffer following a change. | 162 | "Minor mode to auto parse buffer following a change. |
| 189 | When this mode is off, a buffer is only rescanned for tokens when | 163 | When this mode is off, a buffer is only rescanned for tokens when |
| 190 | some command requests the list of available tokens. When idle-scheduler | 164 | some command requests the list of available tokens. When idle-scheduler |
| @@ -195,26 +169,19 @@ With prefix argument ARG, turn on if positive, otherwise off. The | |||
| 195 | minor mode can be turned on only if semantic feature is available and | 169 | minor mode can be turned on only if semantic feature is available and |
| 196 | the current buffer was set up for parsing. Return non-nil if the | 170 | the current buffer was set up for parsing. Return non-nil if the |
| 197 | minor mode is enabled." | 171 | minor mode is enabled." |
| 198 | (interactive | 172 | nil nil nil |
| 199 | (list (or current-prefix-arg | 173 | (if semantic-idle-scheduler-mode |
| 200 | (if semantic-idle-scheduler-mode 0 1)))) | 174 | (if (not (and (featurep 'semantic) (semantic-active-p))) |
| 201 | (setq semantic-idle-scheduler-mode | 175 | (progn |
| 202 | (if arg | 176 | ;; Disable minor mode if semantic stuff not available |
| 203 | (> | 177 | (setq semantic-idle-scheduler-mode nil) |
| 204 | (prefix-numeric-value arg) | 178 | (error "Buffer %s was not set up idle time scheduling" |
| 205 | 0) | 179 | (buffer-name))) |
| 206 | (not semantic-idle-scheduler-mode))) | 180 | (semantic-idle-scheduler-setup-timers))) |
| 207 | (semantic-idle-scheduler-mode-setup) | 181 | (semantic-mode-line-update)) |
| 208 | (run-hooks 'semantic-idle-scheduler-mode-hook) | ||
| 209 | (if (called-interactively-p 'interactive) | ||
| 210 | (message "idle-scheduler minor mode %sabled" | ||
| 211 | (if semantic-idle-scheduler-mode "en" "dis"))) | ||
| 212 | (semantic-mode-line-update) | ||
| 213 | semantic-idle-scheduler-mode) | ||
| 214 | 182 | ||
| 215 | (semantic-add-minor-mode 'semantic-idle-scheduler-mode | 183 | (semantic-add-minor-mode 'semantic-idle-scheduler-mode |
| 216 | "ARP" | 184 | "ARP") |
| 217 | nil) | ||
| 218 | 185 | ||
| 219 | ;;; SERVICES services | 186 | ;;; SERVICES services |
| 220 | ;; | 187 | ;; |
| @@ -582,31 +549,23 @@ This routine creates the following functions and variables:" | |||
| 582 | (mode (intern (concat (symbol-name name) "-mode"))) | 549 | (mode (intern (concat (symbol-name name) "-mode"))) |
| 583 | (hook (intern (concat (symbol-name name) "-mode-hook"))) | 550 | (hook (intern (concat (symbol-name name) "-mode-hook"))) |
| 584 | (map (intern (concat (symbol-name name) "-mode-map"))) | 551 | (map (intern (concat (symbol-name name) "-mode-map"))) |
| 585 | (setup (intern (concat (symbol-name name) "-mode-setup"))) | ||
| 586 | (func (intern (concat (symbol-name name) "-idle-function")))) | 552 | (func (intern (concat (symbol-name name) "-idle-function")))) |
| 587 | 553 | ||
| 588 | `(eval-and-compile | 554 | `(eval-and-compile |
| 589 | (defun ,global (&optional arg) | 555 | (define-minor-mode ,global |
| 590 | ,(concat "Toggle " (symbol-name global) ". | 556 | ,(concat "Toggle " (symbol-name global) ". |
| 591 | With ARG, turn the minor mode on if ARG is positive, off otherwise. | 557 | With ARG, turn the minor mode on if ARG is positive, off otherwise. |
| 592 | 558 | ||
| 593 | When this minor mode is enabled, `" (symbol-name mode) "' is | 559 | When this minor mode is enabled, `" (symbol-name mode) "' is |
| 594 | turned on in every Semantic-supported buffer.") | 560 | turned on in every Semantic-supported buffer.") |
| 595 | (interactive "P") | 561 | :global t |
| 596 | (setq ,global | ||
| 597 | (semantic-toggle-minor-mode-globally | ||
| 598 | ',mode arg))) | ||
| 599 | |||
| 600 | (defcustom ,global nil | ||
| 601 | ,(concat "Non-nil if `" (symbol-name mode) "' is enabled.") | ||
| 602 | :group 'semantic | 562 | :group 'semantic |
| 603 | :group 'semantic-modes | 563 | :group 'semantic-modes |
| 604 | :type 'boolean | ||
| 605 | :require 'semantic/idle | 564 | :require 'semantic/idle |
| 606 | :initialize 'custom-initialize-default | 565 | (semantic-toggle-minor-mode-globally |
| 607 | :set (lambda (sym val) | 566 | ',mode (if ,global 1 -1))) |
| 608 | (,global (if val 1 -1)))) | ||
| 609 | 567 | ||
| 568 | ;; FIXME: Get rid of this when define-minor-mode does it for us. | ||
| 610 | (defcustom ,hook nil | 569 | (defcustom ,hook nil |
| 611 | ,(concat "Hook run at the end of function `" (symbol-name mode) "'.") | 570 | ,(concat "Hook run at the end of function `" (symbol-name mode) "'.") |
| 612 | :group 'semantic | 571 | :group 'semantic |
| @@ -617,14 +576,9 @@ turned on in every Semantic-supported buffer.") | |||
| 617 | km) | 576 | km) |
| 618 | ,(concat "Keymap for `" (symbol-name mode) "'.")) | 577 | ,(concat "Keymap for `" (symbol-name mode) "'.")) |
| 619 | 578 | ||
| 620 | (defvar ,mode nil | 579 | (define-minor-mode ,mode |
| 621 | ,(concat "Non-nil if the minor mode `" (symbol-name mode) "' is enabled. | 580 | ,doc |
| 622 | Use the command `" (symbol-name mode) "' to change this variable.")) | 581 | :keymap ,map |
| 623 | (make-variable-buffer-local ',mode) | ||
| 624 | |||
| 625 | (defun ,setup () | ||
| 626 | ,(concat "Set up `" (symbol-name mode) "'. | ||
| 627 | Return non-nil if the minor mode is enabled.") | ||
| 628 | (if ,mode | 582 | (if ,mode |
| 629 | (if (not (and (featurep 'semantic) (semantic-active-p))) | 583 | (if (not (and (featurep 'semantic) (semantic-active-p))) |
| 630 | (progn | 584 | (progn |
| @@ -633,36 +587,13 @@ Return non-nil if the minor mode is enabled.") | |||
| 633 | (error "Buffer %s was not set up for parsing" | 587 | (error "Buffer %s was not set up for parsing" |
| 634 | (buffer-name))) | 588 | (buffer-name))) |
| 635 | ;; Enable the mode mode | 589 | ;; Enable the mode mode |
| 636 | (semantic-idle-scheduler-add #',func) | 590 | (semantic-idle-scheduler-add #',func)) |
| 637 | ) | ||
| 638 | ;; Disable the mode mode | 591 | ;; Disable the mode mode |
| 639 | (semantic-idle-scheduler-remove #',func) | 592 | (semantic-idle-scheduler-remove #',func)) |
| 640 | ) | 593 | (semantic-mode-line-update)) |
| 641 | ,mode) | ||
| 642 | |||
| 643 | (defun ,mode (&optional arg) | ||
| 644 | ,doc | ||
| 645 | (interactive | ||
| 646 | (list (or current-prefix-arg | ||
| 647 | (if ,mode 0 1)))) | ||
| 648 | (setq ,mode | ||
| 649 | (if arg | ||
| 650 | (> | ||
| 651 | (prefix-numeric-value arg) | ||
| 652 | 0) | ||
| 653 | (not ,mode))) | ||
| 654 | (,setup) | ||
| 655 | (run-hooks ,hook) | ||
| 656 | (if (called-interactively-p 'interactive) | ||
| 657 | (message "%s %sabled" | ||
| 658 | (symbol-name ',mode) | ||
| 659 | (if ,mode "en" "dis"))) | ||
| 660 | (semantic-mode-line-update) | ||
| 661 | ,mode) | ||
| 662 | 594 | ||
| 663 | (semantic-add-minor-mode ',mode | 595 | (semantic-add-minor-mode ',mode |
| 664 | "" ; idle schedulers are quiet? | 596 | "") ; idle schedulers are quiet? |
| 665 | ,map) | ||
| 666 | 597 | ||
| 667 | (defun ,func () | 598 | (defun ,func () |
| 668 | ,(concat "Perform idle activity for the minor mode `" | 599 | ,(concat "Perform idle activity for the minor mode `" |
| @@ -814,21 +745,6 @@ When this minor mode is enabled, the echo area displays a summary | |||
| 814 | of the lexical token at point whenever Emacs is idle." | 745 | of the lexical token at point whenever Emacs is idle." |
| 815 | :group 'semantic | 746 | :group 'semantic |
| 816 | :group 'semantic-modes | 747 | :group 'semantic-modes |
| 817 | (semantic-idle-summary-mode-setup) | ||
| 818 | (semantic-mode-line-update)) | ||
| 819 | |||
| 820 | (defun semantic-idle-summary-refresh-echo-area () | ||
| 821 | (and semantic-idle-summary-mode | ||
| 822 | eldoc-last-message | ||
| 823 | (if (and (not executing-kbd-macro) | ||
| 824 | (not (and (boundp 'edebug-active) edebug-active)) | ||
| 825 | (not cursor-in-echo-area) | ||
| 826 | (not (eq (selected-window) (minibuffer-window)))) | ||
| 827 | (eldoc-message eldoc-last-message) | ||
| 828 | (setq eldoc-last-message nil)))) | ||
| 829 | |||
| 830 | (defun semantic-idle-summary-mode-setup () | ||
| 831 | "Set up `semantic-idle-summary-mode'." | ||
| 832 | (if semantic-idle-summary-mode | 748 | (if semantic-idle-summary-mode |
| 833 | ;; Enable the mode | 749 | ;; Enable the mode |
| 834 | (progn | 750 | (progn |
| @@ -843,7 +759,17 @@ of the lexical token at point whenever Emacs is idle." | |||
| 843 | ;; Disable the mode | 759 | ;; Disable the mode |
| 844 | (semantic-idle-scheduler-remove 'semantic-idle-summary-idle-function) | 760 | (semantic-idle-scheduler-remove 'semantic-idle-summary-idle-function) |
| 845 | (remove-hook 'pre-command-hook 'semantic-idle-summary-refresh-echo-area t)) | 761 | (remove-hook 'pre-command-hook 'semantic-idle-summary-refresh-echo-area t)) |
| 846 | semantic-idle-summary-mode) | 762 | (semantic-mode-line-update)) |
| 763 | |||
| 764 | (defun semantic-idle-summary-refresh-echo-area () | ||
| 765 | (and semantic-idle-summary-mode | ||
| 766 | eldoc-last-message | ||
| 767 | (if (and (not executing-kbd-macro) | ||
| 768 | (not (and (boundp 'edebug-active) edebug-active)) | ||
| 769 | (not cursor-in-echo-area) | ||
| 770 | (not (eq (selected-window) (minibuffer-window)))) | ||
| 771 | (eldoc-message eldoc-last-message) | ||
| 772 | (setq eldoc-last-message nil)))) | ||
| 847 | 773 | ||
| 848 | (semantic-add-minor-mode 'semantic-idle-summary-mode "") | 774 | (semantic-add-minor-mode 'semantic-idle-summary-mode "") |
| 849 | 775 | ||
| @@ -957,22 +883,22 @@ Call `semantic-symref-hits-in-region' to identify local references." | |||
| 957 | 883 | ||
| 958 | 884 | ||
| 959 | ;;;###autoload | 885 | ;;;###autoload |
| 960 | (defun global-semantic-idle-scheduler-mode (&optional arg) | 886 | (define-minor-mode global-semantic-idle-scheduler-mode |
| 961 | "Toggle global use of option `semantic-idle-scheduler-mode'. | 887 | "Toggle global use of option `semantic-idle-scheduler-mode'. |
| 962 | The idle scheduler will automatically reparse buffers in idle time, | 888 | The idle scheduler will automatically reparse buffers in idle time, |
| 963 | and then schedule other jobs setup with `semantic-idle-scheduler-add'. | 889 | and then schedule other jobs setup with `semantic-idle-scheduler-add'. |
| 964 | If ARG is positive, enable, if it is negative, disable. | 890 | If ARG is positive or nil, enable, if it is negative, disable." |
| 965 | If ARG is nil, then toggle." | 891 | :global t |
| 966 | (interactive "P") | 892 | :group 'semantic |
| 893 | :group 'semantic-modes | ||
| 967 | ;; When turning off, disable other idle modes. | 894 | ;; When turning off, disable other idle modes. |
| 968 | (when (or (and (numberp arg) (< arg 0)) | 895 | (when (null global-semantic-idle-scheduler-mode) |
| 969 | (and (null arg) global-semantic-idle-scheduler-mode)) | ||
| 970 | (global-semantic-idle-summary-mode -1) | 896 | (global-semantic-idle-summary-mode -1) |
| 971 | (global-semantic-idle-tag-highlight-mode -1) | 897 | (global-semantic-idle-tag-highlight-mode -1) |
| 972 | (global-semantic-idle-completions-mode -1)) | 898 | (global-semantic-idle-completions-mode -1)) |
| 973 | (setq global-semantic-idle-scheduler-mode | 899 | (semantic-toggle-minor-mode-globally |
| 974 | (semantic-toggle-minor-mode-globally | 900 | 'semantic-idle-scheduler-mode |
| 975 | 'semantic-idle-scheduler-mode arg))) | 901 | (if global-semantic-idle-scheduler-mode 1 -1))) |
| 976 | 902 | ||
| 977 | 903 | ||
| 978 | ;;; Completion Popup Mode | 904 | ;;; Completion Popup Mode |
diff --git a/lisp/cedet/semantic/mru-bookmark.el b/lisp/cedet/semantic/mru-bookmark.el index 1982f81cbad..b69d2f69a01 100644 --- a/lisp/cedet/semantic/mru-bookmark.el +++ b/lisp/cedet/semantic/mru-bookmark.el | |||
| @@ -239,27 +239,15 @@ This function pushes tags onto the tag ring." | |||
| 239 | ;; | 239 | ;; |
| 240 | ;; Tracking minor mode. | 240 | ;; Tracking minor mode. |
| 241 | 241 | ||
| 242 | (defcustom global-semantic-mru-bookmark-mode nil | ||
| 243 | "If non-nil, enable `semantic-mru-bookmark-mode' globally. | ||
| 244 | When this mode is enabled, Emacs keeps track of which tags have | ||
| 245 | been edited, and you can re-visit them with \\[semantic-mrub-switch-tags]." | ||
| 246 | :group 'semantic | ||
| 247 | :group 'semantic-modes | ||
| 248 | :type 'boolean | ||
| 249 | :require 'semantic-util-modes | ||
| 250 | :initialize 'custom-initialize-default | ||
| 251 | :set (lambda (sym val) | ||
| 252 | (global-semantic-mru-bookmark-mode (if val 1 -1)))) | ||
| 253 | |||
| 254 | ;;;###autoload | 242 | ;;;###autoload |
| 255 | (defun global-semantic-mru-bookmark-mode (&optional arg) | 243 | (define-minor-mode global-semantic-mru-bookmark-mode |
| 256 | "Toggle global use of option `semantic-mru-bookmark-mode'. | 244 | "Toggle global use of option `semantic-mru-bookmark-mode'. |
| 257 | If ARG is positive, enable, if it is negative, disable. | 245 | If ARG is positive or nil, enable, if it is negative, disable." |
| 258 | If ARG is nil, then toggle." | 246 | :global t :group 'semantic :group 'semantic-modes |
| 259 | (interactive "P") | 247 | ;; Not needed because it's autoloaded instead. |
| 260 | (setq global-semantic-mru-bookmark-mode | 248 | ;; :require 'semantic-util-modes |
| 261 | (semantic-toggle-minor-mode-globally | 249 | (semantic-toggle-minor-mode-globally |
| 262 | 'semantic-mru-bookmark-mode arg))) | 250 | 'semantic-mru-bookmark-mode (if global-semantic-mru-bookmark-mode 1 -1))) |
| 263 | 251 | ||
| 264 | (defcustom semantic-mru-bookmark-mode-hook nil | 252 | (defcustom semantic-mru-bookmark-mode-hook nil |
| 265 | "*Hook run at the end of function `semantic-mru-bookmark-mode'." | 253 | "*Hook run at the end of function `semantic-mru-bookmark-mode'." |
| @@ -272,17 +260,18 @@ If ARG is nil, then toggle." | |||
| 272 | km) | 260 | km) |
| 273 | "Keymap for mru-bookmark minor mode.") | 261 | "Keymap for mru-bookmark minor mode.") |
| 274 | 262 | ||
| 275 | (defvar semantic-mru-bookmark-mode nil | 263 | (define-minor-mode semantic-mru-bookmark-mode |
| 276 | "Non-nil if mru-bookmark minor mode is enabled. | 264 | "Minor mode for tracking tag-based bookmarks automatically. |
| 277 | Use the command `semantic-mru-bookmark-mode' to change this variable.") | 265 | When this mode is enabled, Emacs keeps track of which tags have |
| 278 | (make-variable-buffer-local 'semantic-mru-bookmark-mode) | 266 | been edited, and you can re-visit them with \\[semantic-mrub-switch-tags]. |
| 267 | |||
| 268 | \\{semantic-mru-bookmark-mode-map} | ||
| 279 | 269 | ||
| 280 | (defun semantic-mru-bookmark-mode-setup () | 270 | With prefix argument ARG, turn on if positive, otherwise off. The |
| 281 | "Setup option `semantic-mru-bookmark-mode'. | 271 | minor mode can be turned on only if semantic feature is available and |
| 282 | The minor mode can be turned on only if semantic feature is available | 272 | the current buffer was set up for parsing. Return non-nil if the |
| 283 | and the current buffer was set up for parsing. When minor mode is | ||
| 284 | enabled parse the current buffer if needed. Return non-nil if the | ||
| 285 | minor mode is enabled." | 273 | minor mode is enabled." |
| 274 | :keymap semantic-mru-bookmark-mode-map | ||
| 286 | (if semantic-mru-bookmark-mode | 275 | (if semantic-mru-bookmark-mode |
| 287 | (if (not (and (featurep 'semantic) (semantic-active-p))) | 276 | (if (not (and (featurep 'semantic) (semantic-active-p))) |
| 288 | (progn | 277 | (progn |
| @@ -294,47 +283,16 @@ minor mode is enabled." | |||
| 294 | (add-hook 'semantic-edits-new-change-hooks | 283 | (add-hook 'semantic-edits-new-change-hooks |
| 295 | 'semantic-mru-bookmark-change-hook-fcn nil t) | 284 | 'semantic-mru-bookmark-change-hook-fcn nil t) |
| 296 | (add-hook 'semantic-edits-move-change-hooks | 285 | (add-hook 'semantic-edits-move-change-hooks |
| 297 | 'semantic-mru-bookmark-change-hook-fcn nil t) | 286 | 'semantic-mru-bookmark-change-hook-fcn nil t)) |
| 298 | ) | ||
| 299 | ;; Remove hooks | 287 | ;; Remove hooks |
| 300 | (remove-hook 'semantic-edits-new-change-hooks | 288 | (remove-hook 'semantic-edits-new-change-hooks |
| 301 | 'semantic-mru-bookmark-change-hook-fcn t) | 289 | 'semantic-mru-bookmark-change-hook-fcn t) |
| 302 | (remove-hook 'semantic-edits-move-change-hooks | 290 | (remove-hook 'semantic-edits-move-change-hooks |
| 303 | 'semantic-mru-bookmark-change-hook-fcn t) | 291 | 'semantic-mru-bookmark-change-hook-fcn t)) |
| 304 | ) | 292 | (semantic-mode-line-update)) |
| 305 | semantic-mru-bookmark-mode) | ||
| 306 | |||
| 307 | (defun semantic-mru-bookmark-mode (&optional arg) | ||
| 308 | "Minor mode for tracking tag-based bookmarks automatically. | ||
| 309 | When this mode is enabled, Emacs keeps track of which tags have | ||
| 310 | been edited, and you can re-visit them with \\[semantic-mrub-switch-tags]. | ||
| 311 | |||
| 312 | \\{semantic-mru-bookmark-mode-map} | ||
| 313 | |||
| 314 | With prefix argument ARG, turn on if positive, otherwise off. The | ||
| 315 | minor mode can be turned on only if semantic feature is available and | ||
| 316 | the current buffer was set up for parsing. Return non-nil if the | ||
| 317 | minor mode is enabled." | ||
| 318 | (interactive | ||
| 319 | (list (or current-prefix-arg | ||
| 320 | (if semantic-mru-bookmark-mode 0 1)))) | ||
| 321 | (setq semantic-mru-bookmark-mode | ||
| 322 | (if arg | ||
| 323 | (> | ||
| 324 | (prefix-numeric-value arg) | ||
| 325 | 0) | ||
| 326 | (not semantic-mru-bookmark-mode))) | ||
| 327 | (semantic-mru-bookmark-mode-setup) | ||
| 328 | (run-hooks 'semantic-mru-bookmark-mode-hook) | ||
| 329 | (if (called-interactively-p 'interactive) | ||
| 330 | (message "mru-bookmark minor mode %sabled" | ||
| 331 | (if semantic-mru-bookmark-mode "en" "dis"))) | ||
| 332 | (semantic-mode-line-update) | ||
| 333 | semantic-mru-bookmark-mode) | ||
| 334 | 293 | ||
| 335 | (semantic-add-minor-mode 'semantic-mru-bookmark-mode | 294 | (semantic-add-minor-mode 'semantic-mru-bookmark-mode |
| 336 | "k" | 295 | "k") |
| 337 | semantic-mru-bookmark-mode-map) | ||
| 338 | 296 | ||
| 339 | ;;; COMPLETING READ | 297 | ;;; COMPLETING READ |
| 340 | ;; | 298 | ;; |
diff --git a/lisp/cedet/semantic/util-modes.el b/lisp/cedet/semantic/util-modes.el index 7e3a615d0b1..85d02df2638 100644 --- a/lisp/cedet/semantic/util-modes.el +++ b/lisp/cedet/semantic/util-modes.el | |||
| @@ -112,7 +112,7 @@ Only minor modes that are locally enabled are shown in the mode line." | |||
| 112 | BUFFER is the buffer to not initialize a Semantic minor mode in." | 112 | BUFFER is the buffer to not initialize a Semantic minor mode in." |
| 113 | nil) | 113 | nil) |
| 114 | 114 | ||
| 115 | (defun semantic-add-minor-mode (toggle name &optional keymap) | 115 | (defun semantic-add-minor-mode (toggle name) |
| 116 | "Register a new Semantic minor mode. | 116 | "Register a new Semantic minor mode. |
| 117 | TOGGLE is a symbol which is the name of a buffer-local variable that | 117 | TOGGLE is a symbol which is the name of a buffer-local variable that |
| 118 | is toggled on or off to say whether the minor mode is active or not. | 118 | is toggled on or off to say whether the minor mode is active or not. |
| @@ -120,25 +120,12 @@ It is also an interactive function to toggle the mode. | |||
| 120 | 120 | ||
| 121 | NAME specifies what will appear in the mode line when the minor mode | 121 | NAME specifies what will appear in the mode line when the minor mode |
| 122 | is active. NAME should be either a string starting with a space, or a | 122 | is active. NAME should be either a string starting with a space, or a |
| 123 | symbol whose value is such a string. | 123 | symbol whose value is such a string." |
| 124 | |||
| 125 | Optional KEYMAP is the keymap for the minor mode that will be added to | ||
| 126 | `minor-mode-map-alist'." | ||
| 127 | ;; Add a dymmy semantic minor mode to display the status | 124 | ;; Add a dymmy semantic minor mode to display the status |
| 128 | (or (assq 'semantic-minor-modes-status minor-mode-alist) | 125 | (or (assq 'semantic-minor-modes-status minor-mode-alist) |
| 129 | (setq minor-mode-alist (cons (list 'semantic-minor-modes-status | 126 | (setq minor-mode-alist (cons (list 'semantic-minor-modes-status |
| 130 | 'semantic-minor-modes-status) | 127 | 'semantic-minor-modes-status) |
| 131 | minor-mode-alist))) | 128 | minor-mode-alist))) |
| 132 | (if (fboundp 'add-minor-mode) | ||
| 133 | ;; Emacs 21 & XEmacs | ||
| 134 | (add-minor-mode toggle "" keymap) | ||
| 135 | ;; Emacs 20 | ||
| 136 | (or (assq toggle minor-mode-alist) | ||
| 137 | (setq minor-mode-alist (cons (list toggle "") minor-mode-alist))) | ||
| 138 | (or (not keymap) | ||
| 139 | (assq toggle minor-mode-map-alist) | ||
| 140 | (setq minor-mode-map-alist (cons (cons toggle keymap) | ||
| 141 | minor-mode-map-alist)))) | ||
| 142 | ;; Record how to display this minor mode in the mode line | 129 | ;; Record how to display this minor mode in the mode line |
| 143 | (let ((mm (assq toggle semantic-minor-mode-alist))) | 130 | (let ((mm (assq toggle semantic-minor-mode-alist))) |
| 144 | (if mm | 131 | (if mm |
| @@ -157,61 +144,36 @@ Optional KEYMAP is the keymap for the minor mode that will be added to | |||
| 157 | (defun semantic-toggle-minor-mode-globally (mode &optional arg) | 144 | (defun semantic-toggle-minor-mode-globally (mode &optional arg) |
| 158 | "Toggle minor mode MODE in every Semantic enabled buffer. | 145 | "Toggle minor mode MODE in every Semantic enabled buffer. |
| 159 | Return non-nil if MODE is turned on in every Semantic enabled buffer. | 146 | Return non-nil if MODE is turned on in every Semantic enabled buffer. |
| 160 | If ARG is positive, enable, if it is negative, disable. If ARG is | 147 | If ARG is positive, enable, if it is negative, disable. |
| 161 | nil, then toggle. Otherwise do nothing. MODE must be a valid minor | 148 | MODE must be a valid minor mode defined in `minor-mode-alist' and must be |
| 162 | mode defined in `minor-mode-alist' and must be too an interactive | 149 | too an interactive function used to toggle the mode." |
| 163 | function used to toggle the mode." | 150 | ;; FIXME: All callers should pass a -1 or +1 argument. |
| 164 | (or (and (fboundp mode) (assq mode minor-mode-alist)) | 151 | (or (and (fboundp mode) (assq mode minor-mode-alist)) |
| 165 | (error "Semantic minor mode %s not found" mode)) | 152 | (error "Semantic minor mode %s not found" mode)) |
| 166 | (if (not arg) | 153 | ;; Add or remove the MODE toggle function from `semantic-init-hook'. |
| 167 | (if (memq mode semantic-init-hook) | ||
| 168 | (setq arg -1) | ||
| 169 | (setq arg 1))) | ||
| 170 | ;; Add or remove the MODE toggle function from | ||
| 171 | ;; `semantic-init-hook'. Then turn MODE on or off in every | ||
| 172 | ;; Semantic enabled buffer. | ||
| 173 | (cond | 154 | (cond |
| 174 | ;; Turn off if ARG < 0 | 155 | ;; Turn off if ARG < 0 |
| 175 | ((< arg 0) | 156 | ((< arg 0) (remove-hook 'semantic-init-hook mode)) |
| 176 | (remove-hook 'semantic-init-hook mode) | ||
| 177 | (semantic-map-buffers #'(lambda () (funcall mode -1))) | ||
| 178 | nil) | ||
| 179 | ;; Turn on if ARG > 0 | 157 | ;; Turn on if ARG > 0 |
| 180 | ((> arg 0) | 158 | ((> arg 0) (add-hook 'semantic-init-hook mode)) |
| 181 | (add-hook 'semantic-init-hook mode) | ||
| 182 | (semantic-map-buffers #'(lambda () (funcall mode 1))) | ||
| 183 | t) | ||
| 184 | ;; Otherwise just check MODE state | 159 | ;; Otherwise just check MODE state |
| 185 | (t | 160 | (t |
| 186 | (memq mode semantic-init-hook)) | 161 | (error "semantic-toggle-minor-mode-globally: arg should be -1 or 1"))) |
| 187 | )) | 162 | ;; Then turn MODE on or off in every Semantic enabled buffer. |
| 163 | (semantic-map-buffers #'(lambda () (funcall mode arg)))) | ||
| 188 | 164 | ||
| 189 | ;;;; | 165 | ;;;; |
| 190 | ;;;; Minor mode to highlight areas that a user edits. | 166 | ;;;; Minor mode to highlight areas that a user edits. |
| 191 | ;;;; | 167 | ;;;; |
| 192 | 168 | ||
| 193 | ;;;###autoload | 169 | ;;;###autoload |
| 194 | (defun global-semantic-highlight-edits-mode (&optional arg) | 170 | (define-minor-mode global-semantic-highlight-edits-mode |
| 195 | "Toggle global use of option `semantic-highlight-edits-mode'. | 171 | "Toggle global use of option `semantic-highlight-edits-mode'. |
| 196 | If ARG is positive, enable, if it is negative, disable. | 172 | If ARG is positive or nil, enable, if it is negative, disable." |
| 197 | If ARG is nil, then toggle." | 173 | :global t :group 'semantic :group 'semantic-modes |
| 198 | (interactive "P") | 174 | (semantic-toggle-minor-mode-globally |
| 199 | (setq global-semantic-highlight-edits-mode | 175 | 'semantic-highlight-edits-mode |
| 200 | (semantic-toggle-minor-mode-globally | 176 | (if global-semantic-highlight-edits-mode 1 -1))) |
| 201 | 'semantic-highlight-edits-mode arg))) | ||
| 202 | |||
| 203 | ;;;###autoload | ||
| 204 | (defcustom global-semantic-highlight-edits-mode nil | ||
| 205 | "If non-nil enable global use of variable `semantic-highlight-edits-mode'. | ||
| 206 | When this mode is enabled, changes made to a buffer are highlighted | ||
| 207 | until the buffer is reparsed." | ||
| 208 | :group 'semantic | ||
| 209 | :group 'semantic-modes | ||
| 210 | :type 'boolean | ||
| 211 | :require 'semantic/util-modes | ||
| 212 | :initialize 'custom-initialize-default | ||
| 213 | :set (lambda (sym val) | ||
| 214 | (global-semantic-highlight-edits-mode (if val 1 -1)))) | ||
| 215 | 177 | ||
| 216 | (defcustom semantic-highlight-edits-mode-hook nil | 178 | (defcustom semantic-highlight-edits-mode-hook nil |
| 217 | "Hook run at the end of function `semantic-highlight-edits-mode'." | 179 | "Hook run at the end of function `semantic-highlight-edits-mode'." |
| @@ -238,17 +200,18 @@ This function will set the face property on this overlay." | |||
| 238 | km) | 200 | km) |
| 239 | "Keymap for highlight-edits minor mode.") | 201 | "Keymap for highlight-edits minor mode.") |
| 240 | 202 | ||
| 241 | (defvar semantic-highlight-edits-mode nil | 203 | ;;;###autoload |
| 242 | "Non-nil if highlight-edits minor mode is enabled. | 204 | (define-minor-mode semantic-highlight-edits-mode |
| 243 | Use the command `semantic-highlight-edits-mode' to change this variable.") | 205 | "Minor mode for highlighting changes made in a buffer. |
| 244 | (make-variable-buffer-local 'semantic-highlight-edits-mode) | 206 | Changes are tracked by semantic so that the incremental parser can work |
| 245 | 207 | properly. | |
| 246 | (defun semantic-highlight-edits-mode-setup () | 208 | This mode will highlight those changes as they are made, and clear them |
| 247 | "Setup option `semantic-highlight-edits-mode'. | 209 | when the incremental parser accounts for those edits. |
| 248 | The minor mode can be turned on only if semantic feature is available | 210 | With prefix argument ARG, turn on if positive, otherwise off. The |
| 249 | and the current buffer was set up for parsing. When minor mode is | 211 | minor mode can be turned on only if semantic feature is available and |
| 250 | enabled parse the current buffer if needed. Return non-nil if the | 212 | the current buffer was set up for parsing. Return non-nil if the |
| 251 | minor mode is enabled." | 213 | minor mode is enabled." |
| 214 | :keymap semantic-highlight-edits-mode-map | ||
| 252 | (if semantic-highlight-edits-mode | 215 | (if semantic-highlight-edits-mode |
| 253 | (if (not (and (featurep 'semantic) (semantic-active-p))) | 216 | (if (not (and (featurep 'semantic) (semantic-active-p))) |
| 254 | (progn | 217 | (progn |
| @@ -258,73 +221,29 @@ minor mode is enabled." | |||
| 258 | (buffer-name))) | 221 | (buffer-name))) |
| 259 | (semantic-make-local-hook 'semantic-edits-new-change-hooks) | 222 | (semantic-make-local-hook 'semantic-edits-new-change-hooks) |
| 260 | (add-hook 'semantic-edits-new-change-hooks | 223 | (add-hook 'semantic-edits-new-change-hooks |
| 261 | 'semantic-highlight-edits-new-change-hook-fcn nil t) | 224 | 'semantic-highlight-edits-new-change-hook-fcn nil t)) |
| 262 | ) | ||
| 263 | ;; Remove hooks | 225 | ;; Remove hooks |
| 264 | (remove-hook 'semantic-edits-new-change-hooks | 226 | (remove-hook 'semantic-edits-new-change-hooks |
| 265 | 'semantic-highlight-edits-new-change-hook-fcn t) | 227 | 'semantic-highlight-edits-new-change-hook-fcn t)) |
| 266 | ) | 228 | (semantic-mode-line-update)) |
| 267 | semantic-highlight-edits-mode) | ||
| 268 | |||
| 269 | ;;;###autoload | ||
| 270 | (defun semantic-highlight-edits-mode (&optional arg) | ||
| 271 | "Minor mode for highlighting changes made in a buffer. | ||
| 272 | Changes are tracked by semantic so that the incremental parser can work | ||
| 273 | properly. | ||
| 274 | This mode will highlight those changes as they are made, and clear them | ||
| 275 | when the incremental parser accounts for those edits. | ||
| 276 | With prefix argument ARG, turn on if positive, otherwise off. The | ||
| 277 | minor mode can be turned on only if semantic feature is available and | ||
| 278 | the current buffer was set up for parsing. Return non-nil if the | ||
| 279 | minor mode is enabled." | ||
| 280 | (interactive | ||
| 281 | (list (or current-prefix-arg | ||
| 282 | (if semantic-highlight-edits-mode 0 1)))) | ||
| 283 | (setq semantic-highlight-edits-mode | ||
| 284 | (if arg | ||
| 285 | (> | ||
| 286 | (prefix-numeric-value arg) | ||
| 287 | 0) | ||
| 288 | (not semantic-highlight-edits-mode))) | ||
| 289 | (semantic-highlight-edits-mode-setup) | ||
| 290 | (run-hooks 'semantic-highlight-edits-mode-hook) | ||
| 291 | (if (called-interactively-p 'interactive) | ||
| 292 | (message "highlight-edits minor mode %sabled" | ||
| 293 | (if semantic-highlight-edits-mode "en" "dis"))) | ||
| 294 | (semantic-mode-line-update) | ||
| 295 | semantic-highlight-edits-mode) | ||
| 296 | 229 | ||
| 297 | (semantic-add-minor-mode 'semantic-highlight-edits-mode | 230 | (semantic-add-minor-mode 'semantic-highlight-edits-mode |
| 298 | "e" | 231 | "e") |
| 299 | semantic-highlight-edits-mode-map) | ||
| 300 | |||
| 301 | 232 | ||
| 302 | ;;;; | 233 | ;;;; |
| 303 | ;;;; Minor mode to show unmatched-syntax elements | 234 | ;;;; Minor mode to show unmatched-syntax elements |
| 304 | ;;;; | 235 | ;;;; |
| 305 | 236 | ||
| 306 | ;;;###autoload | 237 | ;;;###autoload |
| 307 | (defun global-semantic-show-unmatched-syntax-mode (&optional arg) | 238 | (define-minor-mode global-semantic-show-unmatched-syntax-mode |
| 308 | "Toggle global use of option `semantic-show-unmatched-syntax-mode'. | 239 | "Toggle global use of option `semantic-show-unmatched-syntax-mode'. |
| 309 | If ARG is positive, enable, if it is negative, disable. | 240 | If ARG is positive or nil, enable, if it is negative, disable." |
| 310 | If ARG is nil, then toggle." | 241 | :global t :group 'semantic :group 'semantic-modes |
| 311 | (interactive "P") | 242 | ;; Not needed because it's autoloaded instead. |
| 312 | (setq global-semantic-show-unmatched-syntax-mode | 243 | ;; :require 'semantic/util-modes |
| 313 | (semantic-toggle-minor-mode-globally | 244 | (semantic-toggle-minor-mode-globally |
| 314 | 'semantic-show-unmatched-syntax-mode arg))) | 245 | 'semantic-show-unmatched-syntax-mode |
| 315 | 246 | (if global-semantic-show-unmatched-syntax-mode 1 -1))) | |
| 316 | ;;;###autoload | ||
| 317 | (defcustom global-semantic-show-unmatched-syntax-mode nil | ||
| 318 | "If non-nil, enable global use of `semantic-show-unmatched-syntax-mode'. | ||
| 319 | When this mode is enabled, syntax in the current buffer which the | ||
| 320 | semantic parser cannot match is highlighted with a red underline." | ||
| 321 | :group 'semantic | ||
| 322 | :group 'semantic-modes | ||
| 323 | :type 'boolean | ||
| 324 | :require 'semantic/util-modes | ||
| 325 | :initialize 'custom-initialize-default | ||
| 326 | :set (lambda (sym val) | ||
| 327 | (global-semantic-show-unmatched-syntax-mode (if val 1 -1)))) | ||
| 328 | 247 | ||
| 329 | (defcustom semantic-show-unmatched-syntax-mode-hook nil | 248 | (defcustom semantic-show-unmatched-syntax-mode-hook nil |
| 330 | "Hook run at the end of function `semantic-show-unmatched-syntax-mode'." | 249 | "Hook run at the end of function `semantic-show-unmatched-syntax-mode'." |
| @@ -432,18 +351,21 @@ Do not search past BOUND if non-nil." | |||
| 432 | km) | 351 | km) |
| 433 | "Keymap for command `semantic-show-unmatched-syntax-mode'.") | 352 | "Keymap for command `semantic-show-unmatched-syntax-mode'.") |
| 434 | 353 | ||
| 435 | (defvar semantic-show-unmatched-syntax-mode nil | 354 | ;;;###autoload |
| 436 | "Non-nil if show-unmatched-syntax minor mode is enabled. | 355 | (define-minor-mode semantic-show-unmatched-syntax-mode |
| 437 | Use the command `semantic-show-unmatched-syntax-mode' to change this | 356 | "Minor mode to highlight unmatched lexical syntax tokens. |
| 438 | variable.") | 357 | When a parser executes, some elements in the buffer may not match any |
| 439 | (make-variable-buffer-local 'semantic-show-unmatched-syntax-mode) | 358 | parser rules. These text characters are considered unmatched syntax. |
| 440 | 359 | Often time, the display of unmatched syntax can expose coding | |
| 441 | (defun semantic-show-unmatched-syntax-mode-setup () | 360 | problems before the compiler is run. |
| 442 | "Setup the `semantic-show-unmatched-syntax' minor mode. | 361 | |
| 443 | The minor mode can be turned on only if semantic feature is available | 362 | With prefix argument ARG, turn on if positive, otherwise off. The |
| 444 | and the current buffer was set up for parsing. When minor mode is | 363 | minor mode can be turned on only if semantic feature is available and |
| 445 | enabled parse the current buffer if needed. Return non-nil if the | 364 | the current buffer was set up for parsing. Return non-nil if the |
| 446 | minor mode is enabled." | 365 | minor mode is enabled. |
| 366 | |||
| 367 | \\{semantic-show-unmatched-syntax-mode-map}" | ||
| 368 | :keymap semantic-show-unmatched-syntax-mode-map | ||
| 447 | (if semantic-show-unmatched-syntax-mode | 369 | (if semantic-show-unmatched-syntax-mode |
| 448 | (if (not (and (featurep 'semantic) (semantic-active-p))) | 370 | (if (not (and (featurep 'semantic) (semantic-active-p))) |
| 449 | (progn | 371 | (progn |
| @@ -469,42 +391,10 @@ minor mode is enabled." | |||
| 469 | 'semantic-clean-token-of-unmatched-syntax t) | 391 | 'semantic-clean-token-of-unmatched-syntax t) |
| 470 | ;; Cleanup unmatched-syntax highlighting | 392 | ;; Cleanup unmatched-syntax highlighting |
| 471 | (semantic-clean-unmatched-syntax-in-buffer)) | 393 | (semantic-clean-unmatched-syntax-in-buffer)) |
| 472 | semantic-show-unmatched-syntax-mode) | 394 | (semantic-mode-line-update)) |
| 473 | |||
| 474 | ;;;###autoload | ||
| 475 | (defun semantic-show-unmatched-syntax-mode (&optional arg) | ||
| 476 | "Minor mode to highlight unmatched lexical syntax tokens. | ||
| 477 | When a parser executes, some elements in the buffer may not match any | ||
| 478 | parser rules. These text characters are considered unmatched syntax. | ||
| 479 | Often time, the display of unmatched syntax can expose coding | ||
| 480 | problems before the compiler is run. | ||
| 481 | |||
| 482 | With prefix argument ARG, turn on if positive, otherwise off. The | ||
| 483 | minor mode can be turned on only if semantic feature is available and | ||
| 484 | the current buffer was set up for parsing. Return non-nil if the | ||
| 485 | minor mode is enabled. | ||
| 486 | |||
| 487 | \\{semantic-show-unmatched-syntax-mode-map}" | ||
| 488 | (interactive | ||
| 489 | (list (or current-prefix-arg | ||
| 490 | (if semantic-show-unmatched-syntax-mode 0 1)))) | ||
| 491 | (setq semantic-show-unmatched-syntax-mode | ||
| 492 | (if arg | ||
| 493 | (> | ||
| 494 | (prefix-numeric-value arg) | ||
| 495 | 0) | ||
| 496 | (not semantic-show-unmatched-syntax-mode))) | ||
| 497 | (semantic-show-unmatched-syntax-mode-setup) | ||
| 498 | (run-hooks 'semantic-show-unmatched-syntax-mode-hook) | ||
| 499 | (if (called-interactively-p 'interactive) | ||
| 500 | (message "show-unmatched-syntax minor mode %sabled" | ||
| 501 | (if semantic-show-unmatched-syntax-mode "en" "dis"))) | ||
| 502 | (semantic-mode-line-update) | ||
| 503 | semantic-show-unmatched-syntax-mode) | ||
| 504 | 395 | ||
| 505 | (semantic-add-minor-mode 'semantic-show-unmatched-syntax-mode | 396 | (semantic-add-minor-mode 'semantic-show-unmatched-syntax-mode |
| 506 | "u" | 397 | "u") |
| 507 | semantic-show-unmatched-syntax-mode-map) | ||
| 508 | 398 | ||
| 509 | (defun semantic-show-unmatched-syntax-next () | 399 | (defun semantic-show-unmatched-syntax-next () |
| 510 | "Move forward to the next occurrence of unmatched syntax." | 400 | "Move forward to the next occurrence of unmatched syntax." |
| @@ -519,27 +409,15 @@ minor mode is enabled. | |||
| 519 | ;;;; | 409 | ;;;; |
| 520 | 410 | ||
| 521 | ;;;###autoload | 411 | ;;;###autoload |
| 522 | (defcustom global-semantic-show-parser-state-mode nil | 412 | (define-minor-mode global-semantic-show-parser-state-mode |
| 523 | "If non-nil enable global use of `semantic-show-parser-state-mode'. | ||
| 524 | When enabled, the current parse state of the current buffer is displayed | ||
| 525 | in the mode line. See `semantic-show-parser-state-marker' for details | ||
| 526 | on what is displayed." | ||
| 527 | :group 'semantic | ||
| 528 | :type 'boolean | ||
| 529 | :require 'semantic/util-modes | ||
| 530 | :initialize 'custom-initialize-default | ||
| 531 | :set (lambda (sym val) | ||
| 532 | (global-semantic-show-parser-state-mode (if val 1 -1)))) | ||
| 533 | |||
| 534 | ;;;###autoload | ||
| 535 | (defun global-semantic-show-parser-state-mode (&optional arg) | ||
| 536 | "Toggle global use of option `semantic-show-parser-state-mode'. | 413 | "Toggle global use of option `semantic-show-parser-state-mode'. |
| 537 | If ARG is positive, enable, if it is negative, disable. | 414 | If ARG is positive or nil, enable, if it is negative, disable." |
| 538 | If ARG is nil, then toggle." | 415 | :global t :group 'semantic |
| 539 | (interactive "P") | 416 | ;; Not needed because it's autoloaded instead. |
| 540 | (setq global-semantic-show-parser-state-mode | 417 | ;; :require 'semantic/util-modes |
| 541 | (semantic-toggle-minor-mode-globally | 418 | (semantic-toggle-minor-mode-globally |
| 542 | 'semantic-show-parser-state-mode arg))) | 419 | 'semantic-show-parser-state-mode |
| 420 | (if global-semantic-show-parser-state-mode 1 -1))) | ||
| 543 | 421 | ||
| 544 | (defcustom semantic-show-parser-state-mode-hook nil | 422 | (defcustom semantic-show-parser-state-mode-hook nil |
| 545 | "Hook run at the end of function `semantic-show-parser-state-mode'." | 423 | "Hook run at the end of function `semantic-show-parser-state-mode'." |
| @@ -551,17 +429,22 @@ If ARG is nil, then toggle." | |||
| 551 | km) | 429 | km) |
| 552 | "Keymap for show-parser-state minor mode.") | 430 | "Keymap for show-parser-state minor mode.") |
| 553 | 431 | ||
| 554 | (defvar semantic-show-parser-state-mode nil | 432 | ;;;###autoload |
| 555 | "Non-nil if show-parser-state minor mode is enabled. | 433 | (define-minor-mode semantic-show-parser-state-mode |
| 556 | Use the command `semantic-show-parser-state-mode' to change this variable.") | 434 | "Minor mode for displaying parser cache state in the modeline. |
| 557 | (make-variable-buffer-local 'semantic-show-parser-state-mode) | 435 | The cache can be in one of three states. They are |
| 558 | 436 | Up to date, Partial reparse needed, and Full reparse needed. | |
| 559 | (defun semantic-show-parser-state-mode-setup () | 437 | The state is indicated in the modeline with the following characters: |
| 560 | "Setup option `semantic-show-parser-state-mode'. | 438 | `-' -> The cache is up to date. |
| 561 | The minor mode can be turned on only if semantic feature is available | 439 | `!' -> The cache requires a full update. |
| 562 | and the current buffer was set up for parsing. When minor mode is | 440 | `~' -> The cache needs to be incrementally parsed. |
| 563 | enabled parse the current buffer if needed. Return non-nil if the | 441 | `%' -> The cache is not currently parseable. |
| 442 | `@' -> Auto-parse in progress (not set here.) | ||
| 443 | With prefix argument ARG, turn on if positive, otherwise off. The | ||
| 444 | minor mode can be turned on only if semantic feature is available and | ||
| 445 | the current buffer was set up for parsing. Return non-nil if the | ||
| 564 | minor mode is enabled." | 446 | minor mode is enabled." |
| 447 | :keymap semantic-show-parser-state-mode-map | ||
| 565 | (if semantic-show-parser-state-mode | 448 | (if semantic-show-parser-state-mode |
| 566 | (if (not (and (featurep 'semantic) (semantic-active-p))) | 449 | (if (not (and (featurep 'semantic) (semantic-active-p))) |
| 567 | (progn | 450 | (progn |
| @@ -603,8 +486,7 @@ minor mode is enabled." | |||
| 603 | 'semantic-show-parser-state-auto-marker nil t) | 486 | 'semantic-show-parser-state-auto-marker nil t) |
| 604 | (semantic-make-local-hook 'semantic-after-idle-scheduler-reparse-hook) | 487 | (semantic-make-local-hook 'semantic-after-idle-scheduler-reparse-hook) |
| 605 | (add-hook 'semantic-after-idle-scheduler-reparse-hook | 488 | (add-hook 'semantic-after-idle-scheduler-reparse-hook |
| 606 | 'semantic-show-parser-state-marker nil t) | 489 | 'semantic-show-parser-state-marker nil t)) |
| 607 | ) | ||
| 608 | ;; Remove parts of mode line | 490 | ;; Remove parts of mode line |
| 609 | (setq mode-line-modified | 491 | (setq mode-line-modified |
| 610 | (delq 'semantic-show-parser-state-string mode-line-modified)) | 492 | (delq 'semantic-show-parser-state-string mode-line-modified)) |
| @@ -626,45 +508,11 @@ minor mode is enabled." | |||
| 626 | (remove-hook 'semantic-before-idle-scheduler-reparse-hook | 508 | (remove-hook 'semantic-before-idle-scheduler-reparse-hook |
| 627 | 'semantic-show-parser-state-auto-marker t) | 509 | 'semantic-show-parser-state-auto-marker t) |
| 628 | (remove-hook 'semantic-after-idle-scheduler-reparse-hook | 510 | (remove-hook 'semantic-after-idle-scheduler-reparse-hook |
| 629 | 'semantic-show-parser-state-marker t) | 511 | 'semantic-show-parser-state-marker t)) |
| 630 | ) | 512 | (semantic-mode-line-update)) |
| 631 | semantic-show-parser-state-mode) | ||
| 632 | |||
| 633 | ;;;###autoload | ||
| 634 | (defun semantic-show-parser-state-mode (&optional arg) | ||
| 635 | "Minor mode for displaying parser cache state in the modeline. | ||
| 636 | The cache can be in one of three states. They are | ||
| 637 | Up to date, Partial reparse needed, and Full reparse needed. | ||
| 638 | The state is indicated in the modeline with the following characters: | ||
| 639 | `-' -> The cache is up to date. | ||
| 640 | `!' -> The cache requires a full update. | ||
| 641 | `~' -> The cache needs to be incrementally parsed. | ||
| 642 | `%' -> The cache is not currently parseable. | ||
| 643 | `@' -> Auto-parse in progress (not set here.) | ||
| 644 | With prefix argument ARG, turn on if positive, otherwise off. The | ||
| 645 | minor mode can be turned on only if semantic feature is available and | ||
| 646 | the current buffer was set up for parsing. Return non-nil if the | ||
| 647 | minor mode is enabled." | ||
| 648 | (interactive | ||
| 649 | (list (or current-prefix-arg | ||
| 650 | (if semantic-show-parser-state-mode 0 1)))) | ||
| 651 | (setq semantic-show-parser-state-mode | ||
| 652 | (if arg | ||
| 653 | (> | ||
| 654 | (prefix-numeric-value arg) | ||
| 655 | 0) | ||
| 656 | (not semantic-show-parser-state-mode))) | ||
| 657 | (semantic-show-parser-state-mode-setup) | ||
| 658 | (run-hooks 'semantic-show-parser-state-mode-hook) | ||
| 659 | (if (called-interactively-p 'interactive) | ||
| 660 | (message "show-parser-state minor mode %sabled" | ||
| 661 | (if semantic-show-parser-state-mode "en" "dis"))) | ||
| 662 | (semantic-mode-line-update) | ||
| 663 | semantic-show-parser-state-mode) | ||
| 664 | 513 | ||
| 665 | (semantic-add-minor-mode 'semantic-show-parser-state-mode | 514 | (semantic-add-minor-mode 'semantic-show-parser-state-mode |
| 666 | "" | 515 | "") |
| 667 | semantic-show-parser-state-mode-map) | ||
| 668 | 516 | ||
| 669 | (defvar semantic-show-parser-state-string nil | 517 | (defvar semantic-show-parser-state-string nil |
| 670 | "String showing the parser state for this buffer. | 518 | "String showing the parser state for this buffer. |
| @@ -710,30 +558,14 @@ to indicate a parse in progress." | |||
| 710 | ;;;; | 558 | ;;;; |
| 711 | 559 | ||
| 712 | ;;;###autoload | 560 | ;;;###autoload |
| 713 | (defun global-semantic-stickyfunc-mode (&optional arg) | 561 | (define-minor-mode global-semantic-stickyfunc-mode |
| 714 | "Toggle global use of option `semantic-stickyfunc-mode'. | 562 | "Toggle global use of option `semantic-stickyfunc-mode'. |
| 715 | If ARG is positive, enable, if it is negative, disable. | 563 | If ARG is positive or nil, enable, if it is negative, disable." |
| 716 | If ARG is nil, then toggle." | 564 | :global t :group 'semantic :group 'semantic-modes |
| 717 | (interactive "P") | 565 | ;; Not needed because it's autoloaded instead. |
| 718 | (setq global-semantic-stickyfunc-mode | 566 | ;; :require 'semantic/util-modes |
| 719 | (semantic-toggle-minor-mode-globally | 567 | (semantic-toggle-minor-mode-globally |
| 720 | 'semantic-stickyfunc-mode arg))) | 568 | 'semantic-stickyfunc-mode (if global-semantic-stickyfunc-mode 1 -1))) |
| 721 | |||
| 722 | ;;;###autoload | ||
| 723 | (defcustom global-semantic-stickyfunc-mode nil | ||
| 724 | "If non-nil, enable global use of `semantic-stickyfunc-mode'. | ||
| 725 | This minor mode only works for Emacs 21 or later. | ||
| 726 | When enabled, the header line is enabled, and the first line | ||
| 727 | of the current function or method is displayed in it. | ||
| 728 | This makes it appear that the first line of that tag is | ||
| 729 | `sticky' to the top of the window." | ||
| 730 | :group 'semantic | ||
| 731 | :group 'semantic-modes | ||
| 732 | :type 'boolean | ||
| 733 | :require 'semantic/util-modes | ||
| 734 | :initialize 'custom-initialize-default | ||
| 735 | :set (lambda (sym val) | ||
| 736 | (global-semantic-stickyfunc-mode (if val 1 -1)))) | ||
| 737 | 569 | ||
| 738 | (defcustom semantic-stickyfunc-mode-hook nil | 570 | (defcustom semantic-stickyfunc-mode-hook nil |
| 739 | "Hook run at the end of function `semantic-stickyfunc-mode'." | 571 | "Hook run at the end of function `semantic-stickyfunc-mode'." |
| @@ -781,11 +613,6 @@ This makes it appear that the first line of that tag is | |||
| 781 | (describe-function 'semantic-stickyfunc-mode)) t]) | 613 | (describe-function 'semantic-stickyfunc-mode)) t]) |
| 782 | ) | 614 | ) |
| 783 | 615 | ||
| 784 | (defvar semantic-stickyfunc-mode nil | ||
| 785 | "Non-nil if stickyfunc minor mode is enabled. | ||
| 786 | Use the command `semantic-stickyfunc-mode' to change this variable.") | ||
| 787 | (make-variable-buffer-local 'semantic-stickyfunc-mode) | ||
| 788 | |||
| 789 | (defcustom semantic-stickyfunc-indent-string | 616 | (defcustom semantic-stickyfunc-indent-string |
| 790 | (if (and window-system (not (featurep 'xemacs))) | 617 | (if (and window-system (not (featurep 'xemacs))) |
| 791 | (concat | 618 | (concat |
| @@ -870,11 +697,21 @@ when it lands in the sticky line." | |||
| 870 | (t nil)) | 697 | (t nil)) |
| 871 | "The header line format used by stickyfunc mode.") | 698 | "The header line format used by stickyfunc mode.") |
| 872 | 699 | ||
| 873 | (defun semantic-stickyfunc-mode-setup () | 700 | ;;;###autoload |
| 874 | "Setup option `semantic-stickyfunc-mode'. | 701 | (define-minor-mode semantic-stickyfunc-mode |
| 875 | For semantic enabled buffers, make the function declaration for the top most | 702 | "Minor mode to show the title of a tag in the header line. |
| 876 | function \"sticky\". This is accomplished by putting the first line of | 703 | Enables/disables making the header line of functions sticky. |
| 877 | text for that function in the header line." | 704 | A function (or other tag class specified by |
| 705 | `semantic-stickyfunc-sticky-classes') has a header line, meaning the | ||
| 706 | first line which describes the rest of the construct. This first | ||
| 707 | line is what is displayed in the header line. | ||
| 708 | |||
| 709 | With prefix argument ARG, turn on if positive, otherwise off. The | ||
| 710 | minor mode can be turned on only if semantic feature is available and | ||
| 711 | the current buffer was set up for parsing. Return non-nil if the | ||
| 712 | minor mode is enabled." | ||
| 713 | ;; Don't need indicator. It's quite visible | ||
| 714 | :keymap semantic-stickyfunc-mode-map | ||
| 878 | (if semantic-stickyfunc-mode | 715 | (if semantic-stickyfunc-mode |
| 879 | (progn | 716 | (progn |
| 880 | (unless (and (featurep 'semantic) (semantic-active-p)) | 717 | (unless (and (featurep 'semantic) (semantic-active-p)) |
| @@ -892,8 +729,7 @@ text for that function in the header line." | |||
| 892 | semantic-stickyfunc-header-line-format))) | 729 | semantic-stickyfunc-header-line-format))) |
| 893 | (set (make-local-variable 'semantic-stickyfunc-old-hlf) | 730 | (set (make-local-variable 'semantic-stickyfunc-old-hlf) |
| 894 | header-line-format)) | 731 | header-line-format)) |
| 895 | (setq header-line-format semantic-stickyfunc-header-line-format) | 732 | (setq header-line-format semantic-stickyfunc-header-line-format)) |
| 896 | ) | ||
| 897 | ;; Disable sticky func mode | 733 | ;; Disable sticky func mode |
| 898 | ;; Restore previous buffer local value of header line format if | 734 | ;; Restore previous buffer local value of header line format if |
| 899 | ;; the current one is the sticky func one. | 735 | ;; the current one is the sticky func one. |
| @@ -902,37 +738,7 @@ text for that function in the header line." | |||
| 902 | (when (local-variable-p 'semantic-stickyfunc-old-hlf (current-buffer)) | 738 | (when (local-variable-p 'semantic-stickyfunc-old-hlf (current-buffer)) |
| 903 | (setq header-line-format semantic-stickyfunc-old-hlf) | 739 | (setq header-line-format semantic-stickyfunc-old-hlf) |
| 904 | (kill-local-variable 'semantic-stickyfunc-old-hlf)))) | 740 | (kill-local-variable 'semantic-stickyfunc-old-hlf)))) |
| 905 | semantic-stickyfunc-mode) | 741 | (semantic-mode-line-update)) |
| 906 | |||
| 907 | ;;;###autoload | ||
| 908 | (defun semantic-stickyfunc-mode (&optional arg) | ||
| 909 | "Minor mode to show the title of a tag in the header line. | ||
| 910 | Enables/disables making the header line of functions sticky. | ||
| 911 | A function (or other tag class specified by | ||
| 912 | `semantic-stickyfunc-sticky-classes') has a header line, meaning the | ||
| 913 | first line which describes the rest of the construct. This first | ||
| 914 | line is what is displayed in the header line. | ||
| 915 | |||
| 916 | With prefix argument ARG, turn on if positive, otherwise off. The | ||
| 917 | minor mode can be turned on only if semantic feature is available and | ||
| 918 | the current buffer was set up for parsing. Return non-nil if the | ||
| 919 | minor mode is enabled." | ||
| 920 | (interactive | ||
| 921 | (list (or current-prefix-arg | ||
| 922 | (if semantic-stickyfunc-mode 0 1)))) | ||
| 923 | (setq semantic-stickyfunc-mode | ||
| 924 | (if arg | ||
| 925 | (> | ||
| 926 | (prefix-numeric-value arg) | ||
| 927 | 0) | ||
| 928 | (not semantic-stickyfunc-mode))) | ||
| 929 | (semantic-stickyfunc-mode-setup) | ||
| 930 | (run-hooks 'semantic-stickyfunc-mode-hook) | ||
| 931 | (if (called-interactively-p 'interactive) | ||
| 932 | (message "Stickyfunc minor mode %sabled" | ||
| 933 | (if semantic-stickyfunc-mode "en" "dis"))) | ||
| 934 | (semantic-mode-line-update) | ||
| 935 | semantic-stickyfunc-mode) | ||
| 936 | 742 | ||
| 937 | (defvar semantic-stickyfunc-sticky-classes | 743 | (defvar semantic-stickyfunc-sticky-classes |
| 938 | '(function type) | 744 | '(function type) |
| @@ -1012,8 +818,7 @@ Argument EVENT describes the event that caused this function to be called." | |||
| 1012 | 818 | ||
| 1013 | 819 | ||
| 1014 | (semantic-add-minor-mode 'semantic-stickyfunc-mode | 820 | (semantic-add-minor-mode 'semantic-stickyfunc-mode |
| 1015 | "" ;; Don't need indicator. It's quite visible | 821 | "") ;; Don't need indicator. It's quite visible |
| 1016 | semantic-stickyfunc-mode-map) | ||
| 1017 | 822 | ||
| 1018 | 823 | ||
| 1019 | 824 | ||
| @@ -1025,26 +830,15 @@ Argument EVENT describes the event that caused this function to be called." | |||
| 1025 | ;; from the tag going off the top of the screen. | 830 | ;; from the tag going off the top of the screen. |
| 1026 | 831 | ||
| 1027 | ;;;###autoload | 832 | ;;;###autoload |
| 1028 | (defun global-semantic-highlight-func-mode (&optional arg) | 833 | (define-minor-mode global-semantic-highlight-func-mode |
| 1029 | "Toggle global use of option `semantic-highlight-func-mode'. | 834 | "Toggle global use of option `semantic-highlight-func-mode'. |
| 1030 | If ARG is positive, enable, if it is negative, disable. | 835 | If ARG is positive or nil, enable, if it is negative, disable." |
| 1031 | If ARG is nil, then toggle." | 836 | :global t :group 'semantic :group 'semantic-modes |
| 1032 | (interactive "P") | 837 | ;; Not needed because it's autoloaded instead. |
| 1033 | (setq global-semantic-highlight-func-mode | 838 | ;; :require 'semantic/util-modes |
| 1034 | (semantic-toggle-minor-mode-globally | 839 | (semantic-toggle-minor-mode-globally |
| 1035 | 'semantic-highlight-func-mode arg))) | 840 | 'semantic-highlight-func-mode |
| 1036 | 841 | (if global-semantic-highlight-func-mode 1 -1))) | |
| 1037 | ;;;###autoload | ||
| 1038 | (defcustom global-semantic-highlight-func-mode nil | ||
| 1039 | "If non-nil, enable global use of `semantic-highlight-func-mode'. | ||
| 1040 | When enabled, the first line of the current tag is highlighted." | ||
| 1041 | :group 'semantic | ||
| 1042 | :group 'semantic-modes | ||
| 1043 | :type 'boolean | ||
| 1044 | :require 'semantic/util-modes | ||
| 1045 | :initialize 'custom-initialize-default | ||
| 1046 | :set (lambda (sym val) | ||
| 1047 | (global-semantic-highlight-func-mode (if val 1 -1)))) | ||
| 1048 | 842 | ||
| 1049 | (defcustom semantic-highlight-func-mode-hook nil | 843 | (defcustom semantic-highlight-func-mode-hook nil |
| 1050 | "Hook run at the end of function `semantic-highlight-func-mode'." | 844 | "Hook run at the end of function `semantic-highlight-func-mode'." |
| @@ -1108,11 +902,6 @@ Argument EVENT describes the event that caused this function to be called." | |||
| 1108 | ) | 902 | ) |
| 1109 | (select-window startwin))) | 903 | (select-window startwin))) |
| 1110 | 904 | ||
| 1111 | (defvar semantic-highlight-func-mode nil | ||
| 1112 | "Non-nil if highlight-func minor mode is enabled. | ||
| 1113 | Use the command `semantic-highlight-func-mode' to change this variable.") | ||
| 1114 | (make-variable-buffer-local 'semantic-highlight-func-mode) | ||
| 1115 | |||
| 1116 | (defvar semantic-highlight-func-ct-overlay nil | 905 | (defvar semantic-highlight-func-ct-overlay nil |
| 1117 | "Overlay used to highlight the tag the cursor is in.") | 906 | "Overlay used to highlight the tag the cursor is in.") |
| 1118 | (make-variable-buffer-local 'semantic-highlight-func-ct-overlay) | 907 | (make-variable-buffer-local 'semantic-highlight-func-ct-overlay) |
| @@ -1126,28 +915,8 @@ Use the command `semantic-highlight-func-mode' to change this variable.") | |||
| 1126 | "Face used to show the top of current function." | 915 | "Face used to show the top of current function." |
| 1127 | :group 'semantic-faces) | 916 | :group 'semantic-faces) |
| 1128 | 917 | ||
| 1129 | |||
| 1130 | (defun semantic-highlight-func-mode-setup () | ||
| 1131 | "Setup option `semantic-highlight-func-mode'. | ||
| 1132 | For Semantic enabled buffers, highlight the first line of the | ||
| 1133 | current tag declaration." | ||
| 1134 | (if semantic-highlight-func-mode | ||
| 1135 | (progn | ||
| 1136 | (unless (and (featurep 'semantic) (semantic-active-p)) | ||
| 1137 | ;; Disable minor mode if semantic stuff not available | ||
| 1138 | (setq semantic-highlight-func-mode nil) | ||
| 1139 | (error "Buffer %s was not set up for parsing" (buffer-name))) | ||
| 1140 | ;; Setup our hook | ||
| 1141 | (add-hook 'post-command-hook 'semantic-highlight-func-highlight-current-tag nil t) | ||
| 1142 | ) | ||
| 1143 | ;; Disable highlight func mode | ||
| 1144 | (remove-hook 'post-command-hook 'semantic-highlight-func-highlight-current-tag t) | ||
| 1145 | (semantic-highlight-func-highlight-current-tag t) | ||
| 1146 | ) | ||
| 1147 | semantic-highlight-func-mode) | ||
| 1148 | |||
| 1149 | ;;;###autoload | 918 | ;;;###autoload |
| 1150 | (defun semantic-highlight-func-mode (&optional arg) | 919 | (define-minor-mode semantic-highlight-func-mode |
| 1151 | "Minor mode to highlight the first line of the current tag. | 920 | "Minor mode to highlight the first line of the current tag. |
| 1152 | Enables/disables making the current function's first line light up. | 921 | Enables/disables making the current function's first line light up. |
| 1153 | A function (or other tag class specified by | 922 | A function (or other tag class specified by |
| @@ -1162,21 +931,20 @@ With prefix argument ARG, turn on if positive, otherwise off. The | |||
| 1162 | minor mode can be turned on only if semantic feature is available and | 931 | minor mode can be turned on only if semantic feature is available and |
| 1163 | the current buffer was set up for parsing. Return non-nil if the | 932 | the current buffer was set up for parsing. Return non-nil if the |
| 1164 | minor mode is enabled." | 933 | minor mode is enabled." |
| 1165 | (interactive | 934 | :lighter nil ;; Don't need indicator. It's quite visible. |
| 1166 | (list (or current-prefix-arg | 935 | (if semantic-highlight-func-mode |
| 1167 | (if semantic-highlight-func-mode 0 1)))) | 936 | (progn |
| 1168 | (setq semantic-highlight-func-mode | 937 | (unless (and (featurep 'semantic) (semantic-active-p)) |
| 1169 | (if arg | 938 | ;; Disable minor mode if semantic stuff not available |
| 1170 | (> | 939 | (setq semantic-highlight-func-mode nil) |
| 1171 | (prefix-numeric-value arg) | 940 | (error "Buffer %s was not set up for parsing" (buffer-name))) |
| 1172 | 0) | 941 | ;; Setup our hook |
| 1173 | (not semantic-highlight-func-mode))) | 942 | (add-hook 'post-command-hook |
| 1174 | (semantic-highlight-func-mode-setup) | 943 | 'semantic-highlight-func-highlight-current-tag nil t)) |
| 1175 | (run-hooks 'semantic-highlight-func-mode-hook) | 944 | ;; Disable highlight func mode |
| 1176 | (if (called-interactively-p 'interactive) | 945 | (remove-hook 'post-command-hook |
| 1177 | (message "Highlight-Func minor mode %sabled" | 946 | 'semantic-highlight-func-highlight-current-tag t) |
| 1178 | (if semantic-highlight-func-mode "en" "dis"))) | 947 | (semantic-highlight-func-highlight-current-tag t))) |
| 1179 | semantic-highlight-func-mode) | ||
| 1180 | 948 | ||
| 1181 | (defun semantic-highlight-func-highlight-current-tag (&optional disable) | 949 | (defun semantic-highlight-func-highlight-current-tag (&optional disable) |
| 1182 | "Highlight the current tag under point. | 950 | "Highlight the current tag under point. |
| @@ -1223,8 +991,7 @@ function was called, move the overlay." | |||
| 1223 | nil) | 991 | nil) |
| 1224 | 992 | ||
| 1225 | (semantic-add-minor-mode 'semantic-highlight-func-mode | 993 | (semantic-add-minor-mode 'semantic-highlight-func-mode |
| 1226 | "" ;; Don't need indicator. It's quite visible | 994 | "") ;; Don't need indicator. It's quite visible |
| 1227 | nil) | ||
| 1228 | 995 | ||
| 1229 | (provide 'semantic/util-modes) | 996 | (provide 'semantic/util-modes) |
| 1230 | 997 | ||
diff --git a/lisp/cedet/srecode/mode.el b/lisp/cedet/srecode/mode.el index f588eed2bb1..f1590ed5ec0 100644 --- a/lisp/cedet/srecode/mode.el +++ b/lisp/cedet/srecode/mode.el | |||
| @@ -37,19 +37,6 @@ | |||
| 37 | 37 | ||
| 38 | ;;; Code: | 38 | ;;; Code: |
| 39 | 39 | ||
| 40 | (defcustom global-srecode-minor-mode nil | ||
| 41 | "Non-nil in buffers with Semantic Recoder macro keybindings." | ||
| 42 | :group 'srecode | ||
| 43 | :type 'boolean | ||
| 44 | :require 'srecode/mode | ||
| 45 | :initialize 'custom-initialize-default | ||
| 46 | :set (lambda (sym val) | ||
| 47 | (global-srecode-minor-mode (if val 1 -1)))) | ||
| 48 | |||
| 49 | (defvar srecode-minor-mode nil | ||
| 50 | "Non-nil in buffers with Semantic Recoder macro keybindings.") | ||
| 51 | (make-variable-buffer-local 'srecode-minor-mode) | ||
| 52 | |||
| 53 | (defcustom srecode-minor-mode-hook nil | 40 | (defcustom srecode-minor-mode-hook nil |
| 54 | "Hook run at the end of the function `srecode-minor-mode'." | 41 | "Hook run at the end of the function `srecode-minor-mode'." |
| 55 | :group 'srecode | 42 | :group 'srecode |
| @@ -150,7 +137,7 @@ | |||
| 150 | "Keymap for srecode minor mode.") | 137 | "Keymap for srecode minor mode.") |
| 151 | 138 | ||
| 152 | ;;;###autoload | 139 | ;;;###autoload |
| 153 | (defun srecode-minor-mode (&optional arg) | 140 | (define-minor-mode srecode-minor-mode |
| 154 | "Toggle srecode minor mode. | 141 | "Toggle srecode minor mode. |
| 155 | With prefix argument ARG, turn on if positive, otherwise off. The | 142 | With prefix argument ARG, turn on if positive, otherwise off. The |
| 156 | minor mode can be turned on only if semantic feature is available and | 143 | minor mode can be turned on only if semantic feature is available and |
| @@ -158,16 +145,7 @@ the current buffer was set up for parsing. Return non-nil if the | |||
| 158 | minor mode is enabled. | 145 | minor mode is enabled. |
| 159 | 146 | ||
| 160 | \\{srecode-mode-map}" | 147 | \\{srecode-mode-map}" |
| 161 | (interactive | 148 | :keymap srecode-mode-map |
| 162 | (list (or current-prefix-arg | ||
| 163 | (if srecode-minor-mode 0 1)))) | ||
| 164 | ;; Flip the bits. | ||
| 165 | (setq srecode-minor-mode | ||
| 166 | (if arg | ||
| 167 | (> | ||
| 168 | (prefix-numeric-value arg) | ||
| 169 | 0) | ||
| 170 | (not srecode-minor-mode))) | ||
| 171 | ;; If we are turning things on, make sure we have templates for | 149 | ;; If we are turning things on, make sure we have templates for |
| 172 | ;; this mode first. | 150 | ;; this mode first. |
| 173 | (when srecode-minor-mode | 151 | (when srecode-minor-mode |
| @@ -176,25 +154,20 @@ minor mode is enabled. | |||
| 176 | (mapcar (lambda (map) | 154 | (mapcar (lambda (map) |
| 177 | (srecode-map-entries-for-mode map major-mode)) | 155 | (srecode-map-entries-for-mode map major-mode)) |
| 178 | (srecode-get-maps)))) | 156 | (srecode-get-maps)))) |
| 179 | (setq srecode-minor-mode nil)) | 157 | (setq srecode-minor-mode nil)))) |
| 180 | ) | ||
| 181 | ;; Run hooks if we are turning this on. | ||
| 182 | (when srecode-minor-mode | ||
| 183 | (run-hooks 'srecode-minor-mode-hook)) | ||
| 184 | srecode-minor-mode) | ||
| 185 | 158 | ||
| 186 | ;;;###autoload | 159 | ;;;###autoload |
| 187 | (defun global-srecode-minor-mode (&optional arg) | 160 | (define-minor-mode global-srecode-minor-mode |
| 188 | "Toggle global use of srecode minor mode. | 161 | "Toggle global use of srecode minor mode. |
| 189 | If ARG is positive, enable, if it is negative, disable. | 162 | If ARG is positive or nil, enable, if it is negative, disable." |
| 190 | If ARG is nil, then toggle." | 163 | :global t :group 'srecode |
| 191 | (interactive "P") | 164 | ;; Not needed because it's autoloaded instead. |
| 192 | (setq global-srecode-minor-mode | 165 | ;; :require 'srecode/mode |
| 193 | (semantic-toggle-minor-mode-globally | 166 | (semantic-toggle-minor-mode-globally |
| 194 | 'srecode-minor-mode arg))) | 167 | 'srecode-minor-mode (if global-srecode-minor-mode 1 -1))) |
| 195 | 168 | ||
| 196 | ;; Use the semantic minor mode magic stuff. | 169 | ;; Use the semantic minor mode magic stuff. |
| 197 | (semantic-add-minor-mode 'srecode-minor-mode "" srecode-mode-map) | 170 | (semantic-add-minor-mode 'srecode-minor-mode "") |
| 198 | 171 | ||
| 199 | ;;; Menu Filters | 172 | ;;; Menu Filters |
| 200 | ;; | 173 | ;; |