From 6a40115563a0779ce1d1652b4278f1abcfd50132 Mon Sep 17 00:00:00 2001 From: TEC Date: Tue, 30 Jan 2024 13:58:42 +0800 Subject: [PATCH] org-latex-preview: Ignored cmds list for auto mode * lisp/org-latex-preview.el (org-latex-preview-auto-blacklist): Add a blacklist for commands that should not cause LaTeX preview overlays to be "opened", i.e. for preview images to be hidden and text revealed when using `org-latex-preview-auto-mode'. A common use case would be cursor navigation commands like `next-line' or `scroll-up-command' that are often intended to move the view of the buffer, where opening preview overlays can be distracting. --- lisp/org-latex-preview.el | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lisp/org-latex-preview.el b/lisp/org-latex-preview.el index 6d72d17da..6ce36db95 100644 --- a/lisp/org-latex-preview.el +++ b/lisp/org-latex-preview.el @@ -239,6 +239,15 @@ There are three recognised value symbols: (const :tag "Fringe marker" fringe) (const :tag "Processing face" face))) +(defcustom org-latex-preview-auto-blacklist nil + "List of movement commands that should not affect preview display. + +When these commands are invoked, they will not cause previews to +be revealed when using `org-latex-preview-auto-mode'." + :type '(repeat symbol) + :package-version '(Org . "9.7") + :group 'org-latex-preview) + (defface org-latex-preview-processing-face '((t :inherit shadow)) "Face applied to LaTeX fragments for which a preview is being generated. @@ -655,8 +664,10 @@ If an org-latex-overlay is already present, nothing is done." If there is a latex preview image overlay at point, hide the image and display its text." (dolist (ov (overlays-at (point))) - (when (eq (overlay-get ov 'org-overlay-type) - 'org-latex-overlay) + (when (and (eq (overlay-get ov 'org-overlay-type) + 'org-latex-overlay) + (not (memq this-command + org-latex-preview-auto-blacklist))) (overlay-put ov 'display nil) (overlay-put ov 'view-text t) (when-let ((f (overlay-get ov 'face)))