Commit graph

26 commits

Author SHA1 Message Date
Paul Wise
239fdbbbf0 notmuch-mutt: check that the search cache Maildir is not a real Maildir
This prevents data loss when users configure the search cache Maildir to be a
real Maildir containing their real mail data, since the search cache Maildir
is expected to contain only symlinks to the real mail data.

Prevents: <ZCsQBNmbzwkvbpHA@localhost.localdomain>
2023-05-28 15:34:42 -03:00
Paul Wise
18e35950da notmuch-mutt: do not clear search cache Maildir when nothing is found
The previous results might be useful to the user but
an empty directory definitely isn't useful.
2023-05-28 15:33:11 -03:00
Paul Wise
85916d8a96 notmuch-mutt: clarify the empty Maildir function operates on search caches
Rename the function and adjust the documentation comment.
2023-05-28 15:32:11 -03:00
Paul Wise
93d936c5ae notmuch-mutt: replace extra command with notmuch thread search feature
This should be be slightly faster since it avoids forking a shell
and is less code in and less dependencies for the script.

Since String::ShellQuote isn't used elsewhere, drop mention of it.
2023-05-27 14:26:43 -03:00
Paul Wise
6d383d4049 notmuch-mutt: fix Xapian query construction
Spaces need to be stripped when querying the Message-Id,
because notmuch stores them in Xapian with spaces stripped.

All double-quote characters need to be doubled to escape them,
otherwise they will be added as extra query terms outside the id.
2023-05-27 14:24:40 -03:00
Paul Wise
d155f29eca notmuch-mutt: convert ISO-8859-15 copyright statement to UTF-8
Suggested-by: isutf8 & check-all-the-things
2023-05-25 08:43:14 -03:00
Tomi Ollila
0d4a3c7185 notmuch-mutt: replace shell pipeline with internal pipe processing
The shell pipeline used to symlink files based in search results
to "cache" directory for mutt(1) to use was prone to portability
problems (due to /bin/sh differences).

The replacement executes `notmuch search` without intermediate shell
(so shell_quote was removed in this case), reads the filenames from
piped output and symlinks files internally.
2020-08-12 20:40:46 -03:00
Greg Anders
1fcf068e33 Make notmuch-mutt script more portable
The -D flag to install (used in the Makefile) is GNU-specific and does
not work on BSD distributions (i.e. macOS). Likewise with the xargs -r
flag. These changes use portable alternatives to these flags while
preserving the exact behavior.
2020-03-22 22:57:25 -03:00
David Bremner
84efbda925 contrib/notmuch-mutt: add install target
The main goal here is to be able to install the notmuch-mutt script
with an absolute shebang. I have tried to make the notmuch-mutt
Makefile use configure information from notmuch if available, but make
suitable guesses if not.
2018-09-18 07:54:33 -03:00
Vladimir Panteleev
ca4688e103 Use rooted paths in .gitignore files
A leading / in paths in a .gitignore file matches the beginning of the
path, meaning that for patterns without slashes, git will match files
only in the current directory as opposed to in any subdirectory.

Prefix relevant paths with / in .gitignore files, to prevent
accidentally ignoring files in subdirectories and possibly slightly
improve the performance of "git status".
2017-08-18 19:42:35 -03:00
Daniel Kahn Gillmor
6a833a6e83 Use https instead of http where possible
Many of the external links found in the notmuch source can be resolved
using https instead of http.  This changeset addresses as many as i
could find, without touching the e-mail corpus or expected outputs
found in tests.
2016-06-05 08:32:17 -03:00
Stefano Zacchiroli
e3e03fb718 notmuch-mutt: use env to locate perl for increased portability
Note: this patch drops -w from the shebang line, but we still have
"use warnings" in the script, which is superior anyhow.

Thanks Andreas Tolfsen for the suggestion.
2016-04-30 07:34:00 -03:00
Jack Peirce
1ad02d06b5 notmuch-mutt: fix xargs/ln usage for OpenBSD compatibility
- xargs: use -r flag instead of --no-run-if-empty
- ln: use -I flag/3rd form of ln command instead of -t flag/4th form

Signed-off-by: Stefano Zacchiroli <zack@upsilon.cc>
2015-05-04 08:04:38 +02:00
Stefano Zacchiroli
1722ea2c95 notmuch-mutt: support for messages that lack Message-ID headers
For those messages, compute a synthetic Message-ID based on the SHA1
of the whole message, in the same way that notmuch would do. See:
http://git.notmuchmail.org/git/notmuch/blob/HEAD:/lib/sha1.c

To do the above, rewrite get_message_id() to accumulate header lines,
parse them to check for Message-ID, and fallback to SHA1 computation
if it is not present.

