From b24392d7c8645baf0fe44b0fb2932db41b6fda60 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Sat, 22 Jul 2023 00:01:19 +0800 Subject: eshell: gv is now async and reports progress * eshell-conf.el (eshell-gv): Now gv uses `make-process` to asynchronously compile GraphViz files to image files. Moreover, it reports the progress in the echo area as well, as a quality-of-life improvement. --- eshell-conf.el | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'eshell-conf.el') diff --git a/eshell-conf.el b/eshell-conf.el index 6911901..f2e1d3c 100644 --- a/eshell-conf.el +++ b/eshell-conf.el @@ -800,16 +800,21 @@ The file names should not include any extension." (lambda (arg) (cond ((memq ?* (mapcar #'identity arg)) - (let* ((inhibit-message t) - (splitted (split-string arg "*")) + (let* ((splitted (split-string arg "*")) (matching-re (format "%s.*%s\\.gv" (car splitted) (apply #'concat (cdr splitted)))) (source-files - (directory-files root-dir t matching-re t))) + (directory-files root-dir t matching-re t)) + (len (length source-files)) + (count 0) + (reporter (make-progress-reporter "gv" 0 len )) + inhibit-message) (mapc (lambda (file) + (progress-reporter-update reporter count) + (setq count (1+ count)) (let ((output-file-name (expand-file-name (concat @@ -821,14 +826,22 @@ The file names should not include any extension." (delete-char 2) (cond (verticalp (insert ?T ?B)) ((insert ?L ?R))) - (write-region nil nil file)) - (eshell-command-result - (format - "dot -T%s \"%s\" -o \"%s\"" + (write-region nil nil file nil 'silent)) + (make-process + :name "gv" + :command + (list + "dot" + "-T" image-format file - output-file-name)))) - source-files))) + "-o" + output-file-name) + :buffer nil + :filter #'ignore + :sentinel #'ignore))) + source-files) + (progress-reporter-done reporter))) (t (let* ((arg (file-name-base arg)) (out-file-name (format "%s.%s" arg image-format)) -- cgit v1.2.3-18-g5258