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: Clarification on hooks and custom-set-variables Date: Wed, 05 Aug 2015 09:17:25 +0200 Message-ID: <87oaimdx16.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1438759065 18418 80.91.229.3 (5 Aug 2015 07:17:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 5 Aug 2015 07:17:45 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Aug 05 09:17:36 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 1ZMsxD-0006iQ-PH for ged-emacs-devel@m.gmane.org; Wed, 05 Aug 2015 09:17:35 +0200 Original-Received: from localhost ([::1]:39408 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMsxC-0005zy-TP for ged-emacs-devel@m.gmane.org; Wed, 05 Aug 2015 03:17:34 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMsx9-0005yl-Ln for emacs-devel@gnu.org; Wed, 05 Aug 2015 03:17:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZMsx5-0001bx-H1 for emacs-devel@gnu.org; Wed, 05 Aug 2015 03:17:31 -0400 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]:38521) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMsx5-0001aP-C0 for emacs-devel@gnu.org; Wed, 05 Aug 2015 03:17:27 -0400 Original-Received: from thinkpad-t440p (dhcp28.uni-koblenz.de [141.26.71.28]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by deliver.uni-koblenz.de (Postfix) with ESMTPSA id 750031A831C for ; Wed, 5 Aug 2015 09:17:26 +0200 (CEST) Mail-Followup-To: emacs-devel@gnu.org 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.6.x X-Received-From: 141.26.64.15 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:188429 Archived-At: 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