um-next takes a list of tags, as a comma separated string
remove the '+' logic from the shell component. i'm getting closer to just moving all logic into elisp. but that awk is so great.
This commit is contained in:
parent
96181e9229
commit
124954420a
3 changed files with 31 additions and 16 deletions
16
README.md
16
README.md
|
|
@ -145,6 +145,22 @@ Yields:
|
|||
+ foo
|
||||
```
|
||||
|
||||
Or send a list of tags separated by commas. `+` still works:
|
||||
|
||||
```sh
|
||||
um next foo +,bar,baz
|
||||
```
|
||||
|
||||
Yields:
|
||||
|
||||
```markdown
|
||||
# 05.foo.md
|
||||
: 2024.01.14
|
||||
+ foo
|
||||
+ bar
|
||||
+ baz
|
||||
```
|
||||
|
||||
## last
|
||||
|
||||
`um last` will print the name of the last numbered file. This can be useful on its own, or like this:
|
||||
|
|
|
|||
15
elisp/um.el
15
elisp/um.el
|
|
@ -201,18 +201,23 @@ NOTE: this searches in the current project root only.
|
|||
;; shell integration
|
||||
|
||||
;;;###autoload
|
||||
(defun um-next (next-file &optional tag skip-header)
|
||||
(defun um-next (next-file &optional tags skip-header)
|
||||
"Takes the next-file generated by the shell script and opens it.
|
||||
|
||||
With the optional tag generated by the script.
|
||||
And the option not to insert the um-journal-header.
|
||||
Optional TAGS string may contain more than one tag separated by a comma.
|
||||
The SKIP-HEADER option says not to insert the um-journal-header at all,
|
||||
in which case TAGS is also ignored.
|
||||
"
|
||||
(find-file next-file)
|
||||
(unless skip-header
|
||||
(um-journal-header)
|
||||
(if tag
|
||||
(if tags
|
||||
(progn (forward-line -1)
|
||||
(insert (format "+ %s\n" tag))
|
||||
(dolist (tag (split-string tags ","))
|
||||
(insert (format "+ %s\n"
|
||||
(if (equal "+" tag)
|
||||
(cadr (split-string next-file "\\."))
|
||||
tag))))
|
||||
(forward-line))))
|
||||
(message (format "creating %s" next-file))
|
||||
)
|
||||
|
|
|
|||
|
|
@ -31,13 +31,7 @@ NEXTFILE=`echo $LASTFILE | awk -f $UMBASEPATH/next.awk -v arg=$1`
|
|||
|
||||
# tag is optional second arg to this script
|
||||
if [ $2 ]; then
|
||||
# + means insert the string descriptor as tag
|
||||
if [ $2 = '+' ]; then
|
||||
UMTAG="$1"
|
||||
else
|
||||
UMTAG="$2"
|
||||
fi
|
||||
UMELISP=$(printf '(um-next "%s" "%s")' "$NEXTFILE" "$UMTAG")
|
||||
UMELISP=$(printf '(um-next "%s" "%s")' "$NEXTFILE" "$2")
|
||||
else
|
||||
UMELISP=$(printf '(um-next "%s")' "$NEXTFILE")
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in a new issue