girzel / gnorb

Glue code between the Org, Gnus, and BBDB packages for Emacs.
32 stars 4 forks source link

Feature request: peek at email #2

Closed brabalan closed 10 years ago

brabalan commented 10 years ago

(edit: hit the "submit" button shortcut by mistake)

gnorb-org-handle-mail works great when one already knows how to reply to a mail. There are sometimes when one only wants to have a look at the mail, without triggering a reply, before being able to do something about it.

Right now I use the following to do it:

  (defun as/copy-link-and-open-in-new-frame ()
    (interactive)
    "Copies the next link found and opens it in a new frame"
    (org-next-link)
    (let ((link (org-element-property :raw-link (org-element-link-parser))))
      (make-frame '((name . "follow-link")))
      (select-frame-by-name "follow-link")
      (org-open-link-from-string link)))

Could this be integrated as a gnorb-org functionality?

girzel commented 10 years ago

Most definitely, this is possible, and a good idea. Would you always want a new frame? If the heading had links to multiple messages, would you want an nnvirtual buffer on a series of messages?

I think this is something that needs to be implemented, I'm just trying to think of the best way to do it...

brabalan commented 10 years ago

The reason I create a frame is it's the simplest to get back my agenda layout after. This function could instead save the frame layout to some register, then have another function to call when done dealing with the message.

In the case there are several messages, a choice about which one to open could be given to the user (similar to the attachment approach when there are several of them).

girzel commented 10 years ago

Okay, that's something to think about. It would make sense to have a gnorb-view' kind of command, that just shows you the relevant messages and contacts, rather than taking any action. But it could use the same routine asgnorb-org-handle-mail' for deciding which links to use. Or it could produce a virtual gnus group containing all the linked messages...

On 05/29/14 11:30 AM, Alan Schmitt wrote:

The reason I create a frame is it's the simplest to get back my agenda layout after. This function could instead save the frame layout to some register, then have another function to call when done dealing with the message.

In the case there are several messages, a choice about which one to open could be given to the user (similar to the attachment approach when there are several of them).

Reply to this email directly or view it on GitHub.*

brabalan commented 10 years ago

A virtual gnus group would be great indeed. And I would definitely use such a `gnorb-view' function.

girzel commented 10 years ago

Well this turned into some pretty serious feature creep! It works now, but I ended up creating a custom "nngnorb" server backend, which you'll have to add to your select methods. Before you run in horror -- it's a very simple dummy server that only serves as a place to hang nnir searches.

Try adding something like (nngnorb "Gnorb Server") to your gnus-secondary-select-methods (or do it on-the-fly using "a" in the Server buffer). Then run `gnorb-org-view' on a subtree containing gnus links. See what happens!

The other thing you can do is go to the Server buffer, put point on the nngnorb server, and hit "G" to start an nnir search. Input a tags-todo search string, same as you would for an Agenda search. Gnorb should collect all the subtrees that match the agenda search, scan them all for gnus links, and present all those links in an ephemeral buffer.

I hope.

Thanks for being a guinea pig!

On 05/30/14 04:27 AM, Alan Schmitt wrote:

A virtual gnus group would be great indeed. And I would definitely use such a `gnorb-view' function.

Reply to this email directly or view it on GitHub.*

brabalan commented 10 years ago

I'm sorry, but I cannot make it work. I have this in my configuration:

  (setq gnus-secondary-select-methods 
        '((nnimap 
           "dovecot"
           (nnimap-address "localhost")
           (nnimap-server-port 143)
           (nnimap-stream network))
          (nngnorb "Gnorb Server")))

and when I do gnorb-org-view, I get the error user-error: Please add a "nngnorb" backend to your gnus installation.

How can I make sure the nngnorb server is there (I did a git pull and restarted emacs before testing)?

(a bit later) I can add the server manually (I don't know why it's not picked up with this configuration), but then I have another error:

  signal(error ("Couldn't request group nnir:gnorb-id+EB2C2D08-E92B-4FE9-9FBE-5AD6F7608657: Search produced empty results."))
  error("Couldn't request group %s: %s" "nnir:gnorb-id+EB2C2D08-E92B-4FE9-9FBE-5AD6F7608657" "Search produced empty results.")
  gnus-select-newsgroup("nnir:gnorb-id+EB2C2D08-E92B-4FE9-9FBE-5AD6F7608657" t nil)
  gnus-summary-read-group-1("nnir:gnorb-id+EB2C2D08-E92B-4FE9-9FBE-5AD6F7608657" t t nil nil nil)
  gnus-summary-read-group("nnir:gnorb-id+EB2C2D08-E92B-4FE9-9FBE-5AD6F7608657" t t nil nil nil nil)
girzel commented 10 years ago

Okay, the process for checking whether a nngnorb server is installed or not is a bit fragile, I need to find a better solution.

So you're calling `gnorb-org-view' on a subtree you're sure contains gnus links, right? That's the error I'd expect if it simply didn't find any links.

Can you please:

  1. Pull the newest code
  2. Make a simple test subtree that just contains a gnus link and not much else
  3. Tell me the server backend for the linked message (ie is it nnimap, nnmail, nn-what-have-you)
  4. If gnorb-org-view' still doesn't find the message, would you mind e-debugging thegnorb-scan-links' function in lisp/gnorb-utils.el? Just C-u C-M-x on the function body, then run `gnorb-org-view' on the subtree again, and hit space until you reach the end of the function. When the last sexp is reached, are there gnus links in the ,gnus variable? (my apologies if you edebug all the time and it sounds I'm talking down to you, I don't know your background!)

Getting there, hopefully...

On 06/03/14 05:02 AM, Alan Schmitt wrote:

I'm sorry, but I cannot make it work. I have this in my configuration:

(setq gnus-secondary-select-methods '((nnimap "dovecot" (nnimap-address "localhost") (nnimap-server-port 143) (nnimap-stream network)) (nngnorb "Gnorb Server")))

and when I do gnorb-org-view, I get the error user-error: Please add a "nngnorb" backend to your gnus installation.

How can I make sure the nngnorb server is there (I did a git pull and restarted emacs before testing)?

(a bit later) I can add the server manually (I don't know why it's not picked up with this configuration), but then I have another error:

signal(error ("Couldn't request group nnir:gnorb-id+EB2C2D08-E92B-4FE9-9FBE-5AD6F7608657: Search produced empty results.")) error("Couldn't request group %s: %s" "nnir:gnorb-id+EB2C2D08-E92B-4FE9-9FBE-5AD6F7608657" "Search produced empty results.") gnus-select-newsgroup("nnir:gnorb-id+EB2C2D08-E92B-4FE9-9FBE-5AD6F7608657" t nil) gnus-summary-read-group-1("nnir:gnorb-id+EB2C2D08-E92B-4FE9-9FBE-5AD6F7608657" t t nil nil nil) gnus-summary-read-group("nnir:gnorb-id+EB2C2D08-E92B-4FE9-9FBE-5AD6F7608657" t t nil nil nil nil)

Reply to this email directly or view it on GitHub.*

brabalan commented 10 years ago

The good news is that upon restarting emacs, the nngnorb server was there.

I did a git pull and everything was up to date.

The bad news is that I still have not found the source of the problem. I e-debugged gnorb-scan-links but it's not called. Looking at the code, I don't understand when it's supposed to be called: gnorb-org-view saves the window configuration, sets an id, then call gnorb-gnus-search-messages. This second function starts a gnus-group-read-ephemeral-group that fails with the error. I've probably missed something, but we're out of gnorb's code at that point.

girzel commented 10 years ago

Frustrating...

I've put up another commit that might fix the culprit here. Pull and try again, and if it doesn't work:

Possibilities are: nnir isn't finding the gnorb search engine and it's using a different one, or it's finding the right search engine, but the engine's internal search function, nnir-run-gnorb', isn't finding any links. It would be pretty hard fornnir-run-gnorb' to run without calling `gnorb-scan-links' at all, so my money's on the first possibility.

Nnir finds the appropriate search engine/function to use by the function `nnir-run-query'. In the end, the logic should run like this:

(cadr (assoc (nnir-server-to-search-engine (gnus-method-to-server '(nngnorb))) nnir-engines))

That should return the function name `nnir-run-gnorb'. If it doesn't, can you confirm that (gnus-method-to-server '(nngnorb)) returns the string name of your nngnorb server, and also that the 'nnir-engines and 'nnir-method-default-engines variables contain entries referring to gnorb/nngnorb?

If the above all looks normal, can you edebug nnir-run-gnorb' (in nngnorb.el), and see why it never callsorg-scan-tags'?

brabalan commented 10 years ago

It seems we're getting closer to the problem, but it's still beyond me.

girzel commented 10 years ago

Uh oh, the problem may be different gnus versions -- I'm running the git head of gnus, and line 1617 of nnir.el is in the middle of the nnir-run-find-grep function, which is clearly not where we're supposed to be. Can you tell me your gnus version, and I'll see if that's the source of the problem?

brabalan commented 10 years ago

It's 5.13 (it's the one that comes with emacs 24.3.1).

girzel commented 10 years ago

Oh man, this is going to be a little difficult -- nnir has been largely re-written between that version and the git version, and I'll have to work around that. Standby! In the mean time, play with gnorb-bbdb-posting-styles!

brabalan commented 10 years ago

I can switch to the emacs 24.4 pre-version, if it helps. Would the gnus in it be recent enough?

girzel commented 10 years ago

Yeah, that looks pretty much the same as what's in the git codebase, and ought to work okay. On the other hand, I really need to make this compatible with a standard 24.3, as that's what a majority of people will have installed. If you're in a hurry, try the new version!

brabalan commented 10 years ago

Thanks, I'll wait until either emacs 24.4 comes out or you update gnorb. This is already working well for the other things I'm using it with.

girzel commented 10 years ago

Give it a shot now -- I tested with gnus 5.13 and believe I've caught all the compatibility issues...

On 06/04/14 08:46 AM, Alan Schmitt wrote:

Thanks, I'll wait until either emacs 24.4 comes out or you update gnorb. This is already working well for the other things I'm using it with.

Reply to this email directly or view it on GitHub.*

brabalan commented 10 years ago

It's working great, thanks a lot!

Is there an easy way to get back to the frame configuration before opening the virtual group? This could be a `gnorb-org-view-finished' function ...

girzel commented 10 years ago

Not yet! It's on the list...

On 06/07/14 04:35 AM, Alan Schmitt wrote:

It's working great, thanks a lot!

Is there an easy way to get back to the frame configuration before opening the virtual group? This could be a `gnorb-org-view-finished' function ...

Reply to this email directly or view it on GitHub.*

brabalan commented 10 years ago

As I find this is working nicely, I'll close the issue.