all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: Clarification on hooks and custom-set-variables
Date: Fri, 07 Aug 2015 11:11:28 -0400	[thread overview]
Message-ID: <jwvh9obqgvr.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87oaimdx16.fsf@gnu.org> (Tassilo Horn's message of "Wed, 05 Aug 2015 09:17:25 +0200")

>   (custom-set-variables
>    '(LaTeX-mode-hook '(flyspell-mode LaTeX-math-mode turn-on-reftex)))
[...]
> 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?

> 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.

> 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.
- split it into a defcustom (only set by the user) and a defvar (only
  set by Elisp code).


        Stefan



  reply	other threads:[~2015-08-07 15:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-05  7:17 Clarification on hooks and custom-set-variables Tassilo Horn
2015-08-07 15:11 ` Stefan Monnier [this message]
2015-08-07 15:40   ` Tassilo Horn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvh9obqgvr.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.