unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Folder+tags
@ 2020-12-23 11:53 inwit
  2020-12-24 13:59 ` Folder+tags Alan Schmitt
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: inwit @ 2020-12-23 11:53 UTC (permalink / raw)
  To: notmuch

Hi! 

This is my first message so I'll start by congratulating all the
community around notmuch. Great piece of work you have here!

I guess that my question must have been surely asked before, but I can't
seem to find it in the lists' archive. My excuses if it is the case that
my search abilities have failed. It has happened before.

So, what I'm trying is to have a notmuch system up and running while
preserving my folder structure fully functional in the IMAP server. I
know that most of you will agree that folders are a thing from the past,
but the fact is that, in the past, I've devoted quite a lot of time to
sort my mails, and now I have a 3-level subfolder structure which is
hard-wired in my brain, so up to now sometimes I'm still keen to
searching messages in their expected folders. I guess it's a matter of
time until I abandon this scheme and dive fully into tag based email,
but for the time being I'm afraid of losing that folder structure for
good.

Anyway, I've been reading all around the web about this, and the closest
I got is using the aerc client, where I can configure a Maildir worker
and a notmuch worker, being able to use the former for reading and
classifying mail into folders and the later for tag-based searching.
This works, but at the same time, no matter how exciting the development
of aerc is (and it is a beautiful little piece of code), it is still
very far from emacs mail-mode.

What I would like to, then, is to use notmuch-el to read and classify my
mail. And the functionality I'm missing at the moment is a way to move
an email from the inbox to its corresponding folder, hopefully updating
its folder tags at the same time. That is: I would (mb)sync my mail from
my company's IMAP server to my Maildir folder structure, then I'd go to
the Inbox tag/folder, I'd read my mail and then, by hitting Shift+m, for
example, I'd be able to move that precise email, both in files and tags,
to its corresponding Maildir folder, so my next call to mbsync actually
moves the message in the IMAP server folders as well.  Does that make
sense?  Does anyone know how would I get to something like that?

Again, sorry if this is redundant, and congratulations on the good work.

Salud,

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Folder+tags
  2020-12-23 11:53 Folder+tags inwit
@ 2020-12-24 13:59 ` Alan Schmitt
  2020-12-25 16:41   ` Folder+tags inwit
  2020-12-25  8:04 ` Folder+tags Jaume Devesa
  2020-12-27 11:59 ` Folder+tags inwit
  2 siblings, 1 reply; 12+ messages in thread
From: Alan Schmitt @ 2020-12-24 13:59 UTC (permalink / raw)
  To: inwit, notmuch


[-- Attachment #1.1: Type: text/plain, Size: 1022 bytes --]

On 2020-12-23 12:53, "inwit" <inwit@sindominio.net> writes:

> What I would like to, then, is to use notmuch-el to read and classify my
> mail. And the functionality I'm missing at the moment is a way to move
> an email from the inbox to its corresponding folder, hopefully updating
> its folder tags at the same time. That is: I would (mb)sync my mail from
> my company's IMAP server to my Maildir folder structure, then I'd go to
> the Inbox tag/folder, I'd read my mail and then, by hitting Shift+m, for
> example, I'd be able to move that precise email, both in files and tags,
> to its corresponding Maildir folder, so my next call to mbsync actually
> moves the message in the IMAP server folders as well.  Does that make
> sense?  Does anyone know how would I get to something like that?

To move mail I use afew in move mode
(https://afew.readthedocs.io/en/latest/move_mode.html). I use it to move
deleted messages to the trash, and old email to an archive folder. I
guess it could work in your case.

Best,

Alan

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Folder+tags
  2020-12-23 11:53 Folder+tags inwit
  2020-12-24 13:59 ` Folder+tags Alan Schmitt
