notmuch over ssh

2021-02-10 Thread Keegan Carruthers-Smith


Thought I'd share a hack I've been using recently. I have my 
notmuch database on another machine. I wanted to access it via my 
local emacs session. I didn't want to ssh in to the machine or 
sync the data to another machine. I realised all communication is 
done via the notmuch binary, so I wrote a wrapper script which 
runs notmuch via ssh:

 #!/usr/bin/env bash  args=()  for var in "$@" do 
 args+=($(printf '%q' "$var")) 
 done  exec ssh real.local -- notmuch "${args[@]}" 

Note I have hardcoded the remote (real.local). I also needed to 
escape arguments since the remote shell had a tendancy to 
interpret them. This escaping isn't fullproof, but has been 
working so far.

I put the above script on my PATH as "notmuch", and emacs 
magically uses it. Alternatively you could set the notmuch-command 
to point to the above shell script.

notmuch mailing list --
To unsubscribe send an email to

Re: waiting tag

2020-05-03 Thread Keegan Carruthers-Smith
Chris Tennant  writes:

> I would like to have emails that I am waiting on a response for to have a
> special tag that is removed once I get a reply.  There are other products
> that do this, but I would much rather do it all from NotMuchMail.

You can add a "post-new" hook which does this. Assuming you are use
"waiting" as the special tag and notmuch's default "new" tag this could work
for you:

  notmuch tag -waiting -- tag:waiting and 'thread:{tag:new}'

Just ensure you are clearing out the new tag to get the correct
behaviour. For example by running "notmuch tag -new -- tag:new" at the
end of your post-new hook.

notmuch mailing list

[PATCH] emacs: introduce notmuch-search-by-tag

2020-04-13 Thread Keegan Carruthers-Smith
This is like notmuch-search-filter-by-tag, but creates a new search
rather than filtering the current search. We add this to
notmuch-common-keymap since this can be used by many contexts. We bind
to the key "t", which is the same key used by
notmuch-search-filter-by-tag in notmuch-search-mode-map. This is done
intentionally since the keybinding for notmuch-search-mode-map can be
seen as a specialization of creating a new search.

This change was motivated for use in "notmuch-hello". It is a more
convenient way to search a tag than expanding the list of all tags. I
also noticed many saved searches people use are simply tags.
 devel/ | 2 +-
 emacs/notmuch-lib.el| 1 +
 emacs/notmuch.el| 6 ++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/devel/ b/devel/
index 464b9467..65dfe0eb 100644
--- a/devel/
+++ b/devel/
@@ -20,7 +20,7 @@
 | q | notmuch-bury-or-kill-this-buffer   | 
notmuch-bury-or-kill-this-buffer  | 
 | r | notmuch-search-reply-to-thread-sender  | 
notmuch-show-reply-sender | 
notmuch-show-reply-sender   |
 | s | notmuch-search | notmuch-search  
  | notmuch-search  |
-| t | notmuch-search-filter-by-tag   | toggle-truncate-lines   
  | |
+| t | notmuch-search-filter-by-tag   | toggle-truncate-lines   
  | notmuch-search-by-tag   |
 | u || 
  | |
 | v || 
  | notmuch-show-view-all-mime-parts|
 | w || 
notmuch-show-save-attachments | 
notmuch-show-save-attachments   |
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 73b165e4..e085a06b 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -153,6 +153,7 @@ For example, if you wanted to remove an \"inbox\" tag and 
add an
 (define-key map "?" 'notmuch-help)
 (define-key map "q" 'notmuch-bury-or-kill-this-buffer)
 (define-key map "s" 'notmuch-search)
+(define-key map "t" 'notmuch-search-by-tag)
 (define-key map "z" 'notmuch-tree)
 (define-key map "u" 'notmuch-unthreaded)
 (define-key map "m" 'notmuch-mua-new-mail)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f4789b4f..f5f03244 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -1077,6 +1077,12 @@ current search results AND that are tagged with the 
given tag."
(list (notmuch-select-tag-with-completion "Filter by tag: " 
   (notmuch-search (concat notmuch-search-query-string " and tag:" tag) 
+(defun notmuch-search-by-tag (tag)
+  "Display threads matching TAG in a notmuch-search buffer."
+  (interactive
+   (list (notmuch-select-tag-with-completion "Notmuch search tag: ")))
+  (notmuch-search (concat "tag:" tag)))
 (defun notmuch ()
   "Run notmuch and display saved searches, known tags, etc."
notmuch mailing list

[PATCH] emacs: use def instead of initial-input for notmuch-show-browse-urls

2020-04-13 Thread Keegan Carruthers-Smith
This is the non-deprecated way to use completing-read. Additionally
the old use was broken when using ivy for completing-read. For user's
using completing-read-default they won't see the default URL now, but
if they hit enter it will be visited. Alternatively they can select
it with M-n.

>From the completing-read documentation for initial-input:

 This feature is deprecated--it is best to pass nil for INITIAL-INPUT
 and supply the default value DEF instead.  The user can yank the
 default value into the minibuffer easily using M-n.

Additionally collection is now all urls, rather than all but the
first. I'm not sure why "(cdr urls)" was previously done.
 emacs/notmuch-show.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 214e279f..079281c3 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -2559,7 +2559,7 @@ browsing."
(prompt (if kill "Copy URL to kill ring: " "Browse URL: "))
(fn (if kill #'kill-new #'browse-url)))
 (if urls
-   (funcall fn (completing-read prompt (cdr urls) nil nil (car urls)))
+   (funcall fn (completing-read prompt urls nil nil nil nil (car urls)))
   (message "No URLs found."
 (provide 'notmuch-show)

notmuch mailing list