all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [BUG] Patch: Add an option to silence org-latex-preview (also a feature request) [9.7.11 (release_9.7.11 @ /usr/local/share/emacs/30.0.91/lisp/org/)]
@ 2024-10-04 18:43 Daan Ro
  2024-10-12 15:49 ` Ihor Radchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Daan Ro @ 2024-10-04 18:43 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org


[-- Attachment #1.1: Type: text/plain, Size: 378 bytes --]

[PATCH] org-latex-preview: add org-latex-preview-quiet customization

* lisp/org.el (org-latex-preview): define customizable boolean
org-latex-preview-quiet.

Emacs : GNU Emacs 30.0.91 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.43, cairo version 1.18.2)
of 2024-09-30
Package: Org mode version 9.7.11 (release_9.7.11 @ /usr/local/share/emacs/30.0.91/lisp/org/)

Daanturo


[-- Attachment #1.2: Type: text/html, Size: 1058 bytes --]

[-- Attachment #2: 0001-org-latex-preview-add-org-latex-preview-quiet-customization.patch --]
[-- Type: application/octet-stream, Size: 3657 bytes --]

From 1b1642b1733af1321b6ec390e21bb700a09063af Mon Sep 17 00:00:00 2001
From: Daanturo <daanturo@gmail.com>
Date: Sat, 5 Oct 2024 01:36:21 +0700
Subject: [PATCH] org-latex-preview: add org-latex-preview-quiet customization

* lisp/org.el (org-latex-preview): define customizable boolean
org-latex-preview-quiet.
---
 lisp/org.el | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index df58b47be..bcd30585e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16148,6 +16148,15 @@ BEG and END are buffer positions."
 	 default-directory)
        'overlays nil 'forbuffer org-preview-latex-default-process))))
 
+(defcustom org-latex-preview-quiet nil
+  "Non-nil means `org-latex-preview''s `message' calls are suppressed."
+  :group 'org
+  :type 'boolean)
+
+(defun org-latex-preview--message (format-string &rest args)
+  (unless org-latex-preview-quiet
+    (apply #'message format-string args)))
+
 (defun org-latex-preview (&optional arg)
   "Toggle preview of the LaTeX fragment at point.
 
@@ -16175,12 +16184,12 @@ fragments in the buffer."
    ;; Clear whole buffer.
    ((equal arg '(64))
     (org-clear-latex-preview (point-min) (point-max))
-    (message "LaTeX previews removed from buffer"))
+    (org-latex-preview--message "LaTeX previews removed from buffer"))
    ;; Preview whole buffer.
    ((equal arg '(16))
-    (message "Creating LaTeX previews in buffer...")
+    (org-latex-preview--message "Creating LaTeX previews in buffer...")
     (org--latex-preview-region (point-min) (point-max))
-    (message "Creating LaTeX previews in buffer... done."))
+    (org-latex-preview--message "Creating LaTeX previews in buffer... done."))
    ;; Clear current section.
    ((equal arg '(4))
     (org-clear-latex-preview
@@ -16193,19 +16202,19 @@ fragments in the buffer."
          (region-end)
        (org-with-limited-levels (org-entry-end-position)))))
    ((use-region-p)
-    (message "Creating LaTeX previews in region...")
+    (org-latex-preview--message "Creating LaTeX previews in region...")
     (org--latex-preview-region (region-beginning) (region-end))
-    (message "Creating LaTeX previews in region... done."))
+    (org-latex-preview--message "Creating LaTeX previews in region... done."))
    ;; Toggle preview on LaTeX code at point.
    ((let ((datum (org-element-context)))
       (and (org-element-type-p datum '(latex-environment latex-fragment))
 	   (let ((beg (org-element-begin datum))
 		 (end (org-element-end datum)))
 	     (if (org-clear-latex-preview beg end)
-		 (message "LaTeX preview removed")
-	       (message "Creating LaTeX preview...")
+		 (org-latex-preview--message "LaTeX preview removed")
+	       (org-latex-preview--message "Creating LaTeX preview...")
 	       (org--latex-preview-region beg end)
-	       (message "Creating LaTeX preview... done."))
+	       (org-latex-preview--message "Creating LaTeX preview... done."))
 	     t))))
    ;; Preview current section.
    (t
@@ -16213,9 +16222,9 @@ fragments in the buffer."
 		 (save-excursion
 		   (org-with-limited-levels (org-back-to-heading t) (point)))))
 	  (end (org-with-limited-levels (org-entry-end-position))))
-      (message "Creating LaTeX previews in section...")
+      (org-latex-preview--message "Creating LaTeX previews in section...")
       (org--latex-preview-region beg end)
-      (message "Creating LaTeX previews in section... done.")))))
+      (org-latex-preview--message "Creating LaTeX previews in section... done.")))))
 
 (defun org-format-latex
     (prefix &optional beg end dir overlays msg forbuffer processing-type)
-- 
2.46.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [BUG] Patch: Add an option to silence org-latex-preview (also a feature request) [9.7.11 (release_9.7.11 @ /usr/local/share/emacs/30.0.91/lisp/org/)]
  2024-10-04 18:43 [BUG] Patch: Add an option to silence org-latex-preview (also a feature request) [9.7.11 (release_9.7.11 @ /usr/local/share/emacs/30.0.91/lisp/org/)] Daan Ro
@ 2024-10-12 15:49 ` Ihor Radchenko
  2024-10-13  6:18   ` Daan Ro
  0 siblings, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2024-10-12 15:49 UTC (permalink / raw)
  To: Daan Ro; +Cc: emacs-orgmode@gnu.org

Daan Ro <daanturo@gmail.com> writes:

> [PATCH] org-latex-preview: add org-latex-preview-quiet customization
>
> * lisp/org.el (org-latex-preview): define customizable boolean
> org-latex-preview-quiet.

Thanks for the patch, but may you please elaborate why you want the
messages to be suppressed? And why in org-latex-preview specifically?

Many Org mode commands display messages, so I'd like to know your
motivation as it may affect how we want handle messages across Org mode.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] Patch: Add an option to silence org-latex-preview (also a feature request) [9.7.11 (release_9.7.11 @ /usr/local/share/emacs/30.0.91/lisp/org/)]
  2024-10-12 15:49 ` Ihor Radchenko
