bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#14502: 24.3; dired-load-hook should not be customizable


From: Lars Ingebrigtsen
Subject: bug#14502: 24.3; dired-load-hook should not be customizable
Date: Fri, 16 Aug 2019 13:50:23 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Reuben Thomas <address@hidden> writes:

> dired-x adds dired-extra-startup to dired-mode-hook…

I missed that bit.

> dired-mode-hook in my setup also has sml/set-buffer-identification added by
> smart-mode-line, so yes, it is "one of those hooks"

It seems rather unsatisfactory to have to make a decision between "one
of those hooks" and "the rest of the hooks" on a hook by hook basis...

Stefan wrote in 2013:

> So until Custom is fixed to actually properly handle customisation of
> hooks (e.g. by storing "add functions foo, bar, and baz" rather than
> "ignore current value and just set it to (foo bar baz)").

So I wondered what it would take to fix this in Customize properly.  But:

(define-widget 'hook 'list
  "An Emacs Lisp hook."

[...]

  :set (lambda (symbol value)
         (dolist (elt value)
           (if (fboundp elt)
               (add-hook symbol elt))))

The :set action for hooks doesn't just overwrite the value, but uses
`add-hook' the proper way?

Now I'm even more confused.  Hm...  Perhaps that's not the code that's
used when actually restoring hook values?  Let's see.

(defun customize-set-variable (variable value &optional comment)

[...]

  (funcall (or (get variable 'custom-set) #'set-default) variable value)

(get 'gnus-load-hook 'custom-set)
=> nil

So the setter is not used?  Hm...  Oh, it's only set if you say

(defcustom ...
  :set ...)

Right.  So the :set in the widget is only used interactively?  *tests*
Nope, if I try to modify a hook in a Customize buffer, then it always
overwrites the hook value.

So, as usual, when trying to figure out how Customize works, it's...
just...  rather obscure.

But I think one (probably controversial solution) would be to add a
`custom-set' property on all hook variables that would make it use
`add-hook' instead of just overwriting the value.  That would make
Customize and add-hook coexist...  but would also mean that you can't
set a hook to a specific value with Customize, which will probably break
something for somebody.

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]