summaryrefslogtreecommitdiff
path: root/pancake.el
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-11-28 15:01:12 +0300
committerdefanor <defanor@uberspace.net>2017-11-28 15:01:12 +0300
commit12ea5a943c7f84536e5c7c2dd4591f5f34c7bffb (patch)
tree84c80ed9eb750590434e5b374eb7ae373ff8443d /pancake.el
parent3ee80d00ec31207041ed00018a25e9d3a0242dba (diff)
Cleanup pancake-process-output before processing
There may be an error during rendering, don't let it to get repeated on each iteration.
Diffstat (limited to 'pancake.el')
-rw-r--r--pancake.el47
1 files changed, 24 insertions, 23 deletions
diff --git a/pancake.el b/pancake.el
index dacd593..03022be 100644
--- a/pancake.el
+++ b/pancake.el
@@ -287,29 +287,30 @@ property. Returns a list of collected values."
(with-current-buffer (process-buffer proc)
(setq pancake-process-output (concat pancake-process-output string))
(when (pancake-line-p pancake-process-output)
- ;; there may be multiple lines, processing separately
- (dolist (raw-line (split-string pancake-process-output "\n"))
- (unless (string-empty-p raw-line)
- (let ((output (read raw-line)))
- (pcase output
- (`(render . ,alist)
- ;; todo: maybe store identifiers and links for
- ;; further manipulation
- (let ((inhibit-read-only t))
- (delete-region (point-min) (point-max))
- (setq pancake-headings '())
- (pancake-uri-history-add (alist-get 'uri alist))
- (dolist (line (alist-get 'lines alist))
- (pancake-print-line line)
- (newline))
- (goto-char (point-min)))
- (run-hooks 'pancake-display-hook))
- (`(goto ,line) (goto-line line))
- ;; todo: check if the images were requested
- ;; explicitly, don't just show all the images that get
- ;; saved
- (`(saved ,uri ,path) (pancake-insert-image uri path))))))
- (setq pancake-process-output "")))))
+ (let ((raw-lines (split-string pancake-process-output "\n")))
+ (setq pancake-process-output "")
+ ;; there may be multiple lines, processing separately
+ (dolist (raw-line raw-lines)
+ (unless (string-empty-p raw-line)
+ (let ((output (read raw-line)))
+ (pcase output
+ (`(render . ,alist)
+ ;; todo: maybe store identifiers and links for
+ ;; further manipulation
+ (let ((inhibit-read-only t))
+ (delete-region (point-min) (point-max))
+ (setq pancake-headings '())
+ (pancake-uri-history-add (alist-get 'uri alist))
+ (dolist (line (alist-get 'lines alist))
+ (pancake-print-line line)
+ (newline))
+ (goto-char (point-min)))
+ (run-hooks 'pancake-display-hook))
+ (`(goto ,line) (goto-line line))
+ ;; todo: check if the images were requested
+ ;; explicitly, don't just show all the images that get
+ ;; saved
+ (`(saved ,uri ,path) (pancake-insert-image uri path)))))))))))
(defun pancake-process-stderr-filter (proc string)
"Pancake process filter for stderr."