@ 2024-10-13  6:18   ` Daan Ro
  2024-10-13 11:27     ` Ihor Radchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Daan Ro @ 2024-10-13  6:18 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 1813 bytes --]

Currently I have minor mode that automates `org-latex-preview` every some idle
seconds so that newly typed fragments are automatically rendered. Having an
option to disable messages would make Emacs's interface much cleaner.

About org-mode's similar messages, I just saw that some `message` calls are
conditioned on `(called-interactively-p 'any)`. IMO `org-latex-preview`'s
messages should do the same as the latter (only notify when called
interactively) by default, but maybe that's a breakage for some people.

Additionally, I'd love to make `org-latex-preview` asynchronous. First, that
will definitely speedup opening org files with `org-startup-with-latex-preview`
as Emacs doesn't freeze while generating images. Second, auto preview minor
modes such as mine would be smoother.

I have a rough idea of implementation by passing `org-place-formula-image` as a
callback closure to `org-create-formula-image` and `org-compile-file`. Would
such a feature request/patch be accepted?

Daanturo

On Oct 12 2024, at 10:49 pm, Ihor Radchenko <yantar92@posteo.net> wrote:
> Daan Ro <daanturo@gmail.com> writes:
>
> > [PATCH] org-latex-preview: add org-latex-preview-quiet customization
> >
> > * lisp/org.el (org-latex-preview): define customizable boolean
> > org-latex-preview-quiet.
>
> Thanks for the patch, but may you please elaborate why you want the
> messages to be suppressed? And why in org-latex-preview specifically?
>
> Many Org mode commands display messages, so I'd like to know your
> motivation as it may affect how we want handle messages across Org mode.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
>


