reddit / emacs
Mode (Not Package) for Reading E-mail
blah1998z · 2022-10-04 02:15
So Emacs has Mail mode for writing E-mail which, I believe, you could use on its own to write and sent an E-mail.
Does it have anything similar for reading E-mail?
Most modes that I know of are part of another package (like Gnus or Wanderlust or Mew, etc.) but lets imagine I've fetched my E-mail via some other means; home-grown, if you will.
I, now, want to read them but I don't want to roll my own mode to do so; repurposing another package's for this purpose would probably likewise be fine *so long as* it could be isolated from the rest of the package (e.g. `mh-show`? But we'd want to avoid accidentally triggering `mh-rmail` while using `mh-show`, for example).
I can't seem to find a Mail mode equivalent but for reading mail, instead of sending.
7890yuiop · 2022-10-04 02:49
Reading mail from *where*? (E.g. Which file formats do you need to support?)
whudwl · 2022-10-04 04:15
If your mails are stored locally (often done via offlineimap or mbsync), you can use mu4e or notmuch to view them.
blah1998z · 2022-10-04 04:21
Fair question; reading directly from IMAP. I have all the envelope info., the body, etc. Now I need to feed that info. in, manually, to a mode.
thetemp_ · 2022-10-04 04:40
Isn't that precisely what `rmail` *does*?
The components of an email system would be: Composing emails (the `mail` command), Retrieving emails (any of a number of emacs and non-emacs programs: `gnus`, offlineimap, mbsync, etc.), Reading emails (`gnus`, `rmail`, `mu4e`, `notmuch`, `wanderlust`, etc.). And in the last category, some form of filing is usually included and sometimes an indexed searching capability. I guess those extra capabilities are what you want to avoid?
Only problem I see with `rmail` is that it only supports the mbox local storage format. I think most people prefer Maildir these days.
7890yuiop · 2022-10-04 05:00
> reading directly from IMAP
That sounds like you're looking for a pretty fully-featured email client, sans anything to do with composing and sending?
> I have all the envelope info., the body, etc
But that sounds like you've *already* talked to the IMAP server via some separate process and fetched the message content.
If it's the latter, where is that data? Is it already in Emacs, ready to `insert` into a buffer?
blah1998z · 2022-10-04 05:05
So, as far as I understand it, `rmail` is expecting to read from somewhere, as it also plans to layout the mail which I have at my disposal.
I, however, have fetched my mail, myself; as data, not as files. So imagine I have `to`, `cc`, `subject`, and `body` saved in variables, at the moment. I, now, want to present this info. to the reader, ideally with a mode which already exists (so I don't have to handle creating such a mode myself, from scratch).
Like I mentioned, I don't think `rmail`'s "reading" functionality is so independent as to allow feeding the info. manually to it and then not trigger other elements of `rmail` from reading said E-mail with `rmail`.
blah1998z · 2022-10-04 05:16
>If it's the latter, where is that data? Is it already in Emacs, ready to
>
>insert
>
> into a buffer?
Yup! Exactly; except I don't consider myself remotely competant enough to write a mode like this myself (barely feel competant enough with what I'm attempting; but what's Emacs for if not trying fun new projects that likely won't go anywhere?).
So (if even feasible), I'd like to shell out actually displaying this data to an already existing mode.
Listing out E-mail headers and, say, having `C-a` jump not to the beginning of the line but to right before the colon? No idea how I would even begin to accomplish that. Have the bottom portion be an entirely different minor mode with particular keybindings and, maybe, render the body with `w3m` or `eww`? Not a clue.
But E-mail is *relatively* common so maybe a mode already exists with which to accomplish properly displaying all this data I have stored in variables? 'Hope that makes things a little more clear.
alcanost · 2022-10-04 13:46
> But E-mail is relatively common so maybe a mode already exists with which to accomplish properly displaying all this data I have stored in variables?
`message-mode`, if you already have your mail in text format?
blah1998z · 2022-10-04 15:55
I'd been wondering the same but, from everything I can find, looks like Message Mode is more for editing E-mail, rather than being able to just read it; I may've missed something, though.
alcanost · 2022-10-04 15:58
> looks like Message Mode is more for editing E-mail, rather than being able to just read it
Isn't reading email the same thing than editing it, but without touching the keyboard? Just put your buffer in RO mode, _et voilà_.
blah1998z · 2022-10-04 16:02
Hmm…; that's a…very fair point. Damn it, I like it. I'll give that a whirl, see if I run into anything either of us didn't think of. Thanks!
alcanost · 2022-10-04 16:18
My pleasure!
thetemp_ · 2022-10-04 16:59
Oh, I think I understand now. Just now, reviewing which built-in packages have rmail in the name, there is "rmailmm.el", which has a short description of "MIME decoding and display stuff for RMAIL". I imagine you might be able to call its functions directly, without necessarily invoking the whole Rmail enchilada.
That package requires another package called "mail-parse.el" which describes itself as "Interface functions for parsing mail" and doesn't seem to be specific to `rmail`.
Both packages are found in the "lisp/mail" directory of Emacs's source code, which holds a bunch of other mail-related libraries that might be of interest.
blah1998z · 2022-10-05 20:02
Damn, this is super cool! I'll have to try it out, to see, but there's a function called `rmail-mime-insert` that, while often triggered by functions that expect to be reading from `rmail` buffers, doesn't seem to handle much of anything else other than inserting a piece of mail into a buffer. It uses a Common-Lisp–style struct to represent the mail so I can, probably, just load one of those up with my data and go from there. Thanks so much!