diff --git a/README.md b/README.md index d970ef0..d6935b8 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ To create a new file: 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 # 01.md diff --git a/um.el b/um.el index 34166e0..0e4e32d 100644 --- a/um.el +++ b/um.el @@ -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