]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/srecode/mode.el
Merge from emacs-23
[gnu-emacs] / lisp / cedet / srecode / mode.el
index 08da334767d3f4081ae395d5d41e328aa9630fda..bdb8172eb5ef82498efac2444dc4912d44a495e2 100644 (file)
 
 ;;; Code:
 
-(defcustom global-srecode-minor-mode nil
-  "Non-nil in buffers with Semantic Recoder macro keybindings."
-  :group 'srecode
-  :type 'boolean
-  :require 'srecode/mode
-  :initialize 'custom-initialize-default
-  :set (lambda (sym val)
-         (global-srecode-minor-mode (if val 1 -1))))
-
-(defvar srecode-minor-mode nil
-  "Non-nil in buffers with Semantic Recoder macro keybindings.")
-(make-variable-buffer-local 'srecode-minor-mode)
-
 (defcustom srecode-minor-mode-hook nil
   "Hook run at the end of the function `srecode-minor-mode'."
   :group 'srecode
   "Keymap for srecode minor mode.")
 
 ;;;###autoload
-(defun srecode-minor-mode (&optional arg)
+(define-minor-mode srecode-minor-mode
   "Toggle srecode minor mode.
 With prefix argument ARG, turn on if positive, otherwise off.  The
 minor mode can be turned on only if semantic feature is available and
@@ -164,16 +151,7 @@ the current buffer was set up for parsing.  Return non-nil if the
 minor mode is enabled.
 
 \\{srecode-mode-map}"
-  (interactive
-   (list (or current-prefix-arg
-             (if srecode-minor-mode 0 1))))
-  ;; Flip the bits.
-  (setq srecode-minor-mode
-        (if arg
-            (>
-             (prefix-numeric-value arg)
-             0)
-          (not srecode-minor-mode)))
+  :keymap srecode-mode-map
   ;; If we are turning things on, make sure we have templates for
   ;; this mode first.
   (when srecode-minor-mode
@@ -182,25 +160,20 @@ minor mode is enabled.
                (mapcar (lambda (map)
                          (srecode-map-entries-for-mode map major-mode))
                        (srecode-get-maps))))
-      (setq srecode-minor-mode nil))
-    )
-  ;; Run hooks if we are turning this on.
-  (when srecode-minor-mode
-    (run-hooks 'srecode-minor-mode-hook))
-  srecode-minor-mode)
+      (setq srecode-minor-mode nil))))
 
 ;;;###autoload
-(defun global-srecode-minor-mode (&optional arg)
+(define-minor-mode global-srecode-minor-mode
   "Toggle global use of srecode minor mode.
-If ARG is positive, enable, if it is negative, disable.
-If ARG is nil, then toggle."
-  (interactive "P")
-  (setq global-srecode-minor-mode
-        (semantic-toggle-minor-mode-globally
-         'srecode-minor-mode arg)))
+If ARG is positive or nil, enable, if it is negative, disable."
+  :global t :group 'srecode
+  ;; Not needed because it's autoloaded instead.
+  ;; :require 'srecode/mode
+  (semantic-toggle-minor-mode-globally
+   'srecode-minor-mode (if global-srecode-minor-mode 1 -1)))
 
 ;; Use the semantic minor mode magic stuff.
-(semantic-add-minor-mode 'srecode-minor-mode "" srecode-mode-map)
+(semantic-add-minor-mode 'srecode-minor-mode "")
 
 ;;; Menu Filters
 ;;