Re: use current folder name as argument to abitrary command
- To: mutt-users@xxxxxxxx
- Subject: Re: use current folder name as argument to abitrary command
- From: Kyle Wheeler <kyle-mutt@xxxxxxxxxxxxxx>
- Date: Fri, 12 Dec 2008 09:20:56 -0600
- Comment: DomainKeys? See http://domainkeys.sourceforge.net/
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed; d=memoryhole.net; h=date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; s=default; bh=/oIfTNOIGxllZGXP8Ra2DGO1qYY=; b=EQqd LCNt2z51USYRDrW63Nyl0YMV6lWHRh2vnpBsekevSdzaK0C9jKIGVs3OYRJ6DLJV bldrCmWXN7hLHH2f4PsNDuKQFmQ9/Mv5EuA6X7ZaZTll1qw7iiJ0TluUbFTEDG7d kQi7/k0kaKLxgW19ro9NL/YNSKHXiIE5AI9I8/w=
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=memoryhole.net; b=C8cNvwFGjdIwRwPDh4IUEqlByzlB3Xo6toyCqwkOzd7dZX9lL9KtH+uZg+ai0cB+CG5vG9IE59x4M1faFs57SLjNMJxE9RMJeGoT0Bgia2dgQ01/1wXBoUzboOzodQDtnHHF/qx/YnKNRjy2BqRsQ16m6AL3Fp5Yfkmx731x0hE=; h=Received:Received:Date:From:To:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:OpenPGP:User-Agent;
- In-reply-to: <20081212123041.GA4283@xxxxxxxxxxxxxxx>
- List-post: <mailto:mutt-users@mutt.org>
- List-unsubscribe: send mail to majordomo@mutt.org, body only "unsubscribe mutt-users"
- Mail-followup-to: mutt-users@xxxxxxxx
- Openpgp: id=CA8E235E; url=http://www.memoryhole.net/~kyle/kyle-pgp.asc; preference=signencrypt
- References: <20081212123041.GA4283@xxxxxxxxxxxxxxx>
- Sender: owner-mutt-users@xxxxxxxx
- User-agent: Mutt/1.5.18 (2008-11-30)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Friday, December 12 at 07:30 AM, quoth Noah Sheppard:
> I'm using this to set up some mail archiving. Here's what I tried
> first:
>
> set my_archdir="/mnt/data/storage/mail/boxes" #the path to the directory
> which will contain my archive dirs
> macro index,pager S "<save-message>$my_archdir/^<enter>"
If I recall correctly, mutt's "magic" characters only work when
they're the *first* character in the folder name. Think of them as
behaving similar to the way that ~ behaves in the shell.
> folder-hook . set my_curdir="^"
That doesn't work because mutt doesn't consider random variable
assignments as mailbox path names, and so doesn't attempt to expand
mailbox path shortcuts in them.
> That said, even when I run 'set my_curdir="^"' in mutt after muttrc
> has been read, my_curdir is still empty.
Really? When I do it, my_curdir becomes "^". Test it like this:
set ?my_curdir
Your macro has an additional problem: it wouldn't work even if
my_curdir WAS correctly being set! You see, variable expansion is
evaluated at the time the macro is established! To delay variable
expansion until the macro is *triggered*, you'd have to escape the
variable. For example, consider how this works:
set my_archdir=/foo
macro index,pager S "<save-message>$my_archdir<enter>"
set my_archdir=/bar
When you trigger the macro, where you you expect it to be saved? If
you guessed "/foo", you'd be right, because variable expansion
happened when the macro was established. If you want the variable to
be re-interpreted every the macro is triggered, you'd have to do this:
macro index,pager S "<save-message>\$my_archdir<enter>"
> If 'set record="^"' works to get the current folder name, why
> doesn't it work to put the current folder name in a user variable,
That's because mutt expects $record will be a mailbox path name, and
so expands mailbox path shortcut characters in it. However, things
like $my_curdir are treated the same way variables like $signature are
treated: as arbitrary strings.
> If not, how does one get the current folder name in a variable which
> can be used in various places?
Well, technically, if you set $record to ^, you can use that. That's
not exactly *convenient*, since $record has a primary function, I know
that, but... As far as I know, there isn't a really *good* way to do
what you're looking for (at the moment).
~Kyle
- --
Education is the ability to listen to almost anything without losing
your temper.
-- Robert Frost
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!
iEYEARECAAYFAklCgVgACgkQBkIOoMqOI14TywCgq1IqwdHwq8UdmwKrlNGPXRUo
tIsAoMFwkHqzQ+YzFsebFxjG9FwB9IbZ
=zv1S
-----END PGP SIGNATURE-----