[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Default :group in lisp/emacs-lisp/easy-mmode.el.
From: |
Lute Kamstra |
Subject: |
Re: Default :group in lisp/emacs-lisp/easy-mmode.el. |
Date: |
Fri, 01 Apr 2005 12:21:30 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
Richard Stallman <address@hidden> writes:
> The use of custom-current-group seems like a bad practice to me.
> It is unreliable to make one defun depend on whatever was lying around
> from a previous defun in this way. It has the result that moving
> code from one place in a file to another changes its meaning.
>
> So I think it would be better to document that define-minor-mode
> and easy-mmode-define-global-mode default the group based
> solely on the mode name.
Ok, that was the actual behavior up till now anyway. For
define-minor-mode and easy-mmode-define-global-mode, it doesn't matter
much because you can specify the group explicitly.
I also defined the :group for the defcustom of the mode hook variable
of a generic mode with custom-current-group. So I'd like to add an
extra argument to define-generic-mode to specify the value for :group.
Ok to commit?
Lute.
Index: lisp/ChangeLog
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.7234
diff -c -r1.7234 ChangeLog
*** lisp/ChangeLog 1 Apr 2005 04:48:39 -0000 1.7234
--- lisp/ChangeLog 1 Apr 2005 10:02:14 -0000
***************
*** 1,3 ****
--- 1,12 ----
+ 2005-04-01 Lute Kamstra <address@hidden>
+
+ * generic.el (define-generic-mode): Don't use custom-current-group.
+ Add argument to specify keywords for defcustom.
+
+ * emacs-lisp/easy-mmode.el (define-global-minor-mode): Don't use
+ custom-current-group.
+ (define-minor-mode): Ditto. Document default :group value.
+
2005-03-31 Luc Teirlinck <address@hidden>
* files.el (mode-require-final-newline): Make Custom correctly
Index: lisp/generic.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/generic.el,v
retrieving revision 1.33
diff -c -r1.33 generic.el
*** lisp/generic.el 31 Mar 2005 23:16:20 -0000 1.33
--- lisp/generic.el 1 Apr 2005 10:02:15 -0000
***************
*** 185,191 ****
;;;###autoload
(defmacro define-generic-mode (mode comment-list keyword-list
font-lock-list auto-mode-list
! function-list &optional docstring)
"Create a new generic mode MODE.
MODE is the name of the command for the generic mode; it need not
--- 185,192 ----
;;;###autoload
(defmacro define-generic-mode (mode comment-list keyword-list
font-lock-list auto-mode-list
! function-list &optional docstring
! &rest custom-keyword-args)
"Create a new generic mode MODE.
MODE is the name of the command for the generic mode; it need not
***************
*** 216,221 ****
--- 217,228 ----
FUNCTION-LIST is a list of functions to call to do some
additional setup.
+ The optional CUSTOM-KEYWORD-ARGS are pairs of keywords and
+ values. They will be passed to the generated `defcustom' form of
+ the mode hook variable MODE-hook. If :group is not specified, it
+ defaults to MODE without the possible trailing \"-mode\". You
+ can specify keyword arguments without specifying a docstring.
+
See the file generic-x.el for some examples of `define-generic-mode'."
(declare (debug (sexp def-form def-form def-form form def-form
&optional stringp))
***************
*** 224,234 ****
--- 231,253 ----
;; Backward compatibility.
(when (eq (car-safe mode) 'quote)
(setq mode (eval mode)))
+
+ (when (and docstring (not (stringp docstring)))
+ ;; DOCSTRING is not a string so we assume that it's actually the
+ ;; first keyword of CUSTOM-KEYWORD-ARGS.
+ (push docstring custom-keyword-args)
+ (setq docstring nil))
+
(let* ((mode-name (symbol-name mode))
(pretty-name (capitalize (replace-regexp-in-string
"-mode\\'" "" mode-name)))
(mode-hook (intern (concat mode-name "-hook"))))
+ (unless (plist-get custom-keyword-args :group)
+ (plist-put custom-keyword-args
+ :group `',(intern (replace-regexp-in-string
+ "-mode\\'" "" mode-name))))
+
`(progn
;; Add a new entry.
(add-to-list 'generic-mode-list ,mode-name)
***************
*** 240,248 ****
(defcustom ,mode-hook nil
,(concat "Hook run when entering " pretty-name " mode.")
:type 'hook
! :group (or (custom-current-group)
! ',(intern (replace-regexp-in-string
! "-mode\\'" "" mode-name))))
(defun ,mode ()
,(or docstring
--- 259,265 ----
(defcustom ,mode-hook nil
,(concat "Hook run when entering " pretty-name " mode.")
:type 'hook
! ,@custom-keyword-args)
(defun ,mode ()
,(or docstring
Index: lisp/emacs-lisp/easy-mmode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/easy-mmode.el,v
retrieving revision 1.57
diff -c -r1.57 easy-mmode.el
*** lisp/emacs-lisp/easy-mmode.el 31 Mar 2005 21:15:31 -0000 1.57
--- lisp/emacs-lisp/easy-mmode.el 1 Apr 2005 10:02:15 -0000
***************
*** 94,101 ****
These following keyword arguments are supported (other keywords
will be passed to `defcustom' if the minor mode is global):
:group GROUP Custom group name to use in all generated `defcustom' forms.
:global GLOBAL If non-nil specifies that the minor mode is not meant
to be
! buffer-local, so don't make the variable MODE
buffer-local.
By default, the mode is buffer-local.
:init-value VAL Same as the INIT-VALUE argument.
:lighter SPEC Same as the LIGHTER argument.
--- 94,102 ----
These following keyword arguments are supported (other keywords
will be passed to `defcustom' if the minor mode is global):
:group GROUP Custom group name to use in all generated `defcustom' forms.
+ Defaults to MODE without the possible trailing \"-mode\".
:global GLOBAL If non-nil specifies that the minor mode is not meant
to be
! buffer-local, so don't make the variable MODE buffer-local.
By default, the mode is buffer-local.
:init-value VAL Same as the INIT-VALUE argument.
:lighter SPEC Same as the LIGHTER argument.
***************
*** 153,162 ****
(unless group
;; We might as well provide a best-guess default group.
(setq group
! `(:group (or (custom-current-group)
! ',(intern (replace-regexp-in-string
! "-mode\\'" "" mode-name))))))
!
`(progn
;; Define the variable to enable or disable the mode.
,(if (not globalp)
--- 154,162 ----
(unless group
;; We might as well provide a best-guess default group.
(setq group
! `(:group ',(intern (replace-regexp-in-string
! "-mode\\'" "" mode-name)))))
!
`(progn
;; Define the variable to enable or disable the mode.
,(if (not globalp)
***************
*** 280,288 ****
(unless group
;; We might as well provide a best-guess default group.
(setq group
! `(:group (or (custom-current-group)
! ',(intern (replace-regexp-in-string
! "-mode\\'" "" (symbol-name mode)))))))
`(progn
;; The actual global minor-mode
--- 280,287 ----
(unless group
;; We might as well provide a best-guess default group.
(setq group
! `(:group ',(intern (replace-regexp-in-string
! "-mode\\'" "" (symbol-name mode))))))
`(progn
;; The actual global minor-mode
- Re: Default :group in lisp/emacs-lisp/easy-mmode.el.,
Lute Kamstra <=