Skip to content

Commit

Permalink
Show an alert message if Pandoc run buffer is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushalmodi committed Jul 20, 2018
1 parent 6c94396 commit bb6575b
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions ox-hugo-pandoc-cite.el
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ arguments.")
ORIG-OUTFILE is the Org exported file name.
BIB-LIST is a list of one or more bibliography files."
;; First kill the Pandoc run buffer if already exists (from a
;; previous run).
(when (get-buffer org-hugo-pandoc-cite--run-pandoc-buffer)
(kill-buffer org-hugo-pandoc-cite--run-pandoc-buffer))
(let* ((pandoc-outfile (make-temp-file ;ORIG_FILE_BASENAME.RANDOM.md
(concat (file-name-base orig-outfile) ".")
nil ".md"))
Expand All @@ -74,10 +78,6 @@ BIB-LIST is a list of one or more bibliography files."
(unless (= 0 exit-code)
(user-error (format "[ox-hugo] Pandoc execution failed. See the %S buffer"
org-hugo-pandoc-cite--run-pandoc-buffer)))

;; If no error has happened, we don't need the Pandoc run
;; buffer; kill it.
(kill-buffer org-hugo-pandoc-cite--run-pandoc-buffer)
pandoc-outfile))

(defun org-hugo-pandoc-cite--remove-pandoc-meta-data (fm)
Expand Down Expand Up @@ -235,7 +235,7 @@ ORIG-OUTFILE is the Org exported file name."
(org-trim
bib-file))))
(unless (file-exists-p fname)
(user-error "[ox-hugo-pandoc-cite] Bibliography file %S does not exist"
(user-error "[ox-hugo] Bibliography file %S does not exist"
fname))
fname))
bib-list-1)))))))
Expand All @@ -260,8 +260,18 @@ ORIG-OUTFILE is the Org exported file name."
pandoc-outfile-contents loffset))
(fm-plus-content (concat fm "\n" contents-fixed)))
(write-region fm-plus-content nil orig-outfile)
(delete-file pandoc-outfile)))
(message "[ox-hugo-pandoc-cite] No bibliography file was specified"))))
(delete-file pandoc-outfile))

(with-current-buffer org-hugo-pandoc-cite--run-pandoc-buffer
(if (> (point-max) 1) ;buffer is not empty
(message
(format
(concat "[ox-hugo] See the %S buffer for possible Pandoc warnings.\n"
" Review the exported Markdown file for possible missing citations.")
org-hugo-pandoc-cite--run-pandoc-buffer))
;; Kill the Pandoc run buffer if it is empty.
(kill-buffer org-hugo-pandoc-cite--run-pandoc-buffer))))
(message "[ox-hugo] No bibliography file was specified"))))


(provide 'ox-hugo-pandoc-cite)
Expand Down

0 comments on commit bb6575b

Please sign in to comment.