(um-next) : change the um/next.sh interface to call this function

um/next.sh now has minimal elisp, and calls this function instead, and only prints the next file with UMNEXTPRINT

so that (um-next-shell) can just get the next file and feed it into (next-file)

and we don't have to call (undo) to leave out the header
This commit is contained in:
bth 2024-07-18 14:06:10 -07:00
commit e28aca4de0
3 changed files with 42 additions and 21 deletions

View file

@ -205,20 +205,37 @@ NOTE: this searches in the current project root only.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; shell integration
(defun um-next-file-shell (dir &optional descriptor header)
(defun um-next (next-file &optional tag skip-header)
"Takes the next-file generated by the shell script and opens it.
With the optional tag generated by the script.
And the option not to insert the um-journal-header.
"
(find-file next-file)
(unless skip-header
(um-journal-header)
(if tag
(progn (previous-line)
(insert (format "+ %s\n" tag))
(next-line))))
(message (format "creating %s" next-file))
)
(defun um-next-shell (dir &optional descriptor header)
"Calls um next in the provided dir.
With the option not to leave behind the um-journal-header.
Returns the value of next-file computed by um next
"
(let ((default-directory dir))
(let ((default-directory dir) (next-file))
;; https://emacs.stackexchange.com/a/19878
(eval (car (read-from-string (shell-command-to-string (concat "export UMNEXTECHO=true; um next" descriptor)))))
;; HACK: so that the um-journal-header doesn't
;; leave the file modified.
(unless header
(undo))
(setq next-file (shell-command-to-string
(concat "export UMNEXTPRINT=true; um next"
(concat " " descriptor))))
(um-next next-file nil t)
next-file
)
)
(provide 'um)