From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Clarification on hooks and custom-set-variables Date: Fri, 07 Aug 2015 11:11:28 -0400 Message-ID: References: <87oaimdx16.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1438960323 5064 80.91.229.3 (7 Aug 2015 15:12:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 7 Aug 2015 15:12:03 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 07 17:11:50 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZNjJF-0002lv-Sb for ged-emacs-devel@m.gmane.org; Fri, 07 Aug 2015 17:11:50 +0200 Original-Received: from localhost ([::1]:49511 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNjJF-0003vA-46 for ged-emacs-devel@m.gmane.org; Fri, 07 Aug 2015 11:11:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNjIz-0003sP-JB for emacs-devel@gnu.org; Fri, 07 Aug 2015 11:11:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNjIv-0002fM-C5 for emacs-devel@gnu.org; Fri, 07 Aug 2015 11:11:33 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:41113) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNjIv-0002fC-7j for emacs-devel@gnu.org; Fri, 07 Aug 2015 11:11:29 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0ArEwA731xV//gFNJ1cgxCEAoVVuzcJh0sEAgKBPDkUAQEBAQEBAYEKQQWDXQEBAwFWKAsLNBIUGA2IWwjPIyyKOIEChQwWhBcFtQQjhBQigngBAQE X-IPAS-Result: A0ArEwA731xV//gFNJ1cgxCEAoVVuzcJh0sEAgKBPDkUAQEBAQEBAYEKQQWDXQEBAwFWKAsLNBIUGA2IWwjPIyyKOIEChQwWhBcFtQQjhBQigngBAQE X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="159086195" Original-Received: from 157-52-5-248.cpe.teksavvy.com (HELO pastel.home) ([157.52.5.248]) by ironport2-out.teksavvy.com with ESMTP; 07 Aug 2015 11:11:28 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 9CE6C61710; Fri, 7 Aug 2015 11:11:28 -0400 (EDT) In-Reply-To: <87oaimdx16.fsf@gnu.org> (Tassilo Horn's message of "Wed, 05 Aug 2015 09:17:25 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:188552 Archived-At: > (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