These hooks were broken in the case where there is a space character
in the result of notmuch search. It can be despite the will of the
user (in my case, it is the device name that has a space in it).
---
src/rde/features/mail.scm | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/rde/features/mail.scm b/src/rde/features/mail.scm
index cb08bfdc..c16523d4 100644
--- a/src/rde/features/mail.scm
+++ b/src/rde/features/mail.scm
@@ -1223,6 +1223,7 @@ mail accounts. ISYNC-VERBOSE controls output verboseness of
;;; feature-notmuch.
;;;
+;; Do it in Guile : https://git.oscarnajera.com/dotfiles/tree/bin/tagmail
(define* (default-get-notmuch-configuration config
#:key
(extra-tag-updates-post '()))
@@ -1266,22 +1267,23 @@ mail accounts. ISYNC-VERBOSE controls output verboseness of
(define (move-out-untagged-messages tag)
"If tag was removed -> move out of the related folder."
- (format #f "for f in $(notmuch search --output=files \
-'path:/.*\\/~a/ and not tag:~a' | grep '/~a/'); \
-do mv -v $f \
-$(echo $f | sed 's;/~a/;/archive/;' | sed 's/,U=[0-9]*:/:/'); done"
+ (format #f "notmuch search --output=files \
+'path:/.*\\/~a/ and not tag:~a' | grep '/~a/' | \
+while IFS= read -r f; do mv -v \"$f\" \
+\"$(echo ${f} | sed 's;/~a/;/archive/;' | sed 's/,U=[0-9]*:/:/')\"; done"
tag tag tag tag))
(define* (move-in-tagged-messages
tag
#:key (exclude-dir "nothing-will-match-this"))
- (format #f "for f in $(notmuch search --output=files \
-'not path:/.*\\/~a/ and tag:~a' | grep -v \"/~a/\"); \
-do mv -v $f \
-$(echo $f | sed 's;/[[:alnum:]]*/cur/;/~a/cur/;' | sed 's/,U=[0-9]*:/:/'); done"
+ (format #f "notmuch search --output=files \
+'not path:/.*\\/~a/ and tag:~a' | grep -v \"/~a/\" | \
+while IFS= read -r f; do mv -v \"$f\" \
+\"$(echo ${f} | sed 's;/[[:alnum:]]*/cur/;/~a/cur/;' | sed 's/,U=[0-9]*:/:/')\"; done"
tag tag exclude-dir tag))
(define delete-deleted-messages
- "for f in $(notmuch search --output=files tag:deleted); do rm -v $f; done")
+ "notmuch search --output=files tag:deleted | \
+while IFS= read -r f; do rm -v \"$f\"; done")
(define move-rules
(append
--
2.46.0
On 2024-09-28 22:28, Nicolas Graves wrote:
> These hooks were broken in the case where there is a space character
> in the result of notmuch search. It can be despite the will of the
> user (in my case, it is the device name that has a space in it).
> ---
> src/rde/features/mail.scm | 20 +++++++++++---------
> 1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/src/rde/features/mail.scm b/src/rde/features/mail.scm
> index cb08bfdc..c16523d4 100644
> --- a/src/rde/features/mail.scm
> +++ b/src/rde/features/mail.scm
> @@ -1223,6 +1223,7 @@ mail accounts. ISYNC-VERBOSE controls output verboseness of
> ;;; feature-notmuch.
> ;;;
>
> +;; Do it in Guile : https://git.oscarnajera.com/dotfiles/tree/bin/tagmail
> (define* (default-get-notmuch-configuration config
> #:key
> (extra-tag-updates-post '()))
> @@ -1266,22 +1267,23 @@ mail accounts. ISYNC-VERBOSE controls output verboseness of
>
> (define (move-out-untagged-messages tag)
> "If tag was removed -> move out of the related folder."
> - (format #f "for f in $(notmuch search --output=files \
> -'path:/.*\\/~a/ and not tag:~a' | grep '/~a/'); \
> -do mv -v $f \
> -$(echo $f | sed 's;/~a/;/archive/;' | sed 's/,U=[0-9]*:/:/'); done"
> + (format #f "notmuch search --output=files \
> +'path:/.*\\/~a/ and not tag:~a' | grep '/~a/' | \
> +while IFS= read -r f; do mv -v \"$f\" \
> +\"$(echo ${f} | sed 's;/~a/;/archive/;' | sed 's/,U=[0-9]*:/:/')\"; done"
> tag tag tag tag))
>
> (define* (move-in-tagged-messages
> tag
> #:key (exclude-dir "nothing-will-match-this"))
> - (format #f "for f in $(notmuch search --output=files \
> -'not path:/.*\\/~a/ and tag:~a' | grep -v \"/~a/\"); \
> -do mv -v $f \
> -$(echo $f | sed 's;/[[:alnum:]]*/cur/;/~a/cur/;' | sed 's/,U=[0-9]*:/:/'); done"
> + (format #f "notmuch search --output=files \
> +'not path:/.*\\/~a/ and tag:~a' | grep -v \"/~a/\" | \
> +while IFS= read -r f; do mv -v \"$f\" \
> +\"$(echo ${f} | sed 's;/[[:alnum:]]*/cur/;/~a/cur/;' | sed 's/,U=[0-9]*:/:/')\"; done"
> tag tag exclude-dir tag))
> (define delete-deleted-messages
> - "for f in $(notmuch search --output=files tag:deleted); do rm -v $f; done")
> + "notmuch search --output=files tag:deleted | \
> +while IFS= read -r f; do rm -v \"$f\"; done")
>
> (define move-rules
> (append
Good catch, thank you! Applied, will push soon.
--
Best regards,
Andrew Tropin