[notmuch] Snippet to jump to message in Gnus from notmuch-show buffer

2010-11-20 Thread Brett Viren
Hi Tassilo,

I adapted your code for my use and found it was failing due to some
stray double-quotes.  I'm using notmuch from git so maybe these quotes
were added in the year since you first posted your idea.

See below for the simple fix:

On Tue, Nov 24, 2009 at 3:02 AM, Tassilo Horn  wrote:
> --8<---cut here---start->8---
> (require 'notmuch)
>
> (defun th-notmuch-file-to-group (file)
> ?"Calculate the Gnus group name from the given file name.
>
> Example:
>
> ?IN: /home/horn/Mail/Dovecot/uni/INBOX/dbox-Mails/u.4075
> ?OUT: nnimap+Uni:INBOX"
> ?(concat "nnimap+"
> ? ? ? ? ?(replace-regexp-in-string
> ? ? ? ? ? "^\\([^/]+\\)/" "\\1:"
> ? ? ? ? ? (replace-regexp-in-string
> ? ? ? ? ? ?"/dbox-Mails/.*" ""
> ? ? ? ? ? ?(replace-regexp-in-string
> ? ? ? ? ? ? "/home/horn/Mail/Dovecot/" "" file)
>
> (defun th-notmuch-goto-message-in-gnus ()
> ?"Open a summary buffer containing the current notmuch
> article."
> ?(interactive)
> ?(let ((group (th-notmuch-file-to-group (notmuch-show-get-filename)))
> ? ? ? ?(message-id (replace-regexp-in-string
> ? ? ? ? ? ? ? ? ? ? "^id:" "" (notmuch-show-get-message-id

I needed to define the message-id like:

   (message-id (replace-regexp-in-string
"\"" ""
(replace-regexp-in-string
"^id:" "" (notmuch-show-get-message-id)


> ? ?(message "G: %s, mid: %s" group message-id)
> ? ?(if (and group message-id)
> ? ? ? ?(org-gnus-follow-link group message-id)
> ? ? ?(message "Couldn't get relevant infos for switching to Gnus."
>
> (define-key notmuch-show-mode-map (kbd "C-c C-c") 
> 'th-notmuch-goto-message-in-gnus)
> --8<---cut here---end--->8---

Regards and thanks for this handy code!
-Brett.


Re: [notmuch] Snippet to jump to message in Gnus from notmuch-show buffer

2010-11-20 Thread Brett Viren
Hi Tassilo,

I adapted your code for my use and found it was failing due to some
stray double-quotes.  I'm using notmuch from git so maybe these quotes
were added in the year since you first posted your idea.

See below for the simple fix:

On Tue, Nov 24, 2009 at 3:02 AM, Tassilo Horn tass...@member.fsf.org wrote:
 --8---cut here---start-8---
 (require 'notmuch)

 (defun th-notmuch-file-to-group (file)
  Calculate the Gnus group name from the given file name.

 Example:

  IN: /home/horn/Mail/Dovecot/uni/INBOX/dbox-Mails/u.4075
  OUT: nnimap+Uni:INBOX
  (concat nnimap+
          (replace-regexp-in-string
           ^\\([^/]+\\)/ \\1:
           (replace-regexp-in-string
            /dbox-Mails/.* 
            (replace-regexp-in-string
             /home/horn/Mail/Dovecot/  file)

 (defun th-notmuch-goto-message-in-gnus ()
  Open a summary buffer containing the current notmuch
 article.
  (interactive)
  (let ((group (th-notmuch-file-to-group (notmuch-show-get-filename)))
        (message-id (replace-regexp-in-string
                     ^id:  (notmuch-show-get-message-id

I needed to define the message-id like:

   (message-id (replace-regexp-in-string
\ 
(replace-regexp-in-string
^id:  (notmuch-show-get-message-id)


    (message G: %s, mid: %s group message-id)
    (if (and group message-id)
        (org-gnus-follow-link group message-id)
      (message Couldn't get relevant infos for switching to Gnus.

 (define-key notmuch-show-mode-map (kbd C-c C-c) 
 'th-notmuch-goto-message-in-gnus)
 --8---cut here---end---8---

Regards and thanks for this handy code!
-Brett.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] Snippet to jump to message in Gnus from notmuch-show buffer

2009-12-02 Thread Adam Sjøgren
On Wed, 02 Dec 2009 12:51:41 -0800, Carl wrote:

> Hrm... still seeing the same inscrutable stuff that I find every time I
> try to read gnus documentation. The "I want to read my mail!" post
> describes "nnml" as "a one-file-one-mail backend" but then the closest
> it gets to how to use it is:

>   So if you want to go with nnmbox, you can simply say:

>   (setq gnus-secondary-select-methods '((nnmbox "")))

>   (The same for the other methods, kind of.)

> And I'm lost. Besides the "kind of", which just makes me uneasy, how
> does it make sense to configure an mbox backend with just an empty
> string? Surely something needs to be told where to find an actual mbox
> file?

It uses its defaults.

I use nnml to store my email (I like the one-file per email, indexed).
To do that, I've simply added:

  ; Get email, and store in nnml:
  (setq gnus-secondary-select-methods '((nnml "")))

to my .gnus. Note that this makes Gnus fetch your email and store it in
nnml-"format" under ~/Mail/

I would expect that setting mail-sources to an empty list will make Gnus
not fetch your email for you.

If you store your maildirs somewhere Gnus doesn't expect, you can
configure the select-method further - see the nnmaildir node in the
manual for instance, you can set 'directory' etc.

> Or is this just selecting a backend for how GNUS should store mail that
> it fetches?

Yes, exactly.

> Is there any hope for someone like me that doesn't want GNUS involved in
> fetching mail, but just wants to use GNUS to read mail files that I have
> in a big hierarchy of directories?

Mail files in what format?

I think the quickest way to do that is using foreign groups (but I've
usually only used that to view mbox and RMAIL-files, maybe configuring a
secondary select method is better with maildir).

(It's "Gnus" by the way - "GNUS" was the predecessor of Gnus).

> I keep feeling there must be a simple document somewhere that explains
> how to do that---but I just can't find it.

Simple and Gnus isn't always compatible :-)


  Best regards,

   Adam

-- 
 "Favours for the ungrateful  Adam Sj?gren
  Unqualified & hateful" asjo at koldfront.dk



[notmuch] Snippet to jump to message in Gnus from notmuch-show buffer

2009-12-02 Thread Carl Worth
On Fri, 27 Nov 2009 23:10:30 +0100, Tassilo Horn  
wrote:
> Well, if you only want to have a look at a maildir or mbox, and don't
> want to make the group permanent and let gnus fetch mail, then this
> should do the trick.
> 
>   M-x gnus RET ;; brings you into the *Group* buffer, and then
...
> | `G m'
> |  Make a new group (`gnus-group-make-group').  Gnus will prompt you

For viewing an mbox, I successfully used "C-u G f" that you mentioned
earlier. So I've at least now seen gnus in action, thanks!

What I'd really to view is a maildir though, but I haven't gotten "G m"
to work with that yet. It prompts me for a "group name", (which I assume
is just an arbitrary string), then a "from method" which offers tab
completion for things that look promising (such as "nnmh" and
"nnmaildir") but I can't get anything to work past that. I never see
anything prompting for an actual directory, and it either ends up
creating an empty directory, (such as ${HOME}/Mail/), or
complaining "Wrong type argument: stringp, nil".

I even guessthat that maybe it wants "nnmaildir:/path/to/maildir" or
maybe "nnmaildir+/path/to/maildir" but the prompt won't accept either of
these (just says "[No match]").

And now I've got an entry in the *Group* buffer for each of my attempts,
which variously complain ("Couldn't open server" for nnmaildir:foo,
"Group nnmh:bar contains no messages", and "Couldn't activate group
test: No such group"---I can't remember how I created that one).

Where are all of these groups stored now? (I couldn't find anything
matching ~/.gnus* nor any changes to my .emacs file.) Yet I still see
these broken groups even with "emacs -q -f gnus". And how do I delete
these?

Update: It looks like I've got stuff in ~/.newsrc, ~/.newsrc-dribble,
and ~/.newsrc.eld from my various thrashing here. Still not clear how to
delete things---.newsrc.eld says I shouldn't delete it but should touch
~/.newsrc instead, but that doesn't seem to have any effect. I went
ahead and deleted ~/.newsrc* and most of this stuff does seem to be
nicely cleaned up. All that's left is that I now get a warning on
starting gnus of "Gnus auto-save file exits.  Do you want to read it? (y
or n)". If I do read it, then I get some of the junk groups back. I
can't figure out where this auto-save file exists, (it's even hiding


[notmuch] Snippet to jump to message in Gnus from notmuch-show buffer

2009-11-28 Thread Adam Sjøgren
On Fri, 27 Nov 2009 23:10:30 +0100, Tassilo wrote:

>> Unable to open server nntp+news, go offline? (y or n) 

> Hm, I can reproduce that with "emacs -Q".  Looks wrong to me, probably a
> bug...  Normally, an unconfigured Gnus should start having one nndoc
> server providing some groups with static Gnus infos (FAQ and stuff).

I don't think that is a bug, Gnus defaults to connecting to a
news-server (more info in "Finding the News" in the manual?.)

I think the minimal way to configure Gnus to start up without contacting
a news-server is:

  (setq gnus-select-method '(nnnil ""))


  Best regards,

Adam


? http://gnus.org/manual/gnus_2.html

-- 
 "I'll dye without my hair!"  Adam Sj?gren
 asjo at koldfront.dk



[notmuch] Snippet to jump to message in Gnus from notmuch-show buffer

2009-11-28 Thread Kan-Ru Chen
On Fri, 27 Nov 2009 04:54:17 -0800, Carl Worth  wrote:
> Do you happen to know some good documentation for how to get started
> with gnus for reading mail? I'd be happy even with the bare minimum to
> just get gnus to view one single message from out of my mail
> store. (Which is something I tried to figure out from the gnus manual,
> but I neve succeeded.)

The easiest way to view a mbox in gnus is using Foreign Group, IMO.

Start gnus then type C-u Gf, it will ask the file location and file
type. You can also use Gm to add other foreign groups, but they still
need some basic settings.

Cheers,
  Kanru
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 



[notmuch] Snippet to jump to message in Gnus from notmuch-show buffer

2009-11-27 Thread Tassilo Horn
Carl Worth  writes:

Hi Carl,

> On Tue, 24 Nov 2009 09:02:46 +0100, Tassilo Horn  
> wrote:
>> I'm a Gnus user and use notmuch mostly for searching.  When I want to
>> reply to a message, I need to get back to Gnus, so that my Gnus
>> posting styles (gcc into that group, right email address, correct
>> signature,...)  are applied.
>
> Oh, good. I've been hoping to be able to get some advice from gnus
> users. I want to figure out how to get gnus support for viewing
> encrypted messages, etc.

Oh, I don't have any clue about encryption.  EasyPG is a keyword, that I
can provide, though.

> Do you happen to know some good documentation for how to get started
> with gnus for reading mail? I'd be happy even with the bare minimum to
> just get gnus to view one single message from out of my mail
> store. (Which is something I tried to figure out from the gnus manual,
> but I never succeeded at.)

Well, if you only want to have a look at a maildir or mbox, and don't
want to make the group permanent and let gnus fetch mail, then this
should do the trick.

  M-x gnus RET ;; brings you into the *Group* buffer, and then

,[ (info "(gnus)Foreign Groups") ]
| `G m'
|  Make a new group (`gnus-group-make-group').  Gnus will prompt you
|  for a name, a method and possibly an "address".  For an easier way
|  to subscribe to NNTP groups (*note Browse Foreign Server::).
`

>> Therefore, I created this small snippet.  Now C-c C-c inside some
>> message in the *notmuch-show* buffer opens this article in a Gnus
>> *Summary* buffer, where I can reply to it, forward it, ...
>
> And this would be exactly the thing I would want for exploring gnus,
> if only I could get it working.

This does only work if the group already exists inside Gnus.  So you
might consider setting it up properly, although it's a bit first-time
effort.

> If I just try to run it, I get:
>
>   Symbol's function definition is void: org-gnus-follow-link

Do you use Emacs 23?  If yes, put a (require 'org-gnus) before the
call.  If not, you have to install org-mode manually.

> And I suppose that's expected since I don't have gnus "running". If I
> try to start gnus with "M-x gnus", I get:
>
>   Unable to open server nntp+news, go offline? (y or n) 

Hm, I can reproduce that with "emacs -Q".  Looks wrong to me, probably a
bug...  Normally, an unconfigured Gnus should start having one nndoc
server providing some groups with static Gnus infos (FAQ and stuff).

> What's the simplest way for me to tell gnus that I won't be using it
> in any other way than with the "nnimap+" folder I can tell you're
> using in your snippet?

Here's a quick walkthrough my .gnus.el with only the basics (getting
mail/news).

--8<---cut here---start->8---
;; Gnus has the concept of one select method, and a list of so-called
;; secondary select methods.  I set the former to a do-nothing backend
;; and only use the secondary ones, so that it's a bit more uniformly.

(setq gnus-select-method '(nnnil))

;; Fetch news from my university's nntp server
(add-to-list 'gnus-secondary-select-methods
 '(nntp "Uni"
(nntp-address "news.uni-koblenz.de")
(nntp-open-connection-function nntp-open-tls-stream)
(nntp-port-number 563)))

;; Fetch mail from some POP3 accounts and split them according to
;; address

;; The mails are stored in an nnml group at the given directory
(add-to-list 'gnus-secondary-select-methods
 '(nnml "Popmail"
(nnml-directory   "~/Mail/Popmail")
(nnml-active-file "~/Mail/Popmail/active")))

;; Here the mails are fetched
(setq mail-sources `((pop :server "pop.gmx.de"
  :user "x at gmx.de"
  :password ,th-gnus-gmx-password)
 (pop :server "pop3.freenet.de"
  :user "x at freenet.de"
  :password ,th-gnus-freenet-password)))

;; Split them into the groups nnml+Popmail:gmx, freenet, and misc
(setq nnmail-split-methods 'nnmail-split-fancy
  nnmail-split-fancy
  '(| (any "x at gmx.de" "gmx")
  (any "x at freenet.de" "freenet")
  "misc"))

;; Get mail from my local Dovecot IMAP server which I sync with my
;; different accounts using OfflineIMAP
(add-to-list 'gnus-secondary-select-methods
 '(nnimap "Fastmail"
  (nnimap-address "localhost")
  (nnimap-stream network)
  (nnimap-authenticator login)))

(add-to-list 'gnus-secondary-select-methods
 '(nnimap "Uni"
  (nnimap-address "localhost")
  (nnimap-stream network)
  (nnimap-authenticator login)))
--8<---cut here---end--->8---

HTH,
Tassilo


[notmuch] Snippet to jump to message in Gnus from notmuch-show buffer

2009-11-27 Thread Carl Worth
[Sorry for the previous abbreviated reply---I suppose an early send is
bound to happen when you give me a new function with a "C-c C-c"
binding. ;-)]

On Tue, 24 Nov 2009 09:02:46 +0100, Tassilo Horn  
wrote:
> I'm a Gnus user and use notmuch mostly for searching.  When I want to
> reply to a message, I need to get back to Gnus, so that my Gnus posting
> styles (gcc into that group, right email address, correct signature,...)
> are applied.

Oh, good. I've been hoping to be able to get some advice from gnus
users. I want to figure out how to get gnus support for viewing
encrypted messages, etc.

Do you happen to know some good documentation for how to get started
with gnus for reading mail? I'd be happy even with the bare minimum to
just get gnus to view one single message from out of my mail
store. (Which is something I tried to figure out from the gnus manual,
but I never succeeded at.)

> Therefore, I created this small snippet.  Now C-c C-c inside some
> message in the *notmuch-show* buffer opens this article in a Gnus
> *Summary* buffer, where I can reply to it, forward it, ...

And this would be exactly the thing I would want for exploring gnus, if
only I could get it working.

If I just try to run it, I get:

Symbol's function definition is void: org-gnus-follow-link

And I suppose that's expected since I don't have gnus "running". If I
try to start gnus with "M-x gnus", I get:

Unable to open server nntp+news, go offline? (y or n) 

What's the simplest way for me to tell gnus that I won't be using it in
any other way than with the "nnimap+" folder I can tell you're using in
your snippet?

> BTW, why does `notmuch-show-get-message-id' prefix the message-id with
> "id:"?

That's to make the returned value a valid search string for sake of
"notmuch search". Compare to the way `notmuch-search-find-thread-id'
includes a "thread:" prefix.

-Carl


[notmuch] Snippet to jump to message in Gnus from notmuch-show buffer

2009-11-27 Thread Carl Worth
On Tue, 24 Nov 2009 09:02:46 +0100, Tassilo Horn  
wrote:
> I'm a Gnus user and use notmuch mostly for searching.  When I want to
> reply to a message, I need to get back to Gnus, so that my Gnus posting
> styles (gcc into that group, right email address, correct signature,...)
> are applied.

Oh, good. I've been hoping to be able to get some advice from gnus
users. I want to figure out how to get gnus support for viewing
encrypted messages, etc.

Do you happen to know some good documentation for how to get started
with gnus for reading mail? I'd be happy even with the bare minimum to
just get gnus to view one single message from out of my mail
store. (Which is something I tried to figure out from the gnus manual,
but I neve succeeded.)

> Therefore, I created this small snippet.  Now C-c C-c inside some
> message in the *notmuch-show* buffer opens this article in a Gnus
> *Summary* buffer, where I can reply to it, forward it, ...
> 
> Of course, the translation from file name to Gnus group name is
> something that is different for any user.  The essence of this code is
> the call to the org-gnus.el function `org-gnus-follow-link', which takes
> the group name and the message-id.  It's included in Emacsen >= 23.
> 
> --8<---cut here---start->8---
> (require 'notmuch)
> 
> (defun th-notmuch-file-to-group (file)
>   "Calculate the Gnus group name from the given file name.
> 
> Example:
> 
>   IN: /home/horn/Mail/Dovecot/uni/INBOX/dbox-Mails/u.4075
>   OUT: nnimap+Uni:INBOX"
>   (concat "nnimap+"
>   (replace-regexp-in-string 
>"^\\([^/]+\\)/" "\\1:"
>(replace-regexp-in-string 
> "/dbox-Mails/.*" ""
> (replace-regexp-in-string
>  "/home/horn/Mail/Dovecot/" "" file)
> 
> (defun th-notmuch-goto-message-in-gnus ()
>   "Open a summary buffer containing the current notmuch
> article."
>   (interactive)
>   (let ((group (th-notmuch-file-to-group (notmuch-show-get-filename)))
> (message-id (replace-regexp-in-string
>  "^id:" "" (notmuch-show-get-message-id
> (message "G: %s, mid: %s" group message-id)
> (if (and group message-id)
> (org-gnus-follow-link group message-id)
>   (message "Couldn't get relevant infos for switching to Gnus."
> 
> (define-key notmuch-show-mode-map (kbd "C-c C-c") 
> 'th-notmuch-goto-message-in-gnus)
> --8<---cut here---end--->8---
> 
> BTW, why does `notmuch-show-get-message-id' prefix the message-id with
> "id:"?
> 
> Bye,
> Tassilo
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
> 


[notmuch] Snippet to jump to message in Gnus from notmuch-show buffer

2009-11-24 Thread Tassilo Horn
Hi all,

I'm a Gnus user and use notmuch mostly for searching.  When I want to
reply to a message, I need to get back to Gnus, so that my Gnus posting
styles (gcc into that group, right email address, correct signature,...)
are applied.

Therefore, I created this small snippet.  Now C-c C-c inside some
message in the *notmuch-show* buffer opens this article in a Gnus
*Summary* buffer, where I can reply to it, forward it, ...

Of course, the translation from file name to Gnus group name is
something that is different for any user.  The essence of this code is
the call to the org-gnus.el function `org-gnus-follow-link', which takes
the group name and the message-id.  It's included in Emacsen >= 23.

--8<---cut here---start->8---
(require 'notmuch)

(defun th-notmuch-file-to-group (file)
  "Calculate the Gnus group name from the given file name.

Example:

  IN: /home/horn/Mail/Dovecot/uni/INBOX/dbox-Mails/u.4075
  OUT: nnimap+Uni:INBOX"
  (concat "nnimap+"
  (replace-regexp-in-string 
   "^\\([^/]+\\)/" "\\1:"
   (replace-regexp-in-string 
"/dbox-Mails/.*" ""
(replace-regexp-in-string
 "/home/horn/Mail/Dovecot/" "" file)

(defun th-notmuch-goto-message-in-gnus ()
  "Open a summary buffer containing the current notmuch
article."
  (interactive)
  (let ((group (th-notmuch-file-to-group (notmuch-show-get-filename)))
(message-id (replace-regexp-in-string
 "^id:" "" (notmuch-show-get-message-id
(message "G: %s, mid: %s" group message-id)
(if (and group message-id)
(org-gnus-follow-link group message-id)
  (message "Couldn't get relevant infos for switching to Gnus."

(define-key notmuch-show-mode-map (kbd "C-c C-c") 
'th-notmuch-goto-message-in-gnus)
--8<---cut here---end--->8---

BTW, why does `notmuch-show-get-message-id' prefix the message-id with
"id:"?

Bye,
Tassilo