From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id 4P9KG7uNE2ZMTgAAqHPOHw:P1 (envelope-from ) for ; Mon, 08 Apr 2024 08:24:59 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id 4P9KG7uNE2ZMTgAAqHPOHw (envelope-from ) for ; Mon, 08 Apr 2024 08:24:59 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=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"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1712557499; 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=FKFQLadQNoYykfwExeQBptm1m6CqGZNULTBIVhehHyc=; b=T8k7LTCrJHdkryt3TKZw5EsHyzluIdOjMbRg68hNZG3XNQ5Txl4CfrPR/9fVdgkRL2GsRq LicrnqgbvyiPKR0loig/i5jI0eE0LRXsdluZANIPld9dCD82DUzhvotVGu+hjJfjB0kZhQ meaHSCMI8ztRaJuPW/V/T9ak49GRgdvVBYINV+qFX7xaQ8qmbY13U/P6Fmy7Lkk2+zZV2e dqkJtSzOgc5QF8aS3T7N/EsiwzDfqc2vSIrP8vqigD0QuF+pzKMUneFDugZuovZeUu/zZP xXTXmcTLCJw2u/sKYtBRGA3CbYOPzmPnDAiZG6xWsh7yHBvGNRy/h7LCmHDUMg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1712557499; a=rsa-sha256; cv=none; b=Vk44Vnpd5gIwv3onNfccpDB8DjQiUtRTmTlFLIFi6Lblsu9B9k4cUF2ccGTxlQ7IcNgRFl OAw7xcumgoGfr7kxQE8yevRAiDTLgTj/gqIlxahn/B5A2esBels7bUETvlEY99HjKYJxlw 8mYhh6N82rlg/kqEiCDNQ+cskgOEnkpxjhsgpr9s9Q5ZWvKO9ofi8o8x+uxkfoiJkDhreB w1h90AdLymSar9+QYQO0TUcReM9nB6kpQjqq7ljByqmcueTzJGuH0gsMftIzZX4pCb0nlY ReyEEY07vzzOlkzup5HEWpVwVMBQ0x+y/A0pAGY1lBYsReTetDuQ6pwzVrwF8A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=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"; dmarc=none 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 EB3343EC9A for ; Mon, 8 Apr 2024 08:24:58 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rtiQF-0006gB-RE; Mon, 08 Apr 2024 02:24:03 -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 1rtiQD-0006ff-Bl for emacs-orgmode@gnu.org; Mon, 08 Apr 2024 02:24:01 -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 1rtiQB-0008Je-JB for emacs-orgmode@gnu.org; Mon, 08 Apr 2024 02:24:01 -0400 Received: from sslproxy06.your-server.de ([78.46.172.3]) by www553.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rtiQ8-000L7y-QO; Mon, 08 Apr 2024 08:23:56 +0200 Received: from [141.76.179.178] (helo=comonad) by sslproxy06.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rtiQ8-000QpG-Jq; Mon, 08 Apr 2024 08:23:56 +0200 From: Tony Zorman To: Karthik Chikmagalur , emacs-orgmode@gnu.org Subject: Re: Using org-latex-preview in other major modes In-Reply-To: <874jcdf4hj.fsf@gmail.com> References: <87edbhljr7.fsf@hyperspace> <874jcdf4hj.fsf@gmail.com> User-Agent: Notmuch/0.38.3, Emacs 30.0.50 Date: Mon, 08 Apr 2024 08:23:55 +0200 Message-ID: <87wmp8l6dg.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/27238/Sun Apr 7 10:25:54 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-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -5.87 X-Spam-Score: -5.87 X-Migadu-Queue-Id: EB3343EC9A X-Migadu-Scanner: mx13.migadu.com X-TUID: ANnAIlakdTX7 On Sun, Apr 07 2024 10:48, Karthik Chikmagalur wrote: > [=E2=80=A6 14 lines elided =E2=80=A6] > > There are two issues with numbering: > - providing an Org-agnostic API point to attach a numbering table to, and > - calculating the new numbering table in LaTeX (or other major-modes). > > For The first issue, we need a way to provide an updated numbering table > during the auto-regeneration of edited fragments. Currently this is > done implicitly by calling `org-latex-preview--place-from-elements' from > the `--regenerate-overlay` function. > > The second requires fast numbering table updates. We do it in Org by > mapping over the org-element cache (see > `org-latex-preview--get-numbered-environments'). Even this is too slow > sometimes, so we suspend numbering updates when live-previewing until > the cursor exits the fragment. Parsing the LaTeX buffer from point to > the end when (re)generating each preview is going to be too slow, so > you'll have to create some kind of cache and update it incrementally. Thanks for taking a look! It indeed seems that caching will be the most work to properly implement. However, I'm quite happy to not care about numbers for now and make sure the other stuff works correctly first before tackling this. > [=E2=80=A6 14 lines elided =E2=80=A6] > > `org-latex-preview-auto--detect-fragments-in-change' is written for > speed. It only does quick text-matching and is thus mostly Org-agnostic, > except for a call to a numbering calculation near the end. This should > be easy to adapt. The problem is the function it calls, > `org-latex-preview-auto--maybe-track-element-here', which finds the > bounds of the inserted LaTeX fragment using org-element and > conditionally sets up a preview overlay. You will need an equivalent of > this for LaTeX-mode. > > Since you have auto-mode working already, live previews should be quite > easy to add. From what I can see, you only need to provide your own > `org-latex-preview-live--ensure-overlay'. This function creates the > preview overlay next to or under the LaTeX fragment. All the other live > preview code only changes overlay properties or calls > `--regenerate-overlay`, which you've already implemented. Besides `org-latex-preview-auto--maybe-track-element-here`, I was mostly talking about `org-latex-preview-live--src-buffer-setup` and `org-latex-preview-live--ensure-overlay`, which I think will be the main targets. The latter seems to be quite a straightforward translation (especially my current constraints of not caring about environments), but the former seems to require a bit more work. Then again, maybe I'm being too negative=E2=80=94after taking another quick look at the code I th= ink you're right in that this should not be impossible to overcome. I'll try to conjure up some time this week to get live previews up and running; will report back if I hit any unforeseen major bumps. Tony --=20 Tony Zorman | https://tony-zorman.com/