@ 2020-12-25  8:04 ` Jaume Devesa
  2020-12-25 17:27   ` Folder+tags inwit
  2020-12-27 11:59 ` Folder+tags inwit
  2 siblings, 1 reply; 12+ messages in thread
From: Jaume Devesa @ 2020-12-25  8:04 UTC (permalink / raw)
  To: inwit, notmuch


[-- Attachment #1.1: Type: text/plain, Size: 1443 bytes --]

Hello,

> What I would like to, then, is to use notmuch-el to read and classify my
> mail. And the functionality I'm missing at the moment is a way to move
> an email from the inbox to its corresponding folder, hopefully updating
> its folder tags at the same time. That is: I would (mb)sync my mail from
> my company's IMAP server to my Maildir folder structure, then I'd go to
> the Inbox tag/folder, I'd read my mail and then, by hitting Shift+m, for
> example, I'd be able to move that precise email, both in files and tags,
> to its corresponding Maildir folder, so my next call to mbsync actually
> moves the message in the IMAP server folders as well.  Does that make
> sense?  Does anyone know how would I get to something like that?
> 
> Again, sorry if this is redundant, and congratulations on the good work.
> 

I sync my email with offlineimap and I do something similar, but using
the `presync.sh` hook that offlineimap provides, via simple `xargs`:

	notmuch search --output=files --format=text0 \
	folder:mailbox/INBOX -tag:inbox | xargs -0 --no-run-if-empty \
	mv -t ~/mail/mailbox/Archive/$YEAR/new/

So just before offlineimap starts another round of sync, the emails
tagged as 'not inbox' inside the INBOX folder are being moved to the
Archive/${YEAR} folder.

I've never used emacs, so I ignore if you can do something similar by
binding keys in emacs (but I guess you can).

Hope that helps,

[-- Attachment #1.2: signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

-----BEGIN PGP SIGNATURE-----

iQEzBAABCAAdFiEEhwK6jQKH61pINcppMUCWBWUVQ+MFAl/lnQAACgkQMUCWBWUV
Q+Omfgf+LDH8hjXtdJM2Z1nnIyOv8WPrKQJfabhf1cyMq4Gz3rZBDSQd8kLhevfn
9pxVCsY54SUEnC7T3mBcV4Kqzx6Kiv4HLjtbRgkDdJL3kGAU7y7pzhtakMIpOEKa
8XHO7RJdMd+l4mf1MLCm7YBbDcyD7oPXTUiJg5/3do7ZfY4T/Ri9gLtQQVDvKbNu
8WEeciTFGVw+DxWGjJ2tsBopN8fheGpdKRugwMSU01K+7Dv3X524/mMk0YEoeOT4
sqH8WiQRcAqzFh5aLj3QexeebkJfqEi8JQzgdjx/pQ8l1JO8cozZzYYo5jYcfE7E
ybJkFyC28+4/HC5N1db3FQyQPdpTiQ==
=JGWp
-----END PGP SIGNATURE-----

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Folder+tags
  2020-12-24 13:59 ` Folder+tags Alan Schmitt
@ 2020-12-25 16:41   ` inwit
  0 siblings, 0 replies; 12+ messages in thread
From: inwit @ 2020-12-25 16:41 UTC (permalink / raw)
  To: Alan Schmitt, notmuch

On Thu Dec 24, 2020 at 2:59 PM CET, Alan Schmitt wrote:
> To move mail I use afew in move mode
> (https://afew.readthedocs.io/en/latest/move_mode.html). I use it to
> move deleted messages to the trash, and old email to an archive
> folder. I guess it could work in your case.
Thanks! I'll have a look, although the idea of having to code a rule for
each folder doesn't seem very efficient, especially since I have more
than 30 folders and changes in folder structure are conceivable in the
future. I guess it is a possibility, but I was hoping for something more
general.

Salud,

>
> Best,
>
> Alan

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Folder+tags
  2020-12-25  8:04 ` Folder+tags Jaume Devesa
