Fix 'void-variable: backup' error

Fixes my fix for #3685
This commit is contained in:
Henrik Lissner 2020-08-04 13:58:40 -04:00
parent 8580b53e8e
commit f641bf4554
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -16,20 +16,19 @@ byte-compiled from.")
(print-group! (print-group!
(let* ((default-directory doom-private-dir) (let* ((default-directory doom-private-dir)
(org (expand-file-name +literate-config-file)) (org (expand-file-name +literate-config-file))
(dest (concat (file-name-sans-extension +literate-config-file) ".el"))) (dest (concat (file-name-sans-extension +literate-config-file) ".el"))
(and (require 'ox) ;; Operate on a copy because `org-babel-tangle' has side-effects we
(require 'ob-tangle) ;; don't want to impose on the User's config permanently.
(unwind-protect (backup (make-temp-file (concat (file-name-nondirectory org) "."))))
(unwind-protect
(and (require 'ox)
(require 'ob-tangle)
(letf! ((defun message (msg &rest args) (letf! ((defun message (msg &rest args)
(when msg (when msg
(print! (info "%s") (apply #'format msg args)))) (print! (info "%s") (apply #'format msg args))))
;; Prevent infinite recursion due to recompile-on-save ;; Prevent infinite recursion due to recompile-on-save
;; hooks later. ;; hooks later.
(org-mode-hook nil) (org-mode-hook nil))
;; Operate on a copy because `org-babel-tangle' has
;; side-effects we don't want to impose on the User's
;; config permanently.
(backup (make-temp-file (concat (file-name-nondirectory org) "."))))
(copy-file org backup t) (copy-file org backup t)
(with-current-buffer (find-file-noselect backup) (with-current-buffer (find-file-noselect backup)
;; Tangling won't ordinarily expand #+INCLUDE directives ;; Tangling won't ordinarily expand #+INCLUDE directives
@ -37,9 +36,9 @@ byte-compiled from.")
(org-babel-tangle nil dest) (org-babel-tangle nil dest)
(kill-buffer (current-buffer))) (kill-buffer (current-buffer)))
t) t)
(ignore-errors (delete-file backup))) ;; Write an empty file to serve as our mtime cache
;; Write an empty file to serve as our mtime cache (with-temp-file +literate-config-cache-file))
(with-temp-file +literate-config-cache-file))))) (ignore-errors (delete-file backup))))))
;;;###autoload ;;;###autoload
(add-hook 'org-mode-hook #'+literate-enable-recompile-h) (add-hook 'org-mode-hook #'+literate-enable-recompile-h)