From 12ea5a943c7f84536e5c7c2dd4591f5f34c7bffb Mon Sep 17 00:00:00 2001 From: defanor Date: Tue, 28 Nov 2017 15:01:12 +0300 Subject: Cleanup pancake-process-output before processing There may be an error during rendering, don't let it to get repeated on each iteration. --- pancake.el | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'pancake.el') 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." -- cgit v1.2.3