Thanks to:
- Jan N. Klug for preliminary versions of this patch
- Tomi Ollila for suggesting an elegant implementation
2015-02-16 08:58:13 -04:00
Stefano Zacchiroli
02b554c896 notmuch-mutt README: use metacpn.org/* as deps homepages 2015-02-16 08:57:49 -04:00
Stefano Zacchiroli
f755fd1bda notmuch-mutt: bump copyright year 2015-02-16 08:57:42 -04:00
Kevin J. McCarthy
f3dc5be6f2 notmuch-mutt: Fix tagging issues
This patch fixes three issues with "notmuch-mutt tag":

1. The message_id was not shell quoted.
   Thanks to Jason Miller for the bug report and patch.

2. The tags passed into tag_action() were not being properly quoted.
   The "join before shell_quote" was combining multiple tags into a
   single argument to notmuch tag: '+one -two -three' instead of
   '+one' '-two' '-three'.

3. A "--" was added between the tags and search-term as shown in the
   current notmuch-tag man page.

Thanks to Tomi Ollila for suggesting the simple fix of using
the list form of system(), which bypasses the shell.
2013-09-08 22:47:51 -03:00
Kevin McCarthy
f354b90d5e notmuch-mutt: use notmuch --duplicate flag
Change notmuch-mutt to use the new --duplicate=1 flag for duplicate
removal.  This will remove duplicates based on message-id at the
notmuch level.  Previously we were using fdupes or generating sha sums
after the search.

This version will be faster, but will enable the possibility of hiding
search results due to accidental/malicious duplicate message-ids.
2013-09-08 22:41:38 -03:00
Kevin J. McCarthy
c34effad9a notmuch-mutt: improve robustness of mutt macros
Details:
- $pipe_decode is turned off, to prevent message-id from being
  filtered out by "ignore" settings in the muttrc.
- Original values for $pipe_decode and $wait_key are saved and restored.
- The macros, being much longer now, are line wrapped for improved
  readability.
2013-02-16 11:56:55 -04:00
Stefano Zacchiroli
9b98e9bcbf notmuch-mutt: Use of uninitialized value.
On Thu, Feb 14, 2013 at 12:36:58AM +0100, Profpatsch wrote:
> On 13-02-13 02:35pm, Kevin J. McCarthy wrote:
> > A more likely idea is to check whether you have $pipe_decode set.
>
> BRILLIANT!
> So much for copying a basic rc from someone else.
> Of course, that was it and I’m officially an idiot.

Neat, thanks Kevin for debugging the issue down to $pipe_decode (which
I've never used, mutt never stops to amaze me :-)).

> And apparently Mail::Internet errors out if there is no Message-ID.
> (Which mentioned in the docs at CPAN…)
>
> Mystery solved.

Right, but still a more graceful failure model would be nice.

Please find attached a patch that in such cases should 1) give a
supposedly nice error message explaining what's going on and 2) empty
the results dir to avoid showing you unrelated results. It works for me.
But extra checking never hurts, in particular for the tag action, which
I don't personally use.

I guess it would also be nice to actually disable $pipe_decode in the
relevant Mutt macros, but I'm not sure about to do that without
interfering with user desired configuration. Kevin: do you know if there
is a common Mutt trick to store the value of a variable before changing
it, and restoring it a posteriori?  More isolation for this kind of
things in Mutt would definitely be welcome...

Cheers.
--
Stefano Zacchiroli  . . . . . . .  zack@upsilon.cc . . . . o . . . o . o
Maître de conférences . . . . . http://upsilon.cc/zack . . . o . . . o o
Debian Project Leader . . . . . . @zack on identi.ca . . o o o . . . o .
« the first rule of tautology club is the first rule of tautology club »

From b67ab95855ce7d279d8c0b3ddcbc20e679afc70b Mon Sep 17 00:00:00 2001
From: Stefano Zacchiroli <zack@upsilon.cc>
Date: Thu, 14 Feb 2013 09:31:37 +0100
Subject: [PATCH] notmuch-mutt: more graceful handling of missing Message-Id
 errors

in particular:
- the "thread" action would print an error and empty results dir
- the "tag action would print an error
2013-02-16 11:56:40 -04:00
Kevin J. McCarthy
ff9fd62ab6 Update notmuch-mutt requirements in README file.
This updates the notmuch-mutt README file with requirements for the
recently added duplicate removal patch.

-Kevin
2012-11-16 15:36:28 -04:00
Kevin McCarthy
fffb92da8e Add duplicate message removal for notmuch-mutt.
Add a --remove-dups flag which removes duplicate files from search and
thread results.  Uses fdupes if installed.  Otherwise it runs a size and
Digest::SHA scan on each file to detect duplicates.

Signed-off-by: Stefano Zacchiroli <zack@upsilon.cc>
2012-08-02 21:12:14 -03:00
Stefano Zacchiroli
e40d134e25 notmuch-mutt: fix helper invocation for the tag action
As it was before, "-inbox" was interpreted as a getopt option, rather
than as a tag manipulation request. Making the action unusable.

Closes: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=678012
2012-07-04 14:59:33 -06:00
Stefano Zacchiroli
981a87f735 notmuch-mutt: lookup notmuch-search-terms(7) when asked for help
When asked for interactive help, lookup notmuch-search-terms(7)
instead of notmuch(1). Syntax of notmuch queries used to be described
in the latter, but has recently been moved to the former.

Closes: #675073 (in the Debian BTS)
2012-05-29 18:18:07 -03:00
Stefano Zacchiroli
f162b19148 notmuch-mutt: fix typo in manpage 2012-03-31 11:33:45 -03:00
Stefano Zacchiroli
d13810dc1e contrib: new mutt-notmuch utility for Mutt integration 2012-03-30 18:12:49 -03:00