;;; 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
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
(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
;;