unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 1/5] doc: bring notmuch-dump manual page in line with the rest
@ 2015-01-27 19:48 Jani Nikula
  2015-01-27 19:48 ` [PATCH 2/5] doc: document notmuch-dump --output=filename option Jani Nikula
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Jani Nikula @ 2015-01-27 19:48 UTC (permalink / raw)
  To: notmuch

Fix indentation of options. Move search terms description before
options. Fix synopsis.
---
 doc/man1/notmuch-dump.rst | 100 ++++++++++++++++++++++++----------------------
 1 file changed, 53 insertions(+), 47 deletions(-)

diff --git a/doc/man1/notmuch-dump.rst b/doc/man1/notmuch-dump.rst
index d94cb4f84496..3a6d0b34f505 100644
--- a/doc/man1/notmuch-dump.rst
+++ b/doc/man1/notmuch-dump.rst
@@ -5,7 +5,7 @@ notmuch-dump
 SYNOPSIS
 ========
 
-**notmuch** **dump** [--format=(batch-tag|sup)] [--] [--output=<*file*>] [--] [<*search-term*> ...]
+**notmuch** **dump** [--gzip] [--format=(batch-tag|sup)] [--output=<*file*>] [--] [<*search-term*> ...]
 
 DESCRIPTION
 ===========
@@ -19,52 +19,58 @@ recreated from the messages themselves. The output of notmuch dump is
 therefore the only critical thing to backup (and much more friendly to
 incremental backup than the native database files.)
 
-``--gzip``
-    Compress the output in a format compatible with **gzip(1)**.
-
-``--format=(sup|batch-tag)``
-    Notmuch restore supports two plain text dump formats, both with one
-    message-id per line, followed by a list of tags.
-
-    **batch-tag**
-        The default **batch-tag** dump format is intended to more robust
-        against malformed message-ids and tags containing whitespace or
-        non-\ **ascii(7)** characters. Each line has the form
-
-            +<*encoded-tag*\ > +<*encoded-tag*\ > ... --
-            id:<*quoted-message-id*\ >
-
-        Tags are hex-encoded by replacing every byte not matching the
-        regex **[A-Za-z0-9@=.,\_+-]** with **%nn** where nn is the two
-        digit hex encoding. The message ID is a valid Xapian query,
-        quoted using Xapian boolean term quoting rules: if the ID
-        contains whitespace or a close paren or starts with a double
-        quote, it must be enclosed in double quotes and double quotes
-        inside the ID must be doubled. The astute reader will notice
-        this is a special case of the batch input format for
-        **notmuch-tag(1)**; note that the single message-id query is
-        mandatory for **notmuch-restore(1)**.
-
-    **sup**
-        The **sup** dump file format is specifically chosen to be
-        compatible with the format of files produced by sup-dump. So if
-        you've previously been using sup for mail, then the **notmuch
-        restore** command provides you a way to import all of your tags
-        (or labels as sup calls them). Each line has the following form
-
-            <*message-id*\ > **(** <*tag*\ > ... **)**
-
-        with zero or more tags are separated by spaces. Note that
-        (malformed) message-ids may contain arbitrary non-null
-        characters. Note also that tags with spaces will not be
-        correctly restored with this format.
-
-    With no search terms, a dump of all messages in the database will be
-    generated. A "--" argument instructs notmuch that the remaining
-    arguments are search terms.
-
-    See **notmuch-search-terms(7)** for details of the supported syntax
-    for <search-terms>.
+See **notmuch-search-terms(7)** for details of the supported syntax
+for <search-terms>. With no search terms, a dump of all messages in
+the database will be generated. A "--" argument instructs notmuch that
+the remaining arguments are search terms.
+
+Supported options for **dump** include
+
+    ``--gzip``
+        Compress the output in a format compatible with **gzip(1)**.
+
+    ``--format=(sup|batch-tag)``
+        Notmuch restore supports two plain text dump formats, both with one
+        message-id per line, followed by a list of tags.
+
+        **batch-tag**
+
+            The default **batch-tag** dump format is intended to more
+            robust against malformed message-ids and tags containing
+            whitespace or non-\ **ascii(7)** characters. Each line has
+            the form
+
+                +<*encoded-tag*\ > +<*encoded-tag*\ > ... --
+                id:<*quoted-message-id*\ >
+
+            Tags are hex-encoded by replacing every byte not matching
+            the regex **[A-Za-z0-9@=.,\_+-]** with **%nn** where nn is
+            the two digit hex encoding. The message ID is a valid
+            Xapian query, quoted using Xapian boolean term quoting
+            rules: if the ID contains whitespace or a close paren or
+            starts with a double quote, it must be enclosed in double
+            quotes and double quotes inside the ID must be
+            doubled. The astute reader will notice this is a special
+            case of the batch input format for **notmuch-tag(1)**;
+            note that the single message-id query is mandatory for
+            **notmuch-restore(1)**.
+
+        **sup**
+
+            The **sup** dump file format is specifically chosen to be
+            compatible with the format of files produced by
+            sup-dump. So if you've previously been using sup for mail,
+            then the **notmuch restore** command provides you a way to
+            import all of your tags (or labels as sup calls
+            them). Each line has the following form
+
+                <*message-id*\ > **(** <*tag*\ > ... **)**
+
+            with zero or more tags are separated by spaces. Note that
+            (malformed) message-ids may contain arbitrary non-null
+            characters. Note also that tags with spaces will not be
+            correctly restored with this format.
+
 
 SEE ALSO
 ========
-- 
2.1.4

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

* [PATCH 2/5] doc: document notmuch-dump --output=filename option
  2015-01-27 19:48 [PATCH 1/5] doc: bring notmuch-dump manual page in line with the rest Jani Nikula
@ 2015-01-27 19:48 ` Jani Nikula
  2015-01-27 19:48 ` [PATCH 3/5] doc: document notmuch-restore --input=filename option Jani Nikula
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Jani Nikula @ 2015-01-27 19:48 UTC (permalink / raw)
  To: notmuch

Document all options for completeness.
---
 doc/man1/notmuch-dump.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/doc/man1/notmuch-dump.rst b/doc/man1/notmuch-dump.rst
index 3a6d0b34f505..a37c337c72e6 100644
--- a/doc/man1/notmuch-dump.rst
+++ b/doc/man1/notmuch-dump.rst
@@ -71,6 +71,8 @@ Supported options for **dump** include
             characters. Note also that tags with spaces will not be
             correctly restored with this format.
 
+    ``--output=``\ <filename>
+        Write output to given file instead of stdout.
 
 SEE ALSO
 ========
-- 
2.1.4

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

* [PATCH 3/5] doc: document notmuch-restore --input=filename option
  2015-01-27 19:48 [PATCH 1/5] doc: bring notmuch-dump manual page in line with the rest Jani Nikula
  2015-01-27 19:48 ` [PATCH 2/5] doc: document notmuch-dump --output=filename option Jani Nikula