@ 2020-12-25 17:27   ` inwit
  0 siblings, 0 replies; 12+ messages in thread
From: inwit @ 2020-12-25 17:27 UTC (permalink / raw)
  To: Jaume Devesa, notmuch

On Fri Dec 25, 2020 at 9:04 AM CET, Jaume Devesa wrote:
> I sync my email with offlineimap and I do something similar, but using
> the `presync.sh` hook that offlineimap provides, via simple `xargs`:
>
> notmuch search --output=files --format=text0 \ folder:mailbox/INBOX
> -tag:inbox | xargs -0 --no-run-if-empty \ mv -t
> ~/mail/mailbox/Archive/$YEAR/new/
This is what I was considering so far, but the truth is that my
emacs lisp programming capabilities are still not that strong. 

In any case, I guess I'd need to parameterize the command you propose,
thus making it applicable for any folder/tag. Something like:

notmuch search --output=files --format=text0 tag:$1 AND tag:inbox | \
xargs -0 --no-run-if-empty mv -t ~/mail/$1/new

Then I should plug this somehow into the notmuch-after-tag-hook, where
the recently applied tag and the message id should be available. Does
that sound reasonable to anyone in the list?

> I've never used emacs, so I ignore if you can do something similar by
> binding keys in emacs (but I guess you can).
It is possible for sure, but I'm afraid it'd take an actual lisp
programmer...

> Hope that helps,
It does. Thanks!!

Salud,

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Folder+tags
  2020-12-23 11:53 Folder+tags inwit
  2020-12-24 13:59 ` Folder+tags Alan Schmitt
  2020-12-25  8:04 ` Folder+tags Jaume Devesa
@ 2020-12-27 11:59 ` inwit
  2020-12-27 13:12   ` Folder+tags Tomi Ollila
  2 siblings, 1 reply; 12+ messages in thread
From: inwit @ 2020-12-27 11:59 UTC (permalink / raw)
  To: notmuch

Ok, I've been thinking more about tag-folder synchronisation and reading
everything I could. However, I need some guidance.

I think that maybe the cleanest way to go is to have an after-tag-hook
which, if the recently added tag corresponds with a folder (as produced
by afew's FolderNameFilter, for example), then moves the file of the
message to its corresponding folder. Does that make sense?

Another alternative is to write a new 'tag-n-move' function which would
do both things, calling 'mv' through 'shell-command'. What do you think? 

Salud,




On Wed Dec 23, 2020 at 12:53 PM CET, inwit wrote:
> Hi!
>
> This is my first message so I'll start by congratulating all the
> community around notmuch. Great piece of work you have here!
>
> I guess that my question must have been surely asked before, but I can't
> seem to find it in the lists' archive. My excuses if it is the case that
> my search abilities have failed. It has happened before.
>
> So, what I'm trying is to have a notmuch system up and running while
> preserving my folder structure fully functional in the IMAP server. I
> know that most of you will agree that folders are a thing from the past,
> but the fact is that, in the past, I've devoted quite a lot of time to
> sort my mails, and now I have a 3-level subfolder structure which is
> hard-wired in my brain, so up to now sometimes I'm still keen to
> searching messages in their expected folders. I guess it's a matter of
> time until I abandon this scheme and dive fully into tag based email,
> but for the time being I'm afraid of losing that folder structure for
> good.
>
> Anyway, I've been reading all around the web about this, and the closest
> I got is using the aerc client, where I can configure a Maildir worker
> and a notmuch worker, being able to use the former for reading and
> classifying mail into folders and the later for tag-based searching.
> This works, but at the same time, no matter how exciting the development
> of aerc is (and it is a beautiful little piece of code), it is still
> very far from emacs mail-mode.
>
> What I would like to, then, is to use notmuch-el to read and classify my
> mail. And the functionality I'm missing at the moment is a way to move
> an email from the inbox to its corresponding folder, hopefully updating
> its folder tags at the same time. That is: I would (mb)sync my mail from
> my company's IMAP server to my Maildir folder structure, then I'd go to
> the Inbox tag/folder, I'd read my mail and then, by hitting Shift+m, for
> example, I'd be able to move that precise email, both in files and tags,
> to its corresponding Maildir folder, so my next call to mbsync actually
> moves the message in the IMAP server folders as well. Does that make
> sense? Does anyone know how would I get to something like that?
>
> Again, sorry if this is redundant, and congratulations on the good work.
>
> Salud,
> _______________________________________________
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-leave@notmuchmail.org

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Folder+tags
  2020-12-27 11:59 ` Folder+tags inwit
