GNU bug report logs - #79708
14.1.0; [PATCH] New feature: preview-point

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: auctex; Reported by: Al Haji-Ali <abdo.haji.ali@HIDDEN>; Keywords: patch; dated Mon, 27 Oct 2025 21:01:01 UTC; Maintainer for auctex is bug-auctex@HIDDEN.

Message received at 79708 <at> debbugs.gnu.org:


Received: (at 79708) by debbugs.gnu.org; 25 Nov 2025 20:30:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 25 15:30:35 2025
Received: from localhost ([127.0.0.1]:42245 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vNzgJ-0002rU-0S
	for submit <at> debbugs.gnu.org; Tue, 25 Nov 2025 15:30:35 -0500
Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:54751)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <abdo.haji.ali@HIDDEN>)
 id 1vNzDv-0003z7-3a
 for 79708 <at> debbugs.gnu.org; Tue, 25 Nov 2025 15:01:15 -0500
Received: by mail-ed1-x52f.google.com with SMTP id
 4fb4d7f45d1cf-640c1fda178so9825773a12.1
 for <79708 <at> debbugs.gnu.org>; Tue, 25 Nov 2025 12:01:15 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1764100869; x=1764705669; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=xL+cybS16P7w6K+w/dA4ERxm33GS1CVGBljmbDXZZW8=;
 b=ayc+3qOFmymUzLh6qcmmKb/KGlmVxI14hyLWTOgOqGEFNlCEgnjLgcSeD6gt2Pw5rs
 NuwIsE8vD3oi+QTXhQiGdgXXvyVnLiEtnO3MOabNQh30/9fqOsfr1aVsLh9L4zoin3TB
 5m144Awl/DRX/l6reUQB030UfWScHVfvsbK0aZMX+evZkcw5U83+uM/y8S5CIKgSulRA
 bkDeJptuSEl1JF8Jb3UpwP0SQdaNmU3M2INUG+i8LkUpj3EsQuVFeihmIx9wYuShkLhb
 FnHV8WYRnnR58eD4cD0jjDDDfx6mmftrJEXXeqRlfc9yd8diZetl8wrTV/C3An5eUt0Q
 KX0A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1764100869; x=1764705669;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=xL+cybS16P7w6K+w/dA4ERxm33GS1CVGBljmbDXZZW8=;
 b=JecjqEcKzO3z3DmDbDNr8E///05l83u2hhI7LLpou1WeCig7b6QidUgSXif8sShfmh
 h4WK1pi/2b2UApIHL71xLYdzIdTGnEEPW26CAkRs/MfPUkL8qixUcpf+Nozj0y4+yQo6
 1Z5vQ8b5/x2R6VOs8yZpFCW0txLyG/evSk81pPpQImar6w0FfNWKafWLckiwK71/gMgf
 CU1guEHSFeh37WDALdhdAfRZ2/dLv/DV/TCc2B6AXDENuSKkPu576rgHTPQXzLZ5g4IE
 PiZK5q8UjTuix8C5fL0gxW16XcutnM2jNWCzsVjLmc/7CCb6En6u6XOAHYtPMODoG0Gn
 yMiw==
X-Gm-Message-State: AOJu0YzJTuE3Wajhb4JNEkaPfv8u3Fr+sCSwtQNIPkchQpJI3WTRAwz7
 3GHhG6eLZZUZwALZOa5QEgGvOIG8h6vsiOsY29Z/l7objYwmkvY/ss/EZGTNRMVEBEo=
X-Gm-Gg: ASbGncsp8/7p9oyvCOYpPfrlpceIszFztBmm8fxfURnLuxVAb4AjIzuxZiLfmqXZsdn
 NagjFFjJuQBNZymY0+qvB4YTyAj4mDI8VH+8n49M4/rp+S9zfoiRQjYtE20tY9OfIqG7+CGfy0y
 /rWdKj+rmDg82wShGReh8tVw0evjqUThLMjqz34MBKzBM7NDrYTlmjK1DGRgtauza7H5hOE5qAs
 Tb9eM6jCT9IZwHMpAVRtFWV5Jj09xhpSvZL3XJtoTUnKa7nJPWr2yh7T0F64KCSVFBbmh3KJOUu
 mvhNPdcoVf8cPan0cIjOBEyHRY0wq21DbDE3pGG+JwebA1bm47qrD6FtL5ouA8O20xzSo6iloeg
 j0MhszzZE5iZS+AAj8qJKERdWKYnw3I4HqIa+NN38WT3YCjHHa2B33D+Z4O3v9gT6tBWbzi/HYk
 ASRtCwM+OwixdLC/1/7TIzo1SrC3SxzUUU
X-Google-Smtp-Source: AGHT+IH6hgVhhxs3RoJaYcpNalLIqaVaDf7OuRXSXhe4rkordFCjupxiE93xmq0B6t3hQw0LptWdOw==
X-Received: by 2002:a05:6402:1ecb:b0:641:1cd6:fee9 with SMTP id
 4fb4d7f45d1cf-64555b86ce3mr13962370a12.1.1764100868760; 
 Tue, 25 Nov 2025 12:01:08 -0800 (PST)
Received: from localhost ([2a02:908:1087:8480:1c5f:9af6:eb48:80c4])
 by smtp.gmail.com with ESMTPSA id
 4fb4d7f45d1cf-645363b66e5sm15556315a12.14.2025.11.25.12.01.08
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 25 Nov 2025 12:01:08 -0800 (PST)
From: Al Haji-Ali <abdo.haji.ali@HIDDEN>
To: "Paul D. Nelson" <ultrono@HIDDEN>
Subject: Re: bug#79708: 14.1.0; [PATCH] New feature: preview-point
In-Reply-To: <uxsg7tv7j2j8o8.fsf@HIDDEN>
References: <uxsg7tv7j2j8o8.fsf@HIDDEN>
Date: Tue, 25 Nov 2025 21:01:03 +0100
Message-ID: <m2ikex3mrk.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79708
Cc: 79708 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi again,

A couple of replies to points I missed:

On 22/11/2025, Paul D. Nelson wrote:
>> +                                  ;; Restore point to current one before
>> +                                  ;; placing preview
>> +                                  (goto-char point-current)
> Is there a new reason for adding this goto-char?

Absolutely. `preview-place-preview` calls the 'place' function. This
sets the preview properties and could show the buframe if the cursor is
on top of the overlay. Before, this wasn't possible because the point
was always set to be on top of the overlay when the preview is placed
and there's no way for preview-toggle to know the real cursor position.

>> +                (eq (overlay-buffer ov) (window-buffer))
> Consider: (current-buffer)
I use window-buffer because this function is sometimes called from
within a `with-current-buffer` so (current-buffer) is bogus for purposes
of determining if the currently displayed buffer is the same as the
overlay-buffer. Although, I am realizing this could be unnecessary, so
I'll check it.

-- Al




Information forwarded to bug-auctex@HIDDEN:
bug#79708; Package auctex. Full text available.

Message received at 79708 <at> debbugs.gnu.org:


Received: (at 79708) by debbugs.gnu.org; 25 Nov 2025 20:30:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 25 15:30:34 2025
Received: from localhost ([127.0.0.1]:42238 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vNzgH-0002nB-2Y
	for submit <at> debbugs.gnu.org; Tue, 25 Nov 2025 15:30:34 -0500
Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]:44119)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <abdo.haji.ali@HIDDEN>)
 id 1vNytU-0002Ls-Pk
 for 79708 <at> debbugs.gnu.org; Tue, 25 Nov 2025 14:40:10 -0500
Received: by mail-ej1-x62e.google.com with SMTP id
 a640c23a62f3a-b736cd741c1so1039993566b.0
 for <79708 <at> debbugs.gnu.org>; Tue, 25 Nov 2025 11:40:08 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1764099602; x=1764704402; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=F6h1akNlEQPKVejHpB9Ylq4HTRxFjEH7BxPIuxel814=;
 b=TG6LHyzjcYFB3hP1odQPcojZFsgA1jEAXqLwx/sSO/50u7U3vZRCt+H9GD3a/Fy1+O
 HF9vD7UfEhWIN61qrohuD8+NEusbtS46scWM/HGjnLbV2xrBvXeQNNdvYZH5h3XXlDu7
 u3/sAs7ECP9RI2YeGq/UAE4n5txXHS6hhhaYWRioIRy8qGpSwKc7aWcZKZXOGRfc653C
 umpW5afvCuEXdqkrSzp+OWEH3o8TAlcA5cz4wDdTPc1mRnk+iIlhcT27mR8h7vkt9lT3
 /xJFM9g0TCEXTTW6RGdrKBM6VeZsNX+y+txQqlmOZXsI1K8szIyF8Ks9KP+F4X/ovj00
 jE+A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1764099602; x=1764704402;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=F6h1akNlEQPKVejHpB9Ylq4HTRxFjEH7BxPIuxel814=;
 b=dg+uvd9YaDLS/93W83OzHWxhupBMOdb35Q0Lagojp+cWmeEbEWqCXYvMOWvBd2MO7h
 IkvQwCXbkvvbH7/go2RWb8RyQFknnZYswcYafhTPKEo/w9ArlkYj9K+LWCtQ37YM/GDe
 q3VQJVUDFSwipw3gpKLvxD2ieIi4s4pq9SZrkkENirTclnHqX4OG/FxThfEPbQnCPUF7
 LcNi/nbZ8w6fhlJ1n9xvD9otVoIh8ASnnjR08A17PgBk7Jex0WEicV5pnyKn1xbk+vCe
 hiS9j07KBH5A56EUwRJOBg0j7F/PK8A5m4hBVPYQxTMifBudPz6cvIS6CHrqky3u2dxB
 U5jw==
X-Gm-Message-State: AOJu0YzrnQkK6otij/xtLB8xZX4o2VJuePdXQN2etT/1+q7+sL2l7WLc
 MlennSqiwCIJ9p8ORCEDx8of97hbSuK6T13b+tlcNPsKbrKNQOetukGLAq4l66+yOTY=
X-Gm-Gg: ASbGnct+37yWZosXQyZA8TOTc64w2KL2QCkubRk3LQAWH6X9reZXgXgPJX3In/yPm85
 ZfUpdMjfpVDnGsSDkJoemuyZmfPvDYM3sMX5tozjEa9A9OTgr0NMV4MCHKIiYMf92avNn2LOuRM
 kUZUN7VyBKr22ySxJ6I4nokOpVlvdjSvX49YbBXay3liRBxZ4qmdDsOWERsPlMMf+LgtI8jX7Iz
 bcDwBg4J8TH9Wv88tiJDc/MTvcZETLnrzcakTSJ3d9tf04fDDKYlkJ0ulXaHIhl+gQohWmo1M7b
 9DybSKnV7nVUY6U29CXzWb4wlC+b2FYoa4IwB/dV+0D+1O6NLM2zs2+e/Kcl/iq0la26UL1dasP
 wkUJZBj5+J9nVJaxENiTyB1tM7nbWfRl0NRTP03hfpdjT0650QyT9A2+lmFsN5K+Dm1UGaM/WDh
 RyZE683bx3jqLTanJEmrzY5YlbRLX6mogzqb4kB3PcSd0=
X-Google-Smtp-Source: AGHT+IGsMy4F8ru30jXDZoAuw5X2cEtfMKcrWwo2OJMkESy0eyBOJo7fR7dGWlvGDoKTjQ2hZwcIdg==
X-Received: by 2002:a17:907:3e10:b0:b76:5143:edea with SMTP id
 a640c23a62f3a-b76716953e1mr1683882266b.30.1764099602063; 
 Tue, 25 Nov 2025 11:40:02 -0800 (PST)
Received: from localhost ([2a02:908:1087:8480:1c5f:9af6:eb48:80c4])
 by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-b765c1379ddsm1575246366b.0.2025.11.25.11.40.01
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 25 Nov 2025 11:40:01 -0800 (PST)
From: Al Haji-Ali <abdo.haji.ali@HIDDEN>
To: "Paul D. Nelson" <ultrono@HIDDEN>
Subject: Re: bug#79708: 14.1.0; [PATCH] New feature: preview-point
In-Reply-To: <uxsg7tv7j2j8o8.fsf@HIDDEN>
References: <uxsg7tv7j2j8o8.fsf@HIDDEN>
Date: Tue, 25 Nov 2025 20:32:43 +0100
Message-ID: <m2h5uh52n8.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79708
Cc: 79708 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello Paul,

On 22/11/2025, Paul D. Nelson wrote:
> I wonder whether the default should instead be a new setting "nil",
> meaning that previews at point are not be displayed at all (the current
> default behavior in AUCTeX).

I agree that the current situation is not ideal, in the sense that the
combination/naming of customization variables are not 100% coherent.

However, one use case for `preview-leave-open-previews-visible` (V) is
controlling if an icon is displayed in certain cases, e.g., when the
preview is disabled after editing or when it is being re-generated,
instead of the (outdated) preview. This use case is always relevant for
all values of `preview-point-where` and `preview-always-show`.

The other point is that, currently, the placement of the icon itself is
also determined by the value of `preview-point-where`. If we use a nil
value to denote icons, then we would fix the placement of the icon which
seems unnecessarily inconsistent with the new increased customization.

> I noticed the following issues (A), (B), (C):
What emacs version you are using and what value of `preview-auto-reveal`
(I mainly have my tests with it being set to `t`)?