[-- Attachment #2: Type: text/html, Size: 2821 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] Patch: Add an option to silence org-latex-preview (also a feature request) [9.7.11 (release_9.7.11 @ /usr/local/share/emacs/30.0.91/lisp/org/)]
  2024-10-13  6:18   ` Daan Ro
@ 2024-10-13 11:27     ` Ihor Radchenko
  2024-10-13 17:32       ` Daan Ro
  0 siblings, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2024-10-13 11:27 UTC (permalink / raw)
  To: Daan Ro; +Cc: emacs-orgmode@gnu.org

Daan Ro <daanturo@gmail.com> writes:

> Currently I have minor mode that automates `org-latex-preview` every some idle
> seconds so that newly typed fragments are automatically rendered. Having an
> option to disable messages would make Emacs's interface much cleaner.

You can suppress all the messages via `inhibit-message', which see.
Is it good enough for your needs?

> About org-mode's similar messages, I just saw that some `message` calls are
> conditioned on `(called-interactively-p 'any)`. IMO `org-latex-preview`'s
> messages should do the same as the latter (only notify when called
> interactively) by default, but maybe that's a breakage for some people.

It is not self-evident. Sometimes, it is useful to see messages from
non-interactive calls. Imagine functions that are called by other
interactive Org commands.

> Additionally, I'd love to make `org-latex-preview` asynchronous. First, that
> will definitely speedup opening org files with `org-startup-with-latex-preview`
> as Emacs doesn't freeze while generating images. Second, auto preview minor
> modes such as mine would be smoother.
>
> I have a rough idea of implementation by passing `org-place-formula-image` as a
> callback closure to `org-create-formula-image` and `org-compile-file`. Would
> such a feature request/patch be accepted?

See https://list.orgmode.org/87lek2up0w.fsf@tec.tecosaur.net/

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] Patch: Add an option to silence org-latex-preview (also a feature request) [9.7.11 (release_9.7.11 @ /usr/local/share/emacs/30.0.91/lisp/org/)]
  2024-10-13 11:27     ` Ihor Radchenko
@ 2024-10-13 17:32       ` Daan Ro
  2024-10-14 14:19         ` Ihor Radchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Daan Ro @ 2024-10-13 17:32 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 2151 bytes --]

> See https://list.orgmode.org/87lek2up0w.fsf@tec.tecosaur.net/ (https://link.getmailspring.com/link/37E53521-13CF-4156-93ED-196834780D2F@getmailspring.com/0?redirect=https%3A%2F%2Flist.orgmode.org%2F87lek2up0w.fsf%40tec.tecosaur.net%2F&recipient=ZW1hY3Mtb3JnbW9kZUBnbnUub3Jn)
Thank you, the said fork has all I needed for now. I've decided to use it for now.
I think this bug ticket can be closed.

Daanturo

On Oct 13 2024, at 6:27 pm, Ihor Radchenko <yantar92@posteo.net> wrote:
> Daan Ro <daanturo@gmail.com> writes:
>
> > Currently I have minor mode that automates `org-latex-preview` every some idle
> > seconds so that newly typed fragments are automatically rendered. Having an
> > option to disable messages would make Emacs's interface much cleaner.
>
> You can suppress all the messages via `inhibit-message', which see.
> Is it good enough for your needs?
>
> > About org-mode's similar messages, I just saw that some `message` calls are
> > conditioned on `(called-interactively-p 'any)`. IMO `org-latex-preview`'s
> > messages should do the same as the latter (only notify when called
> > interactively) by default, but maybe that's a breakage for some people.
>
> It is not self-evident. Sometimes, it is useful to see messages from
> non-interactive calls. Imagine functions that are called by other
> interactive Org commands.
>
> > Additionally, I'd love to make `org-latex-preview` asynchronous. First, that
> > will definitely speedup opening org files with `org-startup-with-latex-preview`
> > as Emacs doesn't freeze while generating images. Second, auto preview minor
> > modes such as mine would be smoother.
> >
> > I have a rough idea of implementation by passing `org-place-formula-image` as a
> > callback closure to `org-create-formula-image` and `org-compile-file`. Would
> > such a feature request/patch be accepted?
>
> See https://list.orgmode.org/87lek2up0w.fsf@tec.tecosaur.net/
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
>


[-- Attachment #2: Type: text/html, Size: 3815 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] Patch: Add an option to silence org-latex-preview (also a feature request) [9.7.11 (release_9.7.11 @ /usr/local/share/emacs/30.0.91/lisp/org/)]
  2024-10-13 17:32       ` Daan Ro
@ 2024-10-14 14:19         ` Ihor Radchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Ihor Radchenko @ 2024-10-14 14:19 UTC (permalink / raw)
  To: Daan Ro; +Cc: emacs-orgmode@gnu.org

Daan Ro <daanturo@gmail.com> writes:

> I think this bug ticket can be closed.

Ok.
Canceled.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-10-14 14:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-04 18:43 [BUG] Patch: Add an option to silence org-latex-preview (also a feature request) [9.7.11 (release_9.7.11 @ /usr/local/share/emacs/30.0.91/lisp/org/)] Daan Ro
2024-10-12 15:49 ` Ihor Radchenko
2024-10-13  6:18   ` Daan Ro
2024-10-13 11:27     ` Ihor Radchenko
2024-10-13 17:32       ` Daan Ro
2024-10-14 14:19         ` Ihor Radchenko

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.