um--header

This commit is contained in:
bth 2026-06-07 09:32:18 -07:00
commit 2b82d36796
2 changed files with 28 additions and 30 deletions

56
um.el
View file

@ -137,21 +137,6 @@ ISO8601."
(,um-tag-regexp 1 'font-lock-um-tag-face)
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; journal header
(defun um-journal-header ()
"Create a header composed of:
# filename
: date
"
(interactive)
(insert
(format "# %s\n: %s\n\n" (buffer-name) (format-time-string um-date-format))
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; find-file-at-point
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -364,25 +349,38 @@ Negative prefix arg is handled by `um-tag-do', which see.
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; shell integration
;; CLI
(defun um--header (filename &optional tags)
"Create a header composed of:
# filename
: date
+ tags
"
(insert
(format "# %s\n: %s\n\n" filename (format-time-string um-date-format)))
(when tags
(forward-line -1)
(dolist (tag (split-string tags ","))
(insert (format "+ %s\n"
(if (equal "+" tag)
(cadr (split-string filename "\\."))
tag))))
(forward-line)))
;;;###autoload
(defun um-next (next-file &optional tags)
"Takes the next-file generated by the shell script and opens it.
(defun um-next (filename &optional tags)
"Takes the filename generated by the CLI, opens it, and adds the header.
Optional TAGS string may contain more than one tag separated by a comma.
A tag with a value of \"+\" is rendered as the descriptor portion of the filename.
"
(find-file next-file)
(um-journal-header)
(if tags
(progn (forward-line -1)
(dolist (tag (split-string tags ","))
(insert (format "+ %s\n"
(if (equal "+" tag)
(cadr (split-string next-file "\\."))
tag))))
(forward-line)))
(message (format "um next: %s" next-file)))
(find-file filename)
(um--header filename tags)
(message "um next: %s" filename))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; um-minor-mode : in markdown files under markdown-mode