Prompt for the ledger file if not configured.

This commit is contained in:
Bram Schoenmakers 2023-04-10 16:43:32 +02:00
parent 157d298512
commit 4e5405ed50

View file

@ -42,11 +42,15 @@
"Name of the buffer to use for the `run-ledger' comint instance.")
;;;###autoload
(defun run-ledger ()
"Run an inferior instance of `ledger' inside Emacs."
(interactive)
(defun run-ledger (ledger-file)
"Run an inferior instance of `ledger' inside Emacs, using LEDGER-FILE.
The LEDGER-FILE can be configured through the `ledger-file-path'
variable, otherwise a prompt will appear to select a file."
(interactive (list (or ledger-file-path
(read-file-name "Ledger file: "))))
(let* ((ledger-program ledger-cli-path)
(ledger-file-arguments (list "-f" ledger-file-path))
(ledger-file-arguments (list "--no-pager" "-f" ledger-file))
(ledger-arguments (append ledger-file-arguments ledger-cli-arguments))
(buffer (get-buffer-create ledger-buffer-name))
(proc-alive (comint-check-proc buffer)))