GNU bug report logs - #70295
[PATCH] Allow preprocessing of previews

Previous Next

Package: auctex;

Reported by: Paul Nelson <ultrono <at> gmail.com>

Date: Tue, 9 Apr 2024 03:20:04 UTC

Severity: normal

Tags: patch

Done: Arash Esbati <arash <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 70295 in the body.
You can then email your comments to 70295 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-auctex <at> gnu.org:
bug#70295; Package auctex. (Tue, 09 Apr 2024 03:20:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Paul Nelson <ultrono <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-auctex <at> gnu.org. (Tue, 09 Apr 2024 03:20:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Paul Nelson <ultrono <at> gmail.com>
To: bug-auctex <at> gnu.org
Subject: [PATCH] Allow preprocessing of previews
Date: Tue, 9 Apr 2024 05:18:54 +0200
[Message part 1 (text/plain, inline)]
Hello,

The attached patch introduces an optional preprocessing step to preview-region.

As motivation, I've been using such functionality (implemented via
advice) in https://github.com/ultronozm/czm-preview.el to give correct
equation numbers in previews.  This patch would allow me to excise the
advice.

Thanks, best,

Paul
[0001-Allow-programmatic-preprocessing-of-previews.patch (application/octet-stream, attachment)]

Information forwarded to bug-auctex <at> gnu.org:
bug#70295; Package auctex. (Tue, 09 Apr 2024 09:18:02 GMT) Full text and rfc822 format available.

Message #8 received at 70295 <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: Paul Nelson <ultrono <at> gmail.com>
Cc: 70295 <at> debbugs.gnu.org
Subject: Re: bug#70295: [PATCH] Allow preprocessing of previews
Date: Tue, 09 Apr 2024 11:17:22 +0200
Hi Paul,

Paul Nelson <ultrono <at> gmail.com> writes:

> The attached patch introduces an optional preprocessing step to
> preview-region.
>
> As motivation, I've been using such functionality (implemented via
> advice) in https://github.com/ultronozm/czm-preview.el to give correct
> equation numbers in previews.  This patch would allow me to excise the
> advice.

Thanks, the change is non-intrusive enough so I don't see why we should
not install it.

