fix(literate): improve error handling while tangling
Now emits more informative errors in the case that the user's config.org doesn't exist or contains no src blocks. Fix: #6717
This commit is contained in:
parent
682f151176
commit
0d405329fe
1 changed files with 13 additions and 4 deletions
|
@ -41,10 +41,19 @@
|
||||||
(org-confirm-babel-evaluate nil)
|
(org-confirm-babel-evaluate nil)
|
||||||
;; Say a little more
|
;; Say a little more
|
||||||
(doom-print-message-level 'info))
|
(doom-print-message-level 'info))
|
||||||
(if-let (files (org-babel-tangle-file target dest))
|
(cond ((not (file-exists-p target))
|
||||||
|
(print! (warn "No org file at %s. Skipping...") (path target))
|
||||||
|
nil)
|
||||||
|
((with-temp-buffer
|
||||||
|
(insert-file-contents target)
|
||||||
|
(let ((case-fold-search t))
|
||||||
|
(not (re-search-forward "^ *#\\+begin_src e\\(?:macs-\\)?lisp" nil t))))
|
||||||
|
(print! (warn "No src blocks to tangle in %s. Skipping...") (path target))
|
||||||
|
nil)
|
||||||
|
((if-let (files (org-babel-tangle-file target dest))
|
||||||
(always (print! (success "Done tangling %d file(s)!" (length files))))
|
(always (print! (success "Done tangling %d file(s)!" (length files))))
|
||||||
(print! (error "Failed to tangle any blocks from your config."))
|
(print! (error "Failed to tangle any blocks from your config."))
|
||||||
nil))))))
|
nil))))))))
|
||||||
|
|
||||||
(defun +literate-tangle--sync ()
|
(defun +literate-tangle--sync ()
|
||||||
"Tangles `+literate-config-file' if it has changed."
|
"Tangles `+literate-config-file' if it has changed."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue