From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: orgmode and auctex Date: Sat, 11 Feb 2012 13:11:29 -0500 Message-ID: <14710.1328983889@alphaville> References: <10922.1328638512@alphaville> <4354.1328818115@alphaville> Reply-To: nicholas.dokos@hp.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:48024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwHQ7-0002ak-7p for emacs-orgmode@gnu.org; Sat, 11 Feb 2012 13:11:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RwHQ5-00081W-OC for emacs-orgmode@gnu.org; Sat, 11 Feb 2012 13:11:35 -0500 Received: from g1t0028.austin.hp.com ([15.216.28.35]:39220) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwHQ5-00081E-Gf for emacs-orgmode@gnu.org; Sat, 11 Feb 2012 13:11:33 -0500 In-Reply-To: Message from Carsten Dominik of "Sat\, 11 Feb 2012 18\:40\:05 +0100." List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Carsten Dominik Cc: Thomas Alexander Gerds , nicholas.dokos@hp.com, Org Mode , Christopher Witte Carsten Dominik wrote: >=20 > On 9.2.2012, at 21:08, Nick Dokos wrote: >=20 > > Thomas Alexander Gerds wrote: > >=20 > >>=20 > >> Hi Chris, > >>=20 > >> maybe I cannot follow exactly what you are trying to do, but when I > >> start emacs -q and evaluate (setq-default TeX-master nil) and then open > >> a new file test.tex, then I get the same prompt "Master file:". > >>=20 > >=20 > > I think Chris means that he gets the prompt when he opens a .org file. > > I couldn't reproduce that behavior when I tried it but I have not tried > > it again yet. >=20 > I think this prompt comes from the function `reftex-TeX-master-file'.=20 >=20 Indeed - the backtrace is as follows: ... completing-read-default("Master file: " read-file-name-internal file-exis= ts-p t "~/src/org/" file-name-history "~/src/org/foo.org" nil) completing-read("Master file: " read-file-name-internal file-exists-p t "= ~/src/org/" file-name-history "~/src/org/foo.org") read-file-name-default("Master file: " nil nil t nil nil) read-file-name("Master file: " nil nil t nil) reftex-TeX-master-file() reftex-tie-multifile-symbols() reftex-access-scan-info((16)) reftex-parse-all() (and (buffer-file-name) (file-exists-p (buffer-file-name)) (reftex-parse-= all)) org-mode-reftex-setup() run-hooks(change-major-mode-after-body-hook text-mode-hook outline-mode-h= ook org-mode-hook) apply(run-hooks (change-major-mode-after-body-hook text-mode-hook outline= -mode-hook org-mode-hook)) run-mode-hooks(org-mode-hook) org-mode() set-auto-mode-0(org-mode nil) set-auto-mode() normal-mode(t) after-find-file(nil t) find-file-noselect-1(# "~/src/org/foo.org" nil nil "~/src= /org/foo.org" (3018153 2055)) find-file-noselect("~/src/org/foo.org" nil nil t) find-file("~/src/org/foo.org" t) call-interactively(find-file nil nil) > The user is prompted when TeX-master is an existing variable > (i.e. AUCTeX is loaded), and when its value is nil or `shared'. It's actually a bit more complicated than that: it checks if TeX-master-file is defined as a function (i.e. AUCTEX is loaded) and if so calls it. It then checks if tex-main-file is defined as a function (i.e. Emacs LaTeX mode is loaded) and if so calls it. Then it check if TeX-master is t (in which case (buffer-file-name) is called to set the master, or 'shared (in which case it reads the file name) or non-nil (in which case it is used verbatim) or nil (in which case it reads the file name - the operative case here). I'll leave it here for now: I've been sick for a couple of days and I can't think straight right now (or ever...) Nick > Greetings >=20 > - Carsten >=20 > >=20 > > Nick > >=20 > >=20 > >> so maybe, if you do not want to get prompted, you could try setting > >> (setq-default TeX-master t).=20 > >>=20 > >> Cheers > >> Tomy > >>=20 > >>=20 > >>=20 > >> Christopher Witte writes: > >>=20 > >>> OK so using the setq-default inside a hook is probably not a good > >>> idea. > >>> But I can reliably reproduce this problem, I'm surprised you couldn't. > >>> If > >>> I start emacs using emacs -Q and open an org file everything is fine. > >>> If I > >>> then evaluate this > >>>=20 > >>> (setq-default TeX-master nil) > >>>=20 > >>> (defun org-mode-reftex-setup () > >>> (load-library "reftex") > >>> (and (buffer-file-name) > >>> (file-exists-p (buffer-file-name)) > >>> (reftex-parse-all)) > >>> (define-key org-mode-map (kbd "C-c )") 'reftex-citation)) > >>> (add-hook 'org-mode-hook 'org-mode-reftex-setup) > >>>=20 > >>> and try to open an org file I get prompted "Master file: ~/". I'm > >>> running > >>> Ubuntu 11.10 and the emacs-snapshot package: GNU Emacs 23.3.1 > >>> (i686-pc-linux-gnu, GTK+ Version 2.24.5), latest org pulled from git > >>> today. > >>> Is there any more information I could provide to help diagnose this > >>> problem? > >>>=20 > >>> Cheers > >>> Chris. > >>>=20 > >>> On 7 February 2012 19:15, Nick Dokos wrote: > >>>=20 > >>>> Christopher Witte wrote: > >>>>=20 > >>>>> I've had a small problem with orgmode and auctex. Follwing the > >>> auctex > >>>> quickstart I added the > >>>>> following to my .emacs > >>>>>=20 > >>>>> (setq-default TeX-master nil) > >>>>>=20 > >>>>> and then from the orgmode FAQ to setup reftex in orgmode I added > >>> the > >>>> following > >>>>>=20 > >>>>> (defun org-mode-reftex-setup () > >>>>> (load-library "reftex") > >>>>> (and (buffer-file-name) > >>>>> (file-exists-p (buffer-file-name)) > >>>>> (reftex-parse-all)) > >>>>> (define-key org-mode-map (kbd "C-c )") 'reftex-citation)) > >>>>> (add-hook 'org-mode-hook 'org-mode-reftex-setup) > >>>>>=20 > >>>>> With both of these, whenever I opened an org file I was asked to > >>> name > >>>> the master file. If I comment > >>>>> out the setq-default I don't get the behaviour I would like with > >>>> mulitfile tex files. My solution > >>>>> was to change > >>>>>=20 > >>>>> (setq-default TeX-master nil) > >>>>>=20 > >>>>> to > >>>>>=20 > >>>>> (add-hook 'TeX-mode-hook (lambda () > >>>>> (setq-default TeX-master nil))) > >>>>>=20 > >>>>> I then appear to get the behaviour I desire. Is this a good way > >>> to do > >>>> this? If so I might add it > >>>>> to the FAQ. > >>>>>=20 > >>>>=20 > >>>> Probably not. setq-default sets the default value of the variable > >>>> whereas the hook is supposed to set the local value in order to > >>> override > >>>> the default value: setting the default value from a hook seems > >>> backwards > >>>> to me. > >>>>=20 > >>>> Actually, I added the above code (*without* the TeX-mode-hook mod) > >>> to my > >>>> minimal .emacs and opening org files does not generate any > >>> questions. Are > >>>> you sure you have diagnosed the problem correctly? > >>>>=20 > >>>> Nick > >>>>=20 > >> -- > >> Thomas A. Gerds -- Assoc. Prof. Department of Biostatistics > >> University of Copenhagen, =C3=98ster Farimagsgade 5, 1014 Copenhagen, = Denmark > >> Office: CSS-15.2.07 (Gamle Kommunehospital) > >> tel: 35327914 (sec: 35327901)=20 > >>=20 > >=20 >=20 >=20