@ 2020-12-27 13:12   ` Tomi Ollila
  2020-12-27 17:14     ` Folder+tags inwit
  0 siblings, 1 reply; 12+ messages in thread
From: Tomi Ollila @ 2020-12-27 13:12 UTC (permalink / raw)
  To: inwit, notmuch

On Sun, Dec 27 2020, inwit@sindominio.net wrote:

> Ok, I've been thinking more about tag-folder synchronisation and reading
> everything I could. However, I need some guidance.
>
> I think that maybe the cleanest way to go is to have an after-tag-hook
> which, if the recently added tag corresponds with a folder (as produced
> by afew's FolderNameFilter, for example), then moves the file of the
> message to its corresponding folder. Does that make sense?
>
> Another alternative is to write a new 'tag-n-move' function which would
> do both things, calling 'mv' through 'shell-command'. What do you think? 

There sure is notmuch-after-tag-hook (in emacs MUA), but -hooks don't take
argument(s) so how does it know what was tagged (cannot remember if there 
are let-bound (dynamically bound!) variables that could have such
information).

whatever way, tags are assigned to Message-Id:, so you'd need to find
the filename. With shell-command you can do notmuch | xargs pipeline
(plain 'mv' w/ 'shell-command' would have been easily replaced w/ 
'rename-file' if that were enough). 

>
> Salud,

Tomi

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Folder+tags
  2020-12-27 13:12   ` Folder+tags Tomi Ollila
@ 2020-12-27 17:14     ` inwit
  2020-12-27 21:09       ` Folder+tags Tomi Ollila
  0 siblings, 1 reply; 12+ messages in thread
From: inwit @ 2020-12-27 17:14 UTC (permalink / raw)
  To: Tomi Ollila, notmuch

On Sun Dec 27, 2020 at 2:12 PM CET, Tomi Ollila wrote:
> On Sun, Dec 27 2020, inwit@sindominio.net wrote:
>
> There sure is notmuch-after-tag-hook (in emacs MUA), but -hooks don't
> take argument(s) so how does it know what was tagged (cannot remember
> if there are let-bound (dynamically bound!) variables that could have
> such information).
Apparently (I'm a total noob wrt elisp), the hook should know what was
tagged and how it was tagged. In its documentation it reads:
«'tag-changes' will contain the tags that were added or removed as a
list of strings of the form "+TAG" or "-TAG". 'query' will be a string
containing the search query that determines the messages that were
tagged."

>
> whatever way, tags are assigned to Message-Id:, so you'd need to find
> the filename.
Having the 'query' mentioned above should be enough to find the
filename, shouldn't it?

> With shell-command you can do notmuch | xargs pipeline
> (plain 'mv' w/ 'shell-command' would have been easily replaced w/
> 'rename-file' if that were enough).
I'm not sure if I get what you're trying to say: is rename-file not
enough? 

In any case, if there's really a way to pass 'tag-changes' and 'query'
to such a hook, I could use that hook to move the file with either 'mv'
with 'shell-command' or directly with rename-file, am I wrong?

In any case, I first need to actually learn elisp. This seems as the
right reason to finally get into it.

Thanks for your help.

Salud,

>
> >
> > Salud,
>
> Tomi\r

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Folder+tags
  2020-12-27 17:14     ` Folder+tags inwit
@ 2020-12-27 21:09       ` Tomi Ollila
  2020-12-28 16:51         ` Folder+tags inwit
  2021-01-03 18:09         ` Folder+tags inwit
  0 siblings, 2 replies; 12+ messages in thread
From: Tomi Ollila @ 2020-12-27 21:09 UTC (permalink / raw)
  To: inwit, notmuch

On Sun, Dec 27 2020, inwit@sindominio.net wrote:

> On Sun Dec 27, 2020 at 2:12 PM CET, Tomi Ollila wrote:
>> On Sun, Dec 27 2020, inwit@sindominio.net wrote:
>>
>> There sure is notmuch-after-tag-hook (in emacs MUA), but -hooks don't
>> take argument(s) so how does it know what was tagged (cannot remember
>> if there are let-bound (dynamically bound!) variables that could have
>> such information).
> Apparently (I'm a total noob wrt elisp), the hook should know what was
> tagged and how it was tagged. In its documentation it reads:
> «'tag-changes' will contain the tags that were added or removed as a
> list of strings of the form "+TAG" or "-TAG". 'query' will be a string
> containing the search query that determines the messages that were
> tagged."

nos that you said it, query is a variable the hook can access to know what
was tgged. filnames it doesn't contain. with the query you can find  the
filenames with 'notmuch search --output=files query

(writing on mobiledvice  in a moving train, therefore terse)

Tomi

>
>>
>> Whateveruuuuuuch way, tags are assigned to Message-Id:, so you'd need to find
>> the filename.
> Having the 'query' mentioned above should be enough to find the
> filename, shouldn't it?
>
>> With shell-command you can do notmuch | xargs pipeline
>> (plain 'mv' w/ 'shell-command' would have been easily replaced w/
>> 'rename-file' if that were enough).
> I'm not sure if I get what you're trying to say: is rename-file not
> enough? 
>
> In any case, if there's really a way to pass 'tag-changes' and 'query'
> to such a hook, I could use that hook to move the file with either 'mv'
> with 'shell-command' or directly with rename-file, am I wrong?
>
> In any case, I first need to actually learn elisp. This seems as the
> right reason to finally get into it.
>
> Thanks for your help.
>
> Salud,
>
>>
>> >
>> > Salud,
>>
>> Tomi
> _______________________________________________
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-leave@notmuchmail.org

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Folder+tags
  2020-12-27 21:09       ` Folder+tags Tomi Ollila
@ 2020-12-28 16:51         ` inwit
  2021-01-03 18:09         ` Folder+tags inwit
  1 sibling, 0 replies; 12+ messages in thread
From: inwit @ 2020-12-28 16:51 UTC (permalink / raw)
  To: Tomi Ollila, notmuch

Thanks, Tomi.

While I learn enough elisp to dive into those hooks, I've solved my
need to move files according to tags with the following pre-new script,
which recycles parts from other scripts around:

#!/bin/bash

echo "[pre-new] Syncronizing tags and folders... "

path=/home/jlaznarte/mail/UNED/
exclude='signed attachment spam draft flagged passed replied unread encrypted deleted'
count=$(notmuch count 'folder:Inbox and not tag:inbox')

# Move a message file while removing its UID-part
function safeMove { s=${1##*/}; s=${s%%,*}; mv -f $1 $2/$s; }

if [ $count = 0 ]; then
    echo "[pre-new] No messages needed moving."
    else
        echo "[pre-new] Moving" $count "messages to their corresponding folder."

	for message_id in $(notmuch search --output=messages \
	    'folder:Inbox and not tag:inbox')
	do
		# Find the tags of the message that we need to move
	        tags_orig=$(notmuch search --output=tags $message_id)

	        # Remove notmuch special tags
		# (do not correspond to folders)
	        tags=$(tr ' ' '\n' <<< "$tags_orig" \
		    | grep -vf <(tr ' ' '\n' <<< "$exclude") | paste -sd ' ')

		# Get the path and filename for the message
	        filename=$(notmuch search --output=files $message_id)

	        echo "Moving message to" $tags
		safeMove $filename $path$tags"/cur/"
	done
fi && mbsync



On Sun Dec 27, 2020 at 10:09 PM CET, Tomi Ollila wrote:
> On Sun, Dec 27 2020, inwit@sindominio.net wrote:
>
> > On Sun Dec 27, 2020 at 2:12 PM CET, Tomi Ollila wrote:
> >> On Sun, Dec 27 2020, inwit@sindominio.net wrote:
> >>
> >> There sure is notmuch-after-tag-hook (in emacs MUA), but -hooks don't
> >> take argument(s) so how does it know what was tagged (cannot remember
> >> if there are let-bound (dynamically bound!) variables that could have
> >> such information).
> > Apparently (I'm a total noob wrt elisp), the hook should know what was
> > tagged and how it was tagged. In its documentation it reads:
> > «'tag-changes' will contain the tags that were added or removed as a
> > list of strings of the form "+TAG" or "-TAG". 'query' will be a string
> > containing the search query that determines the messages that were
> > tagged."
>
> nos that you said it, query is a variable the hook can access to know
> what
> was tgged. filnames it doesn't contain. with the query you can find the
> filenames with 'notmuch search --output=files query
>
> (writing on mobiledvice in a moving train, therefore terse)
>
> Tomi
>
> >
> >>
> >> Whateveruuuuuuch way, tags are assigned to Message-Id:, so you'd need to find
> >> the filename.
> > Having the 'query' mentioned above should be enough to find the
> > filename, shouldn't it?
> >
> >> With shell-command you can do notmuch | xargs pipeline
> >> (plain 'mv' w/ 'shell-command' would have been easily replaced w/
> >> 'rename-file' if that were enough).
> > I'm not sure if I get what you're trying to say: is rename-file not
> > enough? 
> >
> > In any case, if there's really a way to pass 'tag-changes' and 'query'
> > to such a hook, I could use that hook to move the file with either 'mv'
> > with 'shell-command' or directly with rename-file, am I wrong?
> >
> > In any case, I first need to actually learn elisp. This seems as the
> > right reason to finally get into it.
> >
> > Thanks for your help.
> >
> > Salud,
> >
> >>
> >> >
> >> > Salud,
> >>
> >> Tomi
> > _______________________________________________
> > notmuch mailing list -- notmuch@notmuchmail.org
> > To unsubscribe send an email to notmuch-leave@notmuchmail.org\r

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Folder+tags
  2020-12-27 21:09       ` Folder+tags Tomi Ollila
  2020-12-28 16:51         ` Folder+tags inwit
@ 2021-01-03 18:09         ` inwit
  2021-01-03 20:01           ` Folder+tags Tomi Ollila
  1 sibling, 1 reply; 12+ messages in thread
From: inwit @ 2021-01-03 18:09 UTC (permalink / raw)
  To: Tomi Ollila, notmuch

On Sun Dec 27, 2020 at 10:09 PM CET, Tomi Ollila wrote:
> On Sun, Dec 27 2020, inwit@sindominio.net wrote:
> > On Sun Dec 27, 2020 at 2:12 PM CET, Tomi Ollila wrote:
> >> On Sun, Dec 27 2020, inwit@sindominio.net wrote:
> >>
> >> There sure is notmuch-after-tag-hook (in emacs MUA), but -hooks
> >> don't take argument(s) so how does it know what was tagged (cannot
> >> remember if there are let-bound (dynamically bound!) variables that
> >> could have such information).
> > Apparently (I'm a total noob wrt elisp), the hook should know what
> > was tagged and how it was tagged. In its documentation it reads:
> > «'tag-changes' will contain the tags that were added or removed as a
> > list of strings of the form "+TAG" or "-TAG". 'query' will be a
> > string containing the search query that determines the messages that
> > were tagged."
>
> nos that you said it, query is a variable the hook can access to know
> what was tgged. filnames it doesn't contain. with the query you can
> find the filenames with 'notmuch search --output=files query
Coming back to this issue, I was wondering if someone could give me some
advice concerning the notmuch-after-tag-hook (I've tried to find answers
in the docs but I failed). 

What I need to know is if, as with pre and post-new, I can write such
hooks in any language (bash would be my choice at the moment) or they
are limited to lisp? In the case I can use bash, how would I access to
'tag-changes' and 'query'?

Also, where should I place my hook once written? 

Thanks for your patience.

Regards,

>
> (writing on mobiledvice in a moving train, therefore terse)
>
> Tomi
>
> >
> >>
> >> Whateveruuuuuuch way, tags are assigned to Message-Id:, so you'd need to find
> >> the filename.
> > Having the 'query' mentioned above should be enough to find the
> > filename, shouldn't it?
> >
> >> With shell-command you can do notmuch | xargs pipeline
> >> (plain 'mv' w/ 'shell-command' would have been easily replaced w/
> >> 'rename-file' if that were enough).
> > I'm not sure if I get what you're trying to say: is rename-file not
> > enough? 
> >
> > In any case, if there's really a way to pass 'tag-changes' and 'query'
> > to such a hook, I could use that hook to move the file with either 'mv'
> > with 'shell-command' or directly with rename-file, am I wrong?
> >
> > In any case, I first need to actually learn elisp. This seems as the
> > right reason to finally get into it.
> >
> > Thanks for your help.
> >
> > Salud,
> >
> >>
> >> >
> >> > Salud,
> >>
> >> Tomi
> > _______________________________________________
> > notmuch mailing list -- notmuch@notmuchmail.org
> > To unsubscribe send an email to notmuch-leave@notmuchmail.org\r

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Folder+tags
  2021-01-03 18:09         ` Folder+tags inwit
@ 2021-01-03 20:01           ` Tomi Ollila
  0 siblings, 0 replies; 12+ messages in thread
From: Tomi Ollila @ 2021-01-03 20:01 UTC (permalink / raw)
  To: inwit, notmuch

On Sun, Jan 03 2021, inwit@sindominio.net wrote:

> On Sun Dec 27, 2020 at 10:09 PM CET, Tomi Ollila wrote:
>> On Sun, Dec 27 2020, inwit@sindominio.net wrote:
>> > On Sun Dec 27, 2020 at 2:12 PM CET, Tomi Ollila wrote:
>> >> On Sun, Dec 27 2020, inwit@sindominio.net wrote:
>> >>
>> >> There sure is notmuch-after-tag-hook (in emacs MUA), but -hooks
>> >> don't take argument(s) so how does it know what was tagged (cannot
>> >> remember if there are let-bound (dynamically bound!) variables that
>> >> could have such information).
>> > Apparently (I'm a total noob wrt elisp), the hook should know what
>> > was tagged and how it was tagged. In its documentation it reads:
>> > «'tag-changes' will contain the tags that were added or removed as a
>> > list of strings of the form "+TAG" or "-TAG". 'query' will be a
>> > string containing the search query that determines the messages that
>> > were tagged."
>>
>> nos that you said it, query is a variable the hook can access to know
>> what was tgged. filnames it doesn't contain. with the query you can
>> find the filenames with 'notmuch search --output=files query
> Coming back to this issue, I was wondering if someone could give me some
> advice concerning the notmuch-after-tag-hook (I've tried to find answers
> in the docs but I failed). 
>
> What I need to know is if, as with pre and post-new, I can write such
> hooks in any language (bash would be my choice at the moment) or they
> are limited to lisp? In the case I can use bash, how would I access to
> 'tag-changes' and 'query'?

The hooks are lisp code, the variables 'tag-changes' and 'query' are
available in the scope when those hooks are called (bound dynamically).

In your hook you can run shell command (if you wanted to run bash command
line)...

to see some samples how you'd do something like that run e.g. 
git grep shell-command  in notmuch source tree and examine found content...

> Also, where should I place my hook once written? 

in .emacs.d/notmuch-config.el

>
> Thanks for your patience.

sure, No prob. 

Tomi

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-01-03 20:02 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-23 11:53 Folder+tags inwit
2020-12-24 13:59 ` Folder+tags Alan Schmitt
2020-12-25 16:41   ` Folder+tags inwit
2020-12-25  8:04 ` Folder+tags Jaume Devesa
2020-12-25 17:27   ` Folder+tags inwit
2020-12-27 11:59 ` Folder+tags inwit
2020-12-27 13:12   ` Folder+tags Tomi Ollila
2020-12-27 17:14     ` Folder+tags inwit
2020-12-27 21:09       ` Folder+tags Tomi Ollila
2020-12-28 16:51         ` Folder+tags inwit
2021-01-03 18:09         ` Folder+tags inwit
2021-01-03 20:01           ` Folder+tags Tomi Ollila

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).