@ 2015-01-27 19:48 ` Jani Nikula
  2015-01-27 19:48 ` [PATCH 4/5] completion: complete notmuch dump --gzip option Jani Nikula
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Jani Nikula @ 2015-01-27 19:48 UTC (permalink / raw)
  To: notmuch

Document all options for completeness.
---
 doc/man1/notmuch-restore.rst | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/doc/man1/notmuch-restore.rst b/doc/man1/notmuch-restore.rst
index 936b1383e045..362e2629e574 100644
--- a/doc/man1/notmuch-restore.rst
+++ b/doc/man1/notmuch-restore.rst
@@ -50,6 +50,9 @@ Supported options for **restore** include
             format, this heuristic, based the fact that batch-tag format
             contains no parentheses, should be accurate.
 
+    ``--input=``\ <filename>
+        Read input from given file instead of stdin.
+
 GZIPPED INPUT
 =============
 
-- 
2.1.4

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

* [PATCH 4/5] completion: complete notmuch dump --gzip option
  2015-01-27 19:48 [PATCH 1/5] doc: bring notmuch-dump manual page in line with the rest Jani Nikula
  2015-01-27 19:48 ` [PATCH 2/5] doc: document notmuch-dump --output=filename option Jani Nikula
  2015-01-27 19:48 ` [PATCH 3/5] doc: document notmuch-restore --input=filename option Jani Nikula
