um--header
This commit is contained in:
parent
1b7b8f1c70
commit
2b82d36796
2 changed files with 28 additions and 30 deletions
|
|
@ -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
|
||||
|
|
|
|||
50
um.el
50
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
|
||||
|
||||
;;;###autoload
|
||||
(defun um-next (next-file &optional tags)
|
||||
"Takes the next-file generated by the shell script and opens it.
|
||||
(defun um--header (filename &optional tags)
|
||||
"Create a header composed of:
|
||||
|
||||
# filename
|
||||
: date
|
||||
+ tags
|
||||
|
||||
Optional TAGS string may contain more than one tag separated by a comma.
|
||||
"
|
||||
(find-file next-file)
|
||||
(um-journal-header)
|
||||
(if tags
|
||||
(progn (forward-line -1)
|
||||
(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 next-file "\\."))
|
||||
(cadr (split-string filename "\\."))
|
||||
tag))))
|
||||
(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
|
||||
|
|
|
|||
Loading…
Reference in a new issue