From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id YKHGIy4uJmbe9AAAqHPOHw:P1 (envelope-from ) for ; Mon, 22 Apr 2024 11:30:22 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id YKHGIy4uJmbe9AAAqHPOHw (envelope-from ) for ; Mon, 22 Apr 2024 11:30:22 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1713778222; a=rsa-sha256; cv=none; b=sdlr/dQFJv0nAISQHYztcLf/SompZG4fC9XZ+k/JnGJ5fPFxMNYzYoP7Q7k+9Qm/ft6USG +19Q1yPfOAAwiQFo9t7LB61wf4mFGkkjCLdDev7XeR6JtuysF9PED/8qmNvQrHwoAonzGa PyyxsQyLNpP5y/4FCUa/vgiKpeBRBQciOrt1BHhQGX/l3Ie36/xWlY2xyhUjQIvGvwBraZ uwmOMof1wMdrPgIppN591kjOxXuvfdtsV3KMFTxmDm4G8qwzJH7UdG0xKXE5bPf614xhwi 5oWV0Ky3i3AbmJ7D6YzMaDC2M3cYfBuxDPVILtin+6PU2npveGAiWu0X66hpAw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1713778222; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bydHCooZlhEZiySAp4Z9wGTYoSED3Ognc0FFexRilYo=; b=LO+romIfaWQKmgZAVx+srcEtX9t0K6HGYnXN1o+qIlmFUcrowCeQ/npGCViMrMbuRhnzct TWYz/RegZuOqpqhdRH3iJAm19EIuW/Iie8o5iUkWBlMqnoryqXQMSLQFEOPBk96PyPSraz 51QNtyXPZQmmXUvFRDcqV6HjcirOE5GiLJCY4Y/QhVbTmnmku35Ez1IcSvvapz1DffNY0v 4iG0rNMBeyhnec+BE/E8NEJVOAE5MYTktSNw+gBvuR+a+z+7jxeIe5yFvyKzllx4AUmPh0 WFUYUMkUaUZ63ALPgLwxc0c4NRD2OoSzADGKTfnX97mayp891d9icEagHwUGAA== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 32F067EE9E for ; Mon, 22 Apr 2024 11:30:22 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rypzH-00017L-Qt; Mon, 22 Apr 2024 05:29:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rypzE-00016v-Jn for emacs-orgmode@gnu.org; Mon, 22 Apr 2024 05:29:21 -0400 Received: from www553.your-server.de ([78.46.153.203]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rypzB-0000zD-S0 for emacs-orgmode@gnu.org; Mon, 22 Apr 2024 05:29:20 -0400 Received: from sslproxy05.your-server.de ([78.46.172.2]) by www553.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rypz8-000MKI-Fd; Mon, 22 Apr 2024 11:29:14 +0200 Received: from [141.76.180.10] (helo=comonad) by sslproxy05.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rypz8-0009ru-01; Mon, 22 Apr 2024 11:29:14 +0200 From: Tony Zorman To: Karthik Chikmagalur , emacs-orgmode@gnu.org Subject: Re: Using org-latex-preview in other major modes In-Reply-To: <87o7a2gj38.fsf@gmail.com> References: <87edbhljr7.fsf@hyperspace> <874jcdf4hj.fsf@gmail.com> <87wmp8l6dg.fsf@hyperspace> <87y19oe4yd.fsf@gmail.com> <87cyqyqp1w.fsf@hyperspace> <87cyqi8rb6.fsf@hyperspace> <87o7a2gj38.fsf@gmail.com> User-Agent: Notmuch/0.38.3, Emacs 30.0.50 Date: Mon, 22 Apr 2024 11:29:13 +0200 Message-ID: <87sezdpwye.fsf@hyperspace> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Authenticated-Sender: mail@tony-zorman.com X-Virus-Scanned: Clear (ClamAV 0.103.10/27252/Sun Apr 21 10:23:14 2024) Received-SPF: pass client-ip=78.46.153.203; envelope-from=mail@tony-zorman.com; helo=www553.your-server.de X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_SBL_A=0.1 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Spam-Score: -5.88 X-Migadu-Queue-Id: 32F067EE9E X-Migadu-Spam-Score: -5.88 X-Migadu-Scanner: mx10.migadu.com X-TUID: T7dQn+6hdkc6 On Sun, Apr 21 2024 20:41, Karthik Chikmagalur wrote: >> Anyways, before I put this off for much longer, there is some more code >> attached. Live previews (and general environments) work now, and besides >> the above mentioned points there were no new surprises waiting=E2=80=94a= t least >> for getting the basic functionality to work. > > Thank you for the update! This looks promising. I'll test it when I > have time. > >> I did notice that precompilation being a bit flaky. In the end, this >> was the result of importing local packages; with the precompilation >> happening somewhere in /tmp/, access to these files wasn't given. >> haven't looked too closely into this=E2=80=94and it's probably a use-case >> that's specific to LaTeX-mode=E2=80=94but it seems worth considering > > Sorry, I should have mentioned this in my original write-up. There is a > reason for this, as explained below. This issue should not be happening > in most cases though, so I'll need more details to help. > >> (lots of people carry one big style file around that they include in >> all of their projects). > > This is true of Org mode files that are intended for LaTeX export too, > but we avoid this problem in Org. > > 1. Why we precompile in /tmp: > > Precompilation is a blocking operation, so we want to do it as > infrequently as possible. Imagine if LaTeX previews in every Org > buffer/file you opened required a precompile step that blocked Emacs > for 3 seconds. > > Precompiled dump files are identified by a hash that includes the > preamble and a default-directory. If we precompile in /tmp (or some > other fixed directory), we can reuse dump files for all Org buffers > that have the same preamble, irrespective of where they're located. > > Precompiled files are stored in org-persist and don't expire for a > long time. So we'd like to avoid generating loads of them, and reuse > them whenever possible. > > 1a. Why is precompilation a blocking operation? > > It doesn't have to be, but including it in the async chain is a > little annoying. It can be made async in the future. > > 2. What happens if the user includes a directory-local .sty, .cls or > other tex files in the header? > > When precompiling, we check the header to see if it has an \input{} > or \include{} statement. If it does, we assume that there are local > dependencies and precompile it in the default-directory. See > org-latex-preview--create-tex-file for the implementation of this > logic. > > Is there some other common way that a LaTeX file can have local > dependencies? \usepackage accepts relative paths, although I think it will generate a warning since the package called will provide =C2=ABpkg=C2=BB instead of .relative/path/to/=C2=ABpkg=C2=BB. Either way, it's not uncommon to see thi= ngs like \usepackage[opt1, opt2=3Dlf]{style/nested/too/deeply/style} Modulo Windows, one might check for slashes in \usepackage invocations, since I don't think TeX packages can have those. (Users *should* really add /path/to/=C2=ABpkg=C2=BB to LaTeX's search path,= but that will never happen :)) > 3. How to force precompilation to occur in the default-directory instead > of in /tmp: > > Based on 1 and 2, the easiest way would be to add an \input{} or > \include{} statement to the preamble. The current test is very > simple, you can even place it in a LaTeX comment and it should work. This does indeed work; thanks! Tony --=20 Tony Zorman | https://tony-zorman.com/