@ 2015-01-27 19:48 ` Jani Nikula
  2015-01-27 19:48 ` [PATCH 5/5] completion: complete addresses in from:/to: search terms Jani Nikula
  2015-02-23 22:04 ` [PATCH 1/5] doc: bring notmuch-dump manual page in line with the rest David Bremner
  4 siblings, 0 replies; 9+ messages in thread
From: Jani Nikula @ 2015-01-27 19:48 UTC (permalink / raw)
  To: notmuch

---
 completion/notmuch-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash
index 39320f8d8107..e0498903f22f 100644
--- a/completion/notmuch-completion.bash
+++ b/completion/notmuch-completion.bash
@@ -169,7 +169,7 @@ _notmuch_dump()
     ! $split &&
     case "${cur}" in
 	-*)
-	    local options="--format= --output="
+	    local options="--gzip --format= --output="
 	    compopt -o nospace
 	    COMPREPLY=( $(compgen -W "$options" -- ${cur}) )
 	    ;;
-- 
2.1.4

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

* [PATCH 5/5] completion: complete addresses in from:/to: search terms
  2015-01-27 19:48 [PATCH 1/5] doc: bring notmuch-dump manual page in line with the rest Jani Nikula
                   ` (2 preceding siblings ...)
  2015-01-27 19:48 ` [PATCH 4/5] completion: complete notmuch dump --gzip option Jani Nikula
@ 2015-01-27 19:48 ` Jani Nikula
  2015-02-24  7:12   ` Tomi Ollila
  2015-02-23 22:04 ` [PATCH 1/5] doc: bring notmuch-dump manual page in line with the rest David Bremner
  4 siblings, 1 reply; 9+ messages in thread
From: Jani Nikula @ 2015-01-27 19:48 UTC (permalink / raw)
  To: notmuch

Use the new notmuch address command to do completion for addresses in
from: and to:.

---

This patch is more of an RFC. The to: completion is sloooow because
typically there are more matches to begin with, and then producing the
results requires reading the messages. Maybe it would be better to use
the same mechanism as from: for both, even if it's not accurate for
to:?
---
 completion/notmuch-completion.bash | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash
index e0498903f22f..db49294fc58c 100644
--- a/completion/notmuch-completion.bash
+++ b/completion/notmuch-completion.bash
@@ -27,10 +27,30 @@
 # on completion.
 #
 
-_notmuch_user_emails()
+# $1: current input of the form prefix:partialinput, where prefix is
+# to or from.
+_notmuch_email()
 {
-    notmuch config get user.primary_email
-    notmuch config get user.other_email
+    local output prefix cur
+
+    prefix="${1%%:*}"
+    cur="${1#*:}"
+
+    # Cut the input to be completed at punctuation because
+    # (apparently) Xapian does not support the trailing wildcard '*'
+    # operator for input with punctuation. We let compgen handle the
+    # extra filtering required.
+    cur="${cur%%[^a-zA-Z0-9]*}"
+
+    case "$prefix" in
+	to) output=recipients;;
+	from) output=sender;;
+	*) return;;
+    esac
+
+    # Only emit plain, lower case, unique addresses.
+    notmuch address --output=$output $prefix:"${cur}*" | \
+	sed 's/[^<]*<\([^>]*\)>/\1/' | tr "[:upper:]" "[:lower:]" | sort -u
 }
 
 _notmuch_search_terms()