> From 417c9e465b4d0cd507e122268c8caad8d74d76f3 Mon Sep 17 00:00:00 2001
> From: Paul Nelson <ultrono <at> gmail.com>
> Date: Tue, 9 Apr 2024 05:04:56 +0200
> Subject: [PATCH] Allow preprocessing of previews
>
> * preview.el.in (preview--preprocess-function): New variable.
> (preview-region): Use the new variable (if non-nil) to
> preprocess the region being previewed.
> ---
>  preview.el.in | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/preview.el.in b/preview.el.in
> index 95410439..6afff5b9 100644
> --- a/preview.el.in
> +++ b/preview.el.in
> @@ -4030,6 +4030,9 @@ stored in `preview-dumped-alist'."
>    (preview-format-kill old-format)
>    (setcdr old-format nil))
>  
> +(defvar preview--preprocess-function nil
> +  "Function used to preprocess region before previewing.")

This variable will be set by your package, right?  Then it doesn't make
sense to me to declare it as an internal one.  What do you think about
something like this:

(defvar preview-preprocess-function nil
  "Function used to preprocess region before previewing.
The function bound to this variable will 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."
>    (interactive "r")
> @@ -4038,7 +4041,10 @@ stored in `preview-dumped-alist'."
>           (concat (preview--counter-information begin)
>                   TeX-region-extra)))
>      (TeX-region-create (TeX-region-file TeX-default-extension)
> -                       (buffer-substring-no-properties begin end)
> +                       (let ((str (buffer-substring-no-properties begin end)))
> +                         (if preview--preprocess-function
> +                             (funcall preview--preprocess-function str)

Need to be adjusted then.

> +                           str))
>                         (if buffer-file-name
>                             (file-name-nondirectory buffer-file-name)
>                           "<none>")

WDYT?  Best, Arash




Information forwarded to bug-auctex <at> gnu.org:
bug#70295; Package auctex. (Tue, 09 Apr 2024 09:27:02 GMT) Full text and rfc822 format available.

Message #11 received at 70295 <at> debbugs.gnu.org (full text, mbox):

From: Paul Nelson <ultrono <at> gmail.com>
To: Arash Esbati <arash <at> gnu.org>
Cc: 70295 <at> debbugs.gnu.org
Subject: Re: bug#70295: [PATCH] Allow preprocessing of previews
Date: Tue, 9 Apr 2024 11:26:18 +0200
Hi Arash,

Yes, your suggestion sounds good.  One other quick thought: maybe it'd
be bad design to have an external variable like this that can only
really be used by one package at a time?  Would something like the
following be preferred?

(defvar preview-preprocess-functions nil
  "List of functions used to preprocess region before previewing.
The functions in this list will be called inside `preview-region' with
one argument which is a string.")

Then (dolist ...) inside preview-region.  Happy to adjust it either
way, let me know.

Thanks, best,

Paul




Information forwarded to bug-auctex <at> gnu.org:
bug#70295; Package auctex. (Tue, 09 Apr 2024 10:05:02 GMT) Full text and rfc822 format available.

Message #14 received at 70295 <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: Paul Nelson <ultrono <at> gmail.com>
Cc: 70295 <at> debbugs.gnu.org
Subject: Re: bug#70295: [PATCH] Allow preprocessing of previews
Date: Tue, 09 Apr 2024 12:04:20 +0200
Hi Paul,

Paul Nelson <ultrono <at> gmail.com> writes:

> Yes, your suggestion sounds good.

Thanks.

> One other quick thought: maybe it'd be bad design to have an external
> variable like this that can only really be used by one package at a
> time?  Would something like the following be preferred?
>
> (defvar preview-preprocess-functions nil
>   "List of functions used to preprocess region before previewing.
> The functions in this list will be called inside `preview-region' with
> one argument which is a string.")
>
> Then (dolist ...) inside preview-region.  Happy to adjust it either
> way, let me know.

Yes, that might become necessary once more libraries need this feature.
Since currently you're the only customer, I suggest we start without a
list and install your first change, we can adjust later.

Do you like to prepare a new patch?

TIA.  Best, Arash




Information forwarded to bug-auctex <at> gnu.org:
bug#70295; Package auctex. (Tue, 09 Apr 2024 10:27:02 GMT) Full text and rfc822 format available.

Message #17 received at 70295 <at> debbugs.gnu.org (full text, mbox):

From: Paul Nelson <ultrono <at> gmail.com>
To: Arash Esbati <arash <at> gnu.org>
Cc: 70295 <at> debbugs.gnu.org
Subject: Re: bug#70295: [PATCH] Allow preprocessing of previews
Date: Tue, 9 Apr 2024 12:25:51 +0200
[Message part 1 (text/plain, inline)]
Hi Arash, see attached.  Thanks, best,  Paul
[0001-Allow-preprocessing-of-previews.patch (application/octet-stream, attachment)]

Reply sent to Arash Esbati <arash <at> gnu.org>:
You have taken responsibility. (Tue, 09 Apr 2024 10:37:02 GMT) Full text and rfc822 format available.

Notification sent to Paul Nelson <ultrono <at> gmail.com>:
bug acknowledged by developer. (Tue, 09 Apr 2024 10:37:02 GMT) Full text and rfc822 format available.

Message #22 received at 70295-done <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: Paul Nelson <ultrono <at> gmail.com>
Cc: 70295-done <at> debbugs.gnu.org
Subject: Re: bug#70295: [PATCH] Allow preprocessing of previews
Date: Tue, 09 Apr 2024 12:36:16 +0200
Paul Nelson <ultrono <at> gmail.com> writes:

> Hi Arash, see attached.

Great, thanks.  Pushed to master (49c9feb133) and closing.

Best, Arash




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 07 May 2024 11:24:13 GMT) Full text and rfc822 format available.

This bug report was last modified 9 days ago.

Previous Next


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