diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | eshell-conf.el | 62 |
2 files changed, 63 insertions, 0 deletions
@@ -25,3 +25,4 @@ projects tramp calc.el multisession/* +elpa/*
\ No newline at end of file diff --git a/eshell-conf.el b/eshell-conf.el index 42b727d..ba14746 100644 --- a/eshell-conf.el +++ b/eshell-conf.el @@ -560,5 +560,67 @@ For example, \"...\" expands into \"../..\"." :override #'durand-eshell-bookmark-jump) +;;; Handle graphviz commands + +;; It is convenient to be able to compile multiple GraphViz files or +;; delete multiple image files simultaneously. + +(defun eshell/gv (&rest args) + "Compile GraphViz files into images, or delete images, depending \ +on `args'." + (eshell-eval-using-options + "gv" args + '((?h "help" nil nil "Print this help message") + (?f "format" t image-format "Which image format to output") + (?r "remove" nil removep "Whether to remove images or not") + (?R "remove-all" nil remove-allp "Whether to remove images and sources or not") + :usage "[-f format] [-r|-R] [graphviz file names...] +This little command can perform two tasks: + +- Compile multiple GraphViz files. +- Remove output image files. + +The file names should not include any extension." + :preserve-args + :parse-leading-options-only + :show-usage) + (let ((removep (cond (remove-allp 'all) (removep)))) + (eshell-gv image-format removep args)))) + +(require 'vc) + +(defun eshell-gv (image-format removep &rest args) + "Internal function for `eshell/gv'." + (let ((args (car args)) + (image-format (cond (image-format) ("png"))) + (root-dir (expand-file-name "output" (vc-root-dir)))) + (cond + (removep + (mapc + (lambda (arg) + (let* ((file-name (expand-file-name + (format "%s.%s" arg image-format))) + (source-file-name (format "%s.gv" arg)) + (source-file-name + (expand-file-name source-file-name root-dir))) + (delete-file file-name) + (cond + ((eq removep 'all) (delete-file source-file-name))))) + args)) + ((mapc + (lambda (arg) + (let* ((out-file-name (format "%s.%s" arg image-format)) + (source-file-name (format "%s.gv" arg)) + (source-file-name + (expand-file-name source-file-name root-dir))) + (eshell-command-result + (format + "dot -T%s \"%s\" -o \"%s\"" + image-format + source-file-name + out-file-name)))) + args)))) + nil) + (provide 'eshell-conf) ;;; eshell-conf.el ends here |