* sending a buffer by mail
@ 2017-08-30 23:00 Jean-Christophe Helary
2017-08-30 23:16 ` Eric Abrahamsen
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Jean-Christophe Helary @ 2017-08-30 23:00 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: sending a buffer by mail
2017-08-30 23:00 sending a buffer by mail Jean-Christophe Helary
@ 2017-08-30 23:16 ` Eric Abrahamsen
2017-08-31 0:46 ` Jean-Christophe Helary
2017-08-31 0:38 ` Mario Castelán Castro
2017-09-07 21:24 ` Emanuel Berg
2 siblings, 1 reply; 12+ messages in thread
From: Eric Abrahamsen @ 2017-08-30 23:16 UTC (permalink / raw)
To: help-gnu-emacs
Jean-Christophe Helary <jean.christophe.helary@gmail.com> 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?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: sending a buffer by mail
2017-08-30 23:16 ` Eric Abrahamsen
@ 2017-08-31 0:46 ` Jean-Christophe Helary
2017-08-31 0:52 ` Eric Abrahamsen
0 siblings, 1 reply; 12+ messages in thread
From: Jean-Christophe Helary @ 2017-08-31 0:46 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
> On Aug 31, 2017, at 8:16, Eric Abrahamsen <eric@ericabrahamsen.net> wrote:
>
> Jean-Christophe Helary <jean.christophe.helary@gmail.com> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: sending a buffer by mail
2017-08-31 0:46 ` Jean-Christophe Helary
@ 2017-08-31 0:52 ` Eric Abrahamsen
2017-08-31 1:11 ` Eric Abrahamsen
0 siblings, 1 reply; 12+ messages in thread
From: Eric Abrahamsen @ 2017-08-31 0:52 UTC (permalink / raw)
To: help-gnu-emacs
Jean-Christophe Helary <jean.christophe.helary@gmail.com> writes:
>> On Aug 31, 2017, at 8:16, Eric Abrahamsen <eric@ericabrahamsen.net> wrote:
>>
>> Jean-Christophe Helary <jean.christophe.helary@gmail.com> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: sending a buffer by mail
2017-08-31 0:52 ` Eric Abrahamsen
@ 2017-08-31 1:11 ` Eric Abrahamsen
2017-08-31 1:55 ` John Mastro
0 siblings, 1 reply; 12+ messages in thread
From: Eric Abrahamsen @ 2017-08-31 1:11 UTC (permalink / raw)
To: help-gnu-emacs
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> Jean-Christophe Helary <jean.christophe.helary@gmail.com> writes:
>
>>> On Aug 31, 2017, at 8:16, Eric Abrahamsen <eric@ericabrahamsen.net> wrote:
>>>
>>> Jean-Christophe Helary <jean.christophe.helary@gmail.com> 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))))
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: sending a buffer by mail
2017-08-31 1:11 ` Eric Abrahamsen
@ 2017-08-31 1:55 ` John Mastro
2017-08-31 2:04 ` Eric Abrahamsen
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: John Mastro @ 2017-08-31 1:55 UTC (permalink / raw)
To: help-gnu-emacs@gnu.org; +Cc: Eric Abrahamsen
Eric Abrahamsen <eric@ericabrahamsen.net> 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))))
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: sending a buffer by mail
2017-08-31 1:55 ` John Mastro
@ 2017-08-31 2:04 ` Eric Abrahamsen
2017-08-31 4:43 ` Teemu Likonen
2017-08-31 4:54 ` Bob Newell
2 siblings, 0 replies; 12+ messages in thread
From: Eric Abrahamsen @ 2017-08-31 2:04 UTC (permalink / raw)
To: help-gnu-emacs
John Mastro <john.b.mastro@gmail.com> writes:
> Eric Abrahamsen <eric@ericabrahamsen.net> 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!
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: sending a buffer by mail
2017-08-31 1:55 ` John Mastro
2017-08-31 2:04 ` Eric Abrahamsen
@ 2017-08-31 4:43 ` Teemu Likonen
2017-09-21 13:05 ` Jean-Christophe Helary
2017-08-31 4:54 ` Bob Newell
2 siblings, 1 reply; 12+ messages in thread
From: Teemu Likonen @ 2017-08-31 4:43 UTC (permalink / raw)
To: John Mastro; +Cc: Eric Abrahamsen, help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 765 bytes --]
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 ///
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: sending a buffer by mail
2017-08-31 4:43 ` Teemu Likonen
@ 2017-09-21 13:05 ` Jean-Christophe Helary
0 siblings, 0 replies; 12+ messages in thread
From: Jean-Christophe Helary @ 2017-09-21 13:05 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
Belated thank you to all who replied and helped.
Jean-Christophe
> On Aug 31, 2017, at 13:43, Teemu Likonen <tlikonen@iki.fi> 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 ///
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: sending a buffer by mail
2017-08-31 1:55 ` John Mastro
2017-08-31 2:04 ` Eric Abrahamsen
2017-08-31 4:43 ` Teemu Likonen
@ 2017-08-31 4:54 ` Bob Newell
2 siblings, 0 replies; 12+ messages in thread
From: Bob Newell @ 2017-08-31 4:54 UTC (permalink / raw)
To: help-gnu-emacs@gnu.org
On Wed, Aug 30, 2017 at 3:55 PM, John Mastro <john.b.mastro@gmail.com> wrote:
> Eric Abrahamsen <eric@ericabrahamsen.net> 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.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: sending a buffer by mail
2017-08-30 23:00 sending a buffer by mail Jean-Christophe Helary
2017-08-30 23:16 ` Eric Abrahamsen
@ 2017-08-31 0:38 ` Mario Castelán Castro
2017-09-07 21:24 ` Emanuel Berg
2 siblings, 0 replies; 12+ messages in thread
From: Mario Castelán Castro @ 2017-08-31 0:38 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 434 bytes --]
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
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: sending a buffer by mail
2017-08-30 23:00 sending a buffer by mail Jean-Christophe Helary
2017-08-30 23:16 ` Eric Abrahamsen
2017-08-31 0:38 ` Mario Castelán Castro
@ 2017-09-07 21:24 ` Emanuel Berg
2 siblings, 0 replies; 12+ messages in thread
From: Emanuel Berg @ 2017-09-07 21:24 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2017-09-21 13:05 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-30 23:00 sending a buffer by mail Jean-Christophe Helary
2017-08-30 23:16 ` Eric Abrahamsen
2017-08-31 0:46 ` Jean-Christophe Helary
2017-08-31 0:52 ` Eric Abrahamsen
2017-08-31 1:11 ` Eric Abrahamsen
2017-08-31 1:55 ` John Mastro
2017-08-31 2:04 ` Eric Abrahamsen
2017-08-31 4:43 ` Teemu Likonen
2017-09-21 13:05 ` Jean-Christophe Helary
2017-08-31 4:54 ` Bob Newell
2017-08-31 0:38 ` Mario Castelán Castro
2017-09-07 21:24 ` Emanuel Berg
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 read-only IMAP folder(s) and NNTP newsgroup(s).