Gnus development mailing list
 help / color / mirror / Atom feed
* How to get message-id from message?
@ 2014-02-27  7:54 Rainer M Krug
  2014-02-27  9:28 ` Tassilo Horn
  0 siblings, 1 reply; 6+ messages in thread
From: Rainer M Krug @ 2014-02-27  7:54 UTC (permalink / raw)
  To: ding

Hi

I am using gnus and notmuch and integrated them using [1]
This works nicely when going from notmuch to gnus. But sometimes, it
would be nice to open a message in notmuch, e.g. when looking for the
whole thread and the mails are spread over different folders. In
addition, I like the folded thread view in notmuch. 

Now it would be easy, if I could 

1) get the message-id of the message open in gnus
2) use this message-id to do a notmuch-search ID:the-message-id and to
open the thread
3) understand elisp better then I actually do...

Now my problem is, I don't know how I can get the message-id.

I found the function planner-gnus-get-message-id at [2] but if I paste
the function into my scratch buffer and evaluate it, I still don't know
how I can wrap this into a function which I can call interactively via
M-x and to return the results of the notmuch search?

Any pointers very much appreciated,

Rainer

Footnotes: 
[1]  http://roland.entierement.nu/blog/2010/09/08/gnus-dovecot-offlineimap-search-a-howto.html

[2]  https://github.com/jwiegley/planner/blob/master/planner-gnus.el

-- 
Rainer M. Krug

email: RMKrug<at>gmail<dot>com




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

* Re: How to get message-id from message?
  2014-02-27  7:54 How to get message-id from message? Rainer M Krug
@ 2014-02-27  9:28 ` Tassilo Horn
  2014-02-27  9:56   ` Rainer M Krug
  0 siblings, 1 reply; 6+ messages in thread
From: Tassilo Horn @ 2014-02-27  9:28 UTC (permalink / raw)
  To: Rainer M Krug; +Cc: ding

Rainer M Krug <Rainer@krugs.de> writes:

Hi Rainer,

> I am using gnus and notmuch and integrated them using [1]
> This works nicely when going from notmuch to gnus. But sometimes, it
> would be nice to open a message in notmuch, e.g. when looking for the
> whole thread and the mails are spread over different folders. In
> addition, I like the folded thread view in notmuch. 
>
> Now it would be easy, if I could 
>
> 1) get the message-id of the message open in gnus

This should work:

  (with-current-buffer gnus-summary-buffer
    (mail-header-id (gnus-summary-article-header)))

> 2) use this message-id to do a notmuch-search ID:the-message-id and to
> open the thread
> 3) understand elisp better then I actually do...
>
> Now my problem is, I don't know how I can get the message-id.
>
> I found the function planner-gnus-get-message-id at [2] but if I paste
> the function into my scratch buffer and evaluate it, I still don't
> know how I can wrap this into a function which I can call
> interactively via M-x and to return the results of the notmuch search?

I don't use notmuch, but your command will probably look like this.
Filling in the notmuch code is left as an excercise to the reader. ;-)

(defun rmk/do-gnus-notmuch-stuff ()
  (interactive)
  (unless (buffer-live-p gnus-summary-buffer)
    (user-error "No open Gnus summary buffer!"))
  (let ((message-id (with-current-buffer gnus-summary-buffer
		      (mail-header-id (gnus-summary-article-header)))))
    ;; Now do the notmuch stuff
    ))

Bye,
Tassilo



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

* Re: How to get message-id from message?
  2014-02-27  9:28 ` Tassilo Horn
@ 2014-02-27  9:56   ` Rainer M Krug
  2014-02-27 11:21     ` Rainer M Krug
  0 siblings, 1 reply; 6+ messages in thread
From: Rainer M Krug @ 2014-02-27  9:56 UTC (permalink / raw)
  To: ding

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

Tassilo Horn <tsdh@gnu.org> writes:

> Rainer M Krug <Rainer@krugs.de> writes:
>
> Hi Rainer,

Hi Tassilo,

>
>> I am using gnus and notmuch and integrated them using [1]
>> This works nicely when going from notmuch to gnus. But sometimes, it
>> would be nice to open a message in notmuch, e.g. when looking for the
>> whole thread and the mails are spread over different folders. In
>> addition, I like the folded thread view in notmuch. 
>>
>> Now it would be easy, if I could 
>>
>> 1) get the message-id of the message open in gnus
>
> This should work:
>
>   (with-current-buffer gnus-summary-buffer
>     (mail-header-id (gnus-summary-article-header)))
>

