summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2023-07-22 00:01:19 +0800
committerJSDurand <mmemmew@gmail.com>2023-07-22 00:01:19 +0800
commitb24392d7c8645baf0fe44b0fb2932db41b6fda60 (patch)
treea4123a45a0e98445e2a88186593ce56af31fd9d1
parent3cdfc7c2c7d25df9824bebf75ba1271ce3995789 (diff)
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.
-rw-r--r--eshell-conf.el31
1 files changed, 22 insertions, 9 deletions
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))