>
> (A) With
>
>   (setq preview-always-show t)
>   (setq preview-point-where 'buframe)
>
I've seen this issue once, but I thought I already addressed it and I no
longer see it. I also don't recognize the behaviour you describe since
with these settings, calling `preview-at-point` updates the preview,
yeets the cursor out of the source and the preview is shown inline until
one enters it again whereupon it is shown in a buframe. Can you confirm
and/or provide more details?

> (B) With
>
>   (setq preview-leave-open-previews-visible t)
>   (setq preview-always-show nil)
>   (setq preview-point-where 'buframe)
>
> Enter a generated preview, edit it, regenerate it in place (e.g., with
> 'preview-at-point'), and then exit it.  Both the tex source and the
> preview remain visible (until the preview is regenerated, so let's
> suppose automatic previewing is disabled).
>

I don't see this behaviour either, definitely not with buframe. Can you
confirm again and provide more details (source)?  The post-command-hook
`preview-move-point` calls `preview--update-buframe` which should hide
the buframe when the overlay at point does not have the buframe
property, so exiting the source should hide the buframe unless there's a
case I am not considering.

> (C) With
>
>   (setq preview-point-where 'buframe)
>
> The buframe feature doesn't work correctly with a multi-monitor setup.
> On my main monitor, it works fine, but on my other two monitors, it
> either doesn't display at all or displays very far from the original
> preview graphic.  I haven't dug in to debug this.
This is possible and is probably a bug in buframe. I will do some tests
to confirm and fix it there.

> The defcustom signature for the final option does not match the
> documentation (and if we adopt the final option via the customize
> interface, then it won't work correctly).  Either put 'buframe in the
> first entry of the list, or test for the final option via 'listp'.

Apologies, I noticed this mistake after sending the patch. I had already
corrected it to the following, which I will send in an updated patch:

```
(choice
          (const :tag "Before string" before-string)
          (const :tag "After string (default)" after-string)
          (const :tag "On frame" buframe)
          (list :tag "On frame with explicit parameters"
                (const buframe)
                (choice
                 (const :tag "Default" nil)
                 (function :tag "Position function"))
                (alist :tag "Frame parameters")
                (alist :tag "Buffer parameters")))
```

>> +(defface preview-disabled-face
>> +  '((t (:inherit shadow)))
>> +  "Face used when preview is disabled."
>> +  :group 'preview)
>
> It's not clear to me what the purpose of this new face is.  I see that
> it affects the text stored in the before/after-string and strings
> properties of the overlay, but not the actual TeX code.
This face is for the preview itself rather than the source. I believe
the face's background colour will affect all previews, while the
size/foreground colour only has an effect if the preview is an svg
image. I could add this explanation to the docstring.

>> +
>> +(defvar preview--frame nil
>> +  "The last active preview popup frame.")
>
> (Maybe consider something like 'preview--buframe' or 'preview--last-buframe'
> to hint at the domain scope of this variable.)
I prefer frame since that's the type of value, but I will update the
docstring to mention buframe.

> (This looks to be just a whitespace change; my understanding was that we
> usually avoid pure whitespace changes unless we're touching the code
> anyway, but others may know better.)

Indeed, I thought the spacing is wrong and could be fixed in this patch
since the function is being modified, but I can remove this change.

Best regards,
-- Al




Information forwarded to bug-auctex@HIDDEN:
bug#79708; Package auctex. Full text available.

Message received at 79708 <at> debbugs.gnu.org:


Received: (at 79708) by debbugs.gnu.org; 25 Nov 2025 20:27:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 25 15:27:33 2025
Received: from localhost ([127.0.0.1]:42092 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vNzdM-0001py-2U
	for submit <at> debbugs.gnu.org; Tue, 25 Nov 2025 15:27:33 -0500
Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:44522)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <ultrono@HIDDEN>) id 1vNZZo-0001Ai-26
 for 79708 <at> debbugs.gnu.org; Mon, 24 Nov 2025 11:38:09 -0500
Received: by mail-ed1-x532.google.com with SMTP id
 4fb4d7f45d1cf-641977dc00fso6395002a12.1
 for <79708 <at> debbugs.gnu.org>; Mon, 24 Nov 2025 08:38:08 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1764002281; x=1764607081; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:from:to
 :cc:subject:date:message-id:reply-to;
 bh=yHaEMkcIzFWUmiIy/XQ94k6n70FVQdFkGkd5mp6x6x4=;
 b=mxC5pgZDnVWaLQVql5v0EZ9SsJXz293dMG93J5D8BZpIn58Kt2yuhIJ4NVd2ssGorS
 acrbu9Z/7nSiVbcTB/4xRemimpFoW9WXbdHFiCaIttHPg6GvbmwOZybBbfCOKSGQty44
 Jkw7xi5zqnCwnT46R7qMkOv+1pVqAFYyOUib1GpziTd5wsGPjJPHA7QMwnTXE1U/RlTP
 /1ZIeB7iBPH8hOuQnP2rKGbKGqTJRYzW0mYTKgeGvidA8f4OqbHnjR4j9XdPVXfpBRLs
 4X3yinz1ySS44x28v+8x6+npGLU7wS5++M2H/XqwM6OuDxIJhvO9zTU4JQPlSlRqg0P2
 h+mw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1764002281; x=1764607081;
 h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:x-gm-gg
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=yHaEMkcIzFWUmiIy/XQ94k6n70FVQdFkGkd5mp6x6x4=;
 b=VriCMvnZ9Ui7L7l3EI8XBVZ0AeyqLzo3wmhtI1E8SW+gtSEeJswSkLuNJ6sWNFXZDD
 3dDOdAP3rWXZvmZio1Sar2RlJriqktMH82waqwTWI+7Z1Fb6mnDNErQGAMaEcsOBUr1s
 ZfslaAoM8EO5CLblQCRls1sg15sK4xtRD++77ZtyUNlM76lJxnOtM+epEU2MpNDfxz23
 OgYDkILfvLUgCOSL+qodR+mqD1WXLT9gteb0LoEMDbXnkuKiFDTw/xOMqnS8NP3pGIGF
 MQK0aY1jdSY4QuArbI6QBCexQbxE0fo1ezWpA2oHTs9zrh+19wZOjpCR/R+bTtmuh4eg
 2F6Q==
X-Gm-Message-State: AOJu0Yw0SWYJ6rldJg7l/lRJ8MHKceKXxR1pp38219rhNRIzWxPzIafu
 aRuWRDcLbXJEhkRwgpQm/3PWvW3KgtQsHVPgeGHEdvEp62Cm/LJhFRlKSB5/eg==
X-Gm-Gg: ASbGncvKMJE8CPpTSGAStZ1yZSBmwpB0LhKWJT4J2aB8KuMB6ZIR5zCoa2rZixADUWZ
 SpOa3Tjt6UHJqyIzhTFgAVvbd8CF1dIbFK+PDaougKDQHmOSbk+9NS91oQJ3P2WYGJflSuTuqJ6
 eiqZ+M1BON0/gGhKzccWFsCHi7rcdi+QIZEbdU6K2fSBLAwPAtmFr4v5M7duLuaX/L2il76F6j/
 KdM+0yTZ8W6iB8ya2fvLB9bIEMt1WyMPOverTBLfHbHMH+lBZK/HvwvM7mWFPtTeuTtjJeppfWJ
 3zLnkW1n6LbI21JM/EUzEqAzlLEzr8C6uJMoNRBv3VKYp7Mwx3dPWOfWWWw+X+65oCIRWH1KiTr
 VTNOqYIORAmD5DD6QxEe89nP0NM6OmGmJKayele/dvriceZLyNx243vKtbbEPivgy/rSmqquw13
 HCGC2OfAfJ+30XSt4pVI8kGJct4et9k5LPEulm
X-Google-Smtp-Source: AGHT+IFZ929gskraH3vK5oYeDjBabXjydct93r0W+G/84LaVSvEva6VkYTr8eWmXZwybc+YZy7cwfA==
X-Received: by 2002:a05:6402:2714:b0:640:b1cf:f800 with SMTP id
 4fb4d7f45d1cf-64554320e36mr11047099a12.4.1764002280875; 
 Mon, 24 Nov 2025 08:38:00 -0800 (PST)
Received: from localhost (users-1190.st.net.au.dk. [130.225.0.251])
 by smtp.gmail.com with UTF8SMTPSA id
 4fb4d7f45d1cf-64536443337sm12452610a12.23.2025.11.24.08.38.00
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 24 Nov 2025 08:38:00 -0800 (PST)
From: "Paul D. Nelson" <ultrono@HIDDEN>
To: Al Haji-Ali <abdo.haji.ali@HIDDEN>
Subject: Re: bug#79708: 14.1.0; [PATCH] New feature: preview-point
In-Reply-To: <m2o6oxwsl8.fsf@HIDDEN> (message from Al Haji-Ali on Wed, 19
 Nov 2025 23:44:19 +0100)
Date: Sat, 22 Nov 2025 18:09:43 +0100
Message-ID: <uxsg7tv7j2j8o8.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 79708
Cc: 79708 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

Hi Al,

Thanks, I've been testing this the past few days and it's looking
very good!  Response and comments below.

> - `preview-point-where`: default 'before-string, can be set to
>   'after-string and 'buframe as well.

I wonder whether the default should instead be a new setting "nil",
meaning that previews at point are not be displayed at all (the current
default behavior in AUCTeX).  To explain more fully, there are three
relevant options:

- 'preview-leave-open-previews-visible' (call it "V")
- 'preview-point-where' (call it "W")
- 'preview-always-show' (call it "S")

The current behavior is as follows (independent of W):

| S   | V   | shown at point |
|-----+-----+----------------|
| t   | nil | TeX icon       |
| nil | nil | preview        |
| t   | t   | preview        |
| nil | t   | preview        |

First, the difference between the first two lines seems odd.  Why should
S, which ostensibly controls preview visibility *away* from point, also
affect whether it is the TeX icon or the preview graphic that is shown
*at* point?

Next, the option V currently has two unrelated effects:

(1) causing the preview graphic (rather than TeX icon) to be shown at
point, and

(2) keeping the preview graphic visible when in the "disabled" state
(post-edit, pre-regeneration).

What do you think about refactoring so that (1) is controlled entirely
by W (rather than by some odd combination of S and V, as above)?
Specifically, the proposal is that if W is nil, then the TeX icon is
shown; otherwise, the preview graphic is shown, and the (non-nil) value
of W controls the precise location.  This would also address what I
found odd about the above table.

With this change, the only effect of V would be (2).

> Also, I wasn't sure if I should respect `preview-auto-reveal` when
> `preview-always-show` is nil, so I've done that for now. This means that
> to truly get the same behaviour as preview-point, set
> `preview-auto-reveal` to t. Otherwise, the default value of that
> variable only shows the preview on specific key strokes.

This also seems right to me, FWIW, because it maximizes flexibility.

I noticed the following issues (A), (B), (C):

(A) With

  (setq preview-always-show t)
  (setq preview-point-where 'buframe)

Create an equation environment with some math, and do 'preview-point'.
Alternatively, add some math at the end of an existing equation, and do
'preview-point'.  When the buframe preview updates, it does not initially
have the correct bounds -- it's typically too small to accommodate the
previewed graphic.  The bounds become correct after exiting and
re-entering the preview.

(B) With

  (setq preview-leave-open-previews-visible t)
  (setq preview-always-show nil)
  (setq preview-point-where 'buframe)

Enter a generated preview, edit it, regenerate it in place (e.g., with
'preview-at-point'), and then exit it.  Both the tex source and the
preview remain visible (until the preview is regenerated, so let's
suppose automatic previewing is disabled).

If we instead use

  (setq preview-leave-open-previews-visible nil)

then the TeX icon remains visible post-edit, pre-regeneration.

In either case, it seems odd that 'preview-always-show' is nil, yet the
preview and/or TeX icon stick around after point leaves the preview.

(C) With

  (setq preview-point-where 'buframe)

The buframe feature doesn't work correctly with a multi-monitor setup.
On my main monitor, it works fine, but on my other two monitors, it
either doesn't display at all or displays very far from the original
preview graphic.  I haven't dug in to debug this.

--

OK, now some comments on the patch (some of which are stylistic, please
feel free to ignore):

> +By default, previews are always shown when available, but this can be
> +disabled by setting @code{preview-always-show} to @code{nil}. In this
> +case, the preview is only shown when the cursor enters the corresponding
> +TeX source.

Maybe mention 'preview-point-where' here.

> +;;; preview-point customizations and variables.
> +(defcustom preview-always-show t
> +  "If non-nil, always show previews.
> +
> +When nil, previews are only shown when a cursor enters their source.  See
> +`preview-point-where' to control where they are shown."
> +  :type 'boolean)

Check the fill on this docstring (M-q); with standard settings, I get:

When nil, previews are only shown when a cursor enters their source.
See `preview-point-where' to control where they are shown."

> +
> +(defcustom preview-point-where 'before-string
> +  "Specifies where to show the preview relative to TeX source.
> +
> +Can be `before-string', `after-string' to show the preview at before or
> +after the TeX code or `buframe' to show it in a separate frame (the
> +`buframe' package must be installed).  Can also be \\='(buframe FN-POS
> +FRAME-PARAMETERS BUF-PARAMETERS) where FN-POS is a position
> +function (default is `buframe-position-right-of-overlay') and
> +FRAME-PARAMETERS is an alist of additional frame parameters, default is
> +nil and BUF-PARAMETERS is an alist of buffer local variables and their
> +values."
> +  :type '(choice
> +          (const :tag "Before string" before-string)
> +          (const :tag "After string (default)" after-string)

"(default)" seems misplaced in the docstring

> +          (const :tag "On frame" buframe)
> +          (list :tag "On frame with explicit parameters"
> +                (function :tag "Position function")
> +                (alist :tag "Frame parameters")
> +                (alist :tag "Buffer parameters"))))
> +

The defcustom signature for the final option does not match the
documentation (and if we adopt the final option via the customize
interface, then it won't work correctly).  Either put 'buframe in the
first entry of the list, or test for the final option via 'listp'.

> +(defface preview-disabled-face
> +  '((t (:inherit shadow)))
> +  "Face used when preview is disabled."
> +  :group 'preview)

It's not clear to me what the purpose of this new face is.  I see that
it affects the text stored in the before/after-string and strings
properties of the overlay, but not the actual TeX code.

> +
> +(defvar preview--frame nil
> +  "The last active preview popup frame.")

(Maybe consider something like 'preview--buframe' or 'preview--last-buframe'
to hint at the domain scope of this variable.)

> +
>  (defun preview-string-expand (arg &optional separator)
>    "Expand ARG as a string.
>  It can already be a string.  Or it can be a list, then it is
> @@ -709,6 +745,8 @@ and tries to restart Ghostscript if necessary."
>                (let* ((err (concat preview-gs-answer "\n"
>                                    (process-name process) " " string))
>                       (ov (preview-gs-behead-outstanding err)))
> +                (when ov
> +                  (preview-overlay-updated ov))
>                  (when (and (null ov) preview-gs-queue)
>                    (save-excursion
>                      (goto-char (if (marker-buffer (process-mark process))
> @@ -1430,16 +1468,16 @@ Try \\[ps-run-start] \\[ps-run-buffer] and \
>           (ps-open
>            (let ((string
>                   (concat
> -                (mapconcat #'shell-quote-argument
> -                            (append (list
> -                                     preview-gs-command
> -                                     outfile)
> -                                    preview-gs-command-line)
> -                            " ")
> -                 "\nGS>"
> -                 preview-gs-init-string
> -                 (aref (overlay-get ov 'queued) 1)
> -                 err)))
> +                  (mapconcat #'shell-quote-argument
> +                             (append (list
> +                                      preview-gs-command
> +                                      outfile)
> +                                     preview-gs-command-line)
> +                             " ")
> +                  "\nGS>"
> +                  preview-gs-init-string
> +                  (aref (overlay-get ov 'queued) 1)
> +                  err)))

(This looks to be just a whitespace change; my understanding was that we
usually avoid pure whitespace changes unless we're touching the code
anyway, but others may know better.)

>              (lambda () (interactive "@") (preview-mouse-open-error string))))
>           (str
>            (preview-make-clickable
> @@ -1463,7 +1501,8 @@ Try \\[ps-run-start] \\[ps-run-buffer] and \
>                                      (apply #'preview-mouse-open-eps
>                                             args))])))))))
>      (overlay-put ov 'strings (cons str str))
> -    (preview-toggle ov)))
> +    (if preview-always-show
> +        (preview-toggle ov))))
>  
>  (defun preview-gs-transact (process answer)
>    "Work off Ghostscript transaction.
> @@ -1494,7 +1533,8 @@ given as ANSWER."
>                                      (preview-ascent-from-bb
>                                       bbox)
>                                      (aref preview-colors 2))))
> -            (overlay-put ov 'queued nil)))))
> +            (overlay-put ov 'queued nil)
> +            (preview-overlay-updated ov)))))
>      (while (and (< (length preview-gs-outstanding)
>                     preview-gs-outstanding-limit)
>                  (setq ov (pop preview-gs-queue)))
> @@ -1706,19 +1746,24 @@ icon is cached in the property list of the SYMBOL."
>  (defun preview-ascent-from-bb (bb)
>    "This calculates the image ascent from its bounding box.
>  The bounding box BB needs to be a 4-component vector of
> -numbers (can be float if available)."
> +numbers (can be float if available).
> +
> +If `preview-point-where' is set to \\='buframe, this simply returns
> +\\='center."

The docstring in this last case could be reworded so as to include the
additional buframe option.

>    ;; baseline is at 1in from the top of letter paper (11in), so it is
>    ;; at 10in from the bottom precisely, which is 720 in PostScript
>    ;; coordinates.  If our bounding box has its bottom not above this
>    ;; line, and its top above, we can calculate a useful ascent value.
>    ;; If not, something is amiss.  We just use 100 in that case.
> -
> -  (let ((bottom (aref bb 1))
> -        (top (aref bb 3)))
> -    (if (and (<= bottom 720)
> -             (> top 720))
> -        (round (* 100.0 (/ (- top 720.0) (- top bottom))))
> -      100)))
> +  (if (or (eq preview-point-where 'buframe)
> +          (eq (car-safe preview-point-where) 'buframe))

This last condition will not be satisfied if we customize according to
the defcustom signature.

> +      'center
> +    (let ((bottom (aref bb 1))
> +          (top (aref bb 3)))
> +      (if (and (<= bottom 720)
> +               (> top 720))
> +          (round (* 100.0 (/ (- top 720.0) (- top bottom))))
> +        100))))
>  
>  (defface preview-face '((((background dark))
>                           (:background "dark slate gray"))
> @@ -2082,32 +2127,46 @@ If EVENT is given, it indicates the window where the event
>  occured, either by being a mouse event or by directly being
>  the window in question.  This may be used for cursor restoration
>  purposes."
> -  (let ((old-urgent (preview-remove-urgentization ov))
> -        (preview-state
> -         (if (if (eq arg 'toggle)
> -                 (null (eq (overlay-get ov 'preview-state) 'active))
> -               arg)
> -             'active
> -           'inactive))
> -        (strings (overlay-get ov 'strings)))
> -    (unless (eq (overlay-get ov 'preview-state) 'disabled)
> -      (overlay-put ov 'preview-state preview-state)
> -      (if (eq preview-state 'active)
> -          (progn
> -            (overlay-put ov 'category 'preview-overlay)
> -            (if (eq (overlay-start ov) (overlay-end ov))
> -                (overlay-put ov 'before-string (car strings))
> +  (let ((old-urgent (preview-remove-urgentization ov)))
> +    (unwind-protect
> +        (let ((preview-state
> +               (if (if (eq arg 'toggle)
> +                       (null (eq (overlay-get ov 'preview-state) 'active))
> +                     arg)
> +                   'active
> +                 'inactive))
> +              (prop (or (and (consp preview-point-where)
> +                             (car preview-point-where))
> +                        preview-point-where))

Consider the following, which seems equivalent for practical purposes:

              (prop (if (consp preview-point-where)
                        (car preview-point-where)
                      preview-point-where))


> +              (strings (overlay-get ov 'strings)))
> +          (unless (eq (overlay-get ov 'preview-state) 'disabled)
> +            (overlay-put ov 'preview-state preview-state)
> +            (if (eq preview-state 'active)
> +                (progn
> +                  (overlay-put ov 'category 'preview-overlay)
> +                  (if (eq (overlay-start ov) (overlay-end ov))
> +                      (overlay-put ov prop (car strings))
> +                    (when preview-always-show
> +                      (dolist (prop '(display keymap mouse-face help-echo))
> +                        (overlay-put ov prop
> +                                     (get-text-property 0 prop
> +                                                        (car strings)))))
> +                    (overlay-put ov prop nil))
> +                  (overlay-put ov 'face nil))
>                (dolist (prop '(display keymap mouse-face help-echo))
> -                (overlay-put ov prop
> -                             (get-text-property 0 prop (car strings))))
> -              (overlay-put ov 'before-string nil))
> -            (overlay-put ov 'face nil))
> -        (dolist (prop '(display keymap mouse-face help-echo))
> -          (overlay-put ov prop nil))
> -        (overlay-put ov 'face 'preview-face)
> -        (unless (cdr strings)
> -          (setcdr strings (preview-inactive-string ov)))
> -        (overlay-put ov 'before-string (cdr strings)))
> +                (overlay-put ov prop nil))
> +              (when preview-always-show
> +                (overlay-put ov 'face 'preview-face))
> +              (unless (cdr strings)
> +                ;; If `preview-always-show' is nil, then we should
> +                ;; always show the preview (i.e. leave it open) when the
> +                ;; preview is "inactive".
> +                (let ((preview-leave-open-previews-visible
> +                       (or preview-leave-open-previews-visible
> +                           (not preview-always-show))))
> +                  (setcdr strings (preview-inactive-string ov))))

This is an instance where, as discussed above, I feel that
'preview-leave-open-previews-visible' is doing more work than it should
-- it's controlling whether to show the TeX icon or the preview graphic,
but perhaps we should defer that decision to 'preview-point-where'.

> +              (overlay-put ov prop (cdr strings)))
> +            (preview--update-buframe ov t)))
>        (if old-urgent
>            (apply #'preview-add-urgentization old-urgent))))
>    (if event
> @@ -2127,13 +2186,14 @@ purposes."
>  
>  (defun preview-mark-point ()
>    "Mark position for fake intangibility."
> -  (when (eq (get-char-property (point) 'preview-state) 'active)
> -    (unless preview-last-location
> -      (setq preview-last-location (make-marker)))
> -    (set-marker preview-last-location (point))
> -    (set-marker preview-marker (point))
> -    (preview-move-point))
> -  (set-marker preview-marker (point)))
> +  (when preview-always-show
> +    (when (eq (get-char-property (point) 'preview-state) 'active)
> +      (unless preview-last-location
> +        (setq preview-last-location (make-marker)))
> +      (set-marker preview-last-location (point))
> +      (set-marker preview-marker (point))
> +      (preview-move-point))
> +    (set-marker preview-marker (point))))
>  
>  (defun preview-restore-position (ov window)
>    "Tweak position after opening/closing preview.
> @@ -2177,17 +2237,19 @@ overlays not in the active window."
>                                (current-buffer))
>                            (- pt (marker-position preview-marker))))))
>            (preview-open-overlays lst)
> -        (while lst
> -          (setq lst
> -                (if (and
> -                     (eq (overlay-get (car lst) 'preview-state) 'active)
> -                     (> pt (overlay-start (car lst))))
> -                    (overlays-at
> -                     (setq pt (if (and distance (< distance 0))
> -                                  (overlay-start (car lst))
> -                                (overlay-end (car lst)))))
> -                  (cdr lst))))
> -        (goto-char pt)))))
> +        (when preview-always-show
> +          (while lst
> +            (setq lst
> +                  (if (and
> +                       (eq (overlay-get (car lst) 'preview-state) 'active)
> +                       (> pt (overlay-start (car lst))))
> +                      (overlays-at
> +                       (setq pt (if (and distance (< distance 0))
> +                                    (overlay-start (car lst))
> +                                  (overlay-end (car lst)))))
> +                    (cdr lst))))
> +          (goto-char pt)))))
> +  (preview--update-buframe))
>  
>  (defun preview-open-overlays (list &optional pos)
>    "Open all previews in LIST, optionally restricted to enclosing POS."
> @@ -2202,7 +2264,8 @@ overlays not in the active window."
>  
>  (defun preview--open-for-replace (beg end &rest _)
>    "Make `query-replace' open preview text about to be replaced."
> -  (preview-open-overlays (overlays-in beg end)))
> +  (when preview-always-show
> +    (preview-open-overlays (overlays-in beg end))))
>  
>  (defcustom preview-query-replace-reveal t
>    "Make `query-replace' autoreveal previews."
> @@ -2314,20 +2377,25 @@ active (`transient-mark-mode'), it is run through `preview-region'."
>  
>  (defun preview-disabled-string (ov)
>    "Generate a before-string for disabled preview overlay OV."
> -  (concat (preview-make-clickable
> -           (overlay-get ov 'preview-map)
> -           preview-icon
> -           "\
> +  (let ((ret (concat (preview-make-clickable
> +                      (overlay-get ov 'preview-map)
> +                      (if preview-leave-open-previews-visible
> +                          (overlay-get ov 'preview-image)
> +                        preview-icon)
> +                      "\
>  %s regenerates preview
>  %s more options"
> -           (lambda () (interactive) (preview-regenerate ov)))
> -;; icon on separate line only for stuff starting on its own line
> -          (with-current-buffer (overlay-buffer ov)
> -            (save-excursion
> -              (save-restriction
> -                (widen)
> -                (goto-char (overlay-start ov))
> -                (if (bolp) "\n" ""))))))
> +                      (lambda () (interactive) (preview-regenerate ov)))
> +                     ;; icon on separate line only for stuff starting on its own line
> +                     (with-current-buffer (overlay-buffer ov)
> +                       (save-excursion
> +                         (save-restriction
> +                           (widen)
> +                           (goto-char (overlay-start ov))
> +                           (if (bolp) "\n" "")))))))
> +    (if preview-leave-open-previews-visible
> +        (propertize ret 'face 'preview-disabled-face)
> +      ret)))
>  
>  (defun preview-disable (ovr)
>    "Change overlay behaviour of OVR after source edits."
> @@ -2341,10 +2409,10 @@ active (`transient-mark-mode'), it is run through `preview-region'."
>      (overlay-put ovr 'preview-image nil))
>    (overlay-put ovr 'timestamp nil)
>    (setcdr (overlay-get ovr 'strings) (preview-disabled-string ovr))
> +  (preview-toggle ovr)
>    (unless preview-leave-open-previews-visible
> -    (preview-toggle ovr))
> -  (overlay-put ovr 'preview-state 'disabled)
> -  (preview--delete-overlay-files ovr))
> +    (preview--delete-overlay-files ovr))
> +  (overlay-put ovr 'preview-state 'disabled))
>  
>  (defun preview--delete-overlay-files (ovr)
>    "Delete files owned by OVR."
> @@ -2618,7 +2686,8 @@ Deletes the dvi file when finished."
>                                      (preview-ascent-from-bb
>                                       (aref queued 0))
>                                      (aref preview-colors 2)))
> -              (overlay-put ov 'queued nil))
> +              (overlay-put ov 'queued nil)
> +              (preview-overlay-updated ov))
>            (push filename oldfiles)
>            ;; Do note modify `filenames' if we are not replacing
>            ;; it, to avoid orphaning files. The filenames will be
> @@ -2759,7 +2828,8 @@ to the close hook."
>        (overlay-put ov 'strings
>                     (list (preview-active-string ov)))
>        (preview-toggle ov t)
> -      (preview-clearout start end tempdir ov))))
> +      (preview-clearout start end tempdir ov)
> +      (preview-overlay-updated ov))))
>  
>  (defun preview-counter-find (begin)
>    "Fetch the next preceding or next preview-counters property.
> @@ -3803,22 +3873,28 @@ name(\\([^)]+\\))\\)\\|\
>                                            (funcall preview-find-end-function
>                                                     region-beg)
>                                          (point)))
> -                                     (ovl (preview-place-preview
> -                                           snippet
> -                                           region-beg
> -                                           region-end
> -                                           (preview-TeX-bb box)
> -                                           (cons lcounters counters)
> -                                           tempdir
> -                                           (cdr open-data))))
> -                                (setq close-data (nconc ovl close-data))
> -                                (when (and preview-protect-point
> -                                           (<= region-beg point-current)
> -                                           (< point-current region-end))
> -                                  ;; Temporarily open the preview if it
> -                                  ;; would bump the point.
> -                                  (preview-toggle (car ovl))
> -                                  (push (car ovl) preview-temporary-opened)))
> +                                     ovl)
> +                                (save-excursion
> +                                  ;; Restore point to current one before
> +                                  ;; placing preview
> +                                  (goto-char point-current)

Is there a new reason for adding this goto-char?

> +                                  (setq ovl (preview-place-preview
> +                                             snippet
> +                                             region-beg
> +                                             region-end
> +                                             (preview-TeX-bb box)
> +                                             (cons lcounters counters)
> +                                             tempdir
> +                                             (cdr open-data)))
> +                                  (setq close-data (nconc ovl close-data))
> +                                  (when (and preview-protect-point
> +                                             preview-always-show
> +                                             (<= region-beg point-current)
> +                                             (< point-current region-end))
> +                                    ;; Temporarily open the preview if it
> +                                    ;; would bump the point.
> +                                    (preview-toggle (car ovl))
> +                                    (push (car ovl) preview-temporary-opened))))
>                              (with-current-buffer run-buffer
>                                (preview-log-error
>                                 (list 'error
> @@ -4211,7 +4287,9 @@ The functions in this variable will each be called inside
>  `preview-region' with one argument which is a string.")
>  
>  (defun preview-region (begin end)
> -  "Run preview on region between BEGIN and END."
> +  "Run preview on region between BEGIN and END.
> +
> +It returns the started process."
>    (interactive "r")
>    (let ((TeX-region-extra
>           ;; Write out counter information to region.
> @@ -4426,6 +4504,97 @@ If not a regular release, the date of the last change.")
>            (insert "\n")))
>      (error nil)))
>  
> +;;; buframe specific
> +
> +;; Buframe functions, it will be assumed that buframe is installed so
> +;; that it can be required.
> +(declare-function buframe-position-right-of-overlay "ext:buframe"
> +                  (frame ov &optional location))
> +(declare-function buframe-make-buffer "ext:buframe" (name &optional locals))
> +(declare-function buframe-make "ext:buframe"
> +                  (frame-or-name fn-pos buffer &optional
> +                                 parent-buffer parent-frame parameters))
> +(declare-function buframe-disable "ext:buframe" (frame-or-name
> +                                                 &optional enable))
> +
> +(defun preview--update-buframe (&optional ov force)
> +  "Show or hide a buframe popup.
> +
> +Search for overlays at point having a non-nil \\='buframe property, or
> +hide it otherwise.  If OV is non-nil, this overlay is used to show the
> +buframe, or hide it if it was already being shown.
> +
> +The frame is not updated if \\='buframe property has not changed, unless
> +FORCE is non-nil."
> +  (if-let* ((ov (or ov
> +                    (cl-find-if
> +                     (lambda (ov) (when (overlay-get ov 'buframe) ov))
> +                     (overlays-at (point)))))
> +            (str (overlay-get ov 'buframe)))
> +      (unless (and (not force)
> +                   preview--frame
> +                   (eq (cdr (frame-parameter preview--frame
> +                                             'auctex-preview))
> +                       str))
> +        (let* ((buf (buframe-make-buffer " *auctex-preview-buffer*"
> +                                         (car-safe
> +                                          (cddr (cdr-safe
> +                                                 preview-point-where)))))
> +               (max-image-size
> +                (if (integerp max-image-size)
> +                    max-image-size
> +                  ;; Set the size max-image-size using the current frame
> +                  ;; since the popup frame will be small to begin with
> +                  (* max-image-size (frame-width)))))
> +          (with-current-buffer buf
> +            (let (buffer-read-only)
> +              (with-silent-modifications
> +                (erase-buffer)
> +                (insert (propertize str
> +                                    ;; Remove unnecessary properties
> +                                    'help-echo nil
> +                                    'keymap nil
> +                                    'mouse-face nil))
> +                (goto-char (point-min)))))
> +          (setq preview--frame
> +                (buframe-make
> +                 "auctex-preview"
> +                 (lambda (frame)
> +                   (funcall
> +                    (or (car-safe (cdr-safe preview-point-where))
> +                        #'buframe-position-right-of-overlay)
> +                    frame
> +                    ov))
> +                 buf
> +                 (overlay-buffer ov)
> +                 (window-frame)
> +                 (car-safe (cdr (cdr-safe preview-point-where)))))
> +          (set-frame-parameter preview--frame 'auctex-preview
> +                               (cons ov str))))
> +    (when (and preview--frame
> +               (or (null ov)
> +                   ;; Do not disable the buframe if it's showing another
> +                   ;; overview.
> +                   (eq ov (car-safe (frame-parameter preview--frame
> +                                                     'auctex-preview)))))
> +      (set-frame-parameter preview--frame 'auctex-preview nil)
> +      (buframe-disable preview--frame))))
> +
> +;;; preview-point
> +(defun preview-overlay-updated (ov)
> +  "Mark preview OV as updated.
> +Has effect only if `preview-always-show' is nil."
> +  (when (and (not preview-always-show)
> +             (let ((pt (and
> +                        (overlay-buffer ov)
> +                        (with-current-buffer (overlay-buffer ov)
> +                          (point)))))

Consider:

             (let ((pt (when-let* ((buf (overlay-buffer ov)))
                         (with-current-buffer buf
                           (point)))))

> +                (eq (overlay-buffer ov) (window-buffer))

Consider: (current-buffer)




Thanks, best,

Paul




Information forwarded to bug-auctex@HIDDEN:
bug#79708; Package auctex. Full text available.

Message received at 79708 <at> debbugs.gnu.org:


Received: (at 79708) by debbugs.gnu.org; 19 Nov 2025 22:50:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 19 17:50:14 2025
Received: from localhost ([127.0.0.1]:41540 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vLr09-0004BV-BX
	for submit <at> debbugs.gnu.org; Wed, 19 Nov 2025 17:50:14 -0500
Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]:42450)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <abdo.haji.ali@HIDDEN>)
 id 1vLr05-00045R-34
 for 79708 <at> debbugs.gnu.org; Wed, 19 Nov 2025 17:50:10 -0500
Received: by mail-ej1-x62a.google.com with SMTP id
 a640c23a62f3a-b73a9592fb8so48715266b.1
 for <79708 <at> debbugs.gnu.org>; Wed, 19 Nov 2025 14:50:09 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1763592603; x=1764197403; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=Jg/jjmo0vQ6dyoEFj/Ru2j57pxvpgacHvrfrEf0dpAk=;
 b=eiyTQubHHJxDG/MfhA85puZKdAa2m1cERn1RAR7Oydnn2+jpwzp1UwPCumpkiJRcoL
 +zlBv1aNjRjNzttt/f1ytC7JR+I9cLQ997jJ4e2O0HHmfGeGevsARvMD4lsfrP8aUaL2
 yFda7F1/jrXpCW1yLcRxGn8lxN/QHb5W+1gwgN8rmz6I/6Tbkw2ESsEXfoSyX2cEXWqU
 AWaJm+G39elQgh3usAPnOGchl1bNW898RQjFaNy4nvT6UJukymaF+G3hgU4sKJEVGl4D
 D/jqkFhIY6lKVzyl94HrMPfjJeMWbOs+LUGka9+a8GCrtSxPHUpsI7XDXvRiz8kG+Axo
 bd8A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1763592603; x=1764197403;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=Jg/jjmo0vQ6dyoEFj/Ru2j57pxvpgacHvrfrEf0dpAk=;
 b=RDQLbiMIhqMUEb5fP5oKLwoCLAlVpH6C60tj4J5ki/L2eZaFA0xcgi9M/NU1wXcjQp
 IRtoPB35PKF0W03/E0Y4MSP9W+45bN0tHXagggFCRsu/mqvGbHxGPptbtepdvA01cjmV
 GPEMCZnKvS1RNYcwk/Io2IkrImB0WeoFDk0W8D5dVMRT21EgNdOO2SnjI13obp3jZO9T
 k9/1LcuzSjhHmAjL4euJyZimBfKHLMP8ppetQtWEzqefj0HEzZvjic7CL0qRTtMFQ2Kp
 dUuG24/4bMZ+Vn5MIBaKsy8qc7KmJzQCsr4u2Hd56dROeaFomaBeBxKOJW6Phkf2HuWw
 JXHA==
X-Gm-Message-State: AOJu0Yy2EoUq+mptKu0hqFsI/2F2wDrA/wi6EJgpjOxEYwmyOD4K9f33
 Ih5hy/HvixIQLbmomBUeaIEJtZ1U4blH58bxiqvz7OY8RbbuFWkOycWN
X-Gm-Gg: ASbGncvKkeVycDW58dc2VeNy3NV3ad3FrwAFsMWrzNnEf4E683S1eVqxKH+XUrkKE1J
 S/SKFfE9dgme4OqQBOxvSXQYW6xzj98I/MLCAdBR7fSHcTVmOZHDImVlYCWWC5BS7AMfKFJ78Ta
 iahBqOBfgI5lQfNBjddeaCsJorUfUyanpEGhUTQesfpy3zm2Xx2fMGAJbh0y0GSIrA1+MMyyt5a
 xVKEgZw/QyZ1q3epv7I7w4klGct2xKpOCvi4/oCe1yM/yb5HR9EgQ51rGus0HTwQcNsNVY3MGLH
 RblTWf5QJffb+9YWCi1e11NPq+7eLrlbT0zGs8zth6tQiCm3xz+AXWi+HKaTKYfg8P/tjlHczCu
 0N9dQyJWRo7n4LUWLN634B7ANWMsSp6dDUPF8lX3lTqK4h2VrPVp3zgT15Ly9NkayiSkhlVLwqr
 myFvcM60JHRJBnKoNLMl96XWQ7e8cSuEX/AtHTNr2zHczckQ67
X-Google-Smtp-Source: AGHT+IGlxpxDO4UxjNNbITyAEhAPjO7hhIneBLmZVJ9iRTfJpMecwcZlnN6+FP7/CQzRjk7AptIPoQ==
X-Received: by 2002:a17:907:7204:b0:b73:7e63:2027 with SMTP id
 a640c23a62f3a-b76572f554dmr28068266b.28.1763592602602; 
 Wed, 19 Nov 2025 14:50:02 -0800 (PST)
Received: from localhost ([2a02:908:1087:8480:e094:ab3c:73b8:55a1])
 by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-b765504e958sm48541566b.66.2025.11.19.14.50.01
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 19 Nov 2025 14:50:01 -0800 (PST)
From: Al Haji-Ali <abdo.haji.ali@HIDDEN>
To: "Paul D. Nelson" <ultrono@HIDDEN>
Subject: Re: bug#79708: 14.1.0; [PATCH] New feature: preview-point
In-Reply-To: <uxsg7t4ir4l5z3.fsf@HIDDEN>
References: <uxsg7t4ir4l5z3.fsf@HIDDEN>
Date: Wed, 19 Nov 2025 23:44:19 +0100
Message-ID: <m2o6oxwsl8.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79708
Cc: 79708 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain


As discussed, I've now made the changes to introduce two customizations
(I am open to changing the names):

- `preview-always-show`: default t, when set to nil it essentially has
the preview-point behaviour (See below).
- `preview-point-where`: default 'before-string, can be set to
  'after-string and 'buframe as well.

As an added bonus, this splitting of customizations forced me to rethink
the implementation and now it is greatly simplified with smaller changes
to the existing code.

Also, I wasn't sure if I should respect `preview-auto-reveal` when
`preview-always-show` is nil, so I've done that for now. This means that
to truly get the same behaviour as preview-point, set
`preview-auto-reveal` to t. Otherwise, the default value of that
variable only shows the preview on specific key strokes.

I've also decided to remove the automatic previewing code for now. Since
the two features are orthogonal, I will send that code as a separate patch
to not confuse things.

Feedback is welcome,
-- Al

--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=New-feature-preview-at-point.patch

From 52f070df6561aabd32e1ededb97f13befd2f87ef Mon Sep 17 00:00:00 2001
From: Al Haji-Ali <a.hajiali@HIDDEN>
Date: Wed, 19 Nov 2025 22:52:37 +0100
Subject: [PATCH] New feature: preview at point

* doc/preview-latex.texi: Add docs for previewing at point.

* preview.el (preview-always-show, preview-point-where): New customizations.
(preview-disabled-face): New face for disabled previews.
(preview--frame): New variable.
(preview-gs-sentinel, preview-gs-transact, preview-dvi*-place-all,
preview-place-preview): Call `preview-overlay-updated'.
(preview-gs-flag-error, preview-mark-point, preview--open-for-replace):
Add condition on `preview-always-show`.
(preview-ascent-from-bb): Return 'center when 'preview-point-where' is
'buframe.
(preview-toggle): Update to handle values of preview-always-show and
preview-point-where.
(preview-move-point): Handle `preview-always-show` and call
`preview--update-buframe`.
(preview-disabled-string): Handle `preview-leave-open-previews-visible`
and add `preview-disabled-face`.
(preview-disable): Always call preview-toggle and condition deleting
files on `preview-leave-open-previews-visible`.
(preview-parse-messages): Restore point before placing preview.
(preview-region): Update documentation to return started process.
(preview--update-buframe, preview-overlay-updated): New functions.
---
 doc/preview-latex.texi |  26 +++
 preview.el             | 365 ++++++++++++++++++++++++++++++-----------
 2 files changed, 293 insertions(+), 98 deletions(-)

diff --git a/doc/preview-latex.texi b/doc/preview-latex.texi
index 19210a3506..c41211156c 100644
--- a/doc/preview-latex.texi
+++ b/doc/preview-latex.texi
@@ -480,6 +480,32 @@ math (@code{$@dots{}$}), or if your usage of @code{$} conflicts with
 @previewlatex{}'s, you can turn off inline math previews.  In the
 @samp{Preview Latex} group, remove @code{textmath} from
 @code{preview-default-option-list} by customizing this variable.
+
+@item Show previews always or at point.
+
+By default, previews are always shown when available, but this can be
+disabled by setting @code{preview-always-show} to @code{nil}. In this
+case, the preview is only shown when the cursor enters the corresponding
+TeX source.
+
+@item Control placement of previews.
+
+You can set @code{preview-point-where} to determine where previews are
+placed relative to the TeX source when both are being shown. This variable
+can take the following values:
+
+@table @code
+
+@item before-string
+Show the preview before the TeX source (default).
+
+@item after-string
+Show the preview after the TeX source.
+
+@item buframe
+Show the preview in a separate frame next to the cursor. Requires the
+@code{buframe} package to be installed (available on ELPA).
+@end table
 @end itemize
 
 @node Known problems, For advanced users, Simple customization, top
diff --git a/preview.el b/preview.el
index 9481288675..ebb4f43860 100644
--- a/preview.el
+++ b/preview.el
@@ -456,6 +456,42 @@ set to `postscript'."
   :group 'preview-latex
   :type 'boolean)
 
+;;; preview-point customizations and variables.
+(defcustom preview-always-show t
+  "If non-nil, always show previews.
+
+When nil, previews are only shown when a cursor enters their source.  See
+`preview-point-where' to control where they are shown."
+  :type 'boolean)
+
+(defcustom preview-point-where 'before-string
+  "Specifies where to show the preview relative to TeX source.
+
+Can be `before-string', `after-string' to show the preview at before or
+after the TeX code or `buframe' to show it in a separate frame (the
+`buframe' package must be installed).  Can also be \\='(buframe FN-POS
+FRAME-PARAMETERS BUF-PARAMETERS) where FN-POS is a position
+function (default is `buframe-position-right-of-overlay') and
+FRAME-PARAMETERS is an alist of additional frame parameters, default is
+nil and BUF-PARAMETERS is an alist of buffer local variables and their
+values."
+  :type '(choice
+          (const :tag "Before string" before-string)
+          (const :tag "After string (default)" after-string)
+          (const :tag "On frame" buframe)
+          (list :tag "On frame with explicit parameters"
+                (function :tag "Position function")
+                (alist :tag "Frame parameters")
+                (alist :tag "Buffer parameters"))))
+
+(defface preview-disabled-face
+  '((t (:inherit shadow)))
+  "Face used when preview is disabled."
+  :group 'preview)
+
+(defvar preview--frame nil
+  "The last active preview popup frame.")
+
 (defun preview-string-expand (arg &optional separator)
   "Expand ARG as a string.
 It can already be a string.  Or it can be a list, then it is
@@ -709,6 +745,8 @@ and tries to restart Ghostscript if necessary."
               (let* ((err (concat preview-gs-answer "\n"
                                   (process-name process) " " string))
                      (ov (preview-gs-behead-outstanding err)))
+                (when ov
+                  (preview-overlay-updated ov))
                 (when (and (null ov) preview-gs-queue)
                   (save-excursion
                     (goto-char (if (marker-buffer (process-mark process))
@@ -1430,16 +1468,16 @@ Try \\[ps-run-start] \\[ps-run-buffer] and \
          (ps-open
           (let ((string
                  (concat
-                (mapconcat #'shell-quote-argument
-                            (append (list
-                                     preview-gs-command
-                                     outfile)
-                                    preview-gs-command-line)
-                            " ")
-                 "\nGS>"
-                 preview-gs-init-string
-                 (aref (overlay-get ov 'queued) 1)
-                 err)))
+                  (mapconcat #'shell-quote-argument
+                             (append (list
+                                      preview-gs-command
+                                      outfile)
+                                     preview-gs-command-line)
+                             " ")
+                  "\nGS>"
+                  preview-gs-init-string
+                  (aref (overlay-get ov 'queued) 1)
+                  err)))
             (lambda () (interactive "@") (preview-mouse-open-error string))))
          (str
           (preview-make-clickable
@@ -1463,7 +1501,8 @@ Try \\[ps-run-start] \\[ps-run-buffer] and \
                                     (apply #'preview-mouse-open-eps
                                            args))])))))))
     (overlay-put ov 'strings (cons str str))
-    (preview-toggle ov)))
+    (if preview-always-show
+        (preview-toggle ov))))
 
 (defun preview-gs-transact (process answer)
   "Work off Ghostscript transaction.
@@ -1494,7 +1533,8 @@ given as ANSWER."
                                     (preview-ascent-from-bb
                                      bbox)
                                     (aref preview-colors 2))))
-            (overlay-put ov 'queued nil)))))
+            (overlay-put ov 'queued nil)
+            (preview-overlay-updated ov)))))
     (while (and (< (length preview-gs-outstanding)
                    preview-gs-outstanding-limit)
                 (setq ov (pop preview-gs-queue)))
@@ -1706,19 +1746,24 @@ icon is cached in the property list of the SYMBOL."
 (defun preview-ascent-from-bb (bb)
   "This calculates the image ascent from its bounding box.
 The bounding box BB needs to be a 4-component vector of
-numbers (can be float if available)."
+numbers (can be float if available).
+
+If `preview-point-where' is set to \\='buframe, this simply returns
+\\='center."
   ;; baseline is at 1in from the top of letter paper (11in), so it is
   ;; at 10in from the bottom precisely, which is 720 in PostScript
   ;; coordinates.  If our bounding box has its bottom not above this
   ;; line, and its top above, we can calculate a useful ascent value.
   ;; If not, something is amiss.  We just use 100 in that case.
-
-  (let ((bottom (aref bb 1))
-        (top (aref bb 3)))
-    (if (and (<= bottom 720)
-             (> top 720))
-        (round (* 100.0 (/ (- top 720.0) (- top bottom))))
-      100)))
+  (if (or (eq preview-point-where 'buframe)
+          (eq (car-safe preview-point-where) 'buframe))
+      'center
+    (let ((bottom (aref bb 1))
+          (top (aref bb 3)))
+      (if (and (<= bottom 720)
+               (> top 720))
+          (round (* 100.0 (/ (- top 720.0) (- top bottom))))
+        100))))
 
 (defface preview-face '((((background dark))
                          (:background "dark slate gray"))
@@ -2082,32 +2127,46 @@ If EVENT is given, it indicates the window where the event
 occured, either by being a mouse event or by directly being
 the window in question.  This may be used for cursor restoration
 purposes."
-  (let ((old-urgent (preview-remove-urgentization ov))
-        (preview-state
-         (if (if (eq arg 'toggle)
-                 (null (eq (overlay-get ov 'preview-state) 'active))
-               arg)
-             'active
-           'inactive))
-        (strings (overlay-get ov 'strings)))
-    (unless (eq (overlay-get ov 'preview-state) 'disabled)
-      (overlay-put ov 'preview-state preview-state)
-      (if (eq preview-state 'active)
-          (progn
-            (overlay-put ov 'category 'preview-overlay)
-            (if (eq (overlay-start ov) (overlay-end ov))
-                (overlay-put ov 'before-string (car strings))
+  (let ((old-urgent (preview-remove-urgentization ov)))
+    (unwind-protect
+        (let ((preview-state
+               (if (if (eq arg 'toggle)
+                       (null (eq (overlay-get ov 'preview-state) 'active))
+                     arg)
+                   'active
+                 'inactive))
+              (prop (or (and (consp preview-point-where)
+                             (car preview-point-where))
+                        preview-point-where))
+              (strings (overlay-get ov 'strings)))
+          (unless (eq (overlay-get ov 'preview-state) 'disabled)
+            (overlay-put ov 'preview-state preview-state)
+            (if (eq preview-state 'active)
+                (progn
+                  (overlay-put ov 'category 'preview-overlay)
+                  (if (eq (overlay-start ov) (overlay-end ov))
+                      (overlay-put ov prop (car strings))
+                    (when preview-always-show
+                      (dolist (prop '(display keymap mouse-face help-echo))
+                        (overlay-put ov prop
+                                     (get-text-property 0 prop
+                                                        (car strings)))))
+                    (overlay-put ov prop nil))
+                  (overlay-put ov 'face nil))
               (dolist (prop '(display keymap mouse-face help-echo))
-                (overlay-put ov prop
-                             (get-text-property 0 prop (car strings))))
-              (overlay-put ov 'before-string nil))
-            (overlay-put ov 'face nil))
-        (dolist (prop '(display keymap mouse-face help-echo))
-          (overlay-put ov prop nil))
-        (overlay-put ov 'face 'preview-face)
-        (unless (cdr strings)
-          (setcdr strings (preview-inactive-string ov)))
-        (overlay-put ov 'before-string (cdr strings)))
+                (overlay-put ov prop nil))
+              (when preview-always-show
+                (overlay-put ov 'face 'preview-face))
+              (unless (cdr strings)
+                ;; If `preview-always-show' is nil, then we should
+                ;; always show the preview (i.e. leave it open) when the
+                ;; preview is "inactive".
+                (let ((preview-leave-open-previews-visible
+                       (or preview-leave-open-previews-visible
+                           (not preview-always-show))))
+                  (setcdr strings (preview-inactive-string ov))))
+              (overlay-put ov prop (cdr strings)))
+            (preview--update-buframe ov t)))
       (if old-urgent
           (apply #'preview-add-urgentization old-urgent))))
   (if event
@@ -2127,13 +2186,14 @@ purposes."
 
 (defun preview-mark-point ()
   "Mark position for fake intangibility."
-  (when (eq (get-char-property (point) 'preview-state) 'active)
-    (unless preview-last-location
-      (setq preview-last-location (make-marker)))
-    (set-marker preview-last-location (point))
-    (set-marker preview-marker (point))
-    (preview-move-point))
-  (set-marker preview-marker (point)))
+  (when preview-always-show
+    (when (eq (get-char-property (point) 'preview-state) 'active)
+      (unless preview-last-location
+        (setq preview-last-location (make-marker)))
+      (set-marker preview-last-location (point))
+      (set-marker preview-marker (point))
+      (preview-move-point))
+    (set-marker preview-marker (point))))
 
 (defun preview-restore-position (ov window)
   "Tweak position after opening/closing preview.
@@ -2177,17 +2237,19 @@ overlays not in the active window."
                               (current-buffer))
                           (- pt (marker-position preview-marker))))))
           (preview-open-overlays lst)
-        (while lst
-          (setq lst
-                (if (and
-                     (eq (overlay-get (car lst) 'preview-state) 'active)
-                     (> pt (overlay-start (car lst))))
-                    (overlays-at
-                     (setq pt (if (and distance (< distance 0))
-                                  (overlay-start (car lst))
-                                (overlay-end (car lst)))))
-                  (cdr lst))))
-        (goto-char pt)))))
+        (when preview-always-show
+          (while lst
+            (setq lst
+                  (if (and
+                       (eq (overlay-get (car lst) 'preview-state) 'active)
+                       (> pt (overlay-start (car lst))))
+                      (overlays-at
+                       (setq pt (if (and distance (< distance 0))
+                                    (overlay-start (car lst))
+                                  (overlay-end (car lst)))))
+                    (cdr lst))))
+          (goto-char pt)))))
+  (preview--update-buframe))
 
 (defun preview-open-overlays (list &optional pos)
   "Open all previews in LIST, optionally restricted to enclosing POS."
@@ -2202,7 +2264,8 @@ overlays not in the active window."
 
 (defun preview--open-for-replace (beg end &rest _)
   "Make `query-replace' open preview text about to be replaced."
-  (preview-open-overlays (overlays-in beg end)))
+  (when preview-always-show
+    (preview-open-overlays (overlays-in beg end))))
 
 (defcustom preview-query-replace-reveal t
   "Make `query-replace' autoreveal previews."
@@ -2314,20 +2377,25 @@ active (`transient-mark-mode'), it is run through `preview-region'."
 
 (defun preview-disabled-string (ov)
   "Generate a before-string for disabled preview overlay OV."
-  (concat (preview-make-clickable
-           (overlay-get ov 'preview-map)
-           preview-icon
-           "\
+  (let ((ret (concat (preview-make-clickable
+                      (overlay-get ov 'preview-map)
+                      (if preview-leave-open-previews-visible
+                          (overlay-get ov 'preview-image)
+                        preview-icon)
+                      "\
 %s regenerates preview
 %s more options"
-           (lambda () (interactive) (preview-regenerate ov)))
-;; icon on separate line only for stuff starting on its own line
-          (with-current-buffer (overlay-buffer ov)
-            (save-excursion
-              (save-restriction
-                (widen)
-                (goto-char (overlay-start ov))
-                (if (bolp) "\n" ""))))))
+                      (lambda () (interactive) (preview-regenerate ov)))
+                     ;; icon on separate line only for stuff starting on its own line
+                     (with-current-buffer (overlay-buffer ov)
+                       (save-excursion
+                         (save-restriction
+                           (widen)
+                           (goto-char (overlay-start ov))
+                           (if (bolp) "\n" "")))))))
+    (if preview-leave-open-previews-visible
+        (propertize ret 'face 'preview-disabled-face)
+      ret)))
 
 (defun preview-disable (ovr)
   "Change overlay behaviour of OVR after source edits."
@@ -2341,10 +2409,10 @@ active (`transient-mark-mode'), it is run through `preview-region'."
     (overlay-put ovr 'preview-image nil))
   (overlay-put ovr 'timestamp nil)
   (setcdr (overlay-get ovr 'strings) (preview-disabled-string ovr))
+  (preview-toggle ovr)
   (unless preview-leave-open-previews-visible
-    (preview-toggle ovr))
-  (overlay-put ovr 'preview-state 'disabled)
-  (preview--delete-overlay-files ovr))
+    (preview--delete-overlay-files ovr))
+  (overlay-put ovr 'preview-state 'disabled))
 
 (defun preview--delete-overlay-files (ovr)
   "Delete files owned by OVR."
@@ -2618,7 +2686,8 @@ Deletes the dvi file when finished."
                                     (preview-ascent-from-bb
                                      (aref queued 0))
                                     (aref preview-colors 2)))
-              (overlay-put ov 'queued nil))
+              (overlay-put ov 'queued nil)
+              (preview-overlay-updated ov))
           (push filename oldfiles)
           ;; Do note modify `filenames' if we are not replacing
           ;; it, to avoid orphaning files. The filenames will be
@@ -2759,7 +2828,8 @@ to the close hook."
       (overlay-put ov 'strings
                    (list (preview-active-string ov)))
       (preview-toggle ov t)
-      (preview-clearout start end tempdir ov))))
+      (preview-clearout start end tempdir ov)
+      (preview-overlay-updated ov))))
 
 (defun preview-counter-find (begin)
   "Fetch the next preceding or next preview-counters property.
@@ -3803,22 +3873,28 @@ name(\\([^)]+\\))\\)\\|\
                                           (funcall preview-find-end-function
                                                    region-beg)
                                         (point)))
-                                     (ovl (preview-place-preview
-                                           snippet
-                                           region-beg
-                                           region-end
-                                           (preview-TeX-bb box)
-                                           (cons lcounters counters)
-                                           tempdir
-                                           (cdr open-data))))
-                                (setq close-data (nconc ovl close-data))
-                                (when (and preview-protect-point
-                                           (<= region-beg point-current)
-                                           (< point-current region-end))
-                                  ;; Temporarily open the preview if it
-                                  ;; would bump the point.
-                                  (preview-toggle (car ovl))
-                                  (push (car ovl) preview-temporary-opened)))
+                                     ovl)
+                                (save-excursion
+                                  ;; Restore point to current one before
+                                  ;; placing preview
+                                  (goto-char point-current)
+                                  (setq ovl (preview-place-preview
+                                             snippet
+                                             region-beg
+                                             region-end
+                                             (preview-TeX-bb box)
+                                             (cons lcounters counters)
+                                             tempdir
+                                             (cdr open-data)))
+                                  (setq close-data (nconc ovl close-data))
+                                  (when (and preview-protect-point
+                                             preview-always-show
+                                             (<= region-beg point-current)
+                                             (< point-current region-end))
+                                    ;; Temporarily open the preview if it
+                                    ;; would bump the point.
+                                    (preview-toggle (car ovl))
+                                    (push (car ovl) preview-temporary-opened))))
                             (with-current-buffer run-buffer
                               (preview-log-error
                                (list 'error
@@ -4211,7 +4287,9 @@ The functions in this variable will each be called inside
 `preview-region' with one argument which is a string.")
 
 (defun preview-region (begin end)
-  "Run preview on region between BEGIN and END."
+  "Run preview on region between BEGIN and END.
+
+It returns the started process."
   (interactive "r")
   (let ((TeX-region-extra
          ;; Write out counter information to region.
@@ -4426,6 +4504,97 @@ If not a regular release, the date of the last change.")
           (insert "\n")))
     (error nil)))
 
+;;; buframe specific
+
+;; Buframe functions, it will be assumed that buframe is installed so
+;; that it can be required.
+(declare-function buframe-position-right-of-overlay "ext:buframe"
+                  (frame ov &optional location))
+(declare-function buframe-make-buffer "ext:buframe" (name &optional locals))
+(declare-function buframe-make "ext:buframe"
+                  (frame-or-name fn-pos buffer &optional
+                                 parent-buffer parent-frame parameters))
+(declare-function buframe-disable "ext:buframe" (frame-or-name
+                                                 &optional enable))
+
+(defun preview--update-buframe (&optional ov force)
+  "Show or hide a buframe popup.
+
+Search for overlays at point having a non-nil \\='buframe property, or
+hide it otherwise.  If OV is non-nil, this overlay is used to show the
+buframe, or hide it if it was already being shown.
+
+The frame is not updated if \\='buframe property has not changed, unless
+FORCE is non-nil."
+  (if-let* ((ov (or ov
+                    (cl-find-if
+                     (lambda (ov) (when (overlay-get ov 'buframe) ov))
+                     (overlays-at (point)))))
+            (str (overlay-get ov 'buframe)))
+      (unless (and (not force)
+                   preview--frame
+                   (eq (cdr (frame-parameter preview--frame
+                                             'auctex-preview))
+                       str))
+        (let* ((buf (buframe-make-buffer " *auctex-preview-buffer*"
+                                         (car-safe
+                                          (cddr (cdr-safe
+                                                 preview-point-where)))))
+               (max-image-size
+                (if (integerp max-image-size)
+                    max-image-size
+                  ;; Set the size max-image-size using the current frame
+                  ;; since the popup frame will be small to begin with
+                  (* max-image-size (frame-width)))))
+          (with-current-buffer buf
+            (let (buffer-read-only)
+              (with-silent-modifications
+                (erase-buffer)
+                (insert (propertize str
+                                    ;; Remove unnecessary properties
+                                    'help-echo nil
+                                    'keymap nil
+                                    'mouse-face nil))
+                (goto-char (point-min)))))
+          (setq preview--frame
+                (buframe-make
+                 "auctex-preview"
+                 (lambda (frame)
+                   (funcall
+                    (or (car-safe (cdr-safe preview-point-where))
+                        #'buframe-position-right-of-overlay)
+                    frame
+                    ov))
+                 buf
+                 (overlay-buffer ov)
+                 (window-frame)
+                 (car-safe (cdr (cdr-safe preview-point-where)))))
+          (set-frame-parameter preview--frame 'auctex-preview
+                               (cons ov str))))
+    (when (and preview--frame
+               (or (null ov)
+                   ;; Do not disable the buframe if it's showing another
+                   ;; overview.
+                   (eq ov (car-safe (frame-parameter preview--frame
+                                                     'auctex-preview)))))
+      (set-frame-parameter preview--frame 'auctex-preview nil)
+      (buframe-disable preview--frame))))
+
+;;; preview-point
+(defun preview-overlay-updated (ov)
+  "Mark preview OV as updated.
+Has effect only if `preview-always-show' is nil."
+  (when (and (not preview-always-show)
+             (let ((pt (and
+                        (overlay-buffer ov)
+                        (with-current-buffer (overlay-buffer ov)
+                          (point)))))
+               (and ;; If pt is inside the overlay
+                (eq (overlay-buffer ov) (window-buffer))
+                (>= pt (overlay-start ov))
+                (< pt (overlay-end ov)))))
+    (preview-toggle ov)))
+
 ;;;###autoload
 (defun preview-report-bug () "Report a bug in the preview-latex package."
        (interactive)
-- 
2.39.5 (Apple Git-154)


--=-=-=--




Information forwarded to bug-auctex@HIDDEN:
bug#79708; Package auctex. Full text available.

Message received at 79708 <at> debbugs.gnu.org:


Received: (at 79708) by debbugs.gnu.org; 8 Nov 2025 18:44:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 08 13:44:29 2025
Received: from localhost ([127.0.0.1]:53154 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vHnvJ-0006zN-5c
	for submit <at> debbugs.gnu.org; Sat, 08 Nov 2025 13:44:29 -0500
Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]:46139)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <ultrono@HIDDEN>) id 1vHnvG-0006yw-5j
 for 79708 <at> debbugs.gnu.org; Sat, 08 Nov 2025 13:44:27 -0500
Received: by mail-lj1-x22f.google.com with SMTP id
 38308e7fff4ca-37a4e329a90so17247521fa.0
 for <79708 <at> debbugs.gnu.org>; Sat, 08 Nov 2025 10:44:26 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1762627459; x=1763232259; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:from:to
 :cc:subject:date:message-id:reply-to;
 bh=rKH31Oly4RgeC4XTFMyq/WU1jAXOA7TU+9ceaDnC7rc=;
 b=F9Qn02mhGPfBwaZkMigvW0xrwhEtMtsyxCKNIk4zPi63w7/q/rkelL8QrERMVb9fCq
 TIi7O+nhI8nKugP/W3Es3vD6m/iziR3A051SPAXnq4e9V5Ckoym20xLyqEAbvqswQcBE
 vKNbWKZYJoNLRauNwHqz59XU0YT2UdmuaQwPCQ43Z/iShwBOUm0/sd1riy2bRUdX5GMZ
 dbjZSFNzfU6+eljIu2TJsKsPEdM7iq/RyPltC8LoVCEVHJXN7X6wghig6bH9y4I7k3mL
 eeBljnQlnPMQCmi6eqEp3JAg1rjSG7K2djOWpJyg6128sLS/GUwq50rfLIyjstpfQaLh
 I7aQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1762627459; x=1763232259;
 h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:x-gm-gg
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=rKH31Oly4RgeC4XTFMyq/WU1jAXOA7TU+9ceaDnC7rc=;
 b=lS6rrCrjarptYSJ4F2WBZtVA2rHS5FVy+qN2n0a1AsuD/dg+NpXtFKhRWK1h4n3qvU
 dwtM05F3H39rbQf4SCYFLPAGLKy+q4jQn7Eb2Uq0lkVJ6vnrKGxiKkyHeC+N5/CDkutH
 tIwSsQ0uHdgCbYmQfDtABdP9aOGUUffgGhYuyaZx1AHGDzYI+tkQ/y2qJZXfhUREkjL+
 s+f3MW81DLSD0mb11ctrLa0CmFFLyQ5ETRmDRt0FWL3IzDuJwznYeb9UtjBZSt76lMBy
 +Jt8DRA2jphnSWOuMZZNYlqtGcCsUVhhcI7B01ZjZR7VL2SQ0luhood1c7H9vC8Z2shy
 GZxQ==
X-Gm-Message-State: AOJu0YzqojNHPnpgNZm3ljJ5mKyqTTEWuO0x/dlMqU8gnojjsbgOyzQ8
 AusWlORmKMETJM7DclpRyZ26XvyE/BqOgnaxgMgkcYD1imLaDFXgZ5UX
X-Gm-Gg: ASbGncuRh20oAWOlOXffOqSWqd5n26XfidyNUfLmguILrgOTroC8a8fGSAtkEv9bN/N
 dwndDZjw+4CuFim7RPDkoH2H3xYxaRbvoyZgIc34pBDJmylBXUSpk0/mVgrnKLl1OwoJ+mHyrkQ
 XNFb1Gxk8skDvUplcwh5AxMBauCABFzMABoZYGbrQ0h7fpngzdeaMHCUomgSyh04KLH4QZBnoEc
 7sUCfLd3N6MPHp0BfPm7kQfAkO1ymy7VgHynw75w/tANnqTC2MG/ujw5GywiTGCNyLIN07YgGbL
 oNajfge7QUWhrcdDGcDfL0yNzLTO5z8AOc/5EUzDaj4pXhe/KC/olrkMEjiw3yd1v1Y0sE30dKy
 K2tMzA/tgvbjvSS4T8UCKzsXNre75PWkrLtRhqxnYg1ueOVtmzU22RtiYYGDWD4393rYp80XVx9
 pOodGouYtMVdtjV71zo2g3jobwo2Fx/xVGoHs2kRDISg==
X-Google-Smtp-Source: AGHT+IHXXxq8LL0gBAl26V22mTjRLebjYUiPypLZmrDDWCRvp1qtPA2zfKCehNeL9C06HxVoVz/NLg==
X-Received: by 2002:a05:651c:f16:b0:37a:3615:89f2 with SMTP id
 38308e7fff4ca-37a7b1b948bmr8101271fa.9.1762627459006; 
 Sat, 08 Nov 2025 10:44:19 -0800 (PST)
Received: from localhost (0x5da5fb5f.static.cust.fastspeed.dk. [93.165.251.95])
 by smtp.gmail.com with UTF8SMTPSA id
 38308e7fff4ca-37a5f058320sm21917561fa.9.2025.11.08.10.44.17
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 08 Nov 2025 10:44:18 -0800 (PST)
From: "Paul D. Nelson" <ultrono@HIDDEN>
To: Al Haji-Ali <abdo.haji.ali@HIDDEN>
Subject: Re: bug#79708: 14.1.0; [PATCH] New feature: preview-point
In-Reply-To: <m0346vnyk5.fsf@HIDDEN> (message from Al Haji-Ali on Mon, 03
 Nov 2025 12:30:18 +0100)
Date: Sat, 08 Nov 2025 19:44:16 +0100
Message-ID: <uxsg7t4ir4l5z3.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79708
Cc: 79708 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> I largely agree with you, and I am happy for finer control over the
> behaviour to be added.

Glad to hear we're on the same page now.

> The new mode of operation I was referring to is when
> `preview-display-style` is set to 'preview (so that previews away from
> point are displayed) and `preview-reveal-display` is `buframe`.
>
> Presumably the previews away from the cursor are being shown using the
> 'display' property of the overlay (as is currently done). When the
> cursor opens the preview, I think you are proposing that the> TeX
> source is displayed in the buffer (by setting 'display to nil) while
> the preview *moves* to a buframe.

This last sentence indeed captures the intended user-facing behavior,
which seems like the amalgam of two features that already exist:

- In traditional preview, when point enters a preview, the preview
  becomes invisible (or the TeX symbol takes its place).

- In preview-point, when point enters a preview, the preview is
  displayed in a buframe.

I might be overlooking some nuance, but I had hoped these two apparently
orthogonal features could be combined fairly easily.

> When the cursor moves out of the source, the preview moves back into
> the buffer as a 'display property, correct?  If so, don't you think
> previews moving between buframe and main buffer would be jarring?

This is a valid concern, and it might take some experimentation to see
how it feels.  I was hoping it'd be no more jarring than what happens in
traditional preview, where the preview becomes invisible and then
visible again.

> I am also still unclear what happens in this case when the TeX source
> is modified. Does the preview return back to the buffer as a 'display
> property or does the TeX source remain visible (I'd guess the latter
> is more reasonable)?

I was thinking we could follow the current "traditional preview"
behavior: when the TeX source is modified, the preview is disabled and
never shown again, except when preview-leave-open-previews-visible is
non-nil, in which case the preview remains visible via the 'display
property (assuming, of course, that preview-display-style is 'preview).

Thanks, best,

Paul




Information forwarded to bug-auctex@HIDDEN:
bug#79708; Package auctex. Full text available.

Message received at 79708 <at> debbugs.gnu.org:


Received: (at 79708) by debbugs.gnu.org; 3 Nov 2025 11:30:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 03 06:30:53 2025
Received: from localhost ([127.0.0.1]:39859 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vFslx-0003B7-0M
	for submit <at> debbugs.gnu.org; Mon, 03 Nov 2025 06:30:53 -0500
Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:50478)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <abdo.haji.ali@HIDDEN>)
 id 1vFsln-0003Ah-LV
 for 79708 <at> debbugs.gnu.org; Mon, 03 Nov 2025 06:30:48 -0500
Received: by mail-wr1-x42e.google.com with SMTP id
 ffacd0b85a97d-429c82bf86bso1722474f8f.1
 for <79708 <at> debbugs.gnu.org>; Mon, 03 Nov 2025 03:30:43 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1762169436; x=1762774236; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=ReHbWEtWds3soVUY1RW07ZOZfUktnMe+fastOGHLDLk=;
 b=jIJ1wnEYVifTN6LmOr++UDC7cXD2rQiEgf91yk4n0QdJGJzpj/9mOFWNOa1SREnuKf
 lAnPbfyx9AfeAihcUd7MCrBi+pyiApdFFSUnoBMir2sX7R+4GSAMPrGbhAX5MJJRbUZ6
 bJ7AjbXV3h71mXnE9wTFco6h6/KmyZU8hdGAzS2elA1eSv5DwZbClG0srHxWxUVyKqQp
 uk6WyuZxsUa4B2YVufB+d7Zl9cj+6A8++iQYAlgvsiN2tYMmoFaV5+9+9zJeBxUxTsKD
 RkLYdX0YcoTNKwiHaz8DK6DWMCeXY0sQ40sQnQvdyd0n8v1lP1YooXPcdYNXBMpdemMi
 MBHA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1762169436; x=1762774236;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=ReHbWEtWds3soVUY1RW07ZOZfUktnMe+fastOGHLDLk=;
 b=N09SubmKywzzh6hobW/I5K2iOXovsulGCRUbyo158oXzd5szpTv+cqm15M6UdQ6Ykw
 Du6vBTCNxU4Pzhc2oSXPT7wBnjOlYKmjgWbxbtZwvTcx8vVBTcUCG424Y6eAKK0zzNOA
 DpBbQXj1Yqg0EZ6PrMQX1F+bIgQBC/5vsv+CTl8pH1HCxvODWrwFmaNUCReXPWUhB5IS
 0wjlPDdzDazmwulF3bVpCISUkcjipaYL6OzA8WMpKo8hFWCra8k4DY8J+fOHBeL4cFD3
 CsPVR4ZnpO2iB+WS0vKCbU6VaNWNF7K6bFWz7WqJznFZE6Kl456Z/gEIhunlyce8LMT4
 kVSA==
X-Gm-Message-State: AOJu0YwtBkJHwSaOgcQ/LR6xBkKGTYE+qrmC6lhRoe7UO8U5b5ZiiY44
 oB+8Hfsi919mxfMdjOz7N0AoZMNRxan1CeEklnaTzP1reOBfyn1N1u3b
X-Gm-Gg: ASbGnct2qlKWOaE+Oq8f1efMtgJDC1pRXKF9dtRAyRD1PM+C7rEkKgP/MdcN4R1qOQ0
 N1muLHv+6ny7NcNwxlC3rR5Y1nVKGg09eGjojTIAiDsOn0ItZozsilOQOkF1pRFBetDg04D8S1v
 npLXox7pXDtIWAkdVz9cHMnJqq3FczzHzq7gV8yv6SKsifshL2uwvObayHgsgfHDHdsHU99oLeB
 ry28YLTw5ZAMmkUx8w/BTgvgZyGKsyQ4f1QuSeBC27nidEKs0F4T3cl4GQ3HaUhFD+/esyw456R
 lySo42ub1hWkjKIjhtPGASkM4YaSbGKPSXtm0DRbuTaTgs0VJehhNawXZGhL4HiCpR9wEpu+KL4
 sco+uycj1/GJsWxuBP1dOqoh7d7ihQFMD0rpRvizeBY7VkHev6sHIKe4s9knr0GA+kiCX/r58Px
 CAyltcUEisPG+FEcb9xpxd5GRpOKUJHvmaQOBR
X-Google-Smtp-Source: AGHT+IH0gH4DUv6252QRsBFXBYGVEEsxn0XjiTf45824fiYP+PXmNr92b9MPDXwIA1mqNhSIAlM+PA==
X-Received: by 2002:a05:6000:430c:b0:429:d565:d7df with SMTP id
 ffacd0b85a97d-429d565db5amr1874156f8f.42.1762169436135; 
 Mon, 03 Nov 2025 03:30:36 -0800 (PST)
Received: from localhost (eduroam-269-2-068.epfl.ch. [192.33.198.68])
 by smtp.gmail.com with UTF8SMTPSA id
 ffacd0b85a97d-429d1a77614sm7521375f8f.21.2025.11.03.03.30.35
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 03 Nov 2025 03:30:35 -0800 (PST)
From: Al Haji-Ali <abdo.haji.ali@HIDDEN>
To: "Paul D. Nelson" <ultrono@HIDDEN>
Subject: Re: bug#79708: 14.1.0; [PATCH] New feature: preview-point
In-Reply-To: <uxsg7t1pmfmq6l.fsf@HIDDEN>
References: <uxsg7t1pmfmq6l.fsf@HIDDEN>
Date: Mon, 03 Nov 2025 12:30:18 +0100
Message-ID: <m0346vnyk5.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79708
Cc: 79708 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On 03/11/2025, Paul D. Nelson wrote:
> I may have added to the confusion by writing "construction symbol" (what
> shows up when a preview is regenerating) in a few places where I should
> have written "TeX symbol" (what shows up when the TeX source is made
> visible after point enters a preview).

Ah this is finally becoming clear to me. Sorry it took a while and I
thank you for your patience.

> I don't think I'm proposing to introduce more modes of operation.  I'm
> just observing that preview-point bundles two orthogonal features: (a)
> disabling preview display by default, and (b) richer customization of
> how to display the preview at point.  Feature (b) would be useful even
> without feature (a), so it seems worth decoupling the two and allowing
> them to be configured separately.  Does that clarify what I had in mind?

I largely agree with you, and I am happy for finer control over the
behaviour to be added.

The new mode of operation I was referring to is when
`preview-display-style` is set to 'preview (so that previews away from
point are displayed) and `preview-reveal-display` is `buframe`.

Presumably the previews away from the cursor are being shown using the
'display' property of the overlay (as is currently done). When the
cursor opens the preview, I think you are proposing that the TeX source
is displayed in the buffer (by setting 'display to nil) while the
preview *moves* to a buframe. When the cursor moves out of the source,
the preview moves back into the buffer as a 'display property, correct?
If so, don't you think previews moving between buframe and main buffer
would be jarring? I am also still unclear what happens in this case when
the TeX source is modified. Does the preview return back to the buffer
as a 'display property or does the TeX source remain visible (I'd guess
the latter is more reasonable)?

In any case, if my understanding is correct, this would require new,
careful implementation of moving the preview back and forth.

Best regards,
-- Al




Information forwarded to bug-auctex@HIDDEN:
bug#79708; Package auctex. Full text available.

Message received at 79708 <at> debbugs.gnu.org:


Received: (at 79708) by debbugs.gnu.org; 3 Nov 2025 09:16:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 03 04:16:52 2025
Received: from localhost ([127.0.0.1]:38987 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vFqgF-0004zR-P1
	for submit <at> debbugs.gnu.org; Mon, 03 Nov 2025 04:16:52 -0500
Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]:47219)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <ultrono@HIDDEN>) id 1vFqg7-0004z0-O1
 for 79708 <at> debbugs.gnu.org; Mon, 03 Nov 2025 04:16:44 -0500
Received: by mail-ed1-x530.google.com with SMTP id
 4fb4d7f45d1cf-6409e985505so2321988a12.2
 for <79708 <at> debbugs.gnu.org>; Mon, 03 Nov 2025 01:16:43 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1762161397; x=1762766197; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:from:to
 :cc:subject:date:message-id:reply-to;
 bh=dkCk8NMnoVVOWu/tCp+/BEBuKWCEqbSHxuUvCbMjHgo=;
 b=imYNzl5OzRzckA5l+GB5dV5OV2cllZHbbECK4Jj8ckX1cF48CPwrp8wzpb8MuZaMho
 KqbaZglYkivJoINvUOlsrwXTbI3gpvaj8JdzcMUkI7/6fpkaYIm6/AdgW2PkG8lkm0Rr
 TIl6+M23pkUauXJfVihA55isEp6PA5iSLtotq0oPqtPzmre7Qk/Gj2PMUk0loExqib1p
 cKRo6RWh0kO7Nz9hVWjKLHrvoEiB8W5m03Wq0bjhkuZ24shr+PlVBgZbZua8oxXiRyCM
 NiXXA+ht7wBZFHFzguAx3Ov8QqsVjw7iUSkpa25ZN4mOoQUops1qwav2xsTobV2+FUTp
 sqlg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1762161397; x=1762766197;
 h=mime-version:message-id:date:in-reply-to:subject:cc:to:from
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=dkCk8NMnoVVOWu/tCp+/BEBuKWCEqbSHxuUvCbMjHgo=;
 b=wQHYtskUvz6dkTwQrA3D3WzZy5Y4wvtWwdb5wwWlpFZtpJye6Udl7JBAXoPDfdMRd/
 TE28XvuIHJG/xj00nUfeBOkOMyFMDR0nq4cB/aPE5niKdQh1yB3pP42ox6bvmFus0aVV
 nhfSwXu8YqhNakiPvpEDH2xuqFmAO64cCEZWSP8F9pbZ5Hj6dZdEYKMafpZP9MuwoF4z
 F6LGemejqz5rU/N8Z2Hv4hx8mTfmsK44denbAvkq2oavpfKQjNNe1T418DvflaKntx30
 Y2Mq1cIfrlpkkOCigowH14YM46QUlgpN6xWR42nvSq7oSf2t6WQFzxAT58SPPEx1Z+K4
 HLpA==
X-Gm-Message-State: AOJu0YxONqGGQdyqpg2wta9omt51wU+3ADVTTlAr3/6b1174twrkznTf
 9BKf9XhFY9V8BT2snHrzmrVw1tFJjgjb5LHISHNRWEMbjYcVfkOarF8k
X-Gm-Gg: ASbGncsgO82BaxsD+jb3f9NfxeWnIzicL4L/WMaSsWQhKP6B2k38PCHSmJ5zRQYNvAO
 cC0AgJ1/68ZcL2dbIp/wcwDtnUuNBwy84kpFIq9ov/U8dPZdJop6+ygRRgo/3FybAiVVDxxT9Ly
 N73yq9B2CcfzWadV+F8E4+L3hh5/5b6lwmP59yK4qYVuRwl4FVlCWzNoQOIvScc2Fli+mTMfo2d
 fMRZbK5N69ZHDs1RC45gh/uWeBUYvSf4zviEcFhaXnDHCqVy1aHbYmWu77Dk7suSXd9f0v4EZGC
 r//hoOuOI11nVAJqC1mQMSBnIujH3iwcMn1R1XqGiI/IN8iFrJEn+zfJs4agbL8sVo8uoCgGegR
 G8hj16e4CKEc3WqiH2zJuHFQxaO+IWJHImLXmSMUB8F9qocLd4vyz4kxmYYxX1UA8cU6kzN8QgQ
 MNl4tICIkpSz8FPTk4OL/OkF2U5gLvGCLbMinpJYVJMTPVlceE98J83A==
X-Google-Smtp-Source: AGHT+IEkcXm9QjVy924mgZYd4wNGOAR7r+o6J/cgJl4LFH3rCZ+FZRzFY/+HTGZuLyx802OHkd7Oow==
X-Received: by 2002:a05:6402:2807:b0:63c:690d:6a46 with SMTP id
 4fb4d7f45d1cf-64076f7522cmr10977467a12.13.1762161396345; 
 Mon, 03 Nov 2025 01:16:36 -0800 (PST)
Received: from localhost (0x5da5fbd2.static.cust.fastspeed.dk.
 [93.165.251.210]) by smtp.gmail.com with UTF8SMTPSA id
 4fb4d7f45d1cf-64098077b1asm6607671a12.7.2025.11.03.01.16.35
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 03 Nov 2025 01:16:35 -0800 (PST)
From: "Paul D. Nelson" <ultrono@HIDDEN>
To: Al Haji-Ali <abdo.haji.ali@HIDDEN>
Subject: Re: bug#79708: 14.1.0; [PATCH] New feature: preview-point
In-Reply-To: <m0wm47r1kd.fsf@HIDDEN> (message from Al Haji-Ali on Mon, 03
 Nov 2025 08:57:06 +0100)
Date: Mon, 03 Nov 2025 10:16:34 +0100
Message-ID: <uxsg7t1pmfmq6l.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79708
Cc: 79708 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> Hmmm... I am not sure what I am missing. On my setup, the construction
> symbol only appears when the source is modified.  If I open the preview
> by having the cursor "go into" the preview image, then navigate away
> from the source, the preview is collapsed again if I don't modify the
> source.
>
> The documentation is also unclear, because the first part of
> `preview-leave-open-previews-visible` leans toward what you say:
>
> --8<---------------cut here---------------start------------->8---
> Whether to leave previews visible when they are opened.
>
> If nil, then the TeX preview icon is used when the preview is opened.
> If non-nil, then the preview image remains visible.  In either case, the
> TeX code appears either below or to the right of the displayed graphic.
> --8<---------------cut here---------------end--------------->8---
>
> but then the next part is what I am seeing:
>
> --8<---------------cut here---------------start------------->8---
> If you enable this option, the preview image doesn't turn into
> construction sign temporarily when you edit the underlying LaTeX code
> and regenerate the preview; it is just replaced by updated image when
> ready.  This behavior suppresses flicker in the appearance.
> --8<---------------cut here---------------end--------------->8---

I may have added to the confusion by writing "construction symbol" (what
shows up when a preview is regenerating) in a few places where I should
have written "TeX symbol" (what shows up when the TeX source is made
visible after point enters a preview).

You're right that the docstring covers two behaviors: (i) what happens
when a preview is revealed, and (ii) what happens when it's regenerated.
I was talking about (i) before.  Since you write that the discussion
below clarified things somewhat, I'll focus my response there.

>
>> Let me restate the proposal using your terminology and proposed setting
>> 'preview-display-style' (for which the 'both option is not what I had in
>> mind, but could also be considered).  Two independent knobs:
>>
>> - preview-display-style ('preview, 'src): controls what's shown for
>>   previews away from point, that the cursor is *not* inside.
>>
>> - preview-reveal-display ('none, 'after, 'before, 'buframe).  What to
>>   show when point enters a previewed region (i.e., the overlay or the
>>   underlying tex source):
>>
>>   - 'none means just show the tex source and the construction sign
>>
>>   - 'before means show the preview before the tex source while editing
>>
>>   - 'after means show the preview after the tex source while editing
>>
>>   - 'buframe means to show the preview in a buframe while editing
>>
>
> OK, this makes it clearer somewhat. Though see above regarding how
> modification of the TeX source changes behaviour (at least in my
> setup). You also mention "while editing", so what happens when not
> editing?

When I say "while editing", I mean "when the point enters the TeX
source, so that the user could in principle edit it".  Consider how
'preview-point' behaves right now: either the point is inside some TeX
region (that's what I mean by "while editing"), or away from it.
Behavior "when not editing" is controlled by 'preview-display-style'.

>> Let's translate current behaviors to the above setup:
>>
>> Traditional preview with preview-leave-open-previews-visible nil:
>>
>> (setopt preview-display-style 'preview)
>> (setopt preview-reveal-display 'none)
>
> I am gonna assume you mean that while editing or during the generation
> of the preview the construction sign appears (before or after?). What
> happens when the preview is ready?

When the point later exits the TeX source (and, if modification occurs,
after the preview regenerates), the display reverts to what is specified
by 'preview-display-style'.

>> One benefit of separating these concerns is that we could keep
>> traditional preview behavior away from point while using a buframe for
>> live editing of tex source:
>>
>> (setopt preview-display-style 'preview)
>> (setopt preview-reveal-display 'buframe)
> This is what I was trying to say. I think using a buframe for source
> editing is not really tenable and would be too difficult to get
> right.

I think we have a misunderstanding.  By "using a buframe for source
editing", I mean:

- The point is in the TeX source, editing the TeX code there.

- The previewed math is (only) displayed in a separate buframe (updating
live as the user edits, if automatic previewing is enabled).

This is what exactly 'preview-point' already does in its current
implementation.  (It sounds to me like you thought I was proposing to
have the TeX source in the buframe, which was not my intention; I can
see how you would view that proposal as untenable.)

> Overall, I am of the opinion that (modulo some forward-thinking
> introduction of the options) we do not over-complicate the current
> implementation at this point by introducing more modes of operation.

I don't think I'm proposing to introduce more modes of operation.  I'm
just observing that preview-point bundles two orthogonal features: (a)
disabling preview display by default, and (b) richer customization of
how to display the preview at point.  Feature (b) would be useful even
without feature (a), so it seems worth decoupling the two and allowing
them to be configured separately.  Does that clarify what I had in mind?

Thanks, best,

Paul





Information forwarded to bug-auctex@HIDDEN:
bug#79708; Package auctex. Full text available.

Message received at 79708 <at> debbugs.gnu.org:


Received: (at 79708) by debbugs.gnu.org; 3 Nov 2025 07:57:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 03 02:57:41 2025
Received: from localhost ([127.0.0.1]:38371 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vFpRc-0006IS-P3
	for submit <at> debbugs.gnu.org; Mon, 03 Nov 2025 02:57:41 -0500
Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:51589)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <abdo.haji.ali@HIDDEN>)
 id 1vFpRX-0006H7-AS
 for 79708 <at> debbugs.gnu.org; Mon, 03 Nov 2025 02:57:36 -0500
Received: by mail-wr1-x429.google.com with SMTP id
 ffacd0b85a97d-4298b865f84so1771893f8f.3
 for <79708 <at> debbugs.gnu.org>; Sun, 02 Nov 2025 23:57:35 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1762156645; x=1762761445; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=6W2HflxCCcBxJNYVY9vq7BHGDZkoEgpf+iOql2DOHqU=;
 b=Z9lMBngLof51CDfuCcmApq3Lwj89Wd+hJixfyaKVT0q9MSedb1XfW23HC00d74MG8O
 540ydqcS5/LLKoCjPWqKONgQ7hM6X15Yx0kyF4m6a+13XiBe2gnay1WnXXMEBaqV4OfR
 rgxDXe16tP8JNGU6iKNDlG+xMjGjcZlNa9EyqrmsFYExgubbrLpQLwvi1aB7Pksy2m8d
 uTtBMWT1dCzvOuQuc4OkcxfMjVP8G51tDoDB/+Mtwx+Z51gCEsfDAsirkKdVIFVY2ohT
 ZYhh1sIyN3NCtL0zLG+vIP2j5uihr2qVUPL5s38W7OLJoZGRlKu6XVOF/B4viDnGEHtn
 l8Aw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1762156645; x=1762761445;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=6W2HflxCCcBxJNYVY9vq7BHGDZkoEgpf+iOql2DOHqU=;
 b=e1HkqrlYSWtIP1hw7uXxwNNukSGAMO6LyNA8uCf759onZqTZbeGhHrtr99f20+d83M
 6N4Ib4YqSNga7uJrTNzDk1EsoAg865pdUiKYm/RrAJlWM1+p6Vw7DkDWB4eLTDDnj3Ow
 AVN1kC3fAaWjrOLhxeFHqwDjqgwQYwFu+q+tq1eG+cSsG/EBsacYw1C6T/Zm13Jy9xP1
 waC60SDZnJntmcSL/1P9xdPei3KElf9Muup4XowRuIc/4N0/SQ58H4pBXRiWIAINm9Or
 YmK6sDbCYdFzub6hKEvvjMGy1BnZOPmDsyP8aSuBoIPahw/yycFPWAfkRGwGHt4A+e/c
 jTVA==
X-Gm-Message-State: AOJu0YyMLl0fM5Hd/eJICNAxYg1mZcaJo3s5AUSEzoIED1ijn0JBBqM7
 Hs0rGdNjuNxVQ/CIycwHZfStPw2rEotLgsqqSAtG1J/ZUz9T06W/aLIF
X-Gm-Gg: ASbGncuAGe2h00LUHPZu/KKm5YlpBq11UF0NkSkrXge8KvH9FqjWcPJnRJxN18CrJd4
 hiu2zS/Th8Wk/Xx/RA+ZtzLbyyKr8U7odXo//oaAyuojnG8dXIR2Wkm8U82hQSA+HINI7eSg9+G
 +aSYXgh8KAURKrJ/Ik3QMZUddLMn6xdY18FcObH3iTuws83HmScjCAjMH5vVXS8lKj0GJWGKmDb
 +nrGcIBLsjaFZcOjGul04Y7uc354DB5dnlq0tXWLSBVBNlnvKnfOtqZlSL8En77+FLFnWHRp9bf
 1l42e9vbZkYUtb8FvC5cXI5Pqzhj56zwTpkHTof6EAqmc4YNZJhn2l4dBvb5u5he8TftiQDnxVz
 Wi4gTDXyrElVi3xn/YHWOUu11ekozvx8Ufi7j8G7XbjIvVVwwCAwoJQV/UT7wUukjdE5D9En/aA
 3pdnSppK/VbdUKE6seV8YvSz6OMLbWI2tHY9seOQ==
X-Google-Smtp-Source: AGHT+IHY8cNbSL299ft3Q9le0gJMghFApLIbIdcogjsLJBLj8X+GMFRdPP+GYp138x1/dhffzlUB1A==
X-Received: by 2002:a05:6000:25e9:b0:429:cacf:108c with SMTP id
 ffacd0b85a97d-429cacf1359mr3764262f8f.10.1762156644577; 
 Sun, 02 Nov 2025 23:57:24 -0800 (PST)
Received: from localhost (eduroam-262-0-205.epfl.ch. [192.33.204.205])
 by smtp.gmail.com with UTF8SMTPSA id
 ffacd0b85a97d-429c13e1d47sm18798467f8f.23.2025.11.02.23.57.23
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 02 Nov 2025 23:57:24 -0800 (PST)
From: Al Haji-Ali <abdo.haji.ali@HIDDEN>
To: "Paul D. Nelson" <ultrono@HIDDEN>
Subject: Re: bug#79708: 14.1.0; [PATCH] New feature: preview-point
In-Reply-To: <uxsg7t4ircm8ki.fsf@HIDDEN>
References: <uxsg7t4ircm8ki.fsf@HIDDEN>
Date: Mon, 03 Nov 2025 08:57:06 +0100
Message-ID: <m0wm47r1kd.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79708
Cc: 79708 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


On 02/11/2025, Paul D. Nelson wrote:
> The main effect of preview-leave-open-previews-visible isn't tied to
> whether the tex source has been modified, but is rather that when point
> enters a preview overlay, the preview remains visible instead of
> collapsing to the construction symbol.

Hmmm... I am not sure what I am missing. On my setup, the construction
symbol only appears when the source is modified.  If I open the preview
by having the cursor "go into" the preview image, then navigate away
from the source, the preview is collapsed again if I don't modify the
source.

The documentation is also unclear, because the first part of
`preview-leave-open-previews-visible` leans toward what you say:

--8<---------------cut here---------------start------------->8---
Whether to leave previews visible when they are opened.

If nil, then the TeX preview icon is used when the preview is opened.
If non-nil, then the preview image remains visible.  In either case, the
TeX code appears either below or to the right of the displayed graphic.
--8<---------------cut here---------------end--------------->8---

but then the next part is what I am seeing:

--8<---------------cut here---------------start------------->8---
If you enable this option, the preview image doesn't turn into
construction sign temporarily when you edit the underlying LaTeX code
and regenerate the preview; it is just replaced by updated image when
ready.  This behavior suppresses flicker in the appearance.
--8<---------------cut here---------------end--------------->8---

> Let me restate the proposal using your terminology and proposed setting
> 'preview-display-style' (for which the 'both option is not what I had in
> mind, but could also be considered).  Two independent knobs:
>
> - preview-display-style ('preview, 'src): controls what's shown for
>   previews away from point, that the cursor is *not* inside.
>
> - preview-reveal-display ('none, 'after, 'before, 'buframe).  What to
>   show when point enters a previewed region (i.e., the overlay or the
>   underlying tex source):
>
>   - 'none means just show the tex source and the construction sign
>
>   - 'before means show the preview before the tex source while editing
>
>   - 'after means show the preview after the tex source while editing
>
>   - 'buframe means to show the preview in a buframe while editing
>

OK, this makes it clearer somewhat. Though see above regarding how
modification of the TeX source changes behaviour (at least in my
setup). You also mention "while editing", so what happens when not
editing?

Also, the placement of the construction sign can be before or after the
source, just like the preview (in fact that's what preview-point does as
well when preview-leave-open-previews-visible is nil).

> Let's translate current behaviors to the above setup:
>
> Traditional preview with preview-leave-open-previews-visible nil:
>
> (setopt preview-display-style 'preview)
> (setopt preview-reveal-display 'none)

I am gonna assume you mean that while editing or during the generation
of the preview the construction sign appears (before or after?). What
happens when the preview is ready?

> One benefit of separating these concerns is that we could keep
> traditional preview behavior away from point while using a buframe for
> live editing of tex source:
>
> (setopt preview-display-style 'preview)
> (setopt preview-reveal-display 'buframe)
This is what I was trying to say. I think using a buframe for source
editing is not really tenable and would be too difficult to get
right.

Overall, I am of the opinion that (modulo some forward-thinking
introduction of the options) we do not over-complicate the current
implementation at this point by introducing more modes of operation.

Best regards,
-- Al




Information forwarded to bug-auctex@HIDDEN:
bug#79708; Package auctex. Full text available.

Message received at 79708 <at> debbugs.gnu.org:


Received: (at 79708) by debbugs.gnu.org; 2 Nov 2025 21:24:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 02 16:24:58 2025
Received: from localhost ([127.0.0.1]:33837 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vFfZJ-00078Z-Jr
	for submit <at> debbugs.gnu.org; Sun, 02 Nov 2025 16:24:58 -0500
Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]:58510)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <ultrono@HIDDEN>) id 1vFfZH-00077X-Eh
 for 79708 <at> debbugs.gnu.org; Sun, 02 Nov 2025 16:24:56 -0500
Received: by mail-ej1-x62d.google.com with SMTP id
 a640c23a62f3a-b4736e043f9so631975766b.0
 for <79708 <at> debbugs.gnu.org>; Sun, 02 Nov 2025 13:24:55 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1762118687; x=1762723487; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:from:to
 :cc:subject:date:message-id:reply-to;
 bh=eWLf83htBeGYWxpuVVoLDB8lwO15CDFnCqei2D6Hteg=;
 b=XsUuNviggGBwEaUODdxPunvkuDOm6nqMPpXwgWN7G11V6O/RsLKpr3IADlhCh7UZyF
 +1/Zo5FvzClA5km3KGM/qaccRQLPvqGATNiq7dTOmVvmL4Q2IYQBlDca1oYhHXvTkPv/
 pO9gcic4/1XBG9OEMcZJHsc9jaseBc2yw0j5h3vTdgWh1S7gz5DAV/EKhZxz56oHQbGR
 w3h0T3DY3Sc+dXVzYwot2vcnbN0hBG7UoM+/eFE3w9GKO3xCSrFG6ANGb9VmJpjBykok
 qiSMl3jpaZBeQEQVgbubLWvvOZV39rVVXPGTJy2LHUO338NBGiWw0w3TKIikSDjvYhMc
 qiSA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1762118687; x=1762723487;
 h=mime-version:message-id:date:in-reply-to:subject:cc:to:from
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=eWLf83htBeGYWxpuVVoLDB8lwO15CDFnCqei2D6Hteg=;
 b=QrIPqpYUAKG4acYO+2qYtlqWIaSPovYpUYwdFERxwAW4aCxOo2i5naIlFqWs6i1cqA
 u+pESBEQxeF3lcBJ+Wkr4aJknen5LFDr/DIZN3/5W/v3YMpB967phrZwkAn98R1oGqkK
 M7ZdWESIu8waWD+3sJjCTaQLFJrmQhNpAW8W59LQk6tQISCniBHw64z2CI7PyWc1v07Z
 Hicf0gbUhIuuw+epLWJfyYij1Wij7RbFfYgkIn+ewVOQGQLbbP1OtwzlU8x1lyJBgCmS
 jJv4Wdg/krsFfvXgRsw1YJ0pIiQuYYGY/RObt1fOFfvHEGIeHVbTkhuLlHd33ks2JrOJ
 uXMA==
X-Gm-Message-State: AOJu0YwrIJyUuTmdCbqF9oV1H4CRijFpYbn/4gi7JcpQyNwklbUuKrF8
 bIRuviiKabhlNY67eqBzo8nRtYEs92lEU3bhs8NfakQZ3cAM4b+41htC45utKw==
X-Gm-Gg: ASbGnctrONyNSADn+QRTEFlp6TDUpvq8fq1amDcFA3v+lbmd2ZWP9ltY2l0ZVAa041Y
 UBWHcZ7AkNudbOWuX2QkUPnYK6kcil1MgMTwufkwMGvvv4IRKQUxBYL8A/0aS+A5KhDLuldJVQ+
 9PUqyKVD1ns0BWFW1M+zVgRLwUV43T+A0lU1g0ANRgtgMY5gCWA/DtyR3wNySVeMyRD4t2v/iVR
 6ep1Likk4/BSjxArZi5F0pzV732bmbWeNPWq60eTFNJDs1ftOMCsF/l4yMsR+jNcf19Cyc5KNjP
 piHzM+tJABvo4v0sceuxzn3sx13LGkmhZxUPR1SPpkwQEzr+OG/Zf8iaiPkzNPOH6yT9uo8EwUj
 +faPh+1YPpiBgTl3aVCt8wi6xUBQTq4WBY6cy6fRRpFdajtoDApDl1bpaOCF90PLy+ehrlh9iHT
 yOdq5S8SF4EEvbCyRsdjI5cwcHtKAekQACMLkjc6ufB7Yak4a3gv/6NA==
X-Google-Smtp-Source: AGHT+IHUMJAFblvzctZITnvqxQUWKc/vrOvBmP6mQJlEQrdN7KhLPWWJSDYIDUEt/8jZPfkDRpwSwQ==
X-Received: by 2002:a17:907:3f8b:b0:b04:5e64:d7cd with SMTP id
 a640c23a62f3a-b707060e439mr1150871366b.46.1762118686793; 
 Sun, 02 Nov 2025 13:24:46 -0800 (PST)
Received: from localhost (0x5da5fbd2.static.cust.fastspeed.dk.
 [93.165.251.210]) by smtp.gmail.com with UTF8SMTPSA id
 a640c23a62f3a-b7077975d77sm838514266b.9.2025.11.02.13.24.45
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 02 Nov 2025 13:24:46 -0800 (PST)
From: "Paul D. Nelson" <ultrono@HIDDEN>
To: Al Haji-Ali <abdo.haji.ali@HIDDEN>
Subject: Re: bug#79708: 14.1.0; [PATCH] New feature: preview-point
In-Reply-To: <m0o6pkus37.fsf@HIDDEN> (message from Al Haji-Ali on Sun, 02
 Nov 2025 20:55:56 +0100)
Date: Sun, 02 Nov 2025 22:24:45 +0100
Message-ID: <uxsg7t4ircm8ki.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79708
Cc: 79708 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi Al,

>> - the preview before the tex code (current behavior of
>>   preview-leave-open-previews-visible t)
>> - the preview after the tex code
> My understanding of the `preview-leave-open-previews-visible` option is
> that the previews remain open only when the tex code is changed rather than
> being replaced with a sign. If the tex source is not changed, the
> previews are not kept open. In particular, this shouldn't affect the
> position of the image AFAIK.

The main effect of preview-leave-open-previews-visible isn't tied to
whether the tex source has been modified, but is rather that when point
enters a preview overlay, the preview remains visible instead of
collapsing to the construction symbol.

Let me restate the proposal using your terminology and proposed setting
'preview-display-style' (for which the 'both option is not what I had in
mind, but could also be considered).  Two independent knobs:

- preview-display-style ('preview, 'src): controls what's shown for
  previews away from point, that the cursor is *not* inside.

- preview-reveal-display ('none, 'after, 'before, 'buframe).  What to
  show when point enters a previewed region (i.e., the overlay or the
  underlying tex source):

  - 'none means just show the tex source and the construction sign

  - 'before means show the preview before the tex source while editing

  - 'after means show the preview after the tex source while editing

  - 'buframe means to show the preview in a buframe while editing

Let's translate current behaviors to the above setup:

Traditional preview with preview-leave-open-previews-visible nil:

(setopt preview-display-style 'preview)
(setopt preview-reveal-display 'none)

Traditional preview with preview-leave-open-previews-visible t:

(setopt preview-display-style 'preview)
(setopt preview-reveal-display 'before)

(In particular, if this proposal makes sense, then I think
preview-reveal-display could supersede
preview-leave-open-previews-visible.)

preview-point with buframe:

(setopt preview-display-style 'src)
(setopt preview-reveal-display 'buframe)

One benefit of separating these concerns is that we could keep
traditional preview behavior away from point while using a buframe for
live editing of tex source:

(setopt preview-display-style 'preview)
(setopt preview-reveal-display 'buframe)

We could similarly position the preview after the tex source, if
desired.

Does that sound consistent with what you had in mind?

Thanks, best,

Paul




Information forwarded to bug-auctex@HIDDEN:
bug#79708; Package auctex. Full text available.

Message received at 79708 <at> debbugs.gnu.org:


Received: (at 79708) by debbugs.gnu.org; 2 Nov 2025 20:00:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 02 15:00:11 2025
Received: from localhost ([127.0.0.1]:33368 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vFeFH-0002ZB-5W
	for submit <at> debbugs.gnu.org; Sun, 02 Nov 2025 15:00:11 -0500
Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:42327)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <abdo.haji.ali@HIDDEN>)
 id 1vFeFE-0002TE-O2
 for 79708 <at> debbugs.gnu.org; Sun, 02 Nov 2025 15:00:09 -0500
Received: by mail-wm1-x32b.google.com with SMTP id
 5b1f17b1804b1-47721293fd3so20378495e9.1
 for <79708 <at> debbugs.gnu.org>; Sun, 02 Nov 2025 12:00:08 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1762113602; x=1762718402; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=nzphbtIa7WA6NLzN2Z4rnoeJ1+SDzjOxLKo77Pxa0iE=;
 b=EKAWVQ6pLzIjqZM1ISYG75cHorlYamtVhyZ6GXtgiNoNfOhAC10yYEFh3I48vg0i55
 Wu650fkwnBt0BnZSATWNRVrU1Pr2qTJCLYqEljYQpuMOfHDpbp+YIUc56qctYTbZYHtQ
 lyXHMwVkGriHN54XIU3dIs+UFN9VH7zNJukRpQf3NxHhvJcf70ApxDLJYspRjhUECx6B
 IRvrizDI6o7cmEYaf+/WxP+16AWzt6p8ACmDjuwCbNqtZWxI5idMJnb/eE/8SgtKXWNp
 bX75ZCYjO1vqidMoi2Wsp5xREouiHllWnoaiTJH9DxNx0+se9bmYTOSAk1Dk0ZdvmhBG
 bcOQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1762113602; x=1762718402;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=nzphbtIa7WA6NLzN2Z4rnoeJ1+SDzjOxLKo77Pxa0iE=;
 b=a2hzelAu2acL5XztySo224Mz79v+cOSoxiPdTd/6+4ZKlONWIDt1vYiFotHcDivxBi
 YeDpxLXGAI0uyd/ITQmLCcEFDt981F5D2+pKmkonyhng97TFuklDx/8Jd3V7VzY38uhw
 SchKzv/D0knfPGtcT78iNbnS4lFryPQbaNeCwO+I99kzys5wPAzwPA8IV9+umqIduUSd
 9MAbPn5dm0tqSCR0PvEPC03CjW0NnSIM8Uo54Hp7pgwCVhHSKaiUyrt9pVJm3CGsYT4k
 o2l01pZjAXStJZmBCK41CgJ5/W8ZCPB3HoQU3gCiRFq1mb1mOg9rK2zoPphw0JWJstbM
 8pdg==
X-Gm-Message-State: AOJu0YwkEIw2D+qi0g+4sv0ZcwDMoq0e9UNTox0/FZcaUSzadntFYO5A
 7r1mZS+3yqEcqADJCanytJAyimPaV4BFcCJLs+V1XG0/LWDFH64F4EynhHKEfX+R674=
X-Gm-Gg: ASbGncugiX6F+3rvqhuYZcdEUbeMVZOlR2P/U5ofnuLwNLZTtt9yiUB7vE3bVqflAqx
 AXU7Pv2/gnG7TKFVQJM3jtuI80eq8CyFgiawlQonPXCT4wdJk6zy0mrZjmxmQzF1Ns1evNuzyU3
 DGerighqCzZmr6u/yYHfLNMr5ZfdUpqJXzUaModvxBAW/fuHCJDVasxbTMCt9RyYuIoLmlcNM7m
 cJyBl/BusAmxEZDr/WO2sUa340f37hZqmUZvPd48KwW82HxNLwB7b3T1J07+eECxqtj95CUmfjQ
 qmeMP8zSmSGcSBf935IR8MQmldUm0Y0RPNgnVxx2JmZDQQteU2In1cOmk2jOlqsHZ7qhnRm6rZz
 Mu/Pe2XArwdMbgoMTD5GDjxnjimw/DzE6AaTD7sVcC4JId24nJVI/R19TUV6WO0+CZjs9m/3EMm
 e+nH4BtUQl6zWsmX01enjZ8SN9jKOobRXb2y51/1Q7hRczDA43
X-Google-Smtp-Source: AGHT+IHhNK8QTYScyDJh69rp4SUzjg6b9LlIazh7+BZ/kztaFTCtk6OljIDY49kASAIO9P/hzB2i7g==
X-Received: by 2002:a7b:ca54:0:b0:475:dc32:5600 with SMTP id
 5b1f17b1804b1-477262e8fd6mr102340375e9.19.1762113602047; 
 Sun, 02 Nov 2025 12:00:02 -0800 (PST)
Received: from localhost (eduroam-262-0-205.epfl.ch. [192.33.204.205])
 by smtp.gmail.com with UTF8SMTPSA id
 5b1f17b1804b1-4773c374f84sm113736295e9.0.2025.11.02.12.00.01
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 02 Nov 2025 12:00:01 -0800 (PST)
From: Al Haji-Ali <abdo.haji.ali@HIDDEN>
To: "Paul D. Nelson" <ultrono@HIDDEN>
Subject: Re: bug#79708: 14.1.0; [PATCH] New feature: preview-point
In-Reply-To: <uxsg7t7bw8mlq9.fsf@HIDDEN>
References: <uxsg7t7bw8mlq9.fsf@HIDDEN>
Date: Sun, 02 Nov 2025 20:55:56 +0100
Message-ID: <m0o6pkus37.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79708
Cc: 79708 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello Paul,

Apologies, there's something I don't fully understand. Below is an
attempt at explaining what I currently understand.

On 02/11/2025, Paul D. Nelson wrote:
>
> - just the construction symbol and the tex code (default behavior in
>   AUCTeX)
>
> - the preview before the tex code (current behavior of
>   preview-leave-open-previews-visible t)
> - the preview after the tex code
My understanding of the `preview-leave-open-previews-visible` option is
that the previews remain open only when the tex code is changed rather than
being replaced with a sign. If the tex source is not changed, the
previews are not kept open. In particular, this shouldn't affect the
position of the image AFAIK.

So, I assume then that you don't mean changing the traditional preview
style after all?  But rather have a mode which always show the preview
before or after the tex source with the point movement not affecting
previews.

> - a buframe showing the preview
This has to be point-specific, otherwise it would require showing too
many frames and I don't think it would look good to always show and move
them around.


In summary, here are the behaviours we can have:
- classical preview, before-string (open on cursor going inside image).
- classical preview, after-string (open on cursor going inside image) -- New, needed?
- preview-point with {after,before}-string or buframe.
- a new mode where previews are not affected by cursor movement, and
  previews are always shown as {before,after}-string.


If my understanding is correct of your proposal, then indeed one can have two options, let's say:
- preview-display: 'preview, 'src, 'both
- preview-display-style: 'after-string, 'before-string, 'buframe

with 'buframe being only supported when `preview-display` is `'src`.

Here:
- preview-display='src is the preview-point style.
- preview-display='preview: is the current preview style.
- preview-display='both: is the new style you want where both source and preview are always shown and point movement does not affect them.

If my understanding is correct, it shouldn't be too difficult to implement these, I think.

Best regards,
-- Al




Information forwarded to bug-auctex@HIDDEN:
bug#79708; Package auctex. Full text available.

Message received at 79708 <at> debbugs.gnu.org:


Received: (at 79708) by debbugs.gnu.org; 2 Nov 2025 16:40:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 02 11:40:43 2025
Received: from localhost ([127.0.0.1]:60180 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vFb8E-0003HA-VD
	for submit <at> debbugs.gnu.org; Sun, 02 Nov 2025 11:40:43 -0500
Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]:59687)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <ultrono@HIDDEN>) id 1vFb8B-0003Ff-DU
 for 79708 <at> debbugs.gnu.org; Sun, 02 Nov 2025 11:40:40 -0500
Received: by mail-ed1-x52b.google.com with SMTP id
 4fb4d7f45d1cf-640bc4ced7bso417565a12.3
 for <79708 <at> debbugs.gnu.org>; Sun, 02 Nov 2025 08:40:39 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1762101632; x=1762706432; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:from:to
 :cc:subject:date:message-id:reply-to;
 bh=opjPjRcU2+PFlfZpKurMnlYtQTHuB3Kan1BHE3WR824=;
 b=L4d/o5Zu0HuqO6sdZP3QYz8gItWz+jOGJL5284VkSpo4kZaUy9Fb5W+n4tOHH+mWRq
 zoksfPKt3XVcSg6L2nAkSQQr0IMUtcpVaEpDTzLmZWLad1ar3Thcd8hacJybYqVRwKR6
 JXZUB56WqxYb+xybmcG0B6nm2TjQe5nSdDGo/csGWYpNBmtPG+jdtQH0CyyVhL9UAr+2
 HnjHTXg43U8Frjhv5HxDtx6IW/YPJ2mUiq+gaednkjCL8fyFiKPdOb7/Sxht5Zq60L4W
 gHBeslfWNHDsRYxSj8JNgmgkrNmploK/E3PPA2NvC3AyYBcGfZ4qDTo30hhcufxgseMu
 eg7A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1762101632; x=1762706432;
 h=mime-version:message-id:date:in-reply-to:subject:cc:to:from
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=opjPjRcU2+PFlfZpKurMnlYtQTHuB3Kan1BHE3WR824=;
 b=SN8YthXUqWLLUplovx27Uxh727nE45PMJR9bWuTmmR+IQuHpvX4uNe5ZE7p70hB6jS
 o+jXtl1+njQpM96X331z4GaxznrJ7BYxdoOJNtDZdwtviBCdUfsNubv7VuSP1XaOeJxJ
 VJbzVsvr6GT/ARVxdAebrAirEHzSPZgmz/vHz0NW2Y88FB0gTC6vWkQhaHmDozw+VHYi
 Zjf6IRTy0rdcZq073Kw3nMlvQYw1+Kd0Qr0hjuH4RBrVm3TIy4cAN+0ASLddMOdXVXzm
 4GPIJ7NKUPUslTgrLU5K7K8Dk/QFhhUWqZ4Kv1Jv52J8mhDJQAJ1h+kiOhX5JkjkLIQu
 1BqA==
X-Gm-Message-State: AOJu0Yya2+2CL5FuO7iT40ghWdLlzf8w2RFXjDhdczQAEzj85fqoxQl/
 48tP+jlSpfU3RF7hHRsF25vWmWxmQzIbk1ywEAxBsumwdPZK5yVkj2ZIsCSQKQ==
X-Gm-Gg: ASbGnctuLWHoMBGafOWrqYJknu3WnvpcjiHKt/TyItUdqhV9Bb2/885eCb0CLEJ1TDa
 mTH13PihLGSNEkcxjGRT+hCquJHMZVH74Mvz2Ezs65bnbrRm/F3uBBEOYzrOPs1BxN/FQhNpyO6
 180gnl/RGX4NSePCh7dsNSELvPDqp0z4vz6TKyV4nZsqC+dKTY5JYCMc1X1PStW24pwlxMnTzhl
 wSn6jd+DUEtvK6TlnHbYQkgayzUeeEl/T/4kDf46U/H5lQwoakx3ljHKrQlm1FcGmkqWOQhIS/u
 WRUvIfr2q/1bYuUMdLjWkmDXgAmUZfok5M/kIKHRz5dN5aZhTY+6sEoAS4qOA/pxrd0+e1Nk2j3
 UC1P4N3fbvAFyb362uj06FBpkkihteFkxYMtpJyNF0cj/SnR94oo1SNdLJbCTh0dKRIIte0U/1B
 uL6guf/MEqDG7qvjINmXtCTA0HAvqEsCVRoN/oeBCQw7Q=
X-Google-Smtp-Source: AGHT+IHxXHydftexAhJHsZ1hZiQuOra8QrysfC/YgzjNd0BinP4yt4FAAOPhKHKFiGakO1dtEhmwBw==
X-Received: by 2002:a17:906:dc8c:b0:b6d:5f02:51e1 with SMTP id
 a640c23a62f3a-b7070178f92mr1036261166b.20.1762101631950; 
 Sun, 02 Nov 2025 08:40:31 -0800 (PST)
Received: from localhost (0x5da5fbd2.static.cust.fastspeed.dk.
 [93.165.251.210]) by smtp.gmail.com with UTF8SMTPSA id
 a640c23a62f3a-b70779abc36sm795778766b.25.2025.11.02.08.40.31
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 02 Nov 2025 08:40:31 -0800 (PST)
From: "Paul D. Nelson" <ultrono@HIDDEN>
To: Al Haji-Ali <abdo.haji.ali@HIDDEN>
Subject: Re: bug#79708: 14.1.0; [PATCH] New feature: preview-point
In-Reply-To: <m0v7jszjmf.fsf@HIDDEN> (message from Al Haji-Ali on Sun, 02
 Nov 2025 13:47:36 +0100)
Date: Sun, 02 Nov 2025 17:40:30 +0100
Message-ID: <uxsg7t7bw8mlq9.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79708
Cc: 79708 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi Al,

Responding just to the structural question for now.  I think I
miscommunicated:

> We could frame the feature as what's being displayed by default, with
> display-styles for either mode being after-string, before-string or
> buframe's.

I wasn't proposing to change what's displayed *by default* for all
previews, but rather what's shown *after entering an existing preview*.
The options would include:

- just the construction symbol and the tex code (default behavior in
  AUCTeX)

- the preview before the tex code (current behavior of
  preview-leave-open-previews-visible t)

- the preview after the tex code

- a buframe showing the preview

Does that clarify?  Could either shoehorn this option into
preview-leave-open-previews-visible, or absorb that into a new defcustom
('preview-reveal-display'?) taking the values 'none, 'after, 'before,
'buframe.  The issue is orthogonal to preview-point vs. normal -- it's
just about "reveal behavior on entry".  Note that we're not trying to
edit inside the preview image - we're just choosing how the preview is
displayed when the tex source is made visible after you enter the
overlay.

Does that clarify?  I think this would be useful (e.g., I would try it
out with traditional previews).

Paul




Information forwarded to bug-auctex@HIDDEN:
bug#79708; Package auctex. Full text available.

Message received at 79708 <at> debbugs.gnu.org:


Received: (at 79708) by debbugs.gnu.org; 2 Nov 2025 12:50:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 02 07:50:27 2025
Received: from localhost ([127.0.0.1]:58365 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vFXXN-0005i9-AZ
	for submit <at> debbugs.gnu.org; Sun, 02 Nov 2025 07:50:27 -0500
Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:45166)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <abdo.haji.ali@HIDDEN>)
 id 1vFXXD-0005en-Rj
 for 79708 <at> debbugs.gnu.org; Sun, 02 Nov 2025 07:50:18 -0500
Received: by mail-pf1-x431.google.com with SMTP id
 d2e1a72fcca58-780fc3b181aso2496432b3a.2
 for <79708 <at> debbugs.gnu.org>; Sun, 02 Nov 2025 04:50:15 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1762087808; x=1762692608; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=XRJDLQOjzUEFV9/G8Y7GkqAZR4mASioRDb6Ifa1vFB4=;
 b=H+BI0EW1F8CGXw/8Mb/yKx15cU+Gml7LWLyKibm/4oADZnWF6n3TBhD7VCpOnjduZl
 lfjhBQKXDrlsOyf1w7oi6dhF8mREsPC7yzVcEUCPnLhp0Qv439WX3Grdq8X2l6H7oCse
 D69+f2xO7Zwv5Sgxu/NY+8zp1ft53MYl672J536AEw6zj817G1XgKS4aShJdCjPtqaDn
 YIcNbKFBY0onc1dLb7u5pmgBF/fCB1A+bSHMwG5dPDukXXc2InVs5X/jI06akNuvasRz
 7eoJe7uczpujsZi/+d+8jF2TDp0XP4Z7GsQDAlGDKsPmfpd6aMLE5lYObyejPjFp4s3d
 ztJw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1762087808; x=1762692608;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=XRJDLQOjzUEFV9/G8Y7GkqAZR4mASioRDb6Ifa1vFB4=;
 b=o+ipcq1r8mJwXVbGmHRym2GWGC7Fa04oxjLlNblSjULkJOKkLtXm4RU6tUkMMaUm8f
 eA+jMpCOkKT5h0dRmhHvPNoa5DgYwx6aeeZ4S/ys2yDPWGnUxalqyv+HTsSRLCkssZY4
 5amh842roWTLCEn4fEZ2fsOQ6Im5uu8RUVN/ex349O+nqsoOPRk6ITGggqIouAXKnvEA
 4f9X3CToV/W7ONmHUhXcQeekwwsgzFkDq1aN2GaZ7CrMjFgJ4q8GFwbGdXmEFtXTvyAK
 H5+d48TKFHyTHzD3ICmVzzVmeJNaM7UXUphwFOCNHDEY/BFhr2e26zvX6CEasHHk2XWc
 UOrA==
X-Gm-Message-State: AOJu0YziahBsCnaYFvfBairguvWN/Bbm08x6+Xu+lzvO6JfDLk7Ztfhp
 +y47mqGGY3Zl+ZOBtuhKUvttxenTrDME0BUIc82sNYmDlQIltbeKIYFCj6JaoYmr5VI=
X-Gm-Gg: ASbGncuFMLpT+j2TJCiGx/F3WPYjp9fGk2hD5qP7Cg+CdM0KgAhW6wCXYT2EopLy0rd
 GZaMpt/o1z/DwW/1RvqsKMsFNkIQ6yAeaGWHx6xgQzodRrfMlT41rLRKovnBZKh/zaggt59UZkB
 o9zTyvBx6dPgEJ/foh2zerD1SNFavI6Vqx377PrAM20PKFp2ITWYg0Y5lqbtPiAe9i1xbKPi7KE
 hk3eKOdWo4Urori5ClykQDFadXVRUPTQ9xnG7ErS4D42VFQ9URFyP8V6ZTvHSp/BoUSXjZVYKvB
 QMcKvyf+yLhZoEKVh+KcUZRPea09bkGlc5BWVKlHUn5a7bze1S4Wth7qLKJnYWlgNul8Nf9OXja
 j5VRN+XLufalnD+g/7skg+jSv47waCcoYI5fDd3nIBSHNGdQ+lN54bicb9JX5zIsSyjVAKUwUgK
 LOlemZ+RvsOofJ7x5yQbn1hw==
X-Google-Smtp-Source: AGHT+IF+7x/AW109Oix7yIpV+dQjNfbVhey4V82Kvxt9t1wvRIYEY7MXPzmI+YhCEtj85rxIXGhfsw==
X-Received: by 2002:a05:6a20:9147:b0:2fd:5bf0:706c with SMTP id
 adf61e73a8af0-348ccdfb46amr15131678637.58.1762087808261; 
 Sun, 02 Nov 2025 04:50:08 -0800 (PST)
Received: from localhost ([45.77.178.229]) by smtp.gmail.com with UTF8SMTPSA id
 41be03b00d2f7-b9887a3f044sm3416590a12.18.2025.11.02.04.50.06
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 02 Nov 2025 04:50:07 -0800 (PST)
From: Al Haji-Ali <abdo.haji.ali@HIDDEN>
To: "Paul D. Nelson" <ultrono@HIDDEN>
Subject: Re: bug#79708: 14.1.0; [PATCH] New feature: preview-point
In-Reply-To: <uxsg7tbjllmnz6.fsf@HIDDEN>
References: <uxsg7tbjllmnz6.fsf@HIDDEN>
Date: Sun, 02 Nov 2025 13:47:36 +0100
Message-ID: <m0v7jszjmf.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79708
Cc: 79708 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain

Hi all,

(Paul, I answer below to your point).

Attached is an updated patch. Following Paul's suggestions, I added two
minor modes:

- preview-point-mode: is a global minor mode to enable point
  preview. Display style is controlled through preview-point-display.

- preview-point-auto-mode: is a local minor mode to enable auto updating
  of existing previews and generation of new ones. Generation is
  controlled via `preview-point-auto-function`. If the function returns
  a region, that is used instead of relying on `preview-next-border`. As
  Paul suggested, auto-previewing can probably can become preview-point
  agnostic once it is thoroughly tested with classical previews.

A couple of points:

- Currently, I update all previews in the current buffer when toggling
  `preview-point-mode` so that the mode can be toggled back and
  forth. This is problematic because other opened buffers will still
  have the "wrong" previews with the "wrong" local hooks. The main issue
  is preview-point-mode is not local while the hooks and the previews
  are. We can either leave it as is, or loop through all open buffers to
  do the necessary cleanup. I found making preview-point-mode local a
  bit cumbersome to implement (I never understood what the best practice
  is to deal with local variables when a master and included files are
  involved -- I might take another crack at it later).
  
- One thing I wanted to check: Can we rely on the `preview-region'
  returning the preview process.  It calls `preview-generate-preview'
  which has this documented behaviour, but `preview-region' does
  not. Perhaps I can add that to the documentation to make it official?

On 01/11/2025, Paul D. Nelson wrote:
> (a) Previews away from point are no longer displayed at all.
> (b) We gain further flexibility in how we can display the preview at
> point -- before the TeX source, after the TeX source, or in a buframe.
> [...]
> WDYT?  Does it reasonable to you to separate these features?

I think fundamentally, preview-point and the classical preview are
different in what they show by default. preview-point shows the source
by default, and then shows the preview when the cursor is inside the
source. Classical preview shows the preview by default, but then
displays the source when the cursor is "inside" the image. Both do not
display the hidden content away from point.

We could frame the feature as what's being displayed by default, with
display-styles for either mode being after-string, before-string or
buframe's.

However, I suspect this or having (b) as a feature on its own will be of
limited value since buframe only really works with
preview-point. Displaying the preview in a buframe means that point
cannot get "inside" it to show the source in classical preview mode
(plus we would have to track the many displayed buframes). We can't of
course show the source in a buframe, since that would prevent editing
it. So the only flexibility one gets is being able to show the preview
in an `after-string`, as well as the current `before-string`, but I am
not sure how desired such a feature is.

Best regards,
-- Al

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline;
 filename=preview-New-feature-preview-point.patch

From e2a5062c3d5e1c266533965ee9acb6ce659036df Mon Sep 17 00:00:00 2001
From: Al Haji-Ali <a.hajiali@HIDDEN>
Date: Tue, 9 Sep 2025 21:19:43 +0100
Subject: [PATCH] preview: New feature, preview-point

* doc/preview-latex.texi: Add docs for preview-point-mode
* preview.el (preview-silent-errors): New local variable.
(preview-point-mode): New globalized minor mode.
(preview-point-display): New custom variables
(preview-point-disabled-face, preview-point-processing-face): New faces.
(preview-point--frame, preview-point--current-overlay): New variables.
(preview-dvipng-image-type): Update doc.
(preview-log-error,preview-reraise-error): Implement silent mode based
on `preview-silent-errors'.
(preview-gs-sentinel, preview-gs-transact): Call `preview-point-refresh'.
(preview-ascent-from-bb): Return 'center when 'preview-point-mode' is
non-nil.
(preview-toggle): Call preview-point activation function.
(preview-disable): Control behaviour based on preview-point-mode.
(preview-map): Add key-binding for `preview-point-mode'.
(preview-mode-setup): Control preview setup based on `preview-point-mode'.
(preview-parse-messages): Restore point before calling place functions.
(preview-point--buframe, preview-point-inside-overlay-p,
preview-point-activate-maybe, preview-point-move-point,
preview-point-updated, preview-point-mode,
preview-point-toggle-auto-refresh, preview-point@around@write-region,
preview-point--preview-at-point, preview-point-has-preview-p,
preview-point-buf-change): New functions.

(preview-point-auto-mode): New local minor mode.
(preview-point-auto-delay,preview-point-auto-function): New custom variable.
(preview-point-auto): New functions.

Automatic previewing code derived from preview-auto.el (Copyright 2024
FSF, by Paul D. Nelson), adapted and integrated here.
---
 NEWS.org               |   2 +
 doc/preview-latex.texi |  12 +
 preview.el             | 522 ++++++++++++++++++++++++++++++++++++-----
 3 files changed, 472 insertions(+), 64 deletions(-)

diff --git a/NEWS.org b/NEWS.org
index ddfcd55c..4fb0d60e 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -21,6 +21,8 @@
 - Add new function ~preview-dvisvgm-command~ to generate SVG images in
   preview.
 
+- New feature: ~preview-point-mode~ and ~preview-point-auto-mode~.
+
 ** Changed
 
 - Change the format of the value stored in ~preview-dumped-alist~.  Add
diff --git a/doc/preview-latex.texi b/doc/preview-latex.texi
index 19210a35..a2052427 100644
--- a/doc/preview-latex.texi
+++ b/doc/preview-latex.texi
@@ -480,6 +480,18 @@ math (@code{$@dots{}$}), or if your usage of @code{$} conflicts with
 @previewlatex{}'s, you can turn off inline math previews.  In the
 @samp{Preview Latex} group, remove @code{textmath} from
 @code{preview-default-option-list} by customizing this variable.
+
+@item Enable preview at point.
+
+Enabling @code{preview-point-mode} restricts the display of previews to
+when the cursor is within a previewable area. The display behaviour is
+controlled by @code{preview-point-display}, which determines whether the
+preview appears before or after the TeX source, or in a temporary frame
+(requires the @code{buframe} package, available on ELPA).
+
+For automatic preview updates or generation, see
+@code{preview-point-auto-mode} and @code{preview-point-auto-function}.
+
 @end itemize
 
 @node Known problems, For advanced users, Simple customization, top
diff --git a/preview.el b/preview.el
index 94812886..8eb5cddb 100644
--- a/preview.el
+++ b/preview.el
@@ -372,6 +372,10 @@ See also `preview-gs-command'."
   "List of overlays to convert using gs.
 Buffer-local to the appropriate TeX process buffer.")
 
+(defvar-local preview-silent-errors nil
+  "When non-nil, do not signal preview errors nor display output buffer.
+This variable should be set in the process buffer.")
+
 (defvar-local preview-gs-outstanding nil
   "Overlays currently processed.")
 
@@ -456,6 +460,86 @@ set to `postscript'."
   :group 'preview-latex
   :type 'boolean)
 
+;;; preview-point customizations and variables.
+(defcustom preview-point-display 'after-string
+  "Specifies where to show the preview.
+
+Can be `before-string', `after-string' to show at before or after the
+TeX code or `buframe' to show in a separate frame (the `buframe' package
+must be installed).  Can also be \\='(buframe FN-POS FRAME-PARAMETERS
+BUF-PARAMETERS) where FN-POS is a position function (default is
+`buframe-position-right-of-overlay') and FRAME-PARAMETERS is an alist of
+additional frame parameters, default is nil and BUF-PARAMETERS is an
+alist of buffer local variables and their values."
+  :type '(choice
+          (const :tag "Before string" before-string)
+          (const :tag "After string (default)" after-string)
+          (const :tag "On frame" buframe)
+          (list :tag "On frame with explicit parameters"
+                (function :tag "Position function")
+                (alist :tag "Frame parameters")
+                (alist :tag "Buffer parameters"))))
+
+(define-minor-mode preview-point-mode
+  "Show the preview at point."
+  :group 'preview
+  :global t
+  :init-value nil
+
+  (if preview-point-mode
+      (when (member #'preview-move-point post-command-hook)
+        (remove-hook 'pre-command-hook #'preview-mark-point t)
+        (remove-hook 'post-command-hook #'preview-move-point t)
+        (add-hook 'post-command-hook #'preview-point-move-point nil t))
+    (when (member #'preview-point-move-point post-command-hook)
+      ;; First hide the current preview, if any
+      (when preview-point--current-overlay
+        (preview-point-activate-maybe preview-point--current-overlay nil))
+      (remove-hook 'post-command-hook #'preview-point-move-point t)
+      (add-hook 'pre-command-hook #'preview-mark-point nil t)
+      (add-hook 'post-command-hook #'preview-move-point nil t)))
+
+  ;; Go through all the preview overlays in the current buffer and reset
+  ;; them to be consistent with the current value of preview-point-mode
+  (dolist (ov (overlays-in (point-min) (point-max)))
+    (and (overlay-get ov 'preview-state)
+         (let ((strings (overlay-get ov 'strings)))
+           (dolist (prop '(display keymap mouse-face help-echo))
+             ;; The overlay inherits the properties of the string
+             (overlay-put ov prop
+                          (if preview-point-mode
+                              nil
+                            (get-text-property 0 prop (car strings)))))
+           (dolist (prop '(before-string after-string face))
+             (overlay-put ov prop nil))
+           ;; CDR of string should be rebuilt based on mode.
+           (setcdr (overlay-get ov 'strings) nil)
+           (when (memq (overlay-get ov 'preview-state) '(active inactive))
+             ;; Reset preview to neutral state of each mode.
+             (overlay-put ov 'preview-state
+                          (if preview-point-mode 'inactive 'active)))
+           (when (eq (overlay-get ov 'preview-state) 'disabled)
+             ;; Redisable preview -- starting from a active state.
+             (overlay-put ov 'preview-state 'active)
+             (preview-toggle ov nil)
+             (preview-disable ov))))))
+
+(defface preview-point-disabled-face
+  '((t (:inherit shadow)))
+  "Face used when preview is disabled."
+  :group 'preview)
+
+(defface preview-point-processing-face
+  '((t (:inherit preview-point-disabled-face)))
+  "Face used when preview is processing."
+  :group 'preview)
+
+(defvar preview-point--frame nil
+  "The last active preview popup frame.")
+
+(defvar preview-point--current-overlay nil
+  "The overlay currently shown in the preview popup frame.")
+
 (defun preview-string-expand (arg &optional separator)
   "Expand ARG as a string.
 It can already be a string.  Or it can be a list, then it is
@@ -629,7 +713,8 @@ is to be used."
         (insert-before-markers
          (format "%s: %s\n"
                  context (error-message-string err)))
-        (display-buffer (current-buffer)))))
+        (unless preview-silent-errors
+          (display-buffer (current-buffer))))))
   (setq preview-error-condition err))
 
 (defun preview-reraise-error (&optional process)
@@ -638,7 +723,11 @@ Makes sure that PROCESS is removed from the \"Compilation\"
 tag in the mode line."
   (when preview-error-condition
     (unwind-protect
-        (signal (car preview-error-condition) (cdr preview-error-condition))
+        (unless (buffer-local-value 'preview-silent-errors
+                                    (or (process-buffer process)
+                                        (current-buffer)))
+          (signal (car preview-error-condition)
+                  (cdr preview-error-condition)))
       (setq preview-error-condition nil
             compilation-in-progress (delq process compilation-in-progress)))))
 
@@ -709,6 +798,8 @@ and tries to restart Ghostscript if necessary."
               (let* ((err (concat preview-gs-answer "\n"
                                   (process-name process) " " string))
                      (ov (preview-gs-behead-outstanding err)))
+                (when ov
+                  (preview-point-updated ov))
                 (when (and (null ov) preview-gs-queue)
                   (save-excursion
                     (goto-char (if (marker-buffer (process-mark process))
@@ -1430,16 +1521,16 @@ Try \\[ps-run-start] \\[ps-run-buffer] and \
          (ps-open
           (let ((string
                  (concat
-                (mapconcat #'shell-quote-argument
-                            (append (list
-                                     preview-gs-command
-                                     outfile)
-                                    preview-gs-command-line)
-                            " ")
-                 "\nGS>"
-                 preview-gs-init-string
-                 (aref (overlay-get ov 'queued) 1)
-                 err)))
+                  (mapconcat #'shell-quote-argument
+                             (append (list
+                                      preview-gs-command
+                                      outfile)
+                                     preview-gs-command-line)
+                             " ")
+                  "\nGS>"
+                  preview-gs-init-string
+                  (aref (overlay-get ov 'queued) 1)
+                  err)))
             (lambda () (interactive "@") (preview-mouse-open-error string))))
          (str
           (preview-make-clickable
@@ -1494,7 +1585,8 @@ given as ANSWER."
                                     (preview-ascent-from-bb
                                      bbox)
                                     (aref preview-colors 2))))
-            (overlay-put ov 'queued nil)))))
+            (overlay-put ov 'queued nil)
+            (preview-point-updated ov)))))
     (while (and (< (length preview-gs-outstanding)
                    preview-gs-outstanding-limit)
                 (setq ov (pop preview-gs-queue)))
@@ -1706,19 +1798,22 @@ icon is cached in the property list of the SYMBOL."
 (defun preview-ascent-from-bb (bb)
   "This calculates the image ascent from its bounding box.
 The bounding box BB needs to be a 4-component vector of
-numbers (can be float if available)."
+numbers (can be float if available).
+
+If `preview-point-mode' is non-nil, this simply returns \\='center."
   ;; baseline is at 1in from the top of letter paper (11in), so it is
   ;; at 10in from the bottom precisely, which is 720 in PostScript
   ;; coordinates.  If our bounding box has its bottom not above this
   ;; line, and its top above, we can calculate a useful ascent value.
   ;; If not, something is amiss.  We just use 100 in that case.
-
-  (let ((bottom (aref bb 1))
-        (top (aref bb 3)))
-    (if (and (<= bottom 720)
-             (> top 720))
-        (round (* 100.0 (/ (- top 720.0) (- top bottom))))
-      100)))
+  (if preview-point-mode
+      'center
+    (let ((bottom (aref bb 1))
+          (top (aref bb 3)))
+      (if (and (<= bottom 720)
+               (> top 720))
+          (round (* 100.0 (/ (- top 720.0) (- top bottom))))
+        100))))
 
 (defface preview-face '((((background dark))
                          (:background "dark slate gray"))
@@ -2090,26 +2185,28 @@ purposes."
              'active
            'inactive))
         (strings (overlay-get ov 'strings)))
-    (unless (eq (overlay-get ov 'preview-state) 'disabled)
-      (overlay-put ov 'preview-state preview-state)
-      (if (eq preview-state 'active)
-          (progn
-            (overlay-put ov 'category 'preview-overlay)
-            (if (eq (overlay-start ov) (overlay-end ov))
-                (overlay-put ov 'before-string (car strings))
-              (dolist (prop '(display keymap mouse-face help-echo))
-                (overlay-put ov prop
-                             (get-text-property 0 prop (car strings))))
-              (overlay-put ov 'before-string nil))
-            (overlay-put ov 'face nil))
-        (dolist (prop '(display keymap mouse-face help-echo))
-          (overlay-put ov prop nil))
-        (overlay-put ov 'face 'preview-face)
-        (unless (cdr strings)
-          (setcdr strings (preview-inactive-string ov)))
-        (overlay-put ov 'before-string (cdr strings)))
-      (if old-urgent
-          (apply #'preview-add-urgentization old-urgent))))
+    (if preview-point-mode
+        (preview-point-activate-maybe ov arg)
+      (unless (eq (overlay-get ov 'preview-state) 'disabled)
+        (overlay-put ov 'preview-state preview-state)
+        (if (eq preview-state 'active)
+            (progn
+              (overlay-put ov 'category 'preview-overlay)
+              (if (eq (overlay-start ov) (overlay-end ov))
+                  (overlay-put ov 'before-string (car strings))
+                (dolist (prop '(display keymap mouse-face help-echo))
+                  (overlay-put ov prop
+                               (get-text-property 0 prop (car strings))))
+                (overlay-put ov 'before-string nil))
+              (overlay-put ov 'face nil))
+          (dolist (prop '(display keymap mouse-face help-echo))
+            (overlay-put ov prop nil))
+          (overlay-put ov 'face 'preview-face)
+          (unless (cdr strings)
+            (setcdr strings (preview-inactive-string ov)))
+          (overlay-put ov 'before-string (cdr strings)))
+        (if old-urgent
+            (apply #'preview-add-urgentization old-urgent)))))
   (if event
       (preview-restore-position
        ov
@@ -2340,11 +2437,21 @@ active (`transient-mark-mode'), it is run through `preview-region'."
   (unless preview-leave-open-previews-visible
     (overlay-put ovr 'preview-image nil))
   (overlay-put ovr 'timestamp nil)
-  (setcdr (overlay-get ovr 'strings) (preview-disabled-string ovr))
-  (unless preview-leave-open-previews-visible
-    (preview-toggle ovr))
+
+  (setcdr (overlay-get ovr 'strings)
+          (unless preview-point-mode
+            ;; It will be updated later in `preview-toggle'.
+            (preview-disabled-string ovr)))
+
+  (unless preview-point-mode
+    (unless preview-leave-open-previews-visible
+      (preview-toggle ovr)
+      ;; Only delete the files if we are not using the images
+      (preview--delete-overlay-files ovr)))
   (overlay-put ovr 'preview-state 'disabled)
-  (preview--delete-overlay-files ovr))
+  (when preview-point-mode
+    ;; Toggle/update preview (maybe) after setting state
+    (preview-toggle ovr t)))
 
 (defun preview--delete-overlay-files (ovr)
   "Delete files owned by OVR."
@@ -2618,7 +2725,8 @@ Deletes the dvi file when finished."
                                     (preview-ascent-from-bb
                                      (aref queued 0))
                                     (aref preview-colors 2)))
-              (overlay-put ov 'queued nil))
+              (overlay-put ov 'queued nil)
+              (preview-point-updated ov))
           (push filename oldfiles)
           ;; Do note modify `filenames' if we are not replacing
           ;; it, to avoid orphaning files. The filenames will be
@@ -2964,6 +3072,7 @@ See description of `TeX-command-list' for details."
 
 (defvar preview-map
   (let ((map (make-sparse-keymap)))
+    (define-key map "\C-t" #'preview-point-mode)
     (define-key map "\C-p" #'preview-at-point)
     (define-key map "\C-r" #'preview-region)
     (define-key map "\C-b" #'preview-buffer)
@@ -3210,8 +3319,10 @@ pp")
 (defun preview-mode-setup ()
   "Setup proper buffer hooks and behavior for previews."
   (setq-local desktop-save-buffer #'desktop-buffer-preview-misc-data)
-  (add-hook 'pre-command-hook #'preview-mark-point nil t)
-  (add-hook 'post-command-hook #'preview-move-point nil t)
+  (if preview-point-mode
+      (add-hook 'post-command-hook #'preview-point-move-point nil t)
+    (add-hook 'pre-command-hook #'preview-mark-point nil t)
+    (add-hook 'post-command-hook #'preview-move-point nil t))
   (when (TeX-buffer-file-name)
     (let* ((filename (expand-file-name (TeX-buffer-file-name)))
            format-cons)
@@ -3803,22 +3914,28 @@ name(\\([^)]+\\))\\)\\|\
                                           (funcall preview-find-end-function
                                                    region-beg)
                                         (point)))
-                                     (ovl (preview-place-preview
-                                           snippet
-                                           region-beg
-                                           region-end
-                                           (preview-TeX-bb box)
-                                           (cons lcounters counters)
-                                           tempdir
-                                           (cdr open-data))))
-                                (setq close-data (nconc ovl close-data))
-                                (when (and preview-protect-point
-                                           (<= region-beg point-current)
-                                           (< point-current region-end))
-                                  ;; Temporarily open the preview if it
-                                  ;; would bump the point.
-                                  (preview-toggle (car ovl))
-                                  (push (car ovl) preview-temporary-opened)))
+                                     ovl)
+                                (save-excursion
+                                  ;; Restore point to current one before
+                                  ;; placing preview
+                                  (goto-char point-current)
+                                  (setq ovl (preview-place-preview
+                                             snippet
+                                             region-beg
+                                             region-end
+                                             (preview-TeX-bb box)
+                                             (cons lcounters counters)
+                                             tempdir
+                                             (cdr open-data)))
+                                  (setq close-data (nconc ovl close-data))
+                                  (when (and preview-protect-point
+                                             (<= region-beg point-current)
+                                             (< point-current region-end)
+                                             (not preview-point-mode))
+                                    ;; Temporarily open the preview if it
+                                    ;; would bump the point.
+                                    (preview-toggle (car ovl))
+                                    (push (car ovl) preview-temporary-opened))))
                             (with-current-buffer run-buffer
                               (preview-log-error
                                (list 'error
@@ -4426,6 +4543,283 @@ If not a regular release, the date of the last change.")
           (insert "\n")))
     (error nil)))
 
+
+;;; preview-point
+
+;; Buframe functions, it will be assumed that buframe is installed so
+;; that it can be required.
+(declare-function buframe-position-right-of-overlay "ext:buframe"
+                  (frame ov &optional location))
+(declare-function buframe-make-buffer "ext:buframe" (name &optional locals))
+(declare-function buframe-make "ext:buframe"
+                  (frame-or-name fn-pos buffer &optional
+                                 parent-buffer parent-frame parameters))
+(declare-function buframe-disable "ext:buframe" (frame-or-name
+                                                 &optional enable))
+
+(defun preview-point--buframe (show ov str)
+  "Show or hide a a buframe popup with STR around overlay OV."
+  (require 'buframe)
+  (if show
+      (let* ((buf (buframe-make-buffer " *preview-point-buffer*"
+                                       (car-safe
+                                        (cddr (cdr-safe
+                                               preview-point-display)))))
+             (max-image-size
+              (if (integerp max-image-size)
+                  max-image-size
+                ;; Set the size max-image-size using the current frame
+                ;; since the popup frame will be small to begin with
+                (* max-image-size (frame-width)))))
+        (with-current-buffer buf
+          (let (buffer-read-only)
+            (with-silent-modifications
+              (erase-buffer)
+              (insert (propertize str
+                                  'help-echo nil
+                                  'keymap nil
+                                  'mouse-face nil))
+              (goto-char (point-min)))))
+        (setq preview-point--frame
+              (buframe-make
+               "preview-point"
+               (lambda (frame)
+                 (when preview-point--current-overlay
+                   (funcall
+                    (or (car-safe (cdr-safe preview-point-display))
+                        #'buframe-position-right-of-overlay)
+                    frame preview-point--current-overlay)))
+               buf
+               (overlay-buffer ov)
+               (window-frame)
+               (car-safe (cdr (cdr-safe preview-point-display))))))
+    (buframe-disable preview-point--frame)))
+
+(defun preview-point-inside-overlay-p (ov &optional pt)
+  "Return PT if inside overlay OV, nil otherwise.
+If PT is nil, use point of OV's buffer."
+  (or pt
+      (setq pt (and
+                (overlay-buffer ov)
+                (with-current-buffer (overlay-buffer ov)
+                  (point)))))
+  (and
+   (eq (overlay-buffer ov) (window-buffer))
+   (>= pt (overlay-start ov))
+   (< pt (overlay-end ov))
+   pt))
+
+(defun preview-point-activate-maybe (ov &optional arg)
+  "Toggle visibility of preview overlay OV.
+If ARG is non-nil, deactivate overlay instead.
+
+If (point) is not inside OV, then a call to activate the overlay is
+ignored.  If the preview is disabled, the disabled symbol is shown when
+activated, otherwise the preview state is not changed."
+  (let* ((pt (and
+              (overlay-buffer ov)
+              (with-current-buffer (overlay-buffer ov)
+                (point))))
+         (strings (overlay-get ov 'strings))
+         (construct-p (overlay-get ov 'queued))
+         (disabled-p (eq (overlay-get ov 'preview-state) 'disabled))
+         (inside-p (preview-point-inside-overlay-p ov pt))
+         (str (car strings))
+         (show (and arg inside-p)))
+    ;; Update `strings' cdr, if needed
+    (when (or construct-p disabled-p)
+      (unless (cdr (overlay-get ov 'strings))
+        (setcdr (overlay-get ov 'strings)
+                (cond
+                 (disabled-p
+                  (if preview-leave-open-previews-visible
+                      (propertize str
+                                  'face
+                                  'preview-point-disabled-face)
+                    (preview-disabled-string ov)))
+                 (construct-p
+                  (if preview-leave-open-previews-visible
+                      (propertize str
+                                  'face
+                                  'preview-point-processing-face)
+                    (propertize "x" 'display preview-nonready-icon))))))
+      (setq str (cdr (overlay-get ov 'strings))))
+
+    (unless disabled-p
+      (overlay-put ov 'preview-state
+                   (if show
+                       'active
+                     'inactive)))
+
+    (when show
+      (overlay-put ov 'category 'preview-overlay))
+
+    (when (or show
+              (eq preview-point--current-overlay ov))
+      (setq preview-point--current-overlay (and show ov))
+      (if (or (eq preview-point-display 'buframe)
+              (eq (car-safe preview-point-display) 'buframe))
+          (preview-point--buframe show ov str)
+        (overlay-put ov preview-point-display (and show str))))))
+
+(defun preview-point-move-point ()
+  "Toggle previews as point enters or leaves overlays."
+  (preview-check-changes)
+  (let* ((pt (point))
+         (lst (overlays-at pt)))
+    ;; Hide any open overlays
+    (when-let* ((ov preview-point--current-overlay))
+      (and (overlay-buffer ov)
+           (overlay-get ov 'preview-state)
+           (not (eq (overlay-get ov 'preview-state) 'inactive))
+           (when (not (preview-point-inside-overlay-p
+                       ov pt))
+             (preview-point-activate-maybe ov nil))))
+
+    ;; Show all overlays under point
+    (dolist (ovr lst)
+      (let ((state (overlay-get ovr 'preview-state)))
+        (when ;; (eq (overlay-get ovr 'preview-state) 'inactive)
+            (and (and state (not (eq state 'active)))
+                 (not (eq ovr preview-point--current-overlay)))
+          (preview-point-activate-maybe ovr t))))))
+
+(defun preview-point-updated (ov)
+  "Mark preview OV as updated.
+Has effect only if `preview-point-mode' is active."
+  (when preview-point-mode
+    (preview-point-activate-maybe ov t)))
+
+;;; preview-point -- Auto-preview
+(defcustom preview-point-auto-delay 0.1
+  "Delay in seconds for automatic preview timer."
+  :type 'number)
+(defcustom preview-point-auto-function nil
+  "Function to determine if a preview should be created at point.
+
+When `preview-point-auto-mode' is enabled and this variable is non-nil,
+it should be a function that is is called with no arguments at (point)
+when there is not a preview already.  If the function returns a non-nil
+value, `preview-region' will be called.
+
+If the function returns a cons, it should be of the form (BEGIN . END),
+which will be used as arguments for `preview-region', otherwise the
+region is determined automatically."
+  :type 'symbol)
+(defvar preview-point-force-update--debounce-timer nil)
+
+(define-minor-mode preview-point-auto-mode
+  "Enable automatic refreshing and generation of previews.
+When enabled, existing previews are automatically updated when there
+text is changed.  Moreover, previews are automatically created whenever
+`preview-point-auto-function' returns a non-nil value at point."
+  :group 'preview
+  :init-value nil
+  (if preview-point-auto-mode
+      (progn
+        (add-hook 'after-change-functions #'preview-point-buf-change nil t)
+        (add-hook 'post-command-hook #'preview-point-auto nil t)
+        (preview-point-buf-change))
+    (remove-hook 'after-change-functions #'preview-point-buf-change t)
+    (remove-hook 'post-command-hook #'preview-point-auto t)))
+
+(defun preview-point-auto ()
+  "Mark current region for preview, if not already there."
+  (when (and
+         preview-point-mode
+         (not (preview-point-has-preview-p))
+         preview-point-auto-function
+         (funcall preview-point-auto-function))
+    (preview-point-force-update (point) (current-buffer) t)))
+
+(defun preview-point@around@write-region (orig-fun &rest args)
+  "Advice around `write-region' to suppress messages.
+ORIG-FUN is the original function.  ARGS are its arguments."
+  (let ((noninteractive t)
+        (inhibit-message t)
+        message-log-max)
+    (apply orig-fun args)))
+
+(defun preview-point-force-update (pos-region buffer &optional debounce)
+  "Update preview at POS-REGION in BUFFER.
+
+POS-REGION can be a position, or a cons (BEGIN . END) signifying the
+region for which the previous should be updated.  When DEBOUNCE is
+non-nil, the call is debounced using an idle timer. This also happens
+automatically when there is an ongoing compilation process."
+  (interactive (list (point) (current-buffer)))
+
+  (when preview-point-force-update--debounce-timer
+    (cancel-timer preview-point-force-update--debounce-timer)
+    (setq preview-point-force-update--debounce-timer nil))
+
+  (when (buffer-live-p buffer)
+    (unless debounce
+      (with-current-buffer buffer
+        (if-let* ((cur-process
+                   (or (get-buffer-process (TeX-process-buffer-name
+                                            (TeX-region-file)))
+                       (get-buffer-process (TeX-process-buffer-name
+                                            (TeX-master-file))))))
+            (progn
+              ;; Force de-bouncing
+              (when (and preview-current-region
+                         (not preview-abort-flag)
+                         ;; (< beg (cdr preview-current-region))
+                         )
+                (progn
+                  (ignore-errors (TeX-kill-job))
+                  (setq preview-abort-flag t)))
+              (with-local-quit (accept-process-output cur-process))
+              (setq debounce t))
+          (let ((TeX-suppress-compilation-message t)
+                (save-silently t))
+            (advice-add 'write-region :around
+                        #'preview-point@around@write-region)
+            (unwind-protect
+                ;; If we are working in a file buffer that is not a tex file,
+                ;; then we want preview-region to operate in "non-file" mode,
+                ;; where it passes "<none>" to TeX-region-create.
+                (save-excursion
+                  ;; TODO: Check if we can rely on the `preview-region'
+                  ;; returning the process. It calls
+                  ;; `preview-generate-preview' which has this documented
+                  ;; behaviour, but not `preview-region'.
+                  (unless (consp pos-region)
+                    (goto-char pos-region)
+                    (setq pos-region
+                          (cons (preview-next-border t)
+                                (preview-next-border nil))))
+                  (let ((process (preview-region (car pos-region)
+                                                 (cdr pos-region))))
+                    (with-current-buffer (process-buffer process)
+                      (setq-local preview-silent-errors t))))
+              (advice-remove 'write-region
+                             #'preview-point@around@write-region))))))
+
+    (when debounce
+      (setq preview-point-force-update--debounce-timer
+            (run-with-idle-timer
+             preview-point-auto-delay nil
+             #'preview-point-force-update
+             pos-region buffer)))))
+
+(defun preview-point-has-preview-p (&optional pt)
+  "Return non-nil if PT has a preview overlay."
+  (cl-find-if
+   (lambda (ov) (overlay-get ov 'preview-state))
+   (overlays-at (or pt (point)))))
+
+(defun preview-point-buf-change (&rest _)
+  "Run preview at point if there is a preview overlay."
+  (let (region)
+    (when (and preview-point-mode
+               (or (preview-point-has-preview-p)
+                   (and preview-point-auto-function
+                        (setq region (funcall preview-point-auto-function)))))
+      (preview-point-force-update
+       (if (consp region) region (point)) (current-buffer) t))))
+
 ;;;###autoload
 (defun preview-report-bug () "Report a bug in the preview-latex package."
        (interactive)
-- 
2.50.1 (Apple Git-155)


--=-=-=--




Information forwarded to bug-auctex@HIDDEN:
bug#79708; Package auctex. Full text available.

Message received at 79708 <at> debbugs.gnu.org:


Received: (at 79708) by debbugs.gnu.org; 1 Nov 2025 21:39:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 01 17:39:56 2025
Received: from localhost ([127.0.0.1]:53900 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vFJKG-0008H1-1Q
	for submit <at> debbugs.gnu.org; Sat, 01 Nov 2025 17:39:56 -0400
Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]:55576)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <ultrono@HIDDEN>) id 1vFJKC-0008Fi-PZ
 for 79708 <at> debbugs.gnu.org; Sat, 01 Nov 2025 17:39:54 -0400
Received: by mail-ed1-x533.google.com with SMTP id
 4fb4d7f45d1cf-63c4f1e7243so5216834a12.3
 for <79708 <at> debbugs.gnu.org>; Sat, 01 Nov 2025 14:39:52 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1762033186; x=1762637986; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:from:to
 :cc:subject:date:message-id:reply-to;
 bh=VUq8znYwpE5ZIqONlieJuiKeIPQJuFOmSumSRlEuTjo=;
 b=YGjnVY9HX6NfBnDkEWN0trb+zr9i0m69vpc5OxC/JWL+OnuLsVKb+0ANw1R0meLbnc
 RgLZEu5uUQjZJ1TYRRpSP+TlpBOT2q1SxMEMcEfFd8gxD6RmRm1olLKsKBEcTdU53xQp
 qIPhJvoQJFPqO6lUQKEIFgMTWa9kxPjcBD+bZVwKOQOCFEy/IsIekbnoV8FSrHxO0X3c
 V5oVqwBLfL5WFrQsCuQn/UGYJ/SkZpMN2NexaRDv8wlg65ZHbju2ty88pUx3lCk3LrJ/
 K+Vf8z1LXKcMSI0xt+m53YQMvq7awFflIPEod9KOEXx7E92rpNoQxEBAC4aX9YdjK7hY
 W1ZQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1762033186; x=1762637986;
 h=mime-version:message-id:date:in-reply-to:subject:cc:to:from
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=VUq8znYwpE5ZIqONlieJuiKeIPQJuFOmSumSRlEuTjo=;
 b=qdu/NtX7wqz97VQt9gJEvZ0uYD4Adw79YbVAxxHPdCC41/wlcdxgbvgGnFThpIqCHC
 AByHmczO+N97nESOepPA+Ibayleyuj/gjOJXtPToUGCj5Fqct8jBRxs6vOo/2qFG0yIh
 vLqXrGf5hh6RLPUYVSaFuSIukDdiVTFdn8IzDrAZidtY/Ux1LuLXDsuEJPqhmzCmxa/j
 n2XXw6a8Ea6eCGyv3WwlG7iWDWfKjBXZpudNAKThTeI/ZAi7RlU+nbQ59lxpFIbDYuZQ
 tgNrRYn+1YYadVAcfPSLFWkr2MRspIElRnAL93dPRIBvFcqAR+PJH8PGZLrvyHjQFWiH
 E+og==
X-Gm-Message-State: AOJu0YyTqBA5ZV5PIQGSNuFgY1h0d4is9B5AeL6wWdhsbEz7EX0jQ6PZ
 8/Ot1+ii+0NdnYMl5zzJtYhC2AJk00I+WADf4uh76TcWGhrLV9iarhB14TXpmRQp
X-Gm-Gg: ASbGncvMDVZEhBlt/KOWmt8peMH5i7FJWRExUkv88xLkSoAlAnfWNPKLhkJIkO6rMWS
 nZ3tD8uLGn4pM5tTkvHAryCQIxLllyK5Mthkb15cWNikgz2wpnWnVRyCDV619cyAtwKxHaxy3RU
 t/DI3sA/b4g6+IkM0TQ8IKufDxKSYiOFxxVueyB4qkG+I2ycU8Cc8o/CY9o46i3mPs3/moWM5Ag
 6HO+KjXF0FmvW96GEMogcipL/Gma+OAaiuDFRyEhGNRg1NMXvdT33ido5bBuaVceN7XWt9sFeQX
 JH/inDM8/XMzJKU/oqfq5cBUnCsC4YO7LCMQGGMFYx+qIKMowft4bBaTMyyGlU6RFCXUNoYHmE0
 MRYJukTq3Gc7pi6+x4x27fuA9U7mcF7NHZ56yTCICl5QrBR0Fd49KCnxDd2U+WzM2bzE/7kPiew
 8JA8Ymgy6ebrupDnEnuLKILvXW8WqVQMkRLUvntQCUW4U=
X-Google-Smtp-Source: AGHT+IFQK8AKvFj1NxrARg3WTAESOY+MB1Ep8bKmabFWHQAB+u0i5ZxwEx73kGIAa2bcIwbwD8xVcA==
X-Received: by 2002:a05:6402:2793:b0:640:9993:3cb8 with SMTP id
 4fb4d7f45d1cf-640999345ddmr2656283a12.5.1762033185632; 
 Sat, 01 Nov 2025 14:39:45 -0700 (PDT)
Received: from localhost (0x5da5fbd2.static.cust.fastspeed.dk.
 [93.165.251.210]) by smtp.gmail.com with UTF8SMTPSA id
 4fb4d7f45d1cf-64093b3868esm3084461a12.28.2025.11.01.14.39.43
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 01 Nov 2025 14:39:43 -0700 (PDT)
From: "Paul D. Nelson" <ultrono@HIDDEN>
To: Al Haji-Ali <abdo.haji.ali@HIDDEN>
Subject: Re: bug#79708: 14.1.0; [PATCH] New feature: preview-point
In-Reply-To: <m0a51ci29v.fsf@HIDDEN> (message from Al Haji-Ali on Mon, 27
 Oct 2025 20:16:12 +0100)
Date: Sat, 01 Nov 2025 22:39:41 +0100
Message-ID: <uxsg7tbjllmnz6.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79708
Cc: 79708 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi Al,

I had another thought about how preview-point could be structured.  It
currently combines two somewhat orthogonal features:

(a) Previews away from point are no longer displayed at all.

(b) We gain further flexibility in how we can display the preview at
point -- before the TeX source, after the TeX source, or in a buframe.

I think (b) makes sense and would be useful, independent of (a).
Conceptually, we could view this as a more flexible form of
preview-leave-open-previews-visible, which currently only allows the
preview to be displayed before the TeX source.

One way to decouple (a) and (b) would be to:

- Control (a) via a new defcustom, preview-hide-away-from-point.

- Control (b) by allowing preview-leave-open-previews-visible to take
  new values (e.g., 'after, 'buframe).  That setting would then
  play the role currently played by preview-point.

To display previews at point with buframe, one would do

  (setopt preview-leave-open-previews-visible 'buframe)

To recover the current preview-point behavior, one would additionally do

  (setopt preview-hide-away-from-point t)

WDYT?  Does it reasonable to you to separate these features?

Thanks, best,

Paul




Information forwarded to bug-auctex@HIDDEN:
bug#79708; Package auctex. Full text available.

Message received at 79708 <at> debbugs.gnu.org:


Received: (at 79708) by debbugs.gnu.org; 30 Oct 2025 10:47:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 30 06:47:24 2025
Received: from localhost ([127.0.0.1]:34595 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vEQBf-00059b-N5
	for submit <at> debbugs.gnu.org; Thu, 30 Oct 2025 06:47:24 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:37200)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <arash@HIDDEN>) id 1vEQBb-00059H-Uh
 for 79708 <at> debbugs.gnu.org; Thu, 30 Oct 2025 06:47:20 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <arash@HIDDEN>)
 id 1vEQBW-0007tm-9j; Thu, 30 Oct 2025 06:47:14 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=DxAexqiFfo5BeOLk2OOaVaP1hxs1aoQVk5lBjsoEB/Y=; b=JCzuvJLfDxKexgeRDgL6
 J6SyJ1z3p0kquQ+7tZy8frUOxSLGsGqmODO2XpbDaAjyBHoFcAAA1vWVUyvNn4joWPrEBitJQDVSa
 DOvEUAvmWRhiRD2fXTaoQ+kZ/0h2lLF5fBvqZpUCkg2hVP3VYSJAQwm1EmI1upL/4JcKljrBL58ZO
 sCgRYMUnYqQz7cBSfhRirMoDlHNdEudEJf0NJATIu0eVPZi+ac/8ijOA8lE/KWhDZJA5dMNHWaIDp
 WOTWQkxtdXSYU5hnQ2HgtpNDIApyO8pv2XywLzb9LUWlyVLRvNBOJod0RpgsP4TDCkpsiWZWHkEPk
 +vQGhFukJZ6KvA==;
From: Arash Esbati <arash@HIDDEN>
To: Al Haji-Ali <abdo.haji.ali@HIDDEN>
Subject: Re: bug#79708: 14.1.0; [PATCH] New feature: preview-point
In-Reply-To: <m05xbwaj8s.fsf@HIDDEN>
References: <uxsg7tjz0cnbvd.fsf@HIDDEN> <m05xbwaj8s.fsf@HIDDEN>
Date: Thu, 30 Oct 2025 11:47:07 +0100
Message-ID: <m234707jkk.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 79708
Cc: 79708 <at> debbugs.gnu.org, "Paul D. Nelson" <ultrono@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi Al,

Al Haji-Ali <abdo.haji.ali@HIDDEN> writes:

> What's the best practice here about updating patches? Should I send an
> updated full patch or a new one on top of the current one?

I'd prefer an updated full patch for each iteration.

> This setting should be for both. Updating existing previews when the
> text is changed and for generating new ones whenever
> `preview-point-auto-p` returns non-nil on (point). For example, one can
> set it to `texmathp` to automatically generate previews for math
> expressions. I will see how I can update the documentation to better
> reflect this.

Can we please find another name for `preview-point-auto-p'?  This is a
custom variable, right?  The '-?p' thing is more for predicate
functions.  I suggest we follow Emacs conventions here[1] and name it
`preview-point-auto-function' or similar.

Best, Arash

Footnotes:
[1]  https://www.gnu.org/software/emacs/manual/html_node/elisp/Tips-for-Defining.html




Information forwarded to bug-auctex@HIDDEN:
bug#79708; Package auctex. Full text available.

Message received at 79708 <at> debbugs.gnu.org:


Received: (at 79708) by debbugs.gnu.org; 30 Oct 2025 10:15:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 30 06:15:23 2025
Received: from localhost ([127.0.0.1]:34391 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vEPgg-0002zt-Rk
	for submit <at> debbugs.gnu.org; Thu, 30 Oct 2025 06:15:23 -0400
Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]:60775)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <ultrono@HIDDEN>) id 1vEPga-0002wr-BP
 for 79708 <at> debbugs.gnu.org; Thu, 30 Oct 2025 06:15:18 -0400
Received: by mail-lf1-x131.google.com with SMTP id
 2adb3069b0e04-59390875930so1152587e87.1
 for <79708 <at> debbugs.gnu.org>; Thu, 30 Oct 2025 03:15:16 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1761819308; x=1762424108; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:from:to
 :cc:subject:date:message-id:reply-to;
 bh=3oysK6bpcwwJRqwUqnc/QjwTjMNUtAbYH/xjueOfVCQ=;
 b=EKsRV4+FlSVqaMGsUFjW5XqpZh3amItO5TBCZr9Cl0ZUPJ1r2nuZVndOSstdZG4MWs
 DeNqTU8eL7c2Sd0RMOH7QcfRHob3vqeMt0x7TrXQi1V9gr50IOBv4JuB+KCoGUmMESUj
 SjcqupUcqoX1af/ip6b8hkG7lBptcPO1FuAHpfGHsWJuQ/3kJ5zosKXfRWyiaBA+8F+4
 tAnl329f6dsFvnRMTJ0AFDdMZPEg8PNabPoU5qkdk7t0KUDIs56REkXAdZgI7OlAvDMC
 l2teB2ssjoN4VzYlO7fVDbK4wBnDxhZK7nlmyVgoqAcKeFuOkVBw58lkN64YAz1WSdR1
 gUgg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1761819308; x=1762424108;
 h=mime-version:message-id:date:in-reply-to:subject:cc:to:from
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=3oysK6bpcwwJRqwUqnc/QjwTjMNUtAbYH/xjueOfVCQ=;
 b=s+kHEgKb27ku4eGtwQFZnGVAiRUSE6KtkUcPjOWguQ9uuu66LORq/aS8j24un7zmm7
 pGZuElWbdQsMLmKi2F/7TmQ6PtEVJI68LH/HVq6hn1+37MEwbLGwAqODSlxiMnlEg12f
 dQ5SsgNfX78INd8xIWL0pnbiiqWWZLIopHtkI3t7P2PyF2s1r/7BbXbvHlvUTPwBUskt
 FSPQceAm3KBxHhPFJ1Hw0SFmAIuzcLJs0KKRy7Uk2MZiLX8//WZpVLadtA0jrwmLSRmN
 vgpVTzobiHtyjZVhx5PL+lUaCe1gfqBNbGMII2gMRBxnaefc49gvyUyB4v1LcmThTj7e
 9oKQ==
X-Gm-Message-State: AOJu0Yx1THzpw3Mfz3pvAxvx2XCU4exdWZ7js95jV81ggZ2gJZ7ia9Tx
 8pfRkcjRCmvOxzWtxNqsMKlYpDR8rLIO7q4E0jLAs2QST9mMmior4kYy
X-Gm-Gg: ASbGncsdZU/eXXBOdLS89EN/lz9OL/jNwENLmLUeCN1jtEWLRZs9HxUuj7M0h89EgAk
 noRcNtOt9iRy/iKiGdsJH7y1vneulIJIKV0/IQ8PVg4Si58F9Cs4oaoFdqcELtEaIyfDnWQfT0y
 Ac4ZI/4r1p+BrjTZS1wiF94KDEg/+xSt68JaVbUpOjCKtWV0sqZWRzPbJh/m6tHnrvrSVsJPSBK
 INpL3qIDRPXm8n0Ayv4SuFAQ+Fl1i8mbYJ+Dxs/ZiVF30sJQt/QriaGS6wM8JnfHmBIgH3qtfxw
 KumWNq8ru1SOcH3o1xUTEtelVFh+gkl2HMXMUjWXNa1JrLrTkuFCOt2lfiiQX+uaCvOxW/ku9B6
 jYVVSG+3bMpXRuvyQk2mIbwUTOy2NgbwW62aWe9cbJWK+9wHShcFHDXZ1feLQb5BO20vWhPPaJ+
 UTMS4m38jEsDp6UsmFbyITiNatYK8nx1XvKoW9yyYo9wYMMwC7oAH4
X-Google-Smtp-Source: AGHT+IHBJ4NONguWZOJ0/wnSN/rC3YdVfngbswcbMuioAvKDjR6r/vUfiQl9WtNFBX240Lkd3iCnkg==
X-Received: by 2002:a05:6512:2395:b0:55f:6c08:a15a with SMTP id
 2adb3069b0e04-59416eed286mr953210e87.32.1761819307306; 
 Thu, 30 Oct 2025 03:15:07 -0700 (PDT)
Received: from localhost (0x573d67e8.static.cust.fastspeed.dk. [87.61.103.232])
 by smtp.gmail.com with UTF8SMTPSA id
 2adb3069b0e04-59301f6856fsm4471885e87.68.2025.10.30.03.15.05
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 30 Oct 2025 03:15:06 -0700 (PDT)
From: "Paul D. Nelson" <ultrono@HIDDEN>
To: Al Haji-Ali <abdo.haji.ali@HIDDEN>
Subject: Re: bug#79708: 14.1.0; [PATCH] New feature: preview-point
In-Reply-To: <m05xbwaj8s.fsf@HIDDEN> (message from Al Haji-Ali on Thu, 30
 Oct 2025 09:25:55 +0100)
Date: Thu, 30 Oct 2025 11:15:04 +0100
Message-ID: <uxsg7th5vgn1av.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79708
Cc: 79708 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi Al,

> What's the best practice here about updating patches? Should I send an
> updated full patch or a new one on top of the current one?

I think sending a full patch is the custom.

>> It would be much more ergonomic if we could enable preview-point after
>> visiting a buffer.  Is this a hard limitation?
> No, I can make this change. It would simply require modifying a couple
> of hooks. Should the logic be in a custom-setter code, or in a
> function/mode? Note that the setting has to be global (at least in the
> current implementation -- though I might be able to make it buffer-local
> if there's a real need for it).

I guess we could go with either of the following:

(A) A defcustom with custom setters that both determines whether the
feature is enabled and how the feature is displayed.

(B) A minor-mode (ideally buffer-local), say preview-point-mode [1],
that determines whether the feature is enabled at all, together with a
defcustom preview-point [2] that determines how the feature displays.

Based on what you wrote elsewhere regarding the intent of the defcustom:

> Just to say, the purpose of this command is to provide an easy way to
> hide/show previews, for example if they are getting in the way of
> editing text. I wasn't thinking about it as a way to enable
> preview-point. I am open to suggestions of improvement to this
> interface.

I think (B) makes more sense.

[1] or maybe preview-at-point-mode?

[2] or maybe preview-point-display, preview-point-display-type,
preview-point-type, preview-at-point-type, etc?

> I had actually wanted to ask you if the introduction of
> `preview-point-auto-p` could be a clean way to incorporate the logic of
> `preview-auto`, since I think one can have the clever code in
> preview-auto which detects if a preview should be generated as a
> customization of this variable.
>
> My thinking is to have automatic previewing split into two logical
> parts: The mechanism of updating previews which should be general
> enough, and the detection of when to do it which will be
> user-controlled.

That sounds good to me.  I'll take a careful look once you've sent the
revised patch.

Thanks, best,

Paul




Information forwarded to bug-auctex@HIDDEN:
bug#79708; Package auctex. Full text available.

Message received at 79708 <at> debbugs.gnu.org:


Received: (at 79708) by debbugs.gnu.org; 30 Oct 2025 08:30:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 30 04:30:18 2025
Received: from localhost ([127.0.0.1]:33914 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vEO30-0002tO-3q
	for submit <at> debbugs.gnu.org; Thu, 30 Oct 2025 04:30:18 -0400
Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:61497)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <abdo.haji.ali@HIDDEN>)
 id 1vEO2s-0002mi-2c
 for 79708 <at> debbugs.gnu.org; Thu, 30 Oct 2025 04:30:11 -0400
Received: by mail-wr1-x435.google.com with SMTP id
 ffacd0b85a97d-4270a3464bcso571142f8f.2
 for <79708 <at> debbugs.gnu.org>; Thu, 30 Oct 2025 01:30:10 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1761813002; x=1762417802; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=+ONboLNRUoCQTlgfduwwjw9z7kq8jA3LHqIbvyLRFp8=;
 b=b5Xlq9krX+Otqk5jF8kVb6mfbDptGHZECJijWpu/v2GFaoHa8++hnpSJPuwny6qLGV
 PezldwgOyf32QaC7kwUK+cL42E4vXdgabrkXdhHkHcarxlieE/HME5Hq6WKlYGpvXREe
 MHVusEWpqVgOQ9/aOLMsbrfW/eu/YNfZNedZN51yubedI/Zn4gL7yKJRlAjBVRcVElui
 nslKJL5sQG8Sewl56YiUBdhx+OvOqE6caXGHcK38nZaA8WkjXi1TX62MslnZ0y5+XXKd
 /QM54yn8vGFP+KLcOhDh6EoWfu4ulTqU40gcjIn2Xw8il/9d1+Ufs6aB6jCT1n67GbkD
 m6Rg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1761813002; x=1762417802;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=+ONboLNRUoCQTlgfduwwjw9z7kq8jA3LHqIbvyLRFp8=;
 b=SQAX1559Jzn0tqXdtbyxzvSaZbsROoOmiDmnaN+Xrv2QzZ/h6idfc959WLpa7oZyTV
 d9JrMA739mtjqN9MlJttkLjYtbo2deeTqptDQh3uhck71IW235VFYzsRSgY4cKZeHJmT
 1hh+Rrd+NZ65MdPIewkpllNNI6pyF3vJ6DeQEl7+n2Ztf0vb6ZDpVVCnwengYXFRGzMD
 Knexm3De1NqaK+KfvEZX40fkjkgr+GeMN/VlgxTzyzhN1NJNC0PM4JHNLMeqmhbvcq7m
 QI0C6zTmgU3LeXDMBNDCCablkodI6P0XCrybP9HisbxSiFwXNRIDe/zXup4tMJef27hM
 HLHA==
X-Gm-Message-State: AOJu0Yz1oketKmYSZgJFL1ofLApgfxaufZVcfqXuw504/E9igwLo5C/3
 Ak/RP3SAnr/04qwMQooqzGVgACUK5DXg4jj9Yomj4NwURJ76eN/866OS
X-Gm-Gg: ASbGncs4UFuH95xNsXN492PaDCX1zzlJLse6OoZpS7J//HIM/UopWgqwUr/DLOPTARH
 cdpgTVNetI1P0EbwGUU5ScNpNILKq/QmA85YSUeI+lUZxGknX/ylV0a1YiF7TV7WOQUpaeuYcSO
 Vs96htUbqW2tmnfWO65mSXVLKU9Y08xL9ZcAhmZ2rCmr0ZtcTMXDjuExyinDW8WGPOycXYPGuwu
 fVCWgeJexw6s8uX/e6DnQ1EEbFGZebPa/1rJ08JY3w8mrnNhGGsnyumUThzrDqK0FNgWjbubCru
 cBhcNDFr2vLBgZ0j2m3juYIWf2AeIbdOim+CYSwT9XHkZFhUiiiykuXVCnEKGKCsYLdjvSAyoyU
 muTD0OssUPaBj/qcXt/PSpeP8nOloiHi3Rc034Uqfij299NLf4STO9F29SVLglqVeRur1YDiCw5
 x0kdZtIg==
X-Google-Smtp-Source: AGHT+IGU4oyilKpBv3bG3Q6jOSMMimq0Xl0OM/dx+1P3V62Z5U/Ryd9JIKDTuAiGBhalHoSCsfOIoA==
X-Received: by 2002:a05:6000:144f:b0:427:cca6:5f4e with SMTP id
 ffacd0b85a97d-429b4ca57f9mr2164430f8f.62.1761813001967; 
 Thu, 30 Oct 2025 01:30:01 -0700 (PDT)
Received: from localhost ([2a00:8a60:e000:101:60ae:fc8c:25c4:17da])
 by smtp.gmail.com with UTF8SMTPSA id
 ffacd0b85a97d-429952d5773sm32861816f8f.27.2025.10.30.01.30.01
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 30 Oct 2025 01:30:01 -0700 (PDT)
From: Al Haji-Ali <abdo.haji.ali@HIDDEN>
To: "Paul D. Nelson" <ultrono@HIDDEN>
Subject: Re: bug#79708: 14.1.0; [PATCH] New feature: preview-point
In-Reply-To: <uxsg7tjz0cnbvd.fsf@HIDDEN>
References: <uxsg7tjz0cnbvd.fsf@HIDDEN>
Date: Thu, 30 Oct 2025 09:25:55 +0100
Message-ID: <m05xbwaj8s.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79708
Cc: 79708 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi Paul,

On 30/10/2025, Paul D. Nelson wrote:

> I've started taking a look and have several comments.
Thank you for taking the time, really appreciate it as well as your
earlier work on preview-auto.

What's the best practice here about updating patches? Should I send an
updated full patch or a new one on top of the current one?

> I have several unrelated comments:
Thanks for those, I agree with all of them and will make those changes.

> It would be much more ergonomic if we could enable preview-point after
> visiting a buffer.  Is this a hard limitation?
No, I can make this change. It would simply require modifying a couple
of hooks. Should the logic be in a custom-setter code, or in a
function/mode? Note that the setting has to be global (at least in the
current implementation -- though I might be able to make it buffer-local
if there's a real need for it).

> The documentation does not indicate any intended value.  Also, from what
> I understand, this setting controls when new previews are generated, but
> does not affect whether existing previews are automatically regenerated;
> the docs don't seem to emphasize this distinction.
This setting should be for both. Updating existing previews when the
text is changed and for generating new ones whenever
`preview-point-auto-p` returns non-nil on (point). For example, one can
set it to `texmathp` to automatically generate previews for math
expressions. I will see how I can update the documentation to better
reflect this.

> The command ends in "-mode" but does not come from a major/minor mode.
> Perhaps instead something like "preview-point-toggle-display"?
>
> It might be cleaner to move the body of this command to a custom setter
> for preview-point and then either delete the command altogether, or
> rewrite it as a light wrapper around customize-set-variable.  That way,
> users can tweak preview-point via either the new C-c C-p C-t bind or
> customize-set-variable.

I'll see how that would look. Just to say, the purpose of this command
is to provide an easy way to hide/show previews, for example if they are
getting in the way of editing text. I wasn't thinking about it as a way
to enable preview-point. I am open to suggestions of improvement
to this interface.

>> +(defun preview-point-toggle-auto-update (enable &optional silent)
>
> This reads like a minor mode.  I would suggest introducing a small,
> display-agnostic "preview-automatic-mode", bound to C-c C-p C-a, that,
> when enabled, automatically regenerates existing previews, for both
> preview-point and "traditional" preview.  This aligns with an earlier
> suggestion [1] to upstream automatic previewing.  (It's simpler than
> preview-auto, which also *finds* new regions to preview, but that
> feature could be added later via a strategy variable or hook.)  I'd be
> happy to draft that refactor on top of your patch if the idea sounds
> reasonable.
>
> [1] https://lists.gnu.org/archive/html/auctex-devel/2024-06/msg00031.html

I agree a minor mode is better here and a patch would be appreciated
(once I send the updated one with your suggested changes).

I had actually wanted to ask you if the introduction of
`preview-point-auto-p` could be a clean way to incorporate the logic of
`preview-auto`, since I think one can have the clever code in
preview-auto which detects if a preview should be generated as a
customization of this variable.

My thinking is to have automatic previewing split into two logical
parts: The mechanism of updating previews which should be general
enough, and the detection of when to do it which will be
user-controlled.

In any case, I think it would be good to have the infrastructure of
automatic previewing which is being added here as suitable for the
integration of preview-auto as possible (we might need to modify
`preview-point-auto-p` so that it can return a region).

>> +
>> +;;; preview-point -- Auto-preview
>
> If we refactor as suggested above, then most of the functions below
> should be given agnostic names ("preview-automatic-*"?), reflecting that
> they are not specific to the preview-point feature.
Agreed, though I haven't tested automatic previewing without
preview-point.

> --8<---------------cut here---------------start------------->8---
> Automatic previewing code derived from preview-auto.el (Copyright 2024
> FSF, by Paul D. Nelson), adapted and integrated by Al-Haji Ali.
> --8<---------------cut here---------------end--------------->8---
Will add this comment to the commit message. 

Best regards,
-- Al




Information forwarded to bug-auctex@HIDDEN:
bug#79708; Package auctex. Full text available.

Message received at 79708 <at> debbugs.gnu.org:


Received: (at 79708) by debbugs.gnu.org; 30 Oct 2025 06:27:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 30 02:27:06 2025
Received: from localhost ([127.0.0.1]:33414 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vEM7l-00033q-Ne
	for submit <at> debbugs.gnu.org; Thu, 30 Oct 2025 02:27:06 -0400
Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]:53331)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <ultrono@HIDDEN>) id 1vEM7e-000332-CH
 for 79708 <at> debbugs.gnu.org; Thu, 30 Oct 2025 02:27:00 -0400
Received: by mail-lj1-x236.google.com with SMTP id
 38308e7fff4ca-378ddffb497so7724821fa.2
 for <79708 <at> debbugs.gnu.org>; Wed, 29 Oct 2025 23:26:58 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1761805609; x=1762410409; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:from:to
 :cc:subject:date:message-id:reply-to;
 bh=bp9g4bMjGAxyo+uWvJyUmNSIj9ipzB995Vp86277JOQ=;
 b=K5YWSwn7gLgPNDmR6E2f4040dKiaOkYf75IMWzohxj520ANBxrVz82xC78e12O74RK
 dk/W2zMbofHjKgkneqX0LLS7AnIGt6KYF/76RMlTd/7sPElWl/djg9eqy/m/34AsEjxQ
 sCRGV6zAk+4BQG7J91mRyvrxE8jDW5C/Wv1vcEqNPLKMvdXSiAvxIq9Aex/Pqya/9XcV
 F+cGf3YIjRi34lBm1tjeLEXPFP7p3nr6+6yqSrTQpH/2Nbh9PIgw762Lu5AkhN1bZHVw
 kbTRhgEPhxlLAud9/ZyOhP37dKPouUyndamgXDj6RBUeGYspbw/r58L3i2EyhJFgt/gL
 UHBw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1761805609; x=1762410409;
 h=mime-version:message-id:date:in-reply-to:subject:cc:to:from
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=bp9g4bMjGAxyo+uWvJyUmNSIj9ipzB995Vp86277JOQ=;
 b=dhlnFYklZW83BLfO0qBrl5/KCpP8TR2N7N5qyfaayofW2SZR5wCca3M3EjrXa4epuu
 /0inmheV5K8I2TOpZiz6WENg5G4WdbdE+QFKuCpG+oo09SUgBUjpqNUXH8a0B2FJTiiD
 FrmPASbSV/1MF4gcD8CzU4WNZaUmd32/cawDg+S56kylCiL3d2hb8k8JlymHB1/L0gCw
 jJqLmAO41D8oBo7zvMLMOSoAxHwVAzQubufb2v/mvtRQlaS6LqtmRzXZwZ2mYaBLZt/9
 AHwsy6RbggD49AeYGh2KaCEAtgt2NTXNzD+V94m2LTUL/lVwiFvzJomK7DhKaHUhMNN0
 Sk0A==
X-Gm-Message-State: AOJu0YxkpNdF5PEkOeWmouqw58xCg1ixtVc0+t4i6GJFqQ98fb+xE7zR
 qCagS6MqVdre9aT6fUkUXur3YozYNtanZr/kI2TbUkJ5wwVBH9+SodJz
X-Gm-Gg: ASbGncsdJ0Q438oYgfmlCxB0oyQxkswQh9HGb+i8b9ZBIcJqsBBKbJHypJrchTsfQ2j
 cuESf9futXXEKcTZ5ioCSRSDhtRpp/CkO9clfzAGZvekfq4OW6CFpTau7EyJjFpK2kJNFs9Yqcr
 IQDbrI6+YBC48KbX53eDkoPqh60Q487DwaeXQa65Z9wLwrK4p8guCkGWlyIzlqcwYQ39JXgc+au
 stlftulcWAhMl0A5qOMc9jf2GoGvLNF8v098kVHRXYYr2rnh0egZLdF+AWCuVdzKXhbXc3bwsS0
 wNnDZJ+ftfu2gwFP3mIhIjnNSG4NPr6F40RvU3RciFUNCpnkSItdkuTYA0pYa2GFCJpH6FGDjM0
 T9mKBMn03uj/lQc/TqR8BL+D3kAovpM/8wjxOJzQTqh66wWg10ICk1Bufu9EMTg5AG13Q3D1n8Z
 rwM3627e6rjIutkzUPMeb0cGYDI83m5w8r7W/D8Hm9ww==
X-Google-Smtp-Source: AGHT+IF8SOo6JI+HpfLSKtpnbaRYD8I9/Y0nTNv5R8+ujTzsG875abbtl6FnIRJronfzu/hY8IpSmw==
X-Received: by 2002:a05:6512:ad1:b0:593:f74:9088 with SMTP id
 2adb3069b0e04-59412a059fcmr1869694e87.43.1761805608348; 
 Wed, 29 Oct 2025 23:26:48 -0700 (PDT)
Received: from localhost (0x573d67e8.static.cust.fastspeed.dk. [87.61.103.232])
 by smtp.gmail.com with UTF8SMTPSA id
 2adb3069b0e04-59301f41bf3sm4330251e87.20.2025.10.29.23.26.47
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 29 Oct 2025 23:26:47 -0700 (PDT)
From: "Paul D. Nelson" <ultrono@HIDDEN>
To: Al Haji-Ali <abdo.haji.ali@HIDDEN>
Subject: Re: bug#79708: 14.1.0; [PATCH] New feature: preview-point
In-Reply-To: <m0a51ci29v.fsf@HIDDEN> (message from Al Haji-Ali on Mon, 27
 Oct 2025 20:16:12 +0100)
Date: Thu, 30 Oct 2025 07:26:46 +0100
Message-ID: <uxsg7tjz0cnbvd.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79708
Cc: 79708 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi Al,

I've started taking a look and have several comments.

Thanks, best,

Paul

> +(defvar-local preview-silent-errors nil
> +  "When non-nil, do not signal preview errors nor display output buffer.
> +This variable should be set in the process buffer.")

(Very good.)

> +;;; preview-point customizations and variables.
> +(defcustom preview-point nil
> +  "Specifies where to show the preview.
> +If non-nil, show the preview at point.  Can be `before-string',
> +`after-string' to show at before or after the TeX code or `buframe' to
> +show in a separate frame (the `buframe' package must be installed).  Can
> +also be \\='(buframe FN-POS FRAME-PARAMETERS BUF-PARAMETERS) where
> +FN-POS is a position function (default is
> +`buframe-position-right-of-overlay') and FRAME-PARAMETERS is an alist of
> +additional frame parameters, default is nil and BUF-PARAMETERS is an
> +alist of buffer local variables and their values.
> +
> +This variable must be set before opening a TeX file. Charging its value
> +while a file is open will lead to previews not being displayed
> +correctly. See `preview-point-toggle-mode'."
> +  :type '(choice
> +          (const :tag "Before string" before-string)
> +          (const :tag "After string (default)" after-string)
> +          (const :tag "On frame" buframe)
> +          (list :tag "On frame with explicit parameters"
> +                (function :tag "Position function")
> +                (alist :tag "Frame parameters")
> +                (alist :tag "Buffer parameters"))))

I have several unrelated comments:

Documentation: preview-point seems to work fine in non-file buffers, so
perhaps replace "TeX file" with "TeX buffer".

Typo: "Charging its value" -> "Changing its value"

The default is nil, but ':type' doesn't accept nil.  Consider adding
(const :tag "Disabled" nil).

It would be much more ergonomic if we could enable preview-point after
visiting a buffer.  Is this a hard limitation?

> +(defcustom preview-point-auto-p nil
> +  "Set this to enable previewing automatically.
> +When non-nil, it is assumed to be a function that is is called with no
> +arguments at (point) when there is not a preview already.  If the
> +function return a non-nil value, a `preview-at-point' will be initiated."
> +  :type 'symbol)

The documentation does not indicate any intended value.  Also, from what
I understand, this setting controls when new previews are generated, but
does not affect whether existing previews are automatically regenerated;
the docs don't seem to emphasize this distinction.

> +(defun preview-point-toggle-mode (mode)
> +  "Set `preview-point' to MODE.
> +If called interactively `preview-point' is toggled and the user is asked
> +for the MODE when it is switch on.
> +
> +This function has an effect only if `preview-point' is non-nil, which
> +should be set before opening a TeX file."
> +  (interactive
> +   (list (if preview-point
> +             (if (not (eq preview-point 'hidden))
> +                 'hidden
> +               (intern
> +                (cadr (read-multiple-choice
> +                       "Mode :"
> +                       '((?b "before-string")
> +                         (?a "after-string")
> +                         (?f "buframe"))))))
> +           (error "Preview-point is not enabled.  \
> +Set preview-point before opening the TeX file"))))
> +
> +  (unless preview-point
> +    (error "Preview-point needs to be enabled first (before opening the tex file)."))
> +  ;; Hide current overlay if it is visible.
> +  (when preview-point--current-overlay
> +    (preview-toggle preview-point--current-overlay nil))
> +  (setq preview-point mode)
> +  ;; Show the preview if it at point.
> +  (preview-point-move-point))

The command ends in "-mode" but does not come from a major/minor mode.
Perhaps instead something like "preview-point-toggle-display"?

It might be cleaner to move the body of this command to a custom setter
for preview-point and then either delete the command altogether, or
rewrite it as a light wrapper around customize-set-variable.  That way,
users can tweak preview-point via either the new C-c C-p C-t bind or
customize-set-variable.

> +(defun preview-point-toggle-auto-update (enable &optional silent)
> +  "Enable auto refresh of previews.
> +When ENABLE is nil, disable auto-update instead.  If called
> +interactively, auto-updating is toggled."
> +  (interactive (list 'toggle))
> +  (when (eq enable 'toggle)
> +    (setq enable (not (memq
> +                       #'preview-point-buf-change
> +                       after-change-functions))))
> +  (if enable
> +      (progn
> +        (add-hook 'after-change-functions #'preview-point-buf-change nil t)
> +        (add-hook 'post-command-hook #'preview-point-auto nil t)
> +        (preview-point-buf-change)
> +        (unless silent
> +          (message "Auto-updating previews enabled")))
> +    (remove-hook 'after-change-functions #'preview-point-buf-change t)
> +    (remove-hook 'post-command-hook #'preview-point-auto t)
> +    (unless silent
> +      (message "Auto-updating previews disabled"))))

This reads like a minor mode.  I would suggest introducing a small,
display-agnostic "preview-automatic-mode", bound to C-c C-p C-a, that,
when enabled, automatically regenerates existing previews, for both
preview-point and "traditional" preview.  This aligns with an earlier
suggestion [1] to upstream automatic previewing.  (It's simpler than
preview-auto, which also *finds* new regions to preview, but that
feature could be added later via a strategy variable or hook.)  I'd be
happy to draft that refactor on top of your patch if the idea sounds
reasonable.

[1] https://lists.gnu.org/archive/html/auctex-devel/2024-06/msg00031.html

> +
> +;;; preview-point -- Auto-preview

If we refactor as suggested above, then most of the functions below
should be given agnostic names ("preview-automatic-*"?), reflecting that
they are not specific to the preview-point feature.

> +(defcustom preview-point-auto-delay 0.1
> +  "Delay in seconds for automatic preview timer."
> +  :type 'number)
> +(defvar preview-point-force-update--debounce-timer nil)
> +
> +(defun preview-point@around@write-region (orig-fun &rest args)
> +  "Advice around `write-region' to suppress messages.
> +ORIG-FUN is the original function.  ARGS are its arguments."
> +  (let ((noninteractive t)
> +        (inhibit-message t)
> +        message-log-max)
> +    (apply orig-fun args)))
> +
> +(defun preview-point-force-update (pt buffer &optional debounce)
> +  "Update preview at PT in BUFFER.
> +
> +When DEBOUNCE is non-nil, the call is debounced using an idle
> +timer. This also happens automatically when there is an ongoing
> +compilation process."
> +  (interactive (list (point) (current-buffer)))
> +
> +  (when preview-point-force-update--debounce-timer
> +    (cancel-timer preview-point-force-update--debounce-timer)
> +    (setq preview-point-force-update--debounce-timer nil))
> +
> +  (when (buffer-live-p buffer)
> +    (unless debounce
> +      (with-current-buffer buffer
> +        (if-let* ((cur-process
> +                   (or (get-buffer-process (TeX-process-buffer-name
> +                                            (TeX-region-file)))
> +                       (get-buffer-process (TeX-process-buffer-name
> +                                            (TeX-master-file))))))
> +            (progn
> +              ;; Force de-bouncing
> +              (when (and preview-current-region
> +                         (not preview-abort-flag)
> +                         ;; (< beg (cdr preview-current-region))
> +                         )
> +                (progn
> +                  (ignore-errors (TeX-kill-job))
> +                  (setq preview-abort-flag t)))
> +              (with-local-quit (accept-process-output cur-process))
> +              (setq debounce t))
> +          ;; The code below is adopted from preview-auto

The code above this comment also appears to be derived from preview-auto
(see [2]), so if such a comment is to appear at all, then it should be
higher up (e.g., after ;;; preview-point -- Auto-preview).  But my
impression is that attribution is more customarily indicated in commit
messages, so I would propose removing such comments from the code and
instead including in the commit message something like the following:

--8<---------------cut here---------------start------------->8---
Automatic previewing code derived from preview-auto.el (Copyright 2024
FSF, by Paul D. Nelson), adapted and integrated by Al-Haji Ali.
--8<---------------cut here---------------end--------------->8---

[2] https://lists.gnu.org/archive/html/auctex-devel/2025-08/msg00047.html

> +          (let ((TeX-suppress-compilation-message t)
> +                (save-silently t))
> +            (advice-add 'write-region :around
> +                        #'preview-point@around@write-region)
> +            (unwind-protect
> +                ;; If we are working in a file buffer that is not a tex file,
> +                ;; then we want preview-region to operate in "non-file" mode,
> +                ;; where it passes "<none>" to TeX-region-create.
> +                (save-excursion
> +                  (goto-char pt)
> +                  ;; TODO: Check if we can rely on the `preview-region'
> +                  ;; returning the process. It calls
> +                  ;; `preview-generate-preview' which has this documented
> +                  ;; behaviour, but not `preview-region'.
> +                  (let ((process (preview-region (preview-next-border t)
> +                                                 (preview-next-border nil))))
> +                    (with-current-buffer (process-buffer process)
> +                      (setq-local preview-silent-errors t))))
> +              (advice-remove 'write-region
> +                             #'preview-point@around@write-region))))))
> +
> +    (when debounce
> +      (setq preview-point-force-update--debounce-timer
> +            (run-with-idle-timer
> +             preview-point-auto-delay nil
> +             #'preview-point-force-update
> +             pt buffer)))))
> +
> +(defun preview-point-has-preview-p (&optional pt)
> +  "Return non-nil if PT has a preview overlay."
> +  (cl-find-if
> +   (lambda (ov) (overlay-get ov 'preview-state))
> +   (overlays-at (or pt (point)))))
> +
> +(defun preview-point-buf-change (&rest _)
> +  "Run preview at point if there is a preview overlay."
> +  (when (and preview-point
> +             (not (eq preview-point 'hidden))
> +             (or
> +              (preview-point-has-preview-p)
> +              (and preview-point-auto-p
> +                   (funcall preview-point-auto-p))))
> +    (preview-point-force-update (point) (current-buffer) t)))
> +
>  ;;;###autoload
>  (defun preview-report-bug () "Report a bug in the preview-latex package."
>         (interactive)

As a final comment, thanks for working on this and for your other recent
improvements to preview.el - much appreciated!




Information forwarded to bug-auctex@HIDDEN:
bug#79708; Package auctex. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 27 Oct 2025 21:00:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 27 17:00:43 2025
Received: from localhost ([127.0.0.1]:50416 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vDUKU-0001Ki-5k
	for submit <at> debbugs.gnu.org; Mon, 27 Oct 2025 17:00:42 -0400
Received: from lists.gnu.org ([2001:470:142::17]:42284)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <abdo.haji.ali@HIDDEN>)
 id 1vDUKO-0001KB-4s
 for submit <at> debbugs.gnu.org; Mon, 27 Oct 2025 17:00:34 -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 <abdo.haji.ali@HIDDEN>)
 id 1vDUKF-00083e-6V
 for bug-auctex@HIDDEN; Mon, 27 Oct 2025 17:00:24 -0400
Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <abdo.haji.ali@HIDDEN>)
 id 1vDUK7-0002jB-Je
 for bug-auctex@HIDDEN; Mon, 27 Oct 2025 17:00:22 -0400
Received: by mail-lf1-x135.google.com with SMTP id
 2adb3069b0e04-591c9934e0cso7408540e87.0
 for <bug-auctex@HIDDEN>; Mon, 27 Oct 2025 14:00:13 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1761598807; x=1762203607; darn=gnu.org;
 h=mime-version:message-id:date:subject:to:from:from:to:cc:subject
 :date:message-id:reply-to;
 bh=8Q6nVnthGeRqQV8xMpmZQAk9Z8nGbz9YMVKXIThGyEw=;
 b=Lw9F7eGtYWBR+uw09W31RfEPigx2a2S0iExqNzrA6K5KNW5NySrTAraEFtClD0ilYR
 V+53Lcrcoiu410vaA5vgl1xyiyiDebif8P8ECf7sqsc2Oo695tC8UY3WRN/Cykokxs3M
 l6ZYVl0iqcocxburw/cLJyk8sOS25PRwUQxOG4ZfKvCWgAUWBOSYGLxcob6P429oZdr1
 WW6QP+JbEFmXeLRV4K8Pxh1Y82TrSPJ2uNNEvW3Hq/x5YaJpcm1h7cEl8pOxNWRxDY2l
 HJ2xLXAVREVn0cJa6xuuLX7j1A2fel4+8Kr8ZyFT7F5uZmHVilMqYKmuWPkriIv+TPAz
 auqQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1761598807; x=1762203607;
 h=mime-version:message-id:date:subject:to:from:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=8Q6nVnthGeRqQV8xMpmZQAk9Z8nGbz9YMVKXIThGyEw=;
 b=i7pB8CkdokLUdfm6BtifLWg+kN7JuhfFq2GdnyLfpnj86yNpqTbTRt8H4+I7zALoFI
 3vARm2cOZjNZ+NgVLhREaLCc1UKpWP5TwH/+NvgWrV2ZlnqxmBmQii1UbyoXiC++m3w2
 G8NjQKLhEILGkmNd2y8YxGprsmt5InvjAnUeLZrBq8uFiLS22WgPvZrOIb8nha3RrAC2
 Dtym8glwP3eb5lYuh4o6x/iMnHgoK3o83IChQtP92IJhpAsSY2Fsc6UpAPfSny95PbPj
 ZNyoOLFkxBpb8zDvEK4bp6v6rsFcCIc36QgUbKxhhuliyHHNeuCFNRbM8EY+LRldgN00
 MoGw==
X-Gm-Message-State: AOJu0Yz7nrzjFjX2kUIk6Prtzje0otNeYHTswlgyF2I4wJcJ8nEz0PCn
 8/ys2evA0DNZw8zNf78wV06W+2LgvJ9pXZ1nATduT8+n1I2tRvT0fDSC45FGrplN9tM=
X-Gm-Gg: ASbGncvwCTji/B6+F2oi0+cFPU7e6y74hTGd8oKliEXbkxjBSHtJDyMVGbWSrT4xzXC
 OSRD8+TL7FMinBR02rB3W8wQhy7jy7pZCC1O+VdLN7niMZb5LGkQca4oL79ehMjpdJdDYNI0jiG
 iTkZ5QL4u5fpnQhvc4Gx1ZJ8d8Ycp6DxCBkU15+F/o2N7l1kqEOrIUIBnj/p8En0C7Uc36K6dRA
 twxQThr61svDzz/as2LPgiyrhV6hWkzpRW2IpftUSZMBpA7uNRoZwxpJjDxqDbxojwARgXRpsDn
 YRCAvjs3+uvEGsnd7sCDudTA93iM9cqpWPrg9Yc/bgHBQPaPUy8yNddTVEiuwzPfAtWgHKd4Yx5
 8Rt52EM/JHhC1sQIA93Vx3TwcNI3jQuWiooYZ/5ynOgqQOuehTEu+XVxtS7jIVAIvJsXPw+AjtU
 eY9jmBI0NGigvmfzsgZPp63o/n6KtvlJj/XKgXIWfXHQSGyg==
X-Google-Smtp-Source: AGHT+IHXn//gYy/FPDS11JkAC7b6ZOUtYPhfbQ9nWYtGOjZcjRthLuCi34I0slpWEjkiascvTg1uBA==
X-Received: by 2002:a05:6512:2307:b0:579:ac00:1f20 with SMTP id
 2adb3069b0e04-5930e993ed4mr405699e87.2.1761598806372; 
 Mon, 27 Oct 2025 14:00:06 -0700 (PDT)
Received: from localhost (ip-217-65-132-10.ptr.icomera.net. [217.65.132.10])
 by smtp.gmail.com with UTF8SMTPSA id
 2adb3069b0e04-59301f8471csm2533230e87.106.2025.10.27.14.00.04
 for <bug-auctex@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 27 Oct 2025 14:00:05 -0700 (PDT)
From: Al Haji-Ali <abdo.haji.ali@HIDDEN>
To: bug-auctex@HIDDEN
Subject: 14.1.0; [PATCH] New feature: preview-point 
Date: Mon, 27 Oct 2025 20:16:12 +0100
Message-ID: <m0a51ci29v.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=2a00:1450:4864:20::135;
 envelope-from=abdo.haji.ali@HIDDEN; helo=mail-lf1-x135.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

--=-=-=
Content-Type: text/plain

Hello,

This is the last follow-up bug-report/patch from:
https://lists.gnu.org/archive/html/auctex-devel/2025-08/msg00026.html

which includes the main preview-point feature. It can be enabled by setting `preview-point` to `'after-string` for example.
To use `buframe`, the package needs to be installed as well (available on ELPA). 

Any comments/questions are welcome. I realized it's a a lot of code to review.

Best regards,
-- Al

--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=New-feature-preview-point.patch

From 33807f005de8403499cd0dd5eb2ba2990847197c Mon Sep 17 00:00:00 2001
From: Al Haji-Ali <a.hajiali@HIDDEN>
Date: Tue, 9 Sep 2025 21:19:43 +0100
Subject: [PATCH] New feature, preview-point

* doc/preview-latex.texi: Add docs for preview-point
* preview.el (preview-silent-errors): New local variable.
(preview-point,preview-point-auto-p): New custom variables
(preview-point-disabled-face, preview-point-processing-face): New faces.
(preview-point--frame, preview-point--current-overlay): New variables.
(preview-dvipng-image-type): Update doc.
(preview-log-error,preview-reraise-error): Implement silent mode based
on `preview-silent-errors'.
(preview-gs-sentinel, preview-gs-transact): Call `preview-point-refresh'.
(preview-ascent-from-bb): Return 'center when 'preview-point' is
non-nil.
(preview-toggle): Call preview-point activation function.
(preview-disable): Control behaviour based on preview-point.
(preview-map): Add key-binding for `preview-point-toggle-mode'.
(preview-mode-setup): Control setup based on `preview-point'.
(preview-parse-messages): Restore point before calling place functions.
(preview-point-auto-delay): New custom variable.
(preview-point--buframe, preview-point-inside-overlay-p,
preview-point-activate-maybe, preview-point-move-point,
preview-point-auto, preview-point-updated, preview-point-toggle-mode,
preview-point-toggle-auto-refresh, preview-point@around@write-region,
preview-point--preview-at-point, preview-point-has-preview-p,
preview-point-buf-change): New functions.
---
 doc/preview-latex.texi |  20 ++
 preview.el             | 507 +++++++++++++++++++++++++++++++++++------
 2 files changed, 463 insertions(+), 64 deletions(-)

diff --git a/doc/preview-latex.texi b/doc/preview-latex.texi
index e9e03fd5..299a161c 100644
--- a/doc/preview-latex.texi
+++ b/doc/preview-latex.texi
@@ -480,6 +480,26 @@ math (@code{$@dots{}$}), or if your usage of @code{$} conflicts with
 @previewlatex{}'s, you can turn off inline math previews.  In the
 @samp{Preview Latex} group, remove @code{textmath} from
 @code{preview-default-option-list} by customizing this variable.
+
+@item Enable preview at point.
+
+To enable a mode where previews are shown only when the cursor is inside
+the preview area, set @code{preview-point}. Valid values are:
+
+@table @code
+@item after-string
+Show the preview after the TeX source.
+
+@item before-string
+Show the preview before the TeX source.
+
+@item buframe
+Show the preview in a separate frame next to the cursor. Requires the
+@code{buframe} package to be installed (available on ELPA).
+@end table
+
+See also @code{preview-point-auto-p} to enable automatic updating or
+generation of previews.
 @end itemize

 @node Known problems, For advanced users, Simple customization, top
diff --git a/preview.el b/preview.el
index e9339307..205d6d93 100644
--- a/preview.el
+++ b/preview.el
@@ -370,6 +370,10 @@ See also `preview-gs-command'."
   "List of overlays to convert using gs.
 Buffer-local to the appropriate TeX process buffer.")

+(defvar-local preview-silent-errors nil
+  "When non-nil, do not signal preview errors nor display output buffer.
+This variable should be set in the process buffer.")
+
 (defvar-local preview-gs-outstanding nil
   "Overlays currently processed.")

@@ -454,6 +458,53 @@ set to `postscript'."
   :group 'preview-latex
   :type 'boolean)

+;;; preview-point customizations and variables.
+(defcustom preview-point nil
+  "Specifies where to show the preview.
+If non-nil, show the preview at point.  Can be `before-string',
+`after-string' to show at before or after the TeX code or `buframe' to
+show in a separate frame (the `buframe' package must be installed).  Can
+also be \\='(buframe FN-POS FRAME-PARAMETERS BUF-PARAMETERS) where
+FN-POS is a position function (default is
+`buframe-position-right-of-overlay') and FRAME-PARAMETERS is an alist of
+additional frame parameters, default is nil and BUF-PARAMETERS is an
+alist of buffer local variables and their values.
+
+This variable must be set before opening a TeX file. Charging its value
+while a file is open will lead to previews not being displayed
+correctly. See `preview-point-toggle-mode'."
+  :type '(choice
+          (const :tag "Before string" before-string)
+          (const :tag "After string (default)" after-string)
+          (const :tag "On frame" buframe)
+          (list :tag "On frame with explicit parameters"
+                (function :tag "Position function")
+                (alist :tag "Frame parameters")
+                (alist :tag "Buffer parameters"))))
+
+(defcustom preview-point-auto-p nil
+  "Set this to enable previewing automatically.
+When non-nil, it is assumed to be a function that is is called with no
+arguments at (point) when there is not a preview already.  If the
+function return a non-nil value, a `preview-at-point' will be initiated."
+  :type 'symbol)
+
+(defface preview-point-disabled-face
+  '((t (:inherit shadow)))
+  "Face used when preview is disabled."
+  :group 'preview-point)
+
+(defface preview-point-processing-face
+  '((t (:inherit preview-point-disabled-face)))
+  "Face used when preview is processing."
+  :group 'preview-point)
+
+(defvar preview-point--frame nil
+  "The last active preview popup frame.")
+
+(defvar preview-point--current-overlay nil
+  "The overlay currently shown in the preview popup frame.")
+
 (defun preview-string-expand (arg &optional separator)
   "Expand ARG as a string.
 It can already be a string.  Or it can be a list, then it is
@@ -625,7 +676,8 @@ is to be used."
         (insert-before-markers
          (format "%s: %s\n"
                  context (error-message-string err)))
-        (display-buffer (current-buffer)))))
+        (unless preview-silent-errors
+          (display-buffer (current-buffer))))))
   (setq preview-error-condition err))

 (defun preview-reraise-error (&optional process)
@@ -634,7 +686,11 @@ Makes sure that PROCESS is removed from the \"Compilation\"
 tag in the mode line."
   (when preview-error-condition
     (unwind-protect
-        (signal (car preview-error-condition) (cdr preview-error-condition))
+        (unless (buffer-local-value 'preview-silent-errors
+                                    (or (process-buffer process)
+                                        (current-buffer)))
+          (signal (car preview-error-condition)
+                  (cdr preview-error-condition)))
       (setq preview-error-condition nil
             compilation-in-progress (delq process compilation-in-progress)))))

@@ -705,6 +761,8 @@ and tries to restart Ghostscript if necessary."
               (let* ((err (concat preview-gs-answer "\n"
                                   (process-name process) " " string))
                      (ov (preview-gs-behead-outstanding err)))
+                (when ov
+                  (preview-point-updated ov))
                 (when (and (null ov) preview-gs-queue)
                   (save-excursion
                     (goto-char (if (marker-buffer (process-mark process))
@@ -1424,16 +1482,16 @@ Try \\[ps-run-start] \\[ps-run-buffer] and \
          (ps-open
           (let ((string
                  (concat
-                (mapconcat #'shell-quote-argument
-                            (append (list
-                                     preview-gs-command
-                                     outfile)
-                                    preview-gs-command-line)
-                            " ")
-                 "\nGS>"
-                 preview-gs-init-string
-                 (aref (overlay-get ov 'queued) 1)
-                 err)))
+                  (mapconcat #'shell-quote-argument
+                             (append (list
+                                      preview-gs-command
+                                      outfile)
+                                     preview-gs-command-line)
+                             " ")
+                  "\nGS>"
+                  preview-gs-init-string
+                  (aref (overlay-get ov 'queued) 1)
+                  err)))
             (lambda () (interactive "@") (preview-mouse-open-error string))))
          (str
           (preview-make-clickable
@@ -1488,7 +1546,8 @@ given as ANSWER."
                                     (preview-ascent-from-bb
                                      bbox)
                                     (aref preview-colors 2))))
-            (overlay-put ov 'queued nil)))))
+            (overlay-put ov 'queued nil)
+            (preview-point-updated ov)))))
     (while (and (< (length preview-gs-outstanding)
                    preview-gs-outstanding-limit)
                 (setq ov (pop preview-gs-queue)))
@@ -1700,19 +1759,22 @@ icon is cached in the property list of the SYMBOL."
 (defun preview-ascent-from-bb (bb)
   "This calculates the image ascent from its bounding box.
 The bounding box BB needs to be a 4-component vector of
-numbers (can be float if available)."
+numbers (can be float if available).
+
+If `preview-point' is non-nil, this simply returns \\='center."
   ;; baseline is at 1in from the top of letter paper (11in), so it is
   ;; at 10in from the bottom precisely, which is 720 in PostScript
   ;; coordinates.  If our bounding box has its bottom not above this
   ;; line, and its top above, we can calculate a useful ascent value.
   ;; If not, something is amiss.  We just use 100 in that case.
-
-  (let ((bottom (aref bb 1))
-        (top (aref bb 3)))
-    (if (and (<= bottom 720)
-             (> top 720))
-        (round (* 100.0 (/ (- top 720.0) (- top bottom))))
-      100)))
+  (if preview-point
+      'center
+    (let ((bottom (aref bb 1))
+          (top (aref bb 3)))
+      (if (and (<= bottom 720)
+               (> top 720))
+          (round (* 100.0 (/ (- top 720.0) (- top bottom))))
+        100))))

 (defface preview-face '((((background dark))
                          (:background "dark slate gray"))
@@ -2084,26 +2146,28 @@ purposes."
              'active
            'inactive))
         (strings (overlay-get ov 'strings)))
-    (unless (eq (overlay-get ov 'preview-state) 'disabled)
-      (overlay-put ov 'preview-state preview-state)
-      (if (eq preview-state 'active)
-          (progn
-            (overlay-put ov 'category 'preview-overlay)
-            (if (eq (overlay-start ov) (overlay-end ov))
-                (overlay-put ov 'before-string (car strings))
-              (dolist (prop '(display keymap mouse-face help-echo))
-                (overlay-put ov prop
-                             (get-text-property 0 prop (car strings))))
-              (overlay-put ov 'before-string nil))
-            (overlay-put ov 'face nil))
-        (dolist (prop '(display keymap mouse-face help-echo))
-          (overlay-put ov prop nil))
-        (overlay-put ov 'face 'preview-face)
-        (unless (cdr strings)
-          (setcdr strings (preview-inactive-string ov)))
-        (overlay-put ov 'before-string (cdr strings)))
-      (if old-urgent
-          (apply #'preview-add-urgentization old-urgent))))
+    (if preview-point
+        (preview-point-activate-maybe ov arg)
+      (unless (eq (overlay-get ov 'preview-state) 'disabled)
+        (overlay-put ov 'preview-state preview-state)
+        (if (eq preview-state 'active)
+            (progn
+              (overlay-put ov 'category 'preview-overlay)
+              (if (eq (overlay-start ov) (overlay-end ov))
+                  (overlay-put ov 'before-string (car strings))
+                (dolist (prop '(display keymap mouse-face help-echo))
+                  (overlay-put ov prop
+                               (get-text-property 0 prop (car strings))))
+                (overlay-put ov 'before-string nil))
+              (overlay-put ov 'face nil))
+          (dolist (prop '(display keymap mouse-face help-echo))
+            (overlay-put ov prop nil))
+          (overlay-put ov 'face 'preview-face)
+          (unless (cdr strings)
+            (setcdr strings (preview-inactive-string ov)))
+          (overlay-put ov 'before-string (cdr strings)))
+        (if old-urgent
+            (apply #'preview-add-urgentization old-urgent)))))
   (if event
       (preview-restore-position
        ov
@@ -2334,11 +2398,21 @@ active (`transient-mark-mode'), it is run through `preview-region'."
   (unless preview-leave-open-previews-visible
     (overlay-put ovr 'preview-image nil))
   (overlay-put ovr 'timestamp nil)
-  (setcdr (overlay-get ovr 'strings) (preview-disabled-string ovr))
-  (unless preview-leave-open-previews-visible
-    (preview-toggle ovr))
+
+  (setcdr (overlay-get ovr 'strings)
+          (unless preview-point
+            ;; It will be updated later in `preview-toggle'.
+            (preview-disabled-string ovr)))
+
+  (unless preview-point
+    (unless preview-leave-open-previews-visible
+      (preview-toggle ovr)
+      ;; Only delete the files if we are not using the images
+      (preview--delete-overlay-files ovr)))
   (overlay-put ovr 'preview-state 'disabled)
-  (preview--delete-overlay-files ovr))
+  (when preview-point
+    ;; Toggle/update preview (maybe) after setting state
+    (preview-toggle ovr t)))

 (defun preview--delete-overlay-files (ovr)
   "Delete files owned by OVR."
@@ -2612,7 +2686,8 @@ Deletes the dvi file when finished."
                                     (preview-ascent-from-bb
                                      (aref queued 0))
                                     (aref preview-colors 2)))
-              (overlay-put ov 'queued nil))
+              (overlay-put ov 'queued nil)
+              (preview-point-updated ov))
           (push filename oldfiles)
           ;; Do note modify `filenames' if we are not replacing
           ;; it, to avoid orphaning files. The filenames will be
@@ -2958,6 +3033,7 @@ See description of `TeX-command-list' for details."

 (defvar preview-map
   (let ((map (make-sparse-keymap)))
+    (define-key map "\C-t" #'preview-point-toggle-mode)
     (define-key map "\C-p" #'preview-at-point)
     (define-key map "\C-r" #'preview-region)
     (define-key map "\C-b" #'preview-buffer)
@@ -3204,8 +3280,10 @@ pp")
 (defun preview-mode-setup ()
   "Setup proper buffer hooks and behavior for previews."
   (setq-local desktop-save-buffer #'desktop-buffer-preview-misc-data)
-  (add-hook 'pre-command-hook #'preview-mark-point nil t)
-  (add-hook 'post-command-hook #'preview-move-point nil t)
+  (if preview-point
+      (add-hook 'post-command-hook #'preview-point-move-point nil t)
+    (add-hook 'pre-command-hook #'preview-mark-point nil t)
+    (add-hook 'post-command-hook #'preview-move-point nil t))
   (when (TeX-buffer-file-name)
     (let* ((filename (expand-file-name (TeX-buffer-file-name)))
            format-cons)
@@ -3797,22 +3875,28 @@ name(\\([^)]+\\))\\)\\|\
                                           (funcall preview-find-end-function
                                                    region-beg)
                                         (point)))
-                                     (ovl (preview-place-preview
-                                           snippet
-                                           region-beg
-                                           region-end
-                                           (preview-TeX-bb box)
-                                           (cons lcounters counters)
-                                           tempdir
-                                           (cdr open-data))))
-                                (setq close-data (nconc ovl close-data))
-                                (when (and preview-protect-point
-                                           (<= region-beg point-current)
-                                           (< point-current region-end))
-                                  ;; Temporarily open the preview if it
-                                  ;; would bump the point.
-                                  (preview-toggle (car ovl))
-                                  (push (car ovl) preview-temporary-opened)))
+                                     ovl)
+                                (save-excursion
+                                  ;; Restore point to current one before
+                                  ;; placing preview
+                                  (goto-char point-current)
+                                  (setq ovl (preview-place-preview
+                                             snippet
+                                             region-beg
+                                             region-end
+                                             (preview-TeX-bb box)
+                                             (cons lcounters counters)
+                                             tempdir
+                                             (cdr open-data)))
+                                  (setq close-data (nconc ovl close-data))
+                                  (when (and preview-protect-point
+                                             (<= region-beg point-current)
+                                             (< point-current region-end)
+                                             (not preview-point))
+                                    ;; Temporarily open the preview if it
+                                    ;; would bump the point.
+                                    (preview-toggle (car ovl))
+                                    (push (car ovl) preview-temporary-opened))))
                             (with-current-buffer run-buffer
                               (preview-log-error
                                (list 'error
@@ -4420,6 +4504,301 @@ If not a regular release, the date of the last change.")
           (insert "\n")))
     (error nil)))

+
+;;; preview-point
+
+;; Buframe functions, it will be assumed that buframe is installed so
+;; that it can be required.
+(declare-function buframe-position-right-of-overlay "ext:buframe"
+                  (frame ov &optional location))
+(declare-function buframe-make-buffer "ext:buframe" (name &optional locals))
+(declare-function buframe-make "ext:buframe"
+                  (frame-or-name fn-pos buffer &optional
+                                 parent-buffer parent-frame parameters))
+(declare-function buframe-disable "ext:buframe" (frame-or-name &optional enable))
+
+(defun preview-point--buframe (show ov str)
+  "Show or hide a a buframe popup with STR around overlay OV."
+  (require 'buframe)
+  (if show
+      (let* ((buf (buframe-make-buffer " *preview-point-buffer*"
+                                       (car-safe (cddr (cdr-safe preview-point)))))
+             (max-image-size
+              (if (integerp max-image-size)
+                  max-image-size
+                ;; Set the size max-image-size using the current frame
+                ;; since the popup frame will be small to begin with
+                (* max-image-size (frame-width)))))
+        (with-current-buffer buf
+          (let (buffer-read-only)
+            (with-silent-modifications
+              (erase-buffer)
+              (insert (propertize str
+                                  'help-echo nil
+                                  'keymap nil
+                                  'mouse-face nil))
+              (goto-char (point-min)))))
+        (setq preview-point--frame
+              (buframe-make
+               "preview-point"
+               (lambda (frame)
+                 (when preview-point--current-overlay
+                   (funcall
+                    (or (car-safe (cdr-safe preview-point))
+                        #'buframe-position-right-of-overlay)
+                    frame preview-point--current-overlay)))
+               buf
+               (overlay-buffer ov)
+               (window-frame)
+               (car-safe (cdr (cdr-safe preview-point))))))
+    (buframe-disable preview-point--frame)))
+
+(defun preview-point-inside-overlay-p (ov &optional pt)
+  "Return PT if inside overlay OV, nil otherwise.
+If PT is nil, use point of OV's buffer."
+  (or pt
+      (setq pt (and
+                (overlay-buffer ov)
+                (with-current-buffer (overlay-buffer ov)
+                  (point)))))
+  (and
+   (eq (overlay-buffer ov) (window-buffer))
+   (>= pt (overlay-start ov))
+   (< pt (overlay-end ov))
+   pt))
+
+(defun preview-point-activate-maybe (ov &optional arg)
+  "Toggle visibility of preview overlay OV.
+If ARG is non-nil, deactivate overlay instead.
+
+If (point) is not inside OV, then a call to activate the overlay is
+ignored.  If the preview is disabled, the disabled symbol is shown when
+activated, otherwise the preview state is not changed."
+  (let* ((pt (and
+              (overlay-buffer ov)
+              (with-current-buffer (overlay-buffer ov)
+                (point))))
+         (strings (overlay-get ov 'strings))
+         (construct-p (overlay-get ov 'queued))
+         (disabled-p (eq (overlay-get ov 'preview-state) 'disabled))
+         (inside-p (preview-point-inside-overlay-p ov pt))
+         (str (car strings))
+         (show (and arg inside-p)))
+    ;; Update `strings' cdr, if needed
+    (when (or construct-p disabled-p)
+      (unless (cdr (overlay-get ov 'strings))
+        (setcdr (overlay-get ov 'strings)
+                (cond
+                 (disabled-p
+                  (if preview-leave-open-previews-visible
+                      (propertize str
+                                  'face
+                                  'preview-point-disabled-face)
+                    (preview-disabled-string ov)))
+                 (construct-p
+                  (if preview-leave-open-previews-visible
+                      (propertize str
+                                  'face
+                                  'preview-point-processing-face)
+                    (propertize "x" 'display preview-nonready-icon))))))
+      (setq str (cdr (overlay-get ov 'strings))))
+
+    (unless disabled-p
+      (overlay-put ov 'preview-state
+                   (if show
+                       'active
+                     'inactive)))
+
+    (when show
+      (overlay-put ov 'category 'preview-overlay))
+
+    (when (or show
+              (eq preview-point--current-overlay ov))
+      (setq preview-point--current-overlay (and show ov))
+      (if (or (eq preview-point 'buframe)
+              (eq (car-safe preview-point) 'buframe))
+          (preview-point--buframe show ov str)
+        (when (memq preview-point '(after-string before-string))
+          (overlay-put ov preview-point (and show str)))))))
+
+(defun preview-point-move-point ()
+  "Toggle previews as point enters or leaves overlays."
+  (preview-check-changes)
+  (let* ((pt (point))
+         (lst (overlays-at pt)))
+    ;; Hide any open overlays
+    (when-let* ((ov preview-point--current-overlay))
+      (and (overlay-buffer ov)
+           (overlay-get ov 'preview-state)
+           (not (eq (overlay-get ov 'preview-state) 'inactive))
+           (when (not (preview-point-inside-overlay-p
+                       ov pt))
+             (preview-point-activate-maybe ov nil))))
+
+    ;; Show all overlays under point
+    (dolist (ovr lst)
+      (let ((state (overlay-get ovr 'preview-state)))
+        (when ;; (eq (overlay-get ovr 'preview-state) 'inactive)
+            (and (and state (not (eq state 'active)))
+                 (not (eq ovr preview-point--current-overlay)))
+          (preview-point-activate-maybe ovr t))))))
+
+(defun preview-point-auto ()
+  "Mark current region for preview, if not already there."
+  (when (and
+         preview-point
+         (not (eq preview-point 'hidden))
+         (not (preview-point-has-preview-p))
+         preview-point-auto-p
+         (funcall preview-point-auto-p))
+    (preview-point-force-update (point) (current-buffer) t)))
+
+(defun preview-point-updated (ov)
+  "Mark preview OV as updated.
+Has effect only if `preview-point' is non-nil"
+  (when preview-point
+    (preview-point-activate-maybe ov t)))
+
+(defun preview-point-toggle-mode (mode)
+  "Set `preview-point' to MODE.
+If called interactively `preview-point' is toggled and the user is asked
+for the MODE when it is switch on.
+
+This function has an effect only if `preview-point' is non-nil, which
+should be set before opening a TeX file."
+  (interactive
+   (list (if preview-point
+             (if (not (eq preview-point 'hidden))
+                 'hidden
+               (intern
+                (cadr (read-multiple-choice
+                       "Mode :"
+                       '((?b "before-string")
+                         (?a "after-string")
+                         (?f "buframe"))))))
+           (error "Preview-point is not enabled.  \
+Set preview-point before opening the TeX file"))))
+
+  (unless preview-point
+    (error "Preview-point needs to be enabled first (before opening the tex file)."))
+  ;; Hide current overlay if it is visible.
+  (when preview-point--current-overlay
+    (preview-toggle preview-point--current-overlay nil))
+  (setq preview-point mode)
+  ;; Show the preview if it at point.
+  (preview-point-move-point))
+
+(defun preview-point-toggle-auto-update (enable &optional silent)
+  "Enable auto refresh of previews.
+When ENABLE is nil, disable auto-update instead.  If called
+interactively, auto-updating is toggled."
+  (interactive (list 'toggle))
+  (when (eq enable 'toggle)
+    (setq enable (not (memq
+                       #'preview-point-buf-change
+                       after-change-functions))))
+  (if enable
+      (progn
+        (add-hook 'after-change-functions #'preview-point-buf-change nil t)
+        (add-hook 'post-command-hook #'preview-point-auto nil t)
+        (preview-point-buf-change)
+        (unless silent
+          (message "Auto-updating previews enabled")))
+    (remove-hook 'after-change-functions #'preview-point-buf-change t)
+    (remove-hook 'post-command-hook #'preview-point-auto t)
+    (unless silent
+      (message "Auto-updating previews disabled"))))
+
+;;; preview-point -- Auto-preview
+(defcustom preview-point-auto-delay 0.1
+  "Delay in seconds for automatic preview timer."
+  :type 'number)
+(defvar preview-point-force-update--debounce-timer nil)
+
+(defun preview-point@around@write-region (orig-fun &rest args)
+  "Advice around `write-region' to suppress messages.
+ORIG-FUN is the original function.  ARGS are its arguments."
+  (let ((noninteractive t)
+        (inhibit-message t)
+        message-log-max)
+    (apply orig-fun args)))
+
+(defun preview-point-force-update (pt buffer &optional debounce)
+  "Update preview at PT in BUFFER.
+
+When DEBOUNCE is non-nil, the call is debounced using an idle
+timer. This also happens automatically when there is an ongoing
+compilation process."
+  (interactive (list (point) (current-buffer)))
+
+  (when preview-point-force-update--debounce-timer
+    (cancel-timer preview-point-force-update--debounce-timer)
+    (setq preview-point-force-update--debounce-timer nil))
+
+  (when (buffer-live-p buffer)
+    (unless debounce
+      (with-current-buffer buffer
+        (if-let* ((cur-process
+                   (or (get-buffer-process (TeX-process-buffer-name
+                                            (TeX-region-file)))
+                       (get-buffer-process (TeX-process-buffer-name
+                                            (TeX-master-file))))))
+            (progn
+              ;; Force de-bouncing
+              (when (and preview-current-region
+                         (not preview-abort-flag)
+                         ;; (< beg (cdr preview-current-region))
+                         )
+                (progn
+                  (ignore-errors (TeX-kill-job))
+                  (setq preview-abort-flag t)))
+              (with-local-quit (accept-process-output cur-process))
+              (setq debounce t))
+          ;; The code below is adopted from preview-auto
+          (let ((TeX-suppress-compilation-message t)
+                (save-silently t))
+            (advice-add 'write-region :around
+                        #'preview-point@around@write-region)
+            (unwind-protect
+                ;; If we are working in a file buffer that is not a tex file,
+                ;; then we want preview-region to operate in "non-file" mode,
+                ;; where it passes "<none>" to TeX-region-create.
+                (save-excursion
+                  (goto-char pt)
+                  ;; TODO: Check if we can rely on the `preview-region'
+                  ;; returning the process. It calls
+                  ;; `preview-generate-preview' which has this documented
+                  ;; behaviour, but not `preview-region'.
+                  (let ((process (preview-region (preview-next-border t)
+                                                 (preview-next-border nil))))
+                    (with-current-buffer (process-buffer process)
+                      (setq-local preview-silent-errors t))))
+              (advice-remove 'write-region
+                             #'preview-point@around@write-region))))))
+
+    (when debounce
+      (setq preview-point-force-update--debounce-timer
+            (run-with-idle-timer
+             preview-point-auto-delay nil
+             #'preview-point-force-update
+             pt buffer)))))
+
+(defun preview-point-has-preview-p (&optional pt)
+  "Return non-nil if PT has a preview overlay."
+  (cl-find-if
+   (lambda (ov) (overlay-get ov 'preview-state))
+   (overlays-at (or pt (point)))))
+
+(defun preview-point-buf-change (&rest _)
+  "Run preview at point if there is a preview overlay."
+  (when (and preview-point
+             (not (eq preview-point 'hidden))
+             (or
+              (preview-point-has-preview-p)
+              (and preview-point-auto-p
+                   (funcall preview-point-auto-p))))
+    (preview-point-force-update (point) (current-buffer) t)))
+
 ;;;###autoload
 (defun preview-report-bug () "Report a bug in the preview-latex package."
        (interactive)
--
2.50.1 (Apple Git-155)

--=-=-=--




Acknowledgement sent to Al Haji-Ali <abdo.haji.ali@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-auctex@HIDDEN. Full text available.
Report forwarded to bug-auctex@HIDDEN:
bug#79708; Package auctex. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 25 Nov 2025 20:45:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.