emacs-devel
[Top][All Lists]
Advanced

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

Clarification on hooks and custom-set-variables


From: Tassilo Horn
Subject: Clarification on hooks and custom-set-variables
Date: Wed, 05 Aug 2015 09:17:25 +0200
User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux)

Hi all,

this is related to AUCTeX bug#21188.  The problem is this: A user who
uses AUCTeX from ELPA customized `LaTeX-mode-hook' so that

  (custom-set-variables
   '(LaTeX-mode-hook '(flyspell-mode LaTeX-math-mode turn-on-reftex)))

is in his ~/.emacs.  I can reproduce the problem with this being the
only contents of ~/.emacs.

Now when he starts emacs, the value of `LaTeX-mode-hook' will be
'(LaTeX-preview-setup).  Huh, where are the configs gone?

AUCTeX uses `LaTeX-mode-hook' internally, too.  auctex-autoloads.el adds
the preview setup function

  (add-hook 'LaTeX-mode-hook #'LaTeX-preview-setup)

which in turn does

  (remove-hook 'LaTeX-mode-hook #'LaTeX-preview-setup)
  (add-hook 'LaTeX-mode-hook #'preview-mode-setup)

But `add-hook' / `remove-hook' should be harmless, and there's no place
where `LaTeX-mode-hook' would be set.

If we add a t NOW flag to the customization, it works.  After startup,
`LaTeX-mode-hook' is the customized value plus `LaTeX-preview-setup'.

The `custom-set-variables' docs don't tell me when customizations are
applied when NOW is omitted or nil.  I guess, it'll be done just when
the corresponding defcustom form is evaluated, right?

So a shot in the blue would be:

  1. Emacs starts and stores the customization value for later
     application since `LaTeX-mode-hook' isn't defined yet.
  2. `package-initialize' runs which loads auctex-autoloads.el which
     adds `LaTeX-preview-setup' to `LaTeX-mode-hook'.
  3. Eventually, latex.el gets loaded and evals the (defcustom
     LaTeX-mode-hook nil) form.  Now customization should kick in but
     maybe it skips applying the customized value because the current
     value '(LaTeX-preview-setup) differs from the default value?

Does that make sense?  Or why does the customized value get lost?  And
most importantly, how to I fix that?

Bye,
Tassilo



reply via email to

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