From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: Clarification on hooks and custom-set-variables Date: Fri, 07 Aug 2015 17:40:48 +0200 Message-ID: <874mkbksxr.fsf@gnu.org> References: <87oaimdx16.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1438962089 5242 80.91.229.3 (7 Aug 2015 15:41:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 7 Aug 2015 15:41:29 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 07 17:41:14 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 1ZNjle-0001n1-Ms for ged-emacs-devel@m.gmane.org; Fri, 07 Aug 2015 17:41:10 +0200 Original-Received: from localhost ([::1]:49590 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNjle-00063m-0J for ged-emacs-devel@m.gmane.org; Fri, 07 Aug 2015 11:41:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37722) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNjlQ-00062i-72 for emacs-devel@gnu.org; Fri, 07 Aug 2015 11:40:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNjlM-00012X-ST for emacs-devel@gnu.org; Fri, 07 Aug 2015 11:40:56 -0400 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:35524) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNjlM-00012N-E7 for emacs-devel@gnu.org; Fri, 07 Aug 2015 11:40:52 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id F4013207C9 for ; Fri, 7 Aug 2015 11:40:51 -0400 (EDT) Original-Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Fri, 07 Aug 2015 11:40:51 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=SZFeZmwaqCeCnFFFoJj1ZlQ0om4=; b=b4b0n myvl+saweAPGGejV/yrDpyq05iW3lHjoK7xl8B7qRxPAsd75lMvyJILW57p6LLWy 6XguY+6UdiGH8Ej+vvr+RvAo06FWwxQP1nVjhdlggMwE2SHnIfxPCC/ETG+RMFbL 9NBXg3K8bi5Xz9S+6QmonpedONiXj24Rnq17Go= X-Sasl-enc: Zn5+PI0AOqN5y6zOehGmYBsi25f3VeVzJf2O5PQHpLWk 1438962051 Original-Received: from thinkpad-t440p (unknown [2.160.252.222]) by mail.messagingengine.com (Postfix) with ESMTPA id 1BE00680103; Fri, 7 Aug 2015 11:40:50 -0400 (EDT) Mail-Followup-To: Stefan Monnier , emacs-devel@gnu.org In-Reply-To: (Stefan Monnier's message of "Fri, 07 Aug 2015 11:11:28 -0400") User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.29 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:188559 Archived-At: Stefan Monnier 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