@@ -44,10 +64,10 @@ _notmuch_search_terms()
 	    COMPREPLY=( $(compgen -P "tag:" -W "`notmuch search --output=tags \*`" -- ${cur##tag:}) )
 	    ;;
 	to:*)
-	    COMPREPLY=( $(compgen -P "to:" -W "`_notmuch_user_emails`" -- ${cur##to:}) )
+	    COMPREPLY=( $(compgen -P "to:" -W "`_notmuch_email ${cur}`" -- ${cur##to:}) )
 	    ;;
 	from:*)
-	    COMPREPLY=( $(compgen -P "from:" -W "`_notmuch_user_emails`" -- ${cur##from:}) )
+	    COMPREPLY=( $(compgen -P "from:" -W "`_notmuch_email ${cur}`" -- ${cur##from:}) )
 	    ;;
 	path:*)
 	    local path=`notmuch config get database.path`
-- 
2.1.4

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

* Re: [PATCH 1/5] doc: bring notmuch-dump manual page in line with the rest
  2015-01-27 19:48 [PATCH 1/5] doc: bring notmuch-dump manual page in line with the rest Jani Nikula
                   ` (3 preceding siblings ...)
  2015-01-27 19:48 ` [PATCH 5/5] completion: complete addresses in from:/to: search terms Jani Nikula
@ 2015-02-23 22:04 ` David Bremner
  4 siblings, 0 replies; 9+ messages in thread
From: David Bremner @ 2015-02-23 22:04 UTC (permalink / raw)
  To: Jani Nikula, notmuch

Jani Nikula <jani@nikula.org> writes:

> Fix indentation of options. Move search terms description before
> options. Fix synopsis.

pushed the first 4 patches.

d

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

* Re: [PATCH 5/5] completion: complete addresses in from:/to: search terms
  2015-01-27 19:48 ` [PATCH 5/5] completion: complete addresses in from:/to: search terms Jani Nikula
@ 2015-02-24  7:12   ` Tomi Ollila
  2015-02-24  7:37     ` Jani Nikula
  0 siblings, 1 reply; 9+ messages in thread
From: Tomi Ollila @ 2015-02-24  7:12 UTC (permalink / raw)
  To: notmuch

On Tue, Jan 27 2015, Jani Nikula <jani@nikula.org> wrote:

> Use the new notmuch address command to do completion for addresses in
> from: and to:.
>
> ---
>
> This patch is more of an RFC. The to: completion is sloooow because
> typically there are more matches to begin with, and then producing the
> results requires reading the messages. Maybe it would be better to use
> the same mechanism as from: for both, even if it's not accurate for
> to:?

Shameless marketing puff: Imagine how fast would it would be to use
nottoomuch-addresses -- the completions are there before one
sees TAB KeyRelease event... ;)

Tomi


> ---
>  completion/notmuch-completion.bash | 30 +++++++++++++++++++++++++-----
>  1 file changed, 25 insertions(+), 5 deletions(-)
>
> diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash
> index e0498903f22f..db49294fc58c 100644
> --- a/completion/notmuch-completion.bash
> +++ b/completion/notmuch-completion.bash
> @@ -27,10 +27,30 @@
>  # on completion.
>  #
>  
> -_notmuch_user_emails()
> +# $1: current input of the form prefix:partialinput, where prefix is
> +# to or from.
> +_notmuch_email()
>  {
> -    notmuch config get user.primary_email
> -    notmuch config get user.other_email
> +    local output prefix cur
> +
> +    prefix="${1%%:*}"
> +    cur="${1#*:}"
> +
> +    # Cut the input to be completed at punctuation because
> +    # (apparently) Xapian does not support the trailing wildcard '*'
> +    # operator for input with punctuation. We let compgen handle the
> +    # extra filtering required.
> +    cur="${cur%%[^a-zA-Z0-9]*}"
> +
> +    case "$prefix" in
> +	to) output=recipients;;
> +	from) output=sender;;
> +	*) return;;
> +    esac
> +
> +    # Only emit plain, lower case, unique addresses.
> +    notmuch address --output=$output $prefix:"${cur}*" | \
> +	sed 's/[^<]*<\([^>]*\)>/\1/' | tr "[:upper:]" "[:lower:]" | sort -u
>  }
>  
>  _notmuch_search_terms()
> @@ -44,10 +64,10 @@ _notmuch_search_terms()
>  	    COMPREPLY=( $(compgen -P "tag:" -W "`notmuch search --output=tags \*`" -- ${cur##tag:}) )
>  	    ;;
>  	to:*)
> -	    COMPREPLY=( $(compgen -P "to:" -W "`_notmuch_user_emails`" -- ${cur##to:}) )
> +	    COMPREPLY=( $(compgen -P "to:" -W "`_notmuch_email ${cur}`" -- ${cur##to:}) )
>  	    ;;
>  	from:*)
> -	    COMPREPLY=( $(compgen -P "from:" -W "`_notmuch_user_emails`" -- ${cur##from:}) )
> +	    COMPREPLY=( $(compgen -P "from:" -W "`_notmuch_email ${cur}`" -- ${cur##from:}) )
>  	    ;;
>  	path:*)
>  	    local path=`notmuch config get database.path`
> -- 
> 2.1.4
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

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

* Re: [PATCH 5/5] completion: complete addresses in from:/to: search terms
  2015-02-24  7:12   ` Tomi Ollila
@ 2015-02-24  7:37     ` Jani Nikula
  2015-02-24  7:50       ` Tomi Ollila
  0 siblings, 1 reply; 9+ messages in thread
From: Jani Nikula @ 2015-02-24  7:37 UTC (permalink / raw)
  To: Tomi Ollila, notmuch

On Tue, 24 Feb 2015, Tomi Ollila <tomi.ollila@iki.fi> wrote:
> On Tue, Jan 27 2015, Jani Nikula <jani@nikula.org> wrote:
>
>> Use the new notmuch address command to do completion for addresses in
>> from: and to:.
>>
>> ---
>>
>> This patch is more of an RFC. The to: completion is sloooow because
>> typically there are more matches to begin with, and then producing the
>> results requires reading the messages. Maybe it would be better to use
>> the same mechanism as from: for both, even if it's not accurate for
>> to:?
>
> Shameless marketing puff: Imagine how fast would it would be to use
> nottoomuch-addresses -- the completions are there before one
> sees TAB KeyRelease event... ;)

Like this? ;)

$ notmuch search to:tomiTABnottoomuch-addresses.sh: command not found

I like the completion to be self contained.

BR,
Jani.

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

* Re: [PATCH 5/5] completion: complete addresses in from:/to: search terms
  2015-02-24  7:37     ` Jani Nikula
@ 2015-02-24  7:50       ` Tomi Ollila
  0 siblings, 0 replies; 9+ messages in thread
From: Tomi Ollila @ 2015-02-24  7:50 UTC (permalink / raw)
  To: Jani Nikula, notmuch

On Tue, Feb 24 2015, Jani Nikula <jani@nikula.org> wrote:

> On Tue, 24 Feb 2015, Tomi Ollila <tomi.ollila@iki.fi> wrote:
>> On Tue, Jan 27 2015, Jani Nikula <jani@nikula.org> wrote:
>>
>>> Use the new notmuch address command to do completion for addresses in
>>> from: and to:.
>>>
>>> ---
>>>
>>> This patch is more of an RFC. The to: completion is sloooow because
>>> typically there are more matches to begin with, and then producing the
>>> results requires reading the messages. Maybe it would be better to use
>>> the same mechanism as from: for both, even if it's not accurate for
>>> to:?
>>
>> Shameless marketing puff: Imagine how fast would it would be to use
>> nottoomuch-addresses -- the completions are there before one
>> sees TAB KeyRelease event... ;)
>
> Like this? ;)
>
> $ notmuch search to:tomiTABnottoomuch-addresses.sh: command not found

Yes! ;)

Tomi

> I like the completion to be self contained.
>
> BR,
> Jani.

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

end of thread, other threads:[~2015-02-24  7:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-27 19:48 [PATCH 1/5] doc: bring notmuch-dump manual page in line with the rest Jani Nikula
2015-01-27 19:48 ` [PATCH 2/5] doc: document notmuch-dump --output=filename option Jani Nikula
2015-01-27 19:48 ` [PATCH 3/5] doc: document notmuch-restore --input=filename option Jani Nikula
2015-01-27 19:48 ` [PATCH 4/5] completion: complete notmuch dump --gzip option Jani Nikula
2015-01-27 19:48 ` [PATCH 5/5] completion: complete addresses in from:/to: search terms Jani Nikula
2015-02-24  7:12   ` Tomi Ollila
2015-02-24  7:37     ` Jani Nikula
2015-02-24  7:50       ` Tomi Ollila
2015-02-23 22:04 ` [PATCH 1/5] doc: bring notmuch-dump manual page in line with the rest David Bremner

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).