Skip to content

Commit

Permalink
Fix #3685: don't mutate org buffer when tangling
Browse files Browse the repository at this point in the history
If the buffer doesn't change, the cursor won't move.
  • Loading branch information
hlissner committed Aug 4, 2020
1 parent 9f84bc3 commit 8580b53
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions modules/config/literate/autoload.el
Expand Up @@ -16,8 +16,7 @@ byte-compiled from.")
(print-group!
(let* ((default-directory doom-private-dir)
(org (expand-file-name +literate-config-file))
(dest (concat (file-name-sans-extension +literate-config-file) ".el"))
(backup (make-temp-file "config.org.backup")))
(dest (concat (file-name-sans-extension +literate-config-file) ".el")))
(and (require 'ox)
(require 'ob-tangle)
(unwind-protect
Expand All @@ -26,18 +25,18 @@ byte-compiled from.")
(print! (info "%s") (apply #'format msg args))))
;; Prevent infinite recursion due to recompile-on-save
;; hooks later.
(org-mode-hook nil))
;; Do the ol' switcheroo because `org-babel-tangle' writes
;; changes to the user's literate config, which would impose on
;; the user.
(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)
(with-current-buffer (find-file-noselect org)
;; Tangling won't ordinarily expand #+INCLUDE directives, so
;; we do it ourselves.
(with-current-buffer (find-file-noselect backup)
;; Tangling won't ordinarily expand #+INCLUDE directives
(org-export-expand-include-keyword)
(org-babel-tangle nil dest))
(org-babel-tangle nil dest)
(kill-buffer (current-buffer)))
t)
(ignore-errors (copy-file backup org t))
(ignore-errors (delete-file backup)))
;; Write an empty file to serve as our mtime cache
(with-temp-file +literate-config-cache-file)))))
Expand Down

0 comments on commit 8580b53

Please sign in to comment.