emacs-orgmode@gnu.org archives
 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

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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).