Make trust status mode line segment more efficent

This commit is contained in:
2026-01-07 01:56:29 -08:00
parent ec1c88d182
commit 0e9ca65e67

13
init.el
View File

@ -81,10 +81,15 @@
(describe-symbol form))))
;; Trusted buffer stuff
(defvar-local my/-trusted-content-segment-cache nil
"Cache variable used in my/-trusted-content-segment.
This is a single element list with that element being the file's trusted status.")
(defun my/temp-trust-buffer ()
"Set the current buffers local value of `trusted-content' to \\=:all."
(interactive)
(setq-local trusted-content :all)
(setq-local trusted-content :all
;; reset the cache
my/-trusted-content-segment-cache nil)
(cond
((and (buffer-modified-p) (y-or-n-p "Save and reload buffer?"))
(save-buffer)
@ -100,7 +105,11 @@
(equal trusted-content :all)
buffer-file-name)
(propertize "[Temp. Trusted]" 'face 'warning))
((not (trusted-content-p))
((progn
(unless my/-trusted-content-segment-cache
(setq-local my/-trusted-content-segment-cache
(list (trusted-content-p))))
(not (car my/-trusted-content-segment-cache)))
(propertize "[Untrusted]" 'face 'error)))))
(add-to-list 'mode-line-misc-info
'(:eval (my/-trusted-content-segment)))