sending a buffer by mail

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

sending a buffer by mail

Jean-Christophe Helary
c-x m creates an empty mail buffer, but say I have a buffer that I need to send by mail, what magic command would do the trick?

Jean-Christophe
Reply | Threaded
Open this post in threaded view
|

Re: sending a buffer by mail

Eric Abrahamsen-2
Jean-Christophe Helary <[hidden email]> writes:

> c-x m creates an empty mail buffer, but say I have a buffer that I need to send by mail, what magic command would do the trick?

M-x insert-buffer?


Reply | Threaded
Open this post in threaded view
|

Re: sending a buffer by mail

Mario Castelán Castro-2
In reply to this post by Jean-Christophe Helary
On 30/08/17 18:00, Jean-Christophe Helary wrote:
> c-x m creates an empty mail buffer, but say I have a buffer that I need to send by mail, what magic command would do the trick?
>
> Jean-Christophe

I do not use GNU Emacs for mail, but you can simply yank the text you
want to send in the mail buffer.

--
Do not eat animals; respect them as you respect people.
https://duckduckgo.com/?q=how+to+(become+OR+eat)+vegan


signature.asc (235 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: sending a buffer by mail

Jean-Christophe Helary
In reply to this post by Eric Abrahamsen-2

> On Aug 31, 2017, at 8:16, Eric Abrahamsen <[hidden email]> wrote:
>
> Jean-Christophe Helary <[hidden email]> writes:
>
>> c-x m creates an empty mail buffer, but say I have a buffer that I need to send by mail, what magic command would do the trick?
>
> M-x insert-buffer?

No. I'm thinking more of something like "send-buffer-as-mail" so that I can do all my editing in the buffer and the command puts all that into a mail and I'm done.

Jean-Christophe
Reply | Threaded
Open this post in threaded view
|

Re: sending a buffer by mail

Eric Abrahamsen-2
Jean-Christophe Helary <[hidden email]> writes:

>> On Aug 31, 2017, at 8:16, Eric Abrahamsen <[hidden email]> wrote:
>>
>> Jean-Christophe Helary <[hidden email]> writes:
>>
>>> c-x m creates an empty mail buffer, but say I have a buffer that I need to send by mail, what magic command would do the trick?
>>
>> M-x insert-buffer?
>
> No. I'm thinking more of something like "send-buffer-as-mail" so that I can do all my editing in the buffer and the command puts all that into a mail and I'm done.

Well, that sounds like a very thin wrapper around insert-buffer:

(defun send-buffer-as-mail ()
  (interactive)
  (let ((str (buffer-string)))
    (compose-mail)
    (message-goto-body)
    (insert str)))

That's pretty much exactly what you'd get if you ran "C-x m", "M-x
insert-buffer", [choose buffer], "<RET>".

Alternately, there are a few functions that do this from Org mode, so
you can have nice structured text editing, and then email it.

Eric


Reply | Threaded
Open this post in threaded view
|

Re: sending a buffer by mail

Eric Abrahamsen-2
Eric Abrahamsen <[hidden email]> writes:

> Jean-Christophe Helary <[hidden email]> writes:
>
>>> On Aug 31, 2017, at 8:16, Eric Abrahamsen <[hidden email]> wrote:
>>>
>>> Jean-Christophe Helary <[hidden email]> writes:
>>>
>>>> c-x m creates an empty mail buffer, but say I have a buffer that I need to send by mail, what magic command would do the trick?
>>>
>>> M-x insert-buffer?
>>
>> No. I'm thinking more of something like "send-buffer-as-mail" so that I can do all my editing in the buffer and the command puts all that into a mail and I'm done.
>
> Well, that sounds like a very thin wrapper around insert-buffer:
>
> (defun send-buffer-as-mail ()
>   (interactive)
>   (let ((str (buffer-string)))
>     (compose-mail)
>     (message-goto-body)
>     (insert str)))

This will be nicer:

(defun send-buffer-as-mail ()
  (interactive)
  (let ((str (buffer-string)))
    (compose-mail)
    (save-excursion
      (message-goto-body)
      (insert str))))


Reply | Threaded
Open this post in threaded view
|

Re: sending a buffer by mail

John Mastro
Eric Abrahamsen <[hidden email]> wrote:

>> Well, that sounds like a very thin wrapper around insert-buffer:
>>
>> (defun send-buffer-as-mail ()
>>   (interactive)
>>   (let ((str (buffer-string)))
>>     (compose-mail)
>>     (message-goto-body)
>>     (insert str)))
>
> This will be nicer:
>
> (defun send-buffer-as-mail ()
>   (interactive)
>   (let ((str (buffer-string)))
>     (compose-mail)
>     (save-excursion
>       (message-goto-body)
>       (insert str))))

The difference is likely irrelevant, but you can still use
`insert-buffer' rather than consing a string of the buffer's contents:

(defun send-buffer-as-mail ()
  (interactive)
  (let ((buf (current-buffer)))
    (compose-mail)
    (save-excursion
      (message-goto-body)
      (insert-buffer buf))))

Reply | Threaded
Open this post in threaded view
|

Re: sending a buffer by mail

Eric Abrahamsen-2
John Mastro <[hidden email]> writes:

> Eric Abrahamsen <[hidden email]> wrote:
>>> Well, that sounds like a very thin wrapper around insert-buffer:
>>>
>>> (defun send-buffer-as-mail ()
>>>   (interactive)
>>>   (let ((str (buffer-string)))
>>>     (compose-mail)
>>>     (message-goto-body)
>>>     (insert str)))
>>
>> This will be nicer:
>>
>> (defun send-buffer-as-mail ()
>>   (interactive)
>>   (let ((str (buffer-string)))
>>     (compose-mail)
>>     (save-excursion
>>       (message-goto-body)
>>       (insert str))))
>
> The difference is likely irrelevant, but you can still use
> `insert-buffer' rather than consing a string of the buffer's contents:
>
> (defun send-buffer-as-mail ()
>   (interactive)
>   (let ((buf (current-buffer)))
>     (compose-mail)
>     (save-excursion
>       (message-goto-body)
>       (insert-buffer buf))))

insert-buffer is still the way to go!


Reply | Threaded
Open this post in threaded view
|

Re: sending a buffer by mail

Teemu Likonen-2
In reply to this post by John Mastro
John Mastro [2017-08-30 18:55:47-07] wrote:

> The difference is likely irrelevant, but you can still use
> `insert-buffer' rather than consing a string of the buffer's contents:
>
> (defun send-buffer-as-mail ()
>   (interactive)
>   (let ((buf (current-buffer)))
>     (compose-mail)
>     (save-excursion
>       (message-goto-body)
>       (insert-buffer buf))))
If you are going to use function message-goto-body I think it's a good
idea to ensure that compose-mail will use message-mode.

    (let ((mail-user-agent 'message-user-agent) ; or gnus-user-agent
          ...)
      (compose-mail)
      ...)

--
/// Teemu Likonen   - .-..   <https://keybase.io/tlikonen> //
// PGP: 4E10 55DC 84E9 DFF6 13D7 8557 719D 69D3 2453 9450 ///

signature.asc (497 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: sending a buffer by mail

Bob Newell
In reply to this post by John Mastro
On Wed, Aug 30, 2017 at 3:55 PM, John Mastro <[hidden email]> wrote:
> Eric Abrahamsen <[hidden email]> wrote:
>>> Well, that sounds like a very thin wrapper around insert-buffer:
>>>

> (defun send-buffer-as-mail ()
>   (interactive)
>   (let ((buf (current-buffer)))
>     (compose-mail)
>     (save-excursion
>       (message-goto-body)
>       (insert-buffer buf))))
>

Quite nice, I'll add that to my startup.

--
Bob Newell
Honolulu, Hawai`i

Sent via Linux Mint 17.

Reply | Threaded
Open this post in threaded view
|

Re: sending a buffer by mail

Emanuel Berg-4
In reply to this post by Jean-Christophe Helary
Jean-Christophe Helary wrote:

> c-x m creates an empty mail buffer, but say
> I have a buffer that I need to send by mail,
> what magic command would do the trick?

You can send mail programmatically and in this
case it would amount to combining the below
code with a function that retrieves the buffer
contents, `buffer-string', perhaps?

But I suspect your use case is better benefited
from just opening a buffer with whatever
command you fancy for that - I use

    (gnus-post-news 'post "")

- and then simply yank the buffer into it!

But here is the code anyway:

(require 'cl-lib)
(require 'gnus-msg)
(require 'message)

(defun mail-to-many (to subject body)
  (cl-dolist (this-to to)
    (gnus-post-news 'post "")
    (message-goto-to)          (insert this-to)
    (message-goto-subject)     (insert subject)
    (message-goto-body)        (insert body)
    (message-send-and-exit) ))

Source: http://user.it.uu.se/~embe8573/emacs-init/gnus/mail-to-many.el

--
underground experts united
http://user.it.uu.se/~embe8573


Reply | Threaded
Open this post in threaded view
|

Re: sending a buffer by mail

Jean-Christophe Helary
In reply to this post by Teemu Likonen-2
Belated thank you to all who replied and helped.

Jean-Christophe

> On Aug 31, 2017, at 13:43, Teemu Likonen <[hidden email]> wrote:
>
> John Mastro [2017-08-30 18:55:47-07] wrote:
>
>> The difference is likely irrelevant, but you can still use
>> `insert-buffer' rather than consing a string of the buffer's contents:
>>
>> (defun send-buffer-as-mail ()
>>  (interactive)
>>  (let ((buf (current-buffer)))
>>    (compose-mail)
>>    (save-excursion
>>      (message-goto-body)
>>      (insert-buffer buf))))
>
> If you are going to use function message-goto-body I think it's a good
> idea to ensure that compose-mail will use message-mode.
>
>    (let ((mail-user-agent 'message-user-agent) ; or gnus-user-agent
>          ...)
>      (compose-mail)
>      ...)
>
> --
> /// Teemu Likonen   - .-..   <https://keybase.io/tlikonen> //
> // PGP: 4E10 55DC 84E9 DFF6 13D7 8557 719D 69D3 2453 9450 ///