From: Daan Ro <daanturo@gmail.com>
To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: [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/)]
Date: Sat, 5 Oct 2024 01:43:54 +0700 [thread overview]
Message-ID: <D2E9D483-0AFD-4AA3-AE65-B1D34DCE0CA6@getmailspring.com> (raw)
[-- 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
next reply other threads:[~2024-10-04 18:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-04 18:43 Daan Ro [this message]
2024-10-12 15:49 ` [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/)] 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D2E9D483-0AFD-4AA3-AE65-B1D34DCE0CA6@getmailspring.com \
--to=daanturo@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).