esv.el: add esv-arguments variable

This commit is contained in:
Jeremy Baxter 2024-07-20 10:50:11 +12:00
parent c57c38444a
commit 3638d0f22a

12
esv.el
View file

@ -56,6 +56,9 @@
:type 'string
:group 'esv)
(defvar esv-arguments '()
"List of additional arguments passed to `esv-program'.")
(define-derived-mode esv-mode text-mode "ESV-Bible"
"Major mode used for reading the Bible with `esv'."
:group 'esv
@ -69,13 +72,16 @@ The result will be redirected to a buffer specified by `esv-buffer'.
Requires the esv command line tool to be in the system's PATH.
esv can be acquired at <https://sr.ht/~jeremy/esv>."
(interactive "MBook: \nMVerses: ")
(let ((buffer (concat book " " verses)))
(let
((buffer (concat book " " verses))
(arg-list (append esv-arguments
(list (format "-l%d" esv-columns)))))
(catch 'buffer-exists
(when (get-buffer buffer)
(message "Buffer `%s' already exists" buffer)
(throw 'buffer-exists nil))
(call-process esv-program nil buffer t
(format "-l%d" esv-columns) book verses)
(apply #'call-process esv-program nil buffer t
(append arg-list (list book) (list verses)))
(display-buffer buffer)
(with-current-buffer buffer
(esv-mode)