From a9fbf9d7cf9627dae80fd648ac2a85d0c5911432 Mon Sep 17 00:00:00 2001 From: Karthik Chikmagalur Date: Sat, 3 Jun 2023 15:06:58 -0700 Subject: [PATCH] org-latex-preview: Rename precompilation vars * lisp/org-latex-preview.el (org-latex-preview-precompile, org-latex-preview--latex-preview-filter, org-latex-preview--create-tex-file, org-latex-preview-use-precompilation, org-latex-preview--precompile): Rename (i) the user option that controls precompilation for LaTeX previews, and (ii) the function that precompiles headres for LaTeX previews. This makes the names shorter and consistent with their corresponding equivalents in `ox-latex'. Rename `org-latex-preview-use-precompilation' -> `org-latex-preview-precompile' `org-latex-preview-precompile' -> `org-latex-preview--precompile' The new names have equivalents `org-latex-precompile' and `org-latex--precompile' in `ox-latex'. * testing/lisp/test-org-latex-preview.el: Update tests that set this user option. * etc/ORG-NEWS: Update the NEWS file. --- etc/ORG-NEWS | 2 +- lisp/org-latex-preview.el | 12 ++++++------ testing/lisp/test-org-latex-preview.el | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 028f264e7..283498eff 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -631,7 +631,7 @@ This option controls the width of text in preview images. This is relevant for displaymath-type LaTeX environments, and can be specified in multiple ways. -***** New option ~org-latex-preview-use-precompilation~ to control LaTeX precompilation +***** New option ~org-latex-preview-precompile~ to control LaTeX precompilation This option controls whether LaTeX headers for buffers are precompiled when generating the first preview for the buffer. Precompilation can diff --git a/lisp/org-latex-preview.el b/lisp/org-latex-preview.el index 047140c71..19572e8af 100644 --- a/lisp/org-latex-preview.el +++ b/lisp/org-latex-preview.el @@ -343,7 +343,7 @@ This can take a few forms, namely: (float :tag "Proportional width") (const :tag "Unset" nil))) -(defcustom org-latex-preview-use-precompilation t +(defcustom org-latex-preview-precompile t "Use LaTeX header precompilation when previewing fragments. This causes a slight delay the first time `org-latex-pdf-process' is called in a buffer, but subsequent calls will be faster. @@ -1482,7 +1482,7 @@ previews." "Create a LaTeX file based on PROCESSING-INFO and FRAGMENTS. More specifically, a preamble will be generated based on -PROCESSING-INFO. Then, if `org-latex-preview-use-precompilation' is +PROCESSING-INFO. Then, if `org-latex-preview-precompile' is non-nil, a precompiled format file will be generated if needed and used. Otherwise the preamble is used normally. @@ -1513,8 +1513,8 @@ The path of the created LaTeX file is returned." (coding-system-for-write buffer-file-coding-system)) (when (and relative-file-p remote-file-p) (error "Org LaTeX Preview does not currently support \\input/\\include in remote files")) - (when org-latex-preview-use-precompilation - (if-let ((format-file (org-latex-preview-precompile processing-info header))) + (when org-latex-preview-precompile + (if-let ((format-file (org-latex-preview--precompile processing-info header))) ;; Replace header with .fmt file path. (setq header (concat "%& " (file-name-sans-extension format-file))) (display-warning @@ -1781,7 +1781,7 @@ fragments in EXTENDED-INFO." ;; as it is currently known to cause issues. (save-excursion (goto-char (point-min)) - (when (if (and org-latex-preview-use-precompilation + (when (if (and org-latex-preview-precompile (re-search-forward "^PRELOADED FILES:" nil t)) (re-search-forward "^ *hyperref\\.sty" nil t) (re-search-forward "^(.*hyperref/hyperref\\.sty" nil t)) @@ -2181,7 +2181,7 @@ the *entire* preview cache will be cleared, and `org-persist-gc' run." (when (or clear-entire-cache (not (or beg end))) (org-latex-preview--clear-preamble-cache))) -(defun org-latex-preview-precompile (processing-info preamble &optional tempfile-p) +(defun org-latex-preview--precompile (processing-info preamble &optional tempfile-p) "Precompile/dump LaTeX PREAMBLE text. The path to the format file (.fmt) is returned. If the format diff --git a/testing/lisp/test-org-latex-preview.el b/testing/lisp/test-org-latex-preview.el index 87157e92f..ca1935861 100644 --- a/testing/lisp/test-org-latex-preview.el +++ b/testing/lisp/test-org-latex-preview.el @@ -232,7 +232,7 @@ ;;; No precompilation, no caching (ert-deftest test-org-latex-preview/place-previews-1 () (org-test-at-id "0b3807b3-69af-40cb-a27a-b380d54879cc" - (let ((org-latex-preview-use-precompilation nil) + (let ((org-latex-preview-precompile nil) (org-latex-preview-persist nil) (org-latex-preview-default-process 'dvisvgm)) (org-latex-preview-auto-mode -1) @@ -267,7 +267,7 @@ (ert-deftest test-org-latex-preview/place-previews-all () (org-test-at-id "0b3807b3-69af-40cb-a27a-b380d54879cc" - (let ((org-latex-preview-use-precompilation nil) + (let ((org-latex-preview-precompile nil) (org-latex-preview-persist nil) (org-latex-preview-default-process 'dvisvgm)) (org-latex-preview-auto-mode -1)