It does indeed.

>> 2) use this message-id to do a notmuch-search ID:the-message-id and to
>> open the thread
>> 3) understand elisp better then I actually do...
>>
>> Now my problem is, I don't know how I can get the message-id.
>>
>> I found the function planner-gnus-get-message-id at [2] but if I paste
>> the function into my scratch buffer and evaluate it, I still don't
>> know how I can wrap this into a function which I can call
>> interactively via M-x and to return the results of the notmuch search?
>
> I don't use notmuch, but your command will probably look like this.
> Filling in the notmuch code is left as an excercise to the reader. ;-)
>
> (defun rmk/do-gnus-notmuch-stuff ()
>   (interactive)
>   (unless (buffer-live-p gnus-summary-buffer)
>     (user-error "No open Gnus summary buffer!"))
>   (let ((message-id (with-current-buffer gnus-summary-buffer
> 		      (mail-header-id (gnus-summary-article-header)))))
>     ;; Now do the notmuch stuff
>     ))


Thanks a million - I got it working. I added a (message message-id) so
that I can see the message id as well.

Only that the notmuch search for the message ID seems to be broken - I
will investigate.

Thanks,

Rainer

>
> Bye,
> Tassilo
>
>

-- 
Rainer M. Krug

email: RMKrug<at>gmail<dot>com

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

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

* Re: How to get message-id from message?
  2014-02-27  9:56   ` Rainer M Krug
@ 2014-02-27 11:21     ` Rainer M Krug
  2014-02-27 13:23       ` Tassilo Horn
  0 siblings, 1 reply; 6+ messages in thread
From: Rainer M Krug @ 2014-02-27 11:21 UTC (permalink / raw)
  To: ding

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

Rainer M Krug <Rainer@krugs.de> writes:

> Tassilo Horn <tsdh@gnu.org> writes:
>
>> Rainer M Krug <Rainer@krugs.de> writes:
>>
>> Hi Rainer,
>
> Hi Tassilo,
>
>>
>>> I am using gnus and notmuch and integrated them using [1]
>>> This works nicely when going from notmuch to gnus. But sometimes, it
>>> would be nice to open a message in notmuch, e.g. when looking for the
>>> whole thread and the mails are spread over different folders. In
>>> addition, I like the folded thread view in notmuch. 
>>>
>>> Now it would be easy, if I could 
>>>
>>> 1) get the message-id of the message open in gnus
>>
>> This should work:
>>
>>   (with-current-buffer gnus-summary-buffer
>>     (mail-header-id (gnus-summary-article-header)))
>>
>
> It does indeed.
>
>>> 2) use this message-id to do a notmuch-search ID:the-message-id and to
>>> open the thread
>>> 3) understand elisp better then I actually do...
>>>
>>> Now my problem is, I don't know how I can get the message-id.
>>>
>>> I found the function planner-gnus-get-message-id at [2] but if I paste
>>> the function into my scratch buffer and evaluate it, I still don't
>>> know how I can wrap this into a function which I can call
>>> interactively via M-x and to return the results of the notmuch search?
>>
>> I don't use notmuch, but your command will probably look like this.
>> Filling in the notmuch code is left as an excercise to the reader. ;-)
>>
>> (defun rmk/do-gnus-notmuch-stuff ()
>>   (interactive)
>>   (unless (buffer-live-p gnus-summary-buffer)
>>     (user-error "No open Gnus summary buffer!"))
>>   (let ((message-id (with-current-buffer gnus-summary-buffer
>> 		      (mail-header-id (gnus-summary-article-header)))))
>>     ;; Now do the notmuch stuff
>>     ))
>
>
> Thanks a million - I got it working. I added a (message message-id) so
> that I can see the message id as well.
>
> Only that the notmuch search for the message ID seems to be broken - I
> will investigate.

It was not broken - the "<>" needed to be stripped.

The following now works perfectly:

--8<---------------cut here---------------start------------->8---
(defun rmk/gnus-goto-message-in-notmuch ()
  (interactive)
  (unless (buffer-live-p gnus-summary-buffer)
    (user-error "No open Gnus summary buffer!"))
  (let ((message-id (substring (with-current-buffer gnus-summary-buffer
                                 (mail-header-id (gnus-summary-article-header))) 1 -1)
                     ))
    
    (message message-id)
    (notmuch-search (concatenate 'string "id:" message-id)) ;; Now do the notmuch stuff
    ))
--8<---------------cut here---------------end--------------->8---

I am sure the indentations and line breaks are completely un-lisp. ANy
tips in this regard?

Thanks a lot,

Rainer

>
> Thanks,
>
> Rainer
>
>>
>> Bye,
>> Tassilo
>>
>>

-- 
Rainer M. Krug

email: RMKrug<at>gmail<dot>com

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

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

* Re: How to get message-id from message?
  2014-02-27 11:21     ` Rainer M Krug
@ 2014-02-27 13:23       ` Tassilo Horn
  2014-02-27 14:09         ` Rainer M Krug
  0 siblings, 1 reply; 6+ messages in thread
From: Tassilo Horn @ 2014-02-27 13:23 UTC (permalink / raw)
  To: Rainer M Krug; +Cc: ding

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

Rainer M Krug <Rainer@krugs.de> writes:

> The following now works perfectly:

Great!

> --8<---------------cut here---------------start------------->8---
> (defun rmk/gnus-goto-message-in-notmuch ()
>   (interactive)
>   (unless (buffer-live-p gnus-summary-buffer)
>     (user-error "No open Gnus summary buffer!"))
>   (let ((message-id (substring (with-current-buffer gnus-summary-buffer
>                                  (mail-header-id (gnus-summary-article-header))) 1 -1)
>                      ))
>     
>     (message message-id)
>     (notmuch-search (concatenate 'string "id:" message-id)) ;; Now do the notmuch stuff
>     ))
> --8<---------------cut here---------------end--------------->8---
>
> I am sure the indentations and line breaks are completely un-lisp. ANy
> tips in this regard?

Closing parens are usually not on their own line.  And the correct
indentation is the one emacs chooses when you hit tab.

Many people hacking lisp regularly (me included) swear by paredit.el
which allows for real structural editing which frees you from manual
indenting and paren placement.

Bye,
Tassilo

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 229 bytes --]

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

* Re: How to get message-id from message?
  2014-02-27 13:23       ` Tassilo Horn
@ 2014-02-27 14:09         ` Rainer M Krug
  0 siblings, 0 replies; 6+ messages in thread
From: Rainer M Krug @ 2014-02-27 14:09 UTC (permalink / raw)
  To: ding

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

Tassilo Horn <tsdh@gnu.org> writes:

> Rainer M Krug <Rainer@krugs.de> writes:
>
>> The following now works perfectly:
>
> Great!
>
>> --8<---------------cut here---------------start------------->8---
>> (defun rmk/gnus-goto-message-in-notmuch ()
>>   (interactive)
>>   (unless (buffer-live-p gnus-summary-buffer)
>>     (user-error "No open Gnus summary buffer!"))
>>   (let ((message-id (substring (with-current-buffer gnus-summary-buffer
>>                                  (mail-header-id (gnus-summary-article-header))) 1 -1)
>>                      ))
>>     
>>     (message message-id)
>>     (notmuch-search (concatenate 'string "id:" message-id)) ;; Now do the notmuch stuff
>>     ))
>> --8<---------------cut here---------------end--------------->8---
>>
>> I am sure the indentations and line breaks are completely un-lisp. ANy
>> tips in this regard?
>
> Closing parens are usually not on their own line.  And the correct
> indentation is the one emacs chooses when you hit tab.

OK - thanks.

>
> Many people hacking lisp regularly (me included) swear by paredit.el
> which allows for real structural editing which frees you from manual
> indenting and paren placement.

I'll check it out for my occasional hacking.

Thanks a lot,

Rainer

>
> Bye,
> Tassilo

-- 
Rainer M. Krug

email: RMKrug<at>gmail<dot>com

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

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

end of thread, other threads:[~2014-02-27 14:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-27  7:54 How to get message-id from message? Rainer M Krug
2014-02-27  9:28 ` Tassilo Horn
2014-02-27  9:56   ` Rainer M Krug
2014-02-27 11:21     ` Rainer M Krug
2014-02-27 13:23       ` Tassilo Horn
2014-02-27 14:09         ` Rainer M Krug

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 NNTP newsgroup(s).