emacs-devel
[Top][All Lists]
Advanced

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

Re: Clarification on hooks and custom-set-variables


From: Tassilo Horn
Subject: Re: Clarification on hooks and custom-set-variables
Date: Fri, 07 Aug 2015 17:40:48 +0200
User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> Now when he starts emacs, the value of `LaTeX-mode-hook' will be
>> '(LaTeX-preview-setup).  Huh, where are the configs gone?
>
> Not applied (yet).  What happens after he opens a LaTeX file?

Then it contains just `preview-mode-setup'.  That's because
`LaTeX-preview-setup' replaces itself with that.  In any case, the user
configs won't be applied.

>> AUCTeX uses `LaTeX-mode-hook' internally, too.  auctex-autoloads.el adds
>> the preview setup function
>>   (add-hook 'LaTeX-mode-hook #'LaTeX-preview-setup)
>
> FWIW, this probably made sense back when latex-preview was a separate
> package, but now you're better off calling LaTeX-preview-setup
> unconditionally from AUCTeX's latex-mode.

Indeed.

>> 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?
>
> Sound be, yes.
>
>> Does that make sense?  Or why does the customized value get lost?
>> And most importantly, how to I fix that?
>
> Custom just sucks at handling vars which are both set via Custom and
> set by random Elisp code.  E.g. depending on the circumstances, you
> could end up with only (flyspell-mode LaTeX-math-mode turn-on-reftex)
> in the hook, i.e. without LaTeX-preview-setup.
>
> The best fixes I can think of:
> - don't make it a defcustom.

Probably that ship has sailed since it has been a defcustom for ages.

> - split it into a defcustom (only set by the user) and a defvar (only
>   set by Elisp code).

Well, in this concrete case I just go with calling `LaTeX-preview-setup'
unconditionally.

Bye,
Tassilo



reply via email to

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