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

View file

@ -115,7 +115,7 @@ To create a new file:
um next um next
``` ```
This will create the file, open it with emacsclient, and run `um-journal-header` in that file: This will create the file, open it with emacsclient, and run `um--header` in that file:
```markdown ```markdown
# 01.md # 01.md

50
um.el
View file

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