GNU bug report logs - #10773
define-derived-mode/define-minor-mode to declare hook variables

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> jurta.org>

Date: Thu, 9 Feb 2012 09:50:02 UTC

Severity: wishlist

Tags: fixed

Found in version 24.0.93

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: Juri Linkov <juri <at> jurta.org>, Glenn Morris <rgm <at> gnu.org>, 10773 <at> debbugs.gnu.org
Subject: bug#10773: set-variable can't change values of user options
Date: Sat, 19 Sep 2020 17:21:53 +0200
Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:

>> But I think that has been previously rejected.
>
> That was a long time ago.  We should do it for 24.2.

Reintroducing defvars for define-minor-mode hook variables was done the
following year:

commit 7f17cc40ef9120ba1b1715399432f26e8850505a
Author:     Stefan Monnier <monnier <at> iro.umontreal.ca>
AuthorDate: Mon May 27 12:12:52 2013 -0400

    Always defvar a mode's hook and provide a docstring.
    * lisp/emacs-lisp/easy-mmode.el (define-minor-mode):
    * lisp/emacs-lisp/derived.el (define-derived-mode): Always defvar the
    mode hook and provide a docstring.

There's still the question of using allowing these variables to be
customized, and that still doesn't work:

(customize-variable 'flyspell-mode-hook)
-> "NO CUSTOMIZATION DATA; not intended to be customized."

But...  why not?  So I've now added the patch below to Emacs 28.

diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index e3eb9294ed..fdc1233540 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -335,6 +335,9 @@ define-minor-mode
 No problems result if this variable is not bound.
 `add-hook' automatically binds it.  (This is true for all hook variables.)"
                        modefun)))
+       ;; Allow using using `M-x customize-variable' on the hook.
+       (put ',hook 'custom-type 'hook)
+       (put ',hook 'standard-value (list nil))
 
        ;; Define the minor-mode keymap.
        ,(unless (symbolp keymap)	;nil is also a symbol.


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




This bug report was last modified 4 years and 326 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.