On Mon, Mar 26, 2012 at 05:29:02PM +0200, Stefano Zacchiroli wrote:
> But while it's trivial to make notmuch-mutt itself support
> $XDG_CACHE_HOME, it is less so for the Mutt configuration snippet
> (i.e. the notmuch-mutt.rc file which is part of my submission). AFAICT
> the <change-folder-readonly> function does not support variable
> expansions, not to mention default values while doing so.

... but Mutt configuration has backtick expansions! So never mind the
above.

The attached patch should be all that's needed to proper $XDG_CACHE_HOME
support, according to XDG basedir spec.

If you folks now consider the contrib submission good enough for
inclusion, feel free to just "git am" the 3 patches. If you want me to
implement other changes --- including bureaucratic stuff like merging
patches together --- just let me know!

Cheers.
-- 
Stefano Zacchiroli     zack@{upsilon.cc,pps.jussieu.fr,debian.org} . o .
Maître de conférences   ......   http://upsilon.cc/zack   ......   . . o
Debian Project Leader    .......   @zack on identi.ca   .......    o o o
« the first rule of tautology club is the first rule of tautology club »
From f68f36448f5bc63211c12b9e53e9db603ed76178 Mon Sep 17 00:00:00 2001
From: Stefano Zacchiroli <[email protected]>
Date: Mon, 26 Mar 2012 20:47:34 +0200
Subject: [PATCH] notmuch-mutt: $XDG_CACHE_HOME support as per XDG basedir
 spec

---
 contrib/notmuch-mutt/notmuch-mutt    |    4 +++-
 contrib/notmuch-mutt/notmuch-mutt.rc |    4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)
 mode change 100755 => 100644 contrib/notmuch-mutt/notmuch-mutt

diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt
old mode 100755
new mode 100644
index 29674ec..9cd01ec
--- a/contrib/notmuch-mutt/notmuch-mutt
+++ b/contrib/notmuch-mutt/notmuch-mutt
@@ -20,7 +20,9 @@ use String::ShellQuote;
 use Term::ReadLine;
 
 
-my $cache_dir = "$ENV{HOME}/.cache/notmuch/mutt";
+my $xdg_cache_dir = "$ENV{HOME}/.cache";
+$xdg_cache_dir = $ENV{XDG_CACHE_HOME} if $ENV{XDG_CACHE_HOME};
+my $cache_dir = "$xdg_cache_dir/notmuch/mutt";
 
 
 # create an empty maildir (if missing) or empty an existing maildir"
diff --git a/contrib/notmuch-mutt/notmuch-mutt.rc b/contrib/notmuch-mutt/notmuch-mutt.rc
index 269f03f..c0ff000 100644
--- a/contrib/notmuch-mutt/notmuch-mutt.rc
+++ b/contrib/notmuch-mutt/notmuch-mutt.rc
@@ -1,8 +1,8 @@
 macro index <F8> \
-      "<enter-command>unset wait_key<enter><shell-escape>notmuch-mutt --prompt search<enter><change-folder-readonly>~/.cache/notmuch/mutt/results<enter>" \
+      "<enter-command>unset wait_key<enter><shell-escape>notmuch-mutt --prompt search<enter><change-folder-readonly>`echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`<enter>" \
       "notmuch: search mail"
 macro index <F9> \
-      "<enter-command>unset wait_key<enter><pipe-message>notmuch-mutt thread<enter><change-folder-readonly>~/.cache/notmuch/mutt/results<enter><enter-command>set wait_key<enter>" \
+      "<enter-command>unset wait_key<enter><pipe-message>notmuch-mutt thread<enter><change-folder-readonly>`echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`<enter><enter-command>set wait_key<enter>" \
       "notmuch: reconstruct thread"
 macro index <F6> \
       "<enter-command>unset wait_key<enter><pipe-message>notmuch-mutt tag -inbox<enter>" \
-- 
1.7.9.1

Attachment: signature.asc
Description: Digital signature

_______________________________________________
notmuch mailing list
[email protected]
http://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to