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
|
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
|
||||||
|
|
|
||||||
56
um.el
56
um.el
|
|
@ -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
|
||||||
|
|
||||||
|
(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
|
;;;###autoload
|
||||||
(defun um-next (next-file &optional tags)
|
(defun um-next (filename &optional tags)
|
||||||
"Takes the next-file generated by the shell script and opens it.
|
"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.
|
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)
|
(find-file filename)
|
||||||
(um-journal-header)
|
(um--header filename tags)
|
||||||
(if tags
|
(message "um next: %s" filename))
|
||||||
(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)))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; um-minor-mode : in markdown files under markdown-mode
|
;; um-minor-mode : in markdown files under markdown-mode
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue