emacs-devel
[Top][All Lists]
Advanced

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

find-file-hook as illustration of Custom problems


From: Luc Teirlinck
Subject: find-file-hook as illustration of Custom problems
Date: Thu, 3 Feb 2005 18:36:55 -0600 (CST)

Programs adding entries to hooks or other lists or alists that are
defined by defcustoms can yield _all kinds_ of problems.

If you do `emacs -q' and then `M-x customize-rogue' you will see well
over twenty variables that are defined with defcustoms and are then
changed by code.  Just experimenting a little bit with these variables
in Custom buffers (_not_ in `emacs -q', because you want a regular
customized Emacs for this) will reveal a wide variety of buggish behavior.

I _only_ took a look at find-file-hook, because I wanted a really easy
example.  (Plenty of other variables, look like they might be a much
bigger mess.)

If you customize find-file-hook, then regret your customizations and
select "Erase Customization" VC will not work any more, for newly
visited files.  If you use auto-revert-tail-mode, it will malfunction
from that moment on, for newly visited files.  Both will work again if
you start a new session, but the fact that they cease to work without
warning in the current session is bad enough.

The problem is that vc-hooks.el contains:

(add-hook 'find-file-hook 'vc-find-file-hook)

and autorevert.el contains:

(add-hook 'find-file-hook
            (lambda ()
                (set (make-local-variable 'auto-revert-tail-pos)
                      (save-restriction (widen) (1- (point-max))))))

Since vc-hooks.el is apparently preloaded, one could either call
vc-find-file-hook directly from after-find-file or one could add it to
the defcustom of find-file-hook.  Since it seems to be a function that
needs to run _unconditionally_, I personally would lean toward calling
it from after-find-file directly.

What should be done with the auto-revert-tail-mode problem is not that
straightforward.  I would say just ignore it for the moment.  I just
noticed auto-revert-tail, because I use auto-revert-mode, but looking
through the code, I noticed that several other packages add stuff to
find-file-hook in the same way and hence will also be disabled by
"Erase Customization ".

I guess that after "21.4" is released, we could split some of the most
often used and most problematic hooks (like find-file-hook) into a
user and a program hook, thereby solving this kind of problem.  (Doing
this for all defcustomed hooks would probably be unrealistic, because
there are too many of them.)

After that more than twenty complete different and much more complex
problems with changing stuff outside Custom remain, if we just look at
problems present at startup.

But problems occurring _after_ startup are much more dangerous, as I
pointed out and they are also apparently even way more numerous.

I would say, let us tackle this seriously after 21.4 is released and
let us leave Custom alone until 21.4 is released.

Sincerely,

Luc.





reply via email to

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