mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-08 15:30:40 -08:00
(define-minor-mode): Add edebug spec.
Accept a :keymap argument, as you'd expect.
This commit is contained in:
parent
b02c53e6ef
commit
2e2a00756f
1 changed files with 15 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
;;; easy-mmode.el --- easy definition for major and minor modes
|
;;; easy-mmode.el --- easy definition for major and minor modes
|
||||||
|
|
||||||
;; Copyright (C) 1997, 2000, 2001 Free Software Foundation, Inc.
|
;; Copyright (C) 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
|
||||||
|
|
||||||
;; Author: Georges Brun-Cottan <Georges.Brun-Cottan@inria.fr>
|
;; Author: Georges Brun-Cottan <Georges.Brun-Cottan@inria.fr>
|
||||||
;; Maintainer: Stefan Monnier <monnier@gnu.org>
|
;; Maintainer: Stefan Monnier <monnier@gnu.org>
|
||||||
|
|
@ -98,12 +98,19 @@ BODY contains code that will be executed each time the mode is (dis)activated.
|
||||||
By default, the mode is buffer-local.
|
By default, the mode is buffer-local.
|
||||||
:init-value VAL Same as the INIT-VALUE argument.
|
:init-value VAL Same as the INIT-VALUE argument.
|
||||||
:lighter SPEC Same as the LIGHTER argument.
|
:lighter SPEC Same as the LIGHTER argument.
|
||||||
|
:keymap MAP Same as the KEYMAP argument.
|
||||||
:require SYM Same as in `defcustom'.
|
:require SYM Same as in `defcustom'.
|
||||||
|
|
||||||
For example, you could write
|
For example, you could write
|
||||||
(define-minor-mode foo-mode \"If enabled, foo on you!\"
|
(define-minor-mode foo-mode \"If enabled, foo on you!\"
|
||||||
:lighter \" Foo\" :require 'foo :global t :group 'hassle :version \"27.5\"
|
:lighter \" Foo\" :require 'foo :global t :group 'hassle :version \"27.5\"
|
||||||
...BODY CODE...)"
|
...BODY CODE...)"
|
||||||
|
(declare (debug (&define name stringp
|
||||||
|
[&optional [¬ keywordp] sexp
|
||||||
|
&optional [¬ keywordp] sexp
|
||||||
|
&optional [¬ keywordp] sexp]
|
||||||
|
[&rest [keywordp sexp]]
|
||||||
|
def-body)))
|
||||||
|
|
||||||
;; Allow skipping the first three args.
|
;; Allow skipping the first three args.
|
||||||
(cond
|
(cond
|
||||||
|
|
@ -121,12 +128,10 @@ For example, you could write
|
||||||
(extra-args nil)
|
(extra-args nil)
|
||||||
(extra-keywords nil)
|
(extra-keywords nil)
|
||||||
(require t)
|
(require t)
|
||||||
(keymap-sym (if (and keymap (symbolp keymap)) keymap
|
|
||||||
(intern (concat mode-name "-map"))))
|
|
||||||
(hook (intern (concat mode-name "-hook")))
|
(hook (intern (concat mode-name "-hook")))
|
||||||
(hook-on (intern (concat mode-name "-on-hook")))
|
(hook-on (intern (concat mode-name "-on-hook")))
|
||||||
(hook-off (intern (concat mode-name "-off-hook")))
|
(hook-off (intern (concat mode-name "-off-hook")))
|
||||||
keyw)
|
keyw keymap-sym)
|
||||||
|
|
||||||
;; Check keys.
|
;; Check keys.
|
||||||
(while (keywordp (setq keyw (car body)))
|
(while (keywordp (setq keyw (car body)))
|
||||||
|
|
@ -138,8 +143,12 @@ For example, you could write
|
||||||
(:extra-args (setq extra-args (pop body)))
|
(:extra-args (setq extra-args (pop body)))
|
||||||
(:group (setq group (nconc group (list :group (pop body)))))
|
(:group (setq group (nconc group (list :group (pop body)))))
|
||||||
(:require (setq require (pop body)))
|
(:require (setq require (pop body)))
|
||||||
|
(:keymap (setq keymap (pop body)))
|
||||||
(t (push keyw extra-keywords) (push (pop body) extra-keywords))))
|
(t (push keyw extra-keywords) (push (pop body) extra-keywords))))
|
||||||
|
|
||||||
|
(setq keymap-sym (if (and keymap (symbolp keymap)) keymap
|
||||||
|
(intern (concat mode-name "-map"))))
|
||||||
|
|
||||||
(unless group
|
(unless group
|
||||||
;; We might as well provide a best-guess default group.
|
;; We might as well provide a best-guess default group.
|
||||||
(setq group
|
(setq group
|
||||||
|
|
@ -204,11 +213,12 @@ With zero or negative ARG turn mode off.
|
||||||
(progn
|
(progn
|
||||||
,(if globalp `(customize-mark-as-set ',mode))
|
,(if globalp `(customize-mark-as-set ',mode))
|
||||||
(unless (current-message)
|
(unless (current-message)
|
||||||
(message ,(format "%s %%sabled" pretty-name)
|
(message ,(format "%s %%sabled" pretty-name)
|
||||||
(if ,mode "en" "dis")))))
|
(if ,mode "en" "dis")))))
|
||||||
(force-mode-line-update)
|
(force-mode-line-update)
|
||||||
;; Return the new setting.
|
;; Return the new setting.
|
||||||
,mode)
|
,mode)
|
||||||
|
|
||||||
;; Autoloading an easy-mmode-define-minor-mode autoloads
|
;; Autoloading an easy-mmode-define-minor-mode autoloads
|
||||||
;; everything up-to-here.
|
;; everything up-to-here.
|
||||||
:autoload-end
|
:autoload-end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue