feat: tag manipulation
This commit is contained in:
@@ -16,9 +16,12 @@ list_threads() {
|
||||
| column -s "$(printf '\t')" -t -l 3 -R 1,2
|
||||
}
|
||||
|
||||
# List all available tags
|
||||
# List all tags of matching entries. If not query is provided, all tags are
|
||||
# listed.
|
||||
# @argument $1: query (optional)
|
||||
list_tags() {
|
||||
$NOTMUCH search --output=tags tag:/./
|
||||
[ "${1:-}" ] && query="$1" || query="tag:/./"
|
||||
$NOTMUCH search --output=tags "$query"
|
||||
}
|
||||
|
||||
# List all email addresses
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
# Print the message id of the last message within a thread.
|
||||
# @argument $1: thread id
|
||||
nm_last_message_in_thread() {
|
||||
$NOTMUCH search --output=messages --offset=-1 thread:"$1" | sed 's/^...//'
|
||||
# TODO: We may be smarter here that just incorporating excluded messages
|
||||
$NOTMUCH search --output=messages --offset=-1 --exclude=false thread:"$1" | sed 's/^...//'
|
||||
}
|
||||
|
||||
# Print the header of a message (with trailing empty line)
|
||||
@@ -31,3 +32,10 @@ nm_message_part_nr() {
|
||||
nm_message_get_part() {
|
||||
$NOTMUCH show --part="$2" id:"$1"
|
||||
}
|
||||
|
||||
# Add/remove a tag
|
||||
# @argument $1: [+/-]tag
|
||||
# @argument $2: query
|
||||
nm_tag() {
|
||||
$NOTMUCH tag "$1" "$2"
|
||||
}
|
||||
|
||||
@@ -11,11 +11,16 @@
|
||||
# @argument #3: if set, then the HTML messages will be taken
|
||||
preview_message() {
|
||||
[ "$1" = "id" ] && messageid="$2" || messageid="$(nm_last_message_in_thread "$2")"
|
||||
echo "preview_message: messageid=$messageid" >> /tmp/foo
|
||||
parts="$(nm_message_parts "$messageid")"
|
||||
echo "preview_message: parts=$parts" >> /tmp/foo
|
||||
html="${3:-}"
|
||||
echo "preview_message: html=$html" >> /tmp/foo
|
||||
nr="$(nm_message_part_nr "$messageid" "$html")"
|
||||
echo "preview_message: nr=$nr" >> /tmp/foo
|
||||
[ ! "$nr" ] && [ ! "$html" ] && html="html" && nr="$(nm_message_part_nr "$messageid" "html")"
|
||||
echo "preview_message: nr=$nr" >> /tmp/foo
|
||||
[ "$html" ] && parser="$PANDOC" || parser="cat"
|
||||
nm_message_header "$messageid" | $CATEMAIL
|
||||
nm_message_get_part "$messageid" "$nr" | $parser | $CATMD
|
||||
[ "$nr" ] && (nm_message_get_part "$messageid" "$nr" | $parser | $CATMD)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user