forked from mirrors/org-mode
org-latex-preview: Make clear-cache user-friendly
* lisp/org-latex-preview.el (org-latex-preview-clear-cache): Ask for confirmation before wiping the entire LaTeX preview cache, and confirm cache clearing at the end when clearing the buffer cache.
This commit is contained in:
parent
b8e2f65cee
commit
daaa034cd0
|
@ -1416,7 +1416,7 @@ When CLEAR-ENTIRE-CACHE is non-nil (interactively set by \\[universal-argument])
|
||||||
the *entire* preview cache will be cleared, and `org-persist-gc' run."
|
the *entire* preview cache will be cleared, and `org-persist-gc' run."
|
||||||
(interactive
|
(interactive
|
||||||
(if current-prefix-arg
|
(if current-prefix-arg
|
||||||
'(nil nil t)
|
(list nil nil (y-or-n-p "This will clear the systemwide LaTeX preview cache, continue? "))
|
||||||
(let ((context (if (derived-mode-p 'org-mode)
|
(let ((context (if (derived-mode-p 'org-mode)
|
||||||
(org-element-context)
|
(org-element-context)
|
||||||
(user-error "This command must be run in an org-mode buffer"))))
|
(user-error "This command must be run in an org-mode buffer"))))
|
||||||
|
@ -1427,7 +1427,7 @@ the *entire* preview cache will be cleared, and `org-persist-gc' run."
|
||||||
'(latex-fragment latex-environment))
|
'(latex-fragment latex-environment))
|
||||||
(list (org-element-property :begin context)
|
(list (org-element-property :begin context)
|
||||||
(org-element-property :end context)))
|
(org-element-property :end context)))
|
||||||
(t (list (point-min) (point-max)))))))
|
(t (list nil nil))))))
|
||||||
(org-latex-preview-clear-overlays beg end)
|
(org-latex-preview-clear-overlays beg end)
|
||||||
(if clear-entire-cache
|
(if clear-entire-cache
|
||||||
(let ((n 0))
|
(let ((n 0))
|
||||||
|
@ -1441,10 +1441,11 @@ the *entire* preview cache will be cleared, and `org-persist-gc' run."
|
||||||
(message "The Org LaTeX preview cache was already empty.")
|
(message "The Org LaTeX preview cache was already empty.")
|
||||||
(org-persist-gc)
|
(org-persist-gc)
|
||||||
(message "Cleared all %d entries fom the Org LaTeX preview cache." n)))
|
(message "Cleared all %d entries fom the Org LaTeX preview cache." n)))
|
||||||
(let* ((imagetype (or (plist-get (alist-get org-latex-preview-default-process
|
(let ((imagetype
|
||||||
org-latex-preview-process-alist)
|
(or (plist-get (alist-get org-latex-preview-default-process
|
||||||
:image-output-type)
|
org-latex-preview-process-alist)
|
||||||
"png")))
|
:image-output-type)
|
||||||
|
"png")))
|
||||||
(dolist (element (org-latex-preview-collect-fragments beg end))
|
(dolist (element (org-latex-preview-collect-fragments beg end))
|
||||||
(pcase-let* ((begin (org-element-property :begin element))
|
(pcase-let* ((begin (org-element-property :begin element))
|
||||||
(`(,fg ,bg) (org-latex-preview--colors-at begin))
|
(`(,fg ,bg) (org-latex-preview--colors-at begin))
|
||||||
|
@ -1452,9 +1453,9 @@ the *entire* preview cache will be cleared, and `org-persist-gc' run."
|
||||||
(org-latex-preview--remove-cached
|
(org-latex-preview--remove-cached
|
||||||
(org-latex-preview--hash
|
(org-latex-preview--hash
|
||||||
org-latex-preview-default-process
|
org-latex-preview-default-process
|
||||||
value
|
value imagetype fg bg))))
|
||||||
imagetype
|
(message "Cleared LaTeX preview cache for %s."
|
||||||
fg bg)))))))
|
(if (or beg end) "region" "buffer")))))
|
||||||
|
|
||||||
;; TODO: Switching processes from imagemagick to dvi* with an existing
|
;; TODO: Switching processes from imagemagick to dvi* with an existing
|
||||||
;; dump-file during a single Emacs session should trigger
|
;; dump-file during a single Emacs session should trigger
|
||||||
|
|
Loading…
Reference in New Issue