* How to pipe text or load a file directly into mail-mode?
@ 2006-05-03 11:29 Adam Funk
2006-05-03 14:26 ` Giorgos Keramidas
` (2 more replies)
0 siblings, 3 replies; 28+ messages in thread
From: Adam Funk @ 2006-05-03 11:29 UTC (permalink / raw)
I'd like the output of a Perl program to end up in an Emacs mail-mode
buffer, ready to proofread, edit and then send with C-c C-c. I don't
mind whether my program
1. pipes the output to an emacs command, or
2. saves the output in a temp file and opens it with an emacs command.
Which is easier for the emacs command to handle (I expect 2)?
What command-line arguments to emacs do I need for this to work?
Does the program's output (emacs's input) need to be formatted in the
normal way for a mail message (with a blank line after the headers) or
the way it shows up in the Emacs mail buffer (with "--text follows
this line--" after the headers)?
Thanks,
Adam
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-03 11:29 How to pipe text or load a file directly into mail-mode? Adam Funk
@ 2006-05-03 14:26 ` Giorgos Keramidas
2006-05-03 15:05 ` Adam Funk
2006-05-03 20:35 ` Ralf Fassel
2006-05-09 11:00 ` Adam Funk
2 siblings, 1 reply; 28+ messages in thread
From: Giorgos Keramidas @ 2006-05-03 14:26 UTC (permalink / raw)
On Wed, 3 May 2006 12:29:03 +0100, Adam Funk <a24061@yahoo.com> wrote:
> I'd like the output of a Perl program to end up in an Emacs mail-mode
> buffer, ready to proofread, edit and then send with C-c C-c. I don't
> mind whether my program
>
> 1. pipes the output to an emacs command, or
>
> 2. saves the output in a temp file and opens it with an emacs command.
One way to do this is:
- Start composing your message
- Then use:
C-u M-x shell-command RET perl /foo/script.pl RET
to run the Perl script.
This should put the output of the script in the mail buffer, starting at
the point location.
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-03 14:26 ` Giorgos Keramidas
@ 2006-05-03 15:05 ` Adam Funk
2006-05-03 18:16 ` Giorgos Keramidas
0 siblings, 1 reply; 28+ messages in thread
From: Adam Funk @ 2006-05-03 15:05 UTC (permalink / raw)
On 2006-05-03, Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
> On Wed, 3 May 2006 12:29:03 +0100, Adam Funk <a24061@yahoo.com> wrote:
>> I'd like the output of a Perl program to end up in an Emacs mail-mode
>> buffer, ready to proofread, edit and then send with C-c C-c. I don't
>> mind whether my program
>>
>> 1. pipes the output to an emacs command, or
>>
>> 2. saves the output in a temp file and opens it with an emacs command.
I forgot to make something clear: emacs is *not* running when the Perl
program starts. The Perl program generates the unedited message and
then launches emacs.
> One way to do this is:
>
> - Start composing your message
>
> - Then use:
>
> C-u M-x shell-command RET perl /foo/script.pl RET
>
> to run the Perl script.
>
> This should put the output of the script in the mail buffer, starting at
> the point location.
On the other hand, I'll see if I can do it this way.
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-03 15:05 ` Adam Funk
@ 2006-05-03 18:16 ` Giorgos Keramidas
2006-05-03 19:05 ` Adam Funk
0 siblings, 1 reply; 28+ messages in thread
From: Giorgos Keramidas @ 2006-05-03 18:16 UTC (permalink / raw)
On Wed, 3 May 2006 16:05:54 +0100, Adam Funk <a24061@yahoo.com> wrote:
> On 2006-05-03, Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
>> On Wed, 3 May 2006 12:29:03 +0100, Adam Funk <a24061@yahoo.com> wrote:
>>> I'd like the output of a Perl program to end up in an Emacs mail-mode
>>> buffer, ready to proofread, edit and then send with C-c C-c. I don't
>>> mind whether my program
>>>
>>> 1. pipes the output to an emacs command, or
>>>
>>> 2. saves the output in a temp file and opens it with an emacs command.
>
> I forgot to make something clear: emacs is *not* running when the Perl
> program starts. The Perl program generates the unedited message and
> then launches emacs.
Oh! I misunderstood you then. Sorry.
This is kind of backwards. I usually let Emacs start other programs as
inferior processes, instead of the other way around. Perhaps someone
more experienced with Emacs can help you with this (i.e. you could write
a function that can be called with:
perl script.pl | emacs --batch -f foo-function
and let `foo-function' read from the standard input stream. But I know
far too little to do that myself.
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-03 18:16 ` Giorgos Keramidas
@ 2006-05-03 19:05 ` Adam Funk
0 siblings, 0 replies; 28+ messages in thread
From: Adam Funk @ 2006-05-03 19:05 UTC (permalink / raw)
On 2006-05-03, Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
> On Wed, 3 May 2006 16:05:54 +0100, Adam Funk <a24061@yahoo.com> wrote:
>> On 2006-05-03, Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
>>> On Wed, 3 May 2006 12:29:03 +0100, Adam Funk <a24061@yahoo.com> wrote:
>>>> I'd like the output of a Perl program to end up in an Emacs mail-mode
>>>> buffer, ready to proofread, edit and then send with C-c C-c. I don't
>>>> mind whether my program
>>>>
>>>> 1. pipes the output to an emacs command, or
>>>>
>>>> 2. saves the output in a temp file and opens it with an emacs command.
>>
>> I forgot to make something clear: emacs is *not* running when the Perl
>> program starts. The Perl program generates the unedited message and
>> then launches emacs.
>
> Oh! I misunderstood you then. Sorry.
To me it seemed perfectly obvious what I meant, if you know what I
mean. That's why I get other people to proofread bigger things!
> This is kind of backwards. I usually let Emacs start other programs as
> inferior processes, instead of the other way around. Perhaps someone
> more experienced with Emacs can help you with this (i.e. you could write
> a function that can be called with:
>
> perl script.pl | emacs --batch -f foo-function
>
> and let `foo-function' read from the standard input stream. But I know
> far too little to do that myself.
I'll look at from that angle and see if I can come up with something
(but my elisp is really bad).
Thanks.
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-03 11:29 How to pipe text or load a file directly into mail-mode? Adam Funk
2006-05-03 14:26 ` Giorgos Keramidas
@ 2006-05-03 20:35 ` Ralf Fassel
2006-05-04 4:24 ` Giorgos Keramidas
2006-05-09 11:00 ` Adam Funk
2 siblings, 1 reply; 28+ messages in thread
From: Ralf Fassel @ 2006-05-03 20:35 UTC (permalink / raw)
* Adam Funk <a24061@yahoo.com>
| 2. saves the output in a temp file and opens it with an emacs
| command.
If you use some well-known extension like ".perl-mail", you could configure
your emacs to load those extensions as mail-mode files:
Add
(setq auto-mode-alist (cons '("\\.perl-mail\\'" . mail-mode) auto-mode-alist))
to your ~/.emacs.
Then save the temp file to say /tmp/xxx.perl-mail and fire up emacs on that
file via perls system()
system("emacs /tmp/xxx.perl-mail");
| Does the program's output (emacs's input) need to be formatted in
| the normal way for a mail message (with a blank line after the
| headers) or the way it shows up in the Emacs mail buffer (with
| "--text follows this line--" after the headers)?
The temp file would need to contain what a buffer created via C-x m
usually contains (i.e. the "--text follows this line--" marker and all
necessary headers (To, CC, ...)).
Untested, especially the usage of temp file names in /tmp.
R'
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-03 20:35 ` Ralf Fassel
@ 2006-05-04 4:24 ` Giorgos Keramidas
2006-05-04 10:49 ` Adam Funk
0 siblings, 1 reply; 28+ messages in thread
From: Giorgos Keramidas @ 2006-05-04 4:24 UTC (permalink / raw)
On Wed, 03 May 2006 22:35:03 +0200, Ralf Fassel <ralfixx@gmx.de> wrote:
> * Adam Funk <a24061@yahoo.com>
> | 2. saves the output in a temp file and opens it with an emacs
> | command.
>
> If you use some well-known extension like ".perl-mail", you
> could configure your emacs to load those extensions as
> mail-mode files:
>
> Add
>
> (setq auto-mode-alist
> (cons '("\\.perl-mail\\'" . mail-mode)
> auto-mode-alist))
>
> to your ~/.emacs.
>
> Then save the temp file to say /tmp/xxx.perl-mail and fire up
> emacs on that file via perls system()
>
> system("emacs /tmp/xxx.perl-mail");
Ah! This is a great idea. You don't even have to use a special
extension for this. Emacs parses command-line arguments in order,
so you can use:
system("emacs /tmp/xxxxxx -f mail-mode");
to bring up Emacs, open `/tmp/xxxxxx' and then run `mail-mode' :)
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-04 4:24 ` Giorgos Keramidas
@ 2006-05-04 10:49 ` Adam Funk
2006-05-04 13:16 ` Peter Dyballa
` (3 more replies)
0 siblings, 4 replies; 28+ messages in thread
From: Adam Funk @ 2006-05-04 10:49 UTC (permalink / raw)
[Adding comp.lang.perl.misc because this is now partly a Perl question
as well as an Emacs question. I hope this doesn't offend anyone.]
On 2006-05-04, Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
> Ah! This is a great idea. You don't even have to use a special
> extension for this. Emacs parses command-line arguments in order,
> so you can use:
>
> system("emacs /tmp/xxxxxx -f mail-mode");
>
> to bring up Emacs, open `/tmp/xxxxxx' and then run `mail-mode' :)
Doh! It's so easy to forget emacs's command-line processing.
Now I know why
$ emacs -f mail-mode foo.mail
didn't seem to do anything!
I think I'm on the right track now, but I'm having problems with the
fact that the Perl program reads STDIN, processes it and stores the
results in a temp file. When the Perl program gets to this line:
my $status = system('emacs', '-nw', $temp_file, '-f mail-mode');
Emacs produces this error:
standard input is not a tty
and doesn't run. If I add the --batch option to the emacs command,
emacs runs and quits (it doesn't come up interactively), so that's not
the solution.
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-04 10:49 ` Adam Funk
@ 2006-05-04 13:16 ` Peter Dyballa
2006-05-04 16:43 ` Ralf Fassel
` (2 subsequent siblings)
3 siblings, 0 replies; 28+ messages in thread
From: Peter Dyballa @ 2006-05-04 13:16 UTC (permalink / raw)
Cc: help-gnu-emacs
Am 04.05.2006 um 12:49 schrieb Adam Funk:
> my $status = system('emacs', '-nw', $temp_file, '-f mail-mode');
>
> Emacs produces this error:
>
> standard input is not a tty
'Emacs -nw' needs a terminal to run in. How about opening an xterm in
which this emacs runs? Or launching GNU Emacs as an iconised X client?
--
Greetings
Pete
To be is to do.
-- I. Kant
To do is to be.
-- A. Sartre
Yabba-Dabba-Doo!
-- F. Flintstone
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-04 10:49 ` Adam Funk
2006-05-04 13:16 ` Peter Dyballa
@ 2006-05-04 16:43 ` Ralf Fassel
2006-05-04 19:46 ` Adam Funk
2006-05-04 17:13 ` Paul Lalli
2006-05-05 21:39 ` John Sullivan
3 siblings, 1 reply; 28+ messages in thread
From: Ralf Fassel @ 2006-05-04 16:43 UTC (permalink / raw)
* Adam Funk <a24061@yahoo.com>
| ... but I'm having problems with the fact that the Perl program
| reads STDIN, processes it and stores the results in a temp file.
| When the Perl program gets to this line:
|
| my $status = system('emacs', '-nw', $temp_file, '-f mail-mode');
|
| Emacs produces this error:
|
| standard input is not a tty
|
| and doesn't run.
Well, via '-nw' you tell emacs to use the tty as input, but the tty is
already used by perl. Do you really need '-nw'? If you really need
-nw, you could try something along the lines of
system("emacs -nw $tempfile -f mail-mode </dev/tty");
I.e. use shell input redirection to the controlling tty. I have no
idea how robust that would be, and would rather get rid of the '-nw'.
R'
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-04 10:49 ` Adam Funk
2006-05-04 13:16 ` Peter Dyballa
2006-05-04 16:43 ` Ralf Fassel
@ 2006-05-04 17:13 ` Paul Lalli
2006-05-04 19:27 ` Adam Funk
2006-05-05 21:39 ` John Sullivan
3 siblings, 1 reply; 28+ messages in thread
From: Paul Lalli @ 2006-05-04 17:13 UTC (permalink / raw)
Adam Funk wrote:
> my $status = system('emacs', '-nw', $temp_file, '-f mail-mode');
>
> Emacs produces this error:
>
> standard input is not a tty
I have no idea what that error message means as far as emacs is
concerned, but your Perl system() command is wrong. That command is
calling the executable "emacs" with three arguments: '-nw',
$temp_file, and '-f mail-mode'. That last one is the problem. This is
no different than if you had called emacs on the command line,
surrounding '-f mail-mode' in quotes. You need -f and mail-mode to be
two separate arguments, not one argument:
my $status = system('emacs', '-nw', $temp_file, '-f', 'mail-mode');
Paul Lalli
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-04 17:13 ` Paul Lalli
@ 2006-05-04 19:27 ` Adam Funk
0 siblings, 0 replies; 28+ messages in thread
From: Adam Funk @ 2006-05-04 19:27 UTC (permalink / raw)
On 2006-05-04, Paul Lalli <mritty@gmail.com> wrote:
> Adam Funk wrote:
>
>> my $status = system('emacs', '-nw', $temp_file, '-f mail-mode');
>>
>> Emacs produces this error:
>>
>> standard input is not a tty
>
> I have no idea what that error message means as far as emacs is
> concerned, but your Perl system() command is wrong. That command is
> calling the executable "emacs" with three arguments: '-nw',
> $temp_file, and '-f mail-mode'. That last one is the problem. This is
> no different than if you had called emacs on the command line,
> surrounding '-f mail-mode' in quotes. You need -f and mail-mode to be
> two separate arguments, not one argument:
>
> my $status = system('emacs', '-nw', $temp_file, '-f', 'mail-mode');
Yes, that was a stupid typing & editing mistake. Thanks for pointing
it out.
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-04 16:43 ` Ralf Fassel
@ 2006-05-04 19:46 ` Adam Funk
2006-05-04 20:49 ` Giorgos Keramidas
2006-05-05 12:13 ` Ralf Fassel
0 siblings, 2 replies; 28+ messages in thread
From: Adam Funk @ 2006-05-04 19:46 UTC (permalink / raw)
On 2006-05-04, Ralf Fassel <ralfixx@gmx.de> wrote:
> Well, via '-nw' you tell emacs to use the tty as input, but the tty is
> already used by perl. Do you really need '-nw'? If you really need
> -nw, you could try something along the lines of
>
> system("emacs -nw $tempfile -f mail-mode </dev/tty");
>
> I.e. use shell input redirection to the controlling tty. I have no
> idea how robust that would be, and would rather get rid of the '-nw'.
Maybe it would help if I explained what I'm *really* trying to do. I
get usenet access by opening an xterm, logging into a server and
running slrn. I really like like slrn except that I can't customize
forwarding articles by e-mail the way I'd like, so I want to bind a
slrn key to a command that just pipes the current article to an
external program.
That external program I want to be a Perl script that puts some stuff
at the beginning of the article, prefaces it with my custom headers,
and then opens it in Emacs in mail-mode (so I can use my ~/.mailrc
aliases and all the other great stuff that Emacs does). Maybe I need
to store the article in a /tmp file then load it into the Perl
program, instead of piping it into the program's STDIN.
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-04 19:46 ` Adam Funk
@ 2006-05-04 20:49 ` Giorgos Keramidas
2006-05-05 8:36 ` Adam Funk
` (2 more replies)
2006-05-05 12:13 ` Ralf Fassel
1 sibling, 3 replies; 28+ messages in thread
From: Giorgos Keramidas @ 2006-05-04 20:49 UTC (permalink / raw)
On Thu, 4 May 2006 20:46:32 +0100, Adam Funk <a24061@yahoo.com> wrote:
> On 2006-05-04, Ralf Fassel <ralfixx@gmx.de> wrote:
>> Well, via '-nw' you tell emacs to use the tty as input, but the tty is
>> already used by perl. Do you really need '-nw'? If you really need
>> -nw, you could try something along the lines of
>>
>> system("emacs -nw $tempfile -f mail-mode </dev/tty");
>>
>> I.e. use shell input redirection to the controlling tty. I have no
>> idea how robust that would be, and would rather get rid of the '-nw'.
>
> Maybe it would help if I explained what I'm *really* trying to do. I
> get usenet access by opening an xterm, logging into a server and
> running slrn. I really like like slrn except that I can't customize
> forwarding articles by e-mail the way I'd like, so I want to bind a
> slrn key to a command that just pipes the current article to an
> external program.
>
> That external program I want to be a Perl script that puts some stuff
> at the beginning of the article, prefaces it with my custom headers,
> and then opens it in Emacs in mail-mode (so I can use my ~/.mailrc
> aliases and all the other great stuff that Emacs does). Maybe I need
> to store the article in a /tmp file then load it into the Perl
> program, instead of piping it into the program's STDIN.
You don't need Perl for that, I guess. It's fairly easy to write a
function in Elisp that does all you need and call it at Emacs startup,
i.e. a _very_ simplistic one could be:
| (defun slrn-setup-post (&optional filename)
| "Load a file and set things up for posting it as a `mail'
| message through Emacs."
| (interactive)
| (if filename
| (insert-filename))
| (beginning-of-buffer)
| (insert-string "From: foo@bar.example.net\n\n")
| (mail-mode))
Then you can set up slrn to use as its `$EDITOR' your Emacs wrapper
script, which would run:
emacs filename -f slrn-setup-post
No need for Perl if you have the full Elisp languaeg at your hands :)
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-04 20:49 ` Giorgos Keramidas
@ 2006-05-05 8:36 ` Adam Funk
2006-05-05 14:26 ` Giorgos Keramidas
2006-05-05 11:17 ` Reiner Steib
2006-05-05 13:54 ` Adam Funk
2 siblings, 1 reply; 28+ messages in thread
From: Adam Funk @ 2006-05-05 8:36 UTC (permalink / raw)
On 2006-05-04, Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
>> That external program I want to be a Perl script that puts some stuff
>> at the beginning of the article, prefaces it with my custom headers,
>> and then opens it in Emacs in mail-mode (so I can use my ~/.mailrc
>> aliases and all the other great stuff that Emacs does). Maybe I need
>> to store the article in a /tmp file then load it into the Perl
>> program, instead of piping it into the program's STDIN.
>
> You don't need Perl for that, I guess. It's fairly easy to write a
> function in Elisp that does all you need and call it at Emacs startup,
ITYM "easy for someone who knows how to write Elisp"!
> i.e. a _very_ simplistic one could be:
>
>| (defun slrn-setup-post (&optional filename)
>| "Load a file and set things up for posting it as a `mail'
>| message through Emacs."
>| (interactive)
>| (if filename
>| (insert-filename))
>| (beginning-of-buffer)
>| (insert-string "From: foo@bar.example.net\n\n")
>| (mail-mode))
>
> Then you can set up slrn to use as its `$EDITOR' your Emacs wrapper
> script, which would run:
>
> emacs filename -f slrn-setup-post
>
> No need for Perl if you have the full Elisp languaeg at your hands :)
But you've given me a lot to start with. Thanks!
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-04 20:49 ` Giorgos Keramidas
2006-05-05 8:36 ` Adam Funk
@ 2006-05-05 11:17 ` Reiner Steib
2006-05-05 13:54 ` Adam Funk
2 siblings, 0 replies; 28+ messages in thread
From: Reiner Steib @ 2006-05-05 11:17 UTC (permalink / raw)
On Thu, May 04 2006, Giorgos Keramidas wrote:
> | (defun slrn-setup-post (&optional filename)
> | "Load a file and set things up for posting it as a `mail'
> | message through Emacs."
> | (interactive)
> | (if filename
> | (insert-filename))
> | (beginning-of-buffer)
> | (insert-string "From: foo@bar.example.net\n\n")
> | (mail-mode))
I'd suggest to set the buffer in mail mode first and then use the
predefined functions like `mail-insert-from-field', `mail-to', ...
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-04 19:46 ` Adam Funk
2006-05-04 20:49 ` Giorgos Keramidas
@ 2006-05-05 12:13 ` Ralf Fassel
1 sibling, 0 replies; 28+ messages in thread
From: Ralf Fassel @ 2006-05-05 12:13 UTC (permalink / raw)
* Adam Funk <a24061@yahoo.com>
| I get usenet access by opening an xterm, logging into a server and
| running slrn.
If you use ssh to log in, you could forward the X11 connection to your
local system and omit the -nw. Just use ssh -X to initiate the
connection which should take care of the necessary environment
settings.
Or simply use emacs instead of perl to set up the mail buffer as
others suggested.
R'
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-04 20:49 ` Giorgos Keramidas
2006-05-05 8:36 ` Adam Funk
2006-05-05 11:17 ` Reiner Steib
@ 2006-05-05 13:54 ` Adam Funk
2 siblings, 0 replies; 28+ messages in thread
From: Adam Funk @ 2006-05-05 13:54 UTC (permalink / raw)
On 2006-05-04, Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
>> That external program I want to be a Perl script that puts some stuff
>> at the beginning of the article, prefaces it with my custom headers,
>> and then opens it in Emacs in mail-mode (so I can use my ~/.mailrc
>> aliases and all the other great stuff that Emacs does). Maybe I need
>> to store the article in a /tmp file then load it into the Perl
>> program, instead of piping it into the program's STDIN.
>
> You don't need Perl for that, I guess. It's fairly easy to write a
> function in Elisp that does all you need and call it at Emacs startup,
> i.e. a _very_ simplistic one could be:
This would require the input to be stored in a /tmp file (not being
piped in), right?
> No need for Perl if you have the full Elisp languaeg at your hands :)
There's not much elisp in my brain, however!
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-05 8:36 ` Adam Funk
@ 2006-05-05 14:26 ` Giorgos Keramidas
0 siblings, 0 replies; 28+ messages in thread
From: Giorgos Keramidas @ 2006-05-05 14:26 UTC (permalink / raw)
On Fri, 5 May 2006 09:36:24 +0100, Adam Funk <a24061@yahoo.com> wrote:
> On 2006-05-04, Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
>>> That external program I want to be a Perl script that puts some stuff
>>> at the beginning of the article, prefaces it with my custom headers,
>>> and then opens it in Emacs in mail-mode (so I can use my ~/.mailrc
>>> aliases and all the other great stuff that Emacs does). Maybe I need
>>> to store the article in a /tmp file then load it into the Perl
>>> program, instead of piping it into the program's STDIN.
>>
>> You don't need Perl for that, I guess. It's fairly easy to write a
>> function in Elisp that does all you need and call it at Emacs startup,
>
> ITYM "easy for someone who knows how to write Elisp"!
On Fri, 5 May 2006 14:54:06 +0100, Adam Funk <a24061@yahoo.com> wrote:
> This would require the input to be stored in a /tmp file (not being
> piped in), right?
Yes, this would make sense, I guess. It will probably be a lot easier
to write an Elisp function if you don't have to worry about how to slurp
in the file, I think.
>> No need for Perl if you have the full Elisp languaeg at your hands :)
>
> There's not much elisp in my brain, however!
Same here, but I'm always learning more :)
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-04 10:49 ` Adam Funk
` (2 preceding siblings ...)
2006-05-04 17:13 ` Paul Lalli
@ 2006-05-05 21:39 ` John Sullivan
3 siblings, 0 replies; 28+ messages in thread
From: John Sullivan @ 2006-05-05 21:39 UTC (permalink / raw)
Adam Funk <a24061@yahoo.com> writes:
> and doesn't run. If I add the --batch option to the emacs command,
> emacs runs and quits (it doesn't come up interactively), so that's not
> the solution.
I know you said that emacs wasn't already running, but you might want to
rethink that. You can have a single emacs process running as a server, and (if
you have emacs from CVS) use 'emacsclient --eval' to connect to it.
--
-John Sullivan
-http://www.wjsullivan.net
-GPG Key: AE8600B6
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-03 11:29 How to pipe text or load a file directly into mail-mode? Adam Funk
2006-05-03 14:26 ` Giorgos Keramidas
2006-05-03 20:35 ` Ralf Fassel
@ 2006-05-09 11:00 ` Adam Funk
2006-05-09 11:48 ` Ralf Fassel
2 siblings, 1 reply; 28+ messages in thread
From: Adam Funk @ 2006-05-09 11:00 UTC (permalink / raw)
I now have most of this working the way I want, except for launching
emacs in mail-mode. The Perl program saves its data in a file named
$edit_file (which ends with the suffix ".mail") and calls
$status = system('emacs', '-nw', $edit_file, '-f', ' mail-mode');
which is equivalent to
emacs -nw $FILENAME -f mail-mode
on the command-line.
This launches Emacs with the correct file open, but it says "Mail
(Fundamental)" on the status line and "Symbol's function definition is
void: \ mail-mode" in the minibuffer.
If I then hit M-x mail-mode, it then says "Mail (Mail MC-w Fill)" on
the status line and "Loading sendmail...done" in the minibuffer, and
everything works correctly.
What else do I need to do to get mail-mode to come up initially?
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-09 11:00 ` Adam Funk
@ 2006-05-09 11:48 ` Ralf Fassel
2006-05-09 12:15 ` Adam Funk
2006-05-09 14:16 ` Adam Funk
0 siblings, 2 replies; 28+ messages in thread
From: Ralf Fassel @ 2006-05-09 11:48 UTC (permalink / raw)
* Adam Funk <a24061@yahoo.com>
| $status = system('emacs', '-nw', $edit_file, '-f', ' mail-mode');
--<snip-snip>--
| and "Symbol's function definition is void: \ mail-mode" in the
Get rid of the leading space in the last argument of the system()
invocation:
' mail-mode'
=>
'mail-mode'
R'
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-09 11:48 ` Ralf Fassel
@ 2006-05-09 12:15 ` Adam Funk
2006-05-09 14:16 ` Adam Funk
1 sibling, 0 replies; 28+ messages in thread
From: Adam Funk @ 2006-05-09 12:15 UTC (permalink / raw)
On 2006-05-09, Ralf Fassel <ralfixx@gmx.de> wrote:
> * Adam Funk <a24061@yahoo.com>
>| $status = system('emacs', '-nw', $edit_file, '-f', ' mail-mode');
> --<snip-snip>--
>| and "Symbol's function definition is void: \ mail-mode" in the
>
> Get rid of the leading space in the last argument of the system()
> invocation:
> ' mail-mode'
>=>
> 'mail-mode'
Exactly, thanks!
(That was an embarrassing editing mistake not to notice.)
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-09 11:48 ` Ralf Fassel
2006-05-09 12:15 ` Adam Funk
@ 2006-05-09 14:16 ` Adam Funk
2006-05-09 14:30 ` Ralf Fassel
1 sibling, 1 reply; 28+ messages in thread
From: Adam Funk @ 2006-05-09 14:16 UTC (permalink / raw)
On 2006-05-09, Ralf Fassel <ralfixx@gmx.de> wrote:
> * Adam Funk <a24061@yahoo.com>
>| $status = system('emacs', '-nw', $edit_file, '-f', ' mail-mode');
> --<snip-snip>--
>| and "Symbol's function definition is void: \ mail-mode" in the
>
> Get rid of the leading space in the last argument of the system()
> invocation:
> ' mail-mode'
>=>
> 'mail-mode'
I think I have just one more question!
Any idea why the expand-mail-aliases command isn't available when
emacs opens the file and goes into mail-mode?
The aliases get expanded when the mail is sent with C-c C-c, but it's
impossible to check them before that point.
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-09 14:16 ` Adam Funk
@ 2006-05-09 14:30 ` Ralf Fassel
2006-05-10 8:23 ` Adam Funk
0 siblings, 1 reply; 28+ messages in thread
From: Ralf Fassel @ 2006-05-09 14:30 UTC (permalink / raw)
* Adam Funk <a24061@yahoo.com>
| Any idea why the expand-mail-aliases command isn't available when
| emacs opens the file and goes into mail-mode?
My emacs online manual contains the following under 'Mail Aliases':
Normally, Emacs expands aliases when you send the message. You do
not need to expand mail aliases before sending the message, but
you can expand them if you want to see where the mail will
actually go. To do this, use the command `M-x
expand-mail-aliases'; it expands all mail aliases currently
present in the mail headers that hold addresses.
If you like, you can have mail aliases expand as abbrevs, as soon
as you type them in (*note Abbrevs::). To enable this feature,
execute the following:
(add-hook 'mail-mode-hook 'mail-abbrevs-setup)
Or do you mean you get 'no-such-command' when trying
M-x expand-mail-aliases?
R'
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-09 14:30 ` Ralf Fassel
@ 2006-05-10 8:23 ` Adam Funk
2006-05-10 12:11 ` Ralf Fassel
0 siblings, 1 reply; 28+ messages in thread
From: Adam Funk @ 2006-05-10 8:23 UTC (permalink / raw)
On 2006-05-09, Ralf Fassel <ralfixx@gmx.de> wrote:
> If you like, you can have mail aliases expand as abbrevs, as soon
> as you type them in (*note Abbrevs::). To enable this feature,
> execute the following:
> (add-hook 'mail-mode-hook 'mail-abbrevs-setup)
I didn't know about this feature -- thanks.
> Or do you mean you get 'no-such-command' when trying
> M-x expand-mail-aliases?
I get "[no match]" when I get to "expand-m" or type any more of it
than that.
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-10 8:23 ` Adam Funk
@ 2006-05-10 12:11 ` Ralf Fassel
2006-05-10 12:22 ` Adam Funk
0 siblings, 1 reply; 28+ messages in thread
From: Ralf Fassel @ 2006-05-10 12:11 UTC (permalink / raw)
* Adam Funk <a24061@yahoo.com>
| > (add-hook 'mail-mode-hook 'mail-abbrevs-setup)
|
| I didn't know about this feature -- thanks.
Does this solve the problem?
| I get "[no match]" when I get to "expand-m" or type any more of it
| than that.
This indicates that the file which defines the function has not been
loaded at that time, and the function is not flagged as auto-loadable.
Most probably invoking C-c C-c loads additional packages which then
define the function. If the above add-hook does not solve the
problem, you can try to find out which library file provides the
functionality (describe-function should tell you which elisp file
defines the function) and load it manually in your .emacs.
Eg, my emacs-21 has
M-x describe-function expand-mail-aliases
=> expand-mail-aliases is an interactive compiled Lisp function in `mailalias'.
M-x locate-library mailalias
=> Library is file /software/emacs/21.3/share/emacs/21.3/lisp/mail/mailalias.el.gz
Inspecting the file shows that it has a
(provide 'mailalias)
So I guess that adding
(require 'mailalias)
to your .emacs could do the trick.
R'
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: How to pipe text or load a file directly into mail-mode?
2006-05-10 12:11 ` Ralf Fassel
@ 2006-05-10 12:22 ` Adam Funk
0 siblings, 0 replies; 28+ messages in thread
From: Adam Funk @ 2006-05-10 12:22 UTC (permalink / raw)
On 2006-05-10, Ralf Fassel <ralfixx@gmx.de> wrote:
> * Adam Funk <a24061@yahoo.com>
>| > (add-hook 'mail-mode-hook 'mail-abbrevs-setup)
>|
>| I didn't know about this feature -- thanks.
>
> Does this solve the problem?
It's even better than that!
Thanks very much.
^ permalink raw reply [flat|nested] 28+ messages in thread
end of thread, other threads:[~2006-05-10 12:22 UTC | newest]
Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-03 11:29 How to pipe text or load a file directly into mail-mode? Adam Funk
2006-05-03 14:26 ` Giorgos Keramidas
2006-05-03 15:05 ` Adam Funk
2006-05-03 18:16 ` Giorgos Keramidas
2006-05-03 19:05 ` Adam Funk
2006-05-03 20:35 ` Ralf Fassel
2006-05-04 4:24 ` Giorgos Keramidas
2006-05-04 10:49 ` Adam Funk
2006-05-04 13:16 ` Peter Dyballa
2006-05-04 16:43 ` Ralf Fassel
2006-05-04 19:46 ` Adam Funk
2006-05-04 20:49 ` Giorgos Keramidas
2006-05-05 8:36 ` Adam Funk
2006-05-05 14:26 ` Giorgos Keramidas
2006-05-05 11:17 ` Reiner Steib
2006-05-05 13:54 ` Adam Funk
2006-05-05 12:13 ` Ralf Fassel
2006-05-04 17:13 ` Paul Lalli
2006-05-04 19:27 ` Adam Funk
2006-05-05 21:39 ` John Sullivan
2006-05-09 11:00 ` Adam Funk
2006-05-09 11:48 ` Ralf Fassel
2006-05-09 12:15 ` Adam Funk
2006-05-09 14:16 ` Adam Funk
2006-05-09 14:30 ` Ralf Fassel
2006-05-10 8:23 ` Adam Funk
2006-05-10 12:11 ` Ralf Fassel
2006-05-10 12:22 ` Adam Funk
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).