aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Oteiza2015-09-13 14:12:22 -0400
committerMark Oteiza2015-09-15 11:11:16 -0400
commitc051487fcf379febf4ce5b38de7017609c84a106 (patch)
treef35ec33352ad7326848a6a7e30906fec0bc0d768
parent7f6b6f1a165b5a52481aa3b1d06ac4cdbce24da3 (diff)
downloademacs-c051487fcf379febf4ce5b38de7017609c84a106.tar.gz
emacs-c051487fcf379febf4ce5b38de7017609c84a106.zip
lisp/custom.el (load-theme): Only compute hash when needed
-rw-r--r--lisp/custom.el9
1 files changed, 4 insertions, 5 deletions
diff --git a/lisp/custom.el b/lisp/custom.el
index ea5ab7a4773..e212e32807d 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -1214,13 +1214,11 @@ Return t if THEME was successfully loaded, nil otherwise."
1214 (put theme 'theme-documentation nil)) 1214 (put theme 'theme-documentation nil))
1215 (let ((fn (locate-file (concat (symbol-name theme) "-theme.el") 1215 (let ((fn (locate-file (concat (symbol-name theme) "-theme.el")
1216 (custom-theme--load-path) 1216 (custom-theme--load-path)
1217 '("" "c"))) 1217 '("" "c"))))
1218 hash)
1219 (unless fn 1218 (unless fn
1220 (error "Unable to find theme file for `%s'" theme)) 1219 (error "Unable to find theme file for `%s'" theme))
1221 (with-temp-buffer 1220 (with-temp-buffer
1222 (insert-file-contents fn) 1221 (insert-file-contents fn)
1223 (setq hash (secure-hash 'sha256 (current-buffer)))
1224 ;; Check file safety with `custom-safe-themes', prompting the 1222 ;; Check file safety with `custom-safe-themes', prompting the
1225 ;; user if necessary. 1223 ;; user if necessary.
1226 (when (or no-confirm 1224 (when (or no-confirm
@@ -1228,8 +1226,9 @@ Return t if THEME was successfully loaded, nil otherwise."
1228 (and (memq 'default custom-safe-themes) 1226 (and (memq 'default custom-safe-themes)
1229 (equal (file-name-directory fn) 1227 (equal (file-name-directory fn)
1230 (expand-file-name "themes/" data-directory))) 1228 (expand-file-name "themes/" data-directory)))
1231 (member hash custom-safe-themes) 1229 (let ((hash (secure-hash 'sha256 (current-buffer))))
1232 (custom-theme-load-confirm hash)) 1230 (or (member hash custom-safe-themes)
1231 (custom-theme-load-confirm hash))))
1233 (let ((custom--inhibit-theme-enable t) 1232 (let ((custom--inhibit-theme-enable t)
1234 (buffer-file-name fn)) ;For load-history. 1233 (buffer-file-name fn)) ;For load-history.
1235 (eval-buffer)) 1234 (eval-buffer))