unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Patches in support of linking from org-mode
@ 2009-12-05  2:26 david
  2009-12-05  2:26 ` [PATCH 1/2] notmuch-search-process-filter: add text properties for authors and subject to each line david
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: david @ 2009-12-05  2:26 UTC (permalink / raw)
  To: notmuch


These two patches are pretty much independent. The first is needed by my 
work in progress patch for org-mode to provide links into notmuch 
(http://pivot.cs.unb.ca/git/?p=org-mode.git;a=shortlog;h=refs/heads/notmuch-link).

The second changes the interface of git-show to take the query-string
recently added explicitly as a parameter. This is more an aesthetic
thing, but it means that I don't have to call notmuch-show like
(let notmuch-query-search-string thread-id
     (notmuch-show thread-id))

Hope you like em. I also hope this whole git-send-email thing works out.

David

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

* [PATCH 1/2] notmuch-search-process-filter: add text properties for authors and subject to each line
  2009-12-05  2:26 Patches in support of linking from org-mode david
@ 2009-12-05  2:26 ` david
  2009-12-05  2:26   ` [PATCH 2/2] notmuch-show: add optional argument for query context instead of using global binding notmuch-search-query-string david
  2009-12-05 14:05 ` [PATCH] notmuch-show-get-header: new function; return alist of parsed header fields David Bremner
  2010-03-09 18:20 ` Patches in support of linking from org-mode Carl Worth
  2 siblings, 1 reply; 8+ messages in thread
From: david @ 2009-12-05  2:26 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner

From: David Bremner <bremner@unb.ca>

Add functions notmuch-search-find-authors and notmuch-find-subject to
match notmuch-find-thread-id.  These functions are just a wrapper
around get-text-property, but in principle that could change.
---
 notmuch.el |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index c504f46..5925907 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -1133,6 +1133,14 @@ Complete list of currently available key bindings:
   "Return the thread for the current thread"
   (get-text-property (point) 'notmuch-search-thread-id))
 
+(defun notmuch-search-find-authors ()
+  "Return the authors for the current thread"
+  (get-text-property (point) 'notmuch-search-authors))
+
+(defun notmuch-search-find-subject ()
+  "Return the subject for the current thread"
+  (get-text-property (point) 'notmuch-search-subject))
+
 (defun notmuch-search-show-thread ()
   "Display the currently selected thread."
   (interactive)
@@ -1257,7 +1265,9 @@ This function advances the next thread when finished."
 		      (goto-char (point-max))
 		      (let ((beg (point-marker)))
 			(insert (format "%s %-7s %-40s %s (%s)\n" date count authors subject tags))
-			(put-text-property beg (point-marker) 'notmuch-search-thread-id thread-id))
+			(put-text-property beg (point-marker) 'notmuch-search-thread-id thread-id)
+			(put-text-property beg (point-marker) 'notmuch-search-authors authors)
+			(put-text-property beg (point-marker) 'notmuch-search-subject subject))
 		      (set 'line (match-end 0)))
 		  (set 'more nil))))))
       (delete-process proc))))
-- 
1.6.5.3

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

* [PATCH 2/2] notmuch-show: add optional argument for query context instead of using global binding notmuch-search-query-string
  2009-12-05  2:26 ` [PATCH 1/2] notmuch-search-process-filter: add text properties for authors and subject to each line david
@ 2009-12-05  2:26   ` david
  2009-12-10 15:14     ` [PATCH] notmuch.el: patch notmuch-show to call notmuch show without query-context (i.e. without tag:inbox) if the first query returns nothing david
  0 siblings, 1 reply; 8+ messages in thread
From: david @ 2009-12-05  2:26 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner

From: David Bremner <bremner@unb.ca>

Also modify the one call to notmuch-show in notmuch.el.  This makes
the call (notmuch-show thread-id) will work when there is no binding
for notmuch-search-query-string; e.g. when called from user code
outside notmuch.
---
 notmuch.el |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 5925907..f7048d5 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -949,15 +949,17 @@ All currently available key bindings:
 	  (lambda()
 	    (hl-line-mode 1) ))
 
-(defun notmuch-show (thread-id &optional parent-buffer)
+(defun notmuch-show (thread-id &optional parent-buffer query-context)
   "Run \"notmuch show\" with the given thread ID and display results.
 
 The optional PARENT-BUFFER is the notmuch-search buffer from
 which this notmuch-show command was executed, (so that the next
-thread from that buffer can be show when done with this one)."
+thread from that buffer can be show when done with this one).
+
+The optional QUERY-CONTEXT is a notmuch search term. Only messages from the thread 
+matching this search term are shown if non-nil. "
   (interactive "sNotmuch show: ")
-  (let ((query notmuch-search-query-string)
-	(buffer (get-buffer-create (concat "*notmuch-show-" thread-id "*"))))
+  (let ((buffer (get-buffer-create (concat "*notmuch-show-" thread-id "*"))))
     (switch-to-buffer buffer)
     (notmuch-show-mode)
     (set (make-local-variable 'notmuch-show-parent-buffer) parent-buffer)
@@ -969,7 +971,9 @@ thread from that buffer can be show when done with this one)."
       (erase-buffer)
       (goto-char (point-min))
       (save-excursion
-	(call-process notmuch-command nil t nil "show" "--entire-thread" thread-id "and (" query ")")
+	(let* ((basic-args (list notmuch-command nil t nil "show" "--entire-thread" thread-id))
+		(args (if query-context (append basic-args (list "and (" query-context ")")) basic-args)))
+	  (apply 'call-process args))
 	(notmuch-show-markup-messages)
 	)
       (run-hooks 'notmuch-show-hook)
@@ -1146,7 +1150,7 @@ Complete list of currently available key bindings:
   (interactive)
   (let ((thread-id (notmuch-search-find-thread-id)))
     (if (> (length thread-id) 0)
-	(notmuch-show thread-id (current-buffer))
+	(notmuch-show thread-id (current-buffer) notmuch-search-query-string)
       (error "End of search results"))))
 
 (defun notmuch-search-reply-to-thread ()
-- 
1.6.5.3

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

* [PATCH] notmuch-show-get-header: new function; return alist of parsed header fields.
  2009-12-05  2:26 Patches in support of linking from org-mode david
  2009-12-05  2:26 ` [PATCH 1/2] notmuch-search-process-filter: add text properties for authors and subject to each line david
@ 2009-12-05 14:05 ` David Bremner
  2010-03-09 18:20 ` Patches in support of linking from org-mode Carl Worth
  2 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2009-12-05 14:05 UTC (permalink / raw)
  To: notmuch

This function parses the displayed message to recover header
fields. It uses mailheader.el to do the actual header parsing, after
preprocessing to remove indentation.  It relies on the variables
notmuch-show-message-begin-regexp, notmuch-show-header-begin-regexp,
and notmuch-show-message-end-regexp.
---

This is another patch needed for org-mode links. Really I just need
some way to get the author and subject of the current message in
notmuch-show-mode.  It seems like a generally useful function,
although of course it would be more efficient to cache these headers
somewhere if the function is being invoked many times.

 notmuch.el |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index f7048d5..cf472f7 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -203,6 +203,30 @@ Unlike builtin `previous-line' this version accepts no arguments."
     (re-search-forward notmuch-show-tags-regexp)
     (split-string (buffer-substring (match-beginning 1) (match-end 1)))))
 
+(defun notmuch-show-get-header ()
+  "Retrieve and parse the header from the current message. Returns an alist with of (header . value) 
+where header is a symbol and value is a string.  The summary from notmuch-show is returned as the 
+pseudoheader summary"
+  (require 'mailheader)
+  (save-excursion
+    (beginning-of-line)
+    (if (not (looking-at notmuch-show-message-begin-regexp))
+	(re-search-backward notmuch-show-message-begin-regexp))
+    (re-search-forward (concat notmuch-show-header-begin-regexp "\n[[:space:]]*\\(.*\\)\n"))
+    (let* ((summary (buffer-substring-no-properties (match-beginning 1) (match-end 1)))
+	  (beg (point)))
+      (re-search-forward notmuch-show-header-end-regexp)
+      (let ((text (buffer-substring beg (match-beginning 0))))
+	(with-temp-buffer
+	  (insert text)
+	  (goto-char (point-min))
+	  (while (looking-at "\\([[:space:]]*\\)[A-Za-z][-A-Za-z0-9]*:")
+	    (delete-region (match-beginning 1) (match-end 1))
+	    (forward-line)
+	    )
+	  (goto-char (point-min))
+	  (cons (cons 'summary summary) (mail-header-extract-no-properties)))))))
+  
 (defun notmuch-show-add-tag (&rest toadd)
   "Add a tag to the current message."
   (interactive
-- 
1.6.5.3

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

* [PATCH] notmuch.el: patch notmuch-show to call notmuch show without query-context (i.e. without tag:inbox) if the first query returns nothing.
  2009-12-05  2:26   ` [PATCH 2/2] notmuch-show: add optional argument for query context instead of using global binding notmuch-search-query-string david
@ 2009-12-10 15:14     ` david
  2009-12-10 18:43       ` Fix viewing of thread after accidentally archiving Carl Worth
  0 siblings, 1 reply; 8+ messages in thread
From: david @ 2009-12-10 15:14 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner

From: David Bremner <bremner@unb.ca>

This fixes the annoying bug of archiving a thread, and then going back
to open it and getting an error.  It needs the notmuch-show API
changing patch of 1259979997-31544-3-git-send-email-david@tethera.net.
---

I'm not really expecting Carl to push this patch, because I think he
has a better solution in mind, but in the mean time maybe someone
finds it useful. It is saving my sanity already, since in wanderlust
 'a' = reply :).

 notmuch.el |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index cf472f7..0cd4386 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -997,7 +997,9 @@ matching this search term are shown if non-nil. "
       (save-excursion
 	(let* ((basic-args (list notmuch-command nil t nil "show" "--entire-thread" thread-id))
 		(args (if query-context (append basic-args (list "and (" query-context ")")) basic-args)))
-	  (apply 'call-process args))
+	  (apply 'call-process args)
+	  (when (and (eq (buffer-size) 0) query-context)
+	    (apply 'call-process basic-args)))
 	(notmuch-show-markup-messages)
 	)
       (run-hooks 'notmuch-show-hook)
-- 
1.6.5.3

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

* Fix viewing of thread after accidentally archiving.
  2009-12-10 15:14     ` [PATCH] notmuch.el: patch notmuch-show to call notmuch show without query-context (i.e. without tag:inbox) if the first query returns nothing david
@ 2009-12-10 18:43       ` Carl Worth
  0 siblings, 0 replies; 8+ messages in thread
From: Carl Worth @ 2009-12-10 18:43 UTC (permalink / raw)
  To: david, notmuch; +Cc: David Bremner

[-- Attachment #1: Type: text/plain, Size: 1232 bytes --]

On Thu, 10 Dec 2009 11:14:35 -0400, david@tethera.net wrote:
> From: David Bremner <bremner@unb.ca>
> 
> This fixes the annoying bug of archiving a thread, and then going back
> to open it and getting an error.  It needs the notmuch-show API
> changing patch of 1259979997-31544-3-git-send-email-david@tethera.net.
> ---
> 
> I'm not really expecting Carl to push this patch, because I think he
> has a better solution in mind, but in the mean time maybe someone
> finds it useful. It is saving my sanity already, since in wanderlust
>  'a' = reply :).

On the contrary, David. I pushed this immediately, so thanks!

I'll still do the other solution, (other interfaces will want it), but
in the meantime, it's *really* nice to have this bug fixed.

I also fixed '+' and '-' to work in this same situation, (so you can
actually put an inbox tag *back* if you accidentally remove it). I
haven't yet fixed '*' for this case, so an accidental '* -inbox' won't
be recoverable with '* +inbox' if the current search is tag:inbox.

I've added a TODO item to fix this, (and the proposed fix there will
incidentally fix '*' to actually provide feedback on the added/removed
tags too, which will also help).

-Carl

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: Patches in support of linking from org-mode
  2009-12-05  2:26 Patches in support of linking from org-mode david
  2009-12-05  2:26 ` [PATCH 1/2] notmuch-search-process-filter: add text properties for authors and subject to each line david
  2009-12-05 14:05 ` [PATCH] notmuch-show-get-header: new function; return alist of parsed header fields David Bremner
@ 2010-03-09 18:20 ` Carl Worth
  2010-03-09 20:08   ` David Bremner
  2 siblings, 1 reply; 8+ messages in thread
From: Carl Worth @ 2010-03-09 18:20 UTC (permalink / raw)
  To: david, notmuch

[-- Attachment #1: Type: text/plain, Size: 824 bytes --]

On Fri,  4 Dec 2009 22:26:35 -0400, david@tethera.net wrote:
> These two patches are pretty much independent. The first is needed by my 
> work in progress patch for org-mode to provide links into notmuch 
> (http://pivot.cs.unb.ca/git/?p=org-mode.git;a=shortlog;h=refs/heads/notmuch-link).
> 
> The second changes the interface of git-show to take the query-string
> recently added explicitly as a parameter.

Hi David,

Somehow I had this mail from you on my backlog of patches to review, but
it looks like everything here has already been applied. So thanks!

And please let me know if you need any further changes to notmuch to
make it work better with org-mode. (A recent message on this list does
make me very interested to try out org-mode and to make sure it
integrates well with notmuch.)

-Carl

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: Patches in support of linking from org-mode
  2010-03-09 18:20 ` Patches in support of linking from org-mode Carl Worth
@ 2010-03-09 20:08   ` David Bremner
  0 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2010-03-09 20:08 UTC (permalink / raw)
  To: Carl Worth, notmuch

On Tue, 09 Mar 2010 10:20:39 -0800, Carl Worth <cworth@cworth.org> wrote:

> And please let me know if you need any further changes to notmuch to
> make it work better with org-mode. (A recent message on this list does
> make me very interested to try out org-mode and to make sure it
> integrates well with notmuch.)

The last patches needed for initial org-mode support are 
    id:1267015920-8999-1-git-send-email-david@tethera.net
    (notmuch-query.el)

    and

    1265773528-30794-1-git-send-email-david@tethera.net 
    (emacs subdirectory)

The first is needed by the code which creates links to notmuch
threads. Since threads are mutable, what it does turn a thread-id into a
list of message-ids.  

All the best,

David

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

end of thread, other threads:[~2010-03-09 20:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-05  2:26 Patches in support of linking from org-mode david
2009-12-05  2:26 ` [PATCH 1/2] notmuch-search-process-filter: add text properties for authors and subject to each line david
2009-12-05  2:26   ` [PATCH 2/2] notmuch-show: add optional argument for query context instead of using global binding notmuch-search-query-string david
2009-12-10 15:14     ` [PATCH] notmuch.el: patch notmuch-show to call notmuch show without query-context (i.e. without tag:inbox) if the first query returns nothing david
2009-12-10 18:43       ` Fix viewing of thread after accidentally archiving Carl Worth
2009-12-05 14:05 ` [PATCH] notmuch-show-get-header: new function; return alist of parsed header fields David Bremner
2010-03-09 18:20 ` Patches in support of linking from org-mode Carl Worth
2010-03-09 20:08   ` 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).