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


Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Kevin Rodgers <kevin.d.rodgers <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#10773: set-variable can't change values of user options
Date: Fri, 10 Feb 2012 01:18:06 -0700
On 2/9/12 11:28 AM, Glenn Morris wrote:
> Juri Linkov wrote:
>
>> Why users are allowed to change the value of `outline-mode-hook',
>> but not `outline-minor-mode-hook'?
>
> The former is defined with (defvar ... "*...").
> The latter is not defined anywhere, but as define-derived-mode says
> about hooks and has been covered several times:
>
>    No problems result if this variable is not bound.
>    `add-hook' automatically binds it.  (This is true for all hook variables.)
>
> I would says it's not very useful to pass a hook to set-variable anyway,
> since you need to type a lisp expression, and probably should use
> an explicit add-hook statement.

Or allow add-hook (and remove-hook) to be called interactively, for convenience:

--- -	2012-02-10 01:14:16.000000000 -0700
+++ /tmp/subr.el	2012-02-10 01:13:17.000000000 -0700
@@ -1216,15 +1216,17 @@
 unless the optional argument APPEND is non-nil, in which case
 FUNCTION is added at the end.

-The optional fourth argument, LOCAL, if non-nil, says to modify
-the hook's buffer-local value rather than its default value.
-This makes the hook buffer-local if needed, and it makes t a member
-of the buffer-local value.  That acts as a flag to run the hook
-functions in the default value as well as in the local value.
+The optional fourth argument, LOCAL, if non-nil or an interactive
+prefix arg, says to modify the hook's buffer-local value rather
+than its default value.  This makes the hook buffer-local if
+needed, and it makes t a member of the buffer-local value.  That
+acts as a flag to run the hook functions in the default value as
+well as in the local value.

 HOOK should be a symbol, and FUNCTION may be any valid function.  If
 HOOK is void, it is first set to nil.  If HOOK's value is a single
 function, it is changed to a list of functions."
+  (interactive "SHook: \naFunction: \ni\nP")
   (or (boundp hook) (set hook nil))
   (or (default-boundp hook) (set-default hook nil))
   (if local (unless (local-variable-if-set-p hook)
@@ -1264,8 +1266,10 @@
 FUNCTION isn't the value of HOOK, or, if FUNCTION doesn't appear in the
 list of hooks to run in HOOK, then nothing is done.  See `add-hook'.

-The optional third argument, LOCAL, if non-nil, says to modify
-the hook's buffer-local value rather than its default value."
+The optional third argument, LOCAL, if non-nil (interactively,
+with prefix argument) says to modify the hook's buffer-local
+value rather than its default value."
+  (interactive "SHook: \naFunction: \nP")
   (or (boundp hook) (set hook nil))
   (or (default-boundp hook) (set-default hook nil))
   ;; Do nothing if LOCAL is t but this hook has no local binding.

-- 
Kevin Rodgers
Denver, Colorado, USA





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.