* Using Emacs as PS converter
@ 2014-12-01 15:05 Angelo Graziosi
2014-12-01 17:16 ` Doug Lewan
2014-12-01 17:52 ` Eli Zaretskii
0 siblings, 2 replies; 8+ messages in thread
From: Angelo Graziosi @ 2014-12-01 15:05 UTC (permalink / raw)
To: help-gnu-emacs
Out of curiosity, I wonder if one can use Emacs as a postscript
converter.. Suppose I have a file foo.txt. If I visit it and the
M-x ps-spool-buffer-with-faces
the result is in a *PostScript* buffer that I can save as foo.ps.
But what if one wants use that from command line o shell script?
I have tried this:
$ emacs --batch foo.txt -f ps-spool-buffer-with-faces --visit
\*PostScript\* -f save-buffer
Formatting... 0%
Collecting face information...
Formatting...100%
Formatting...done
Wrote /home/angelo/work/*PostScript*
but '*PostScript*' is saved empty...
$ ls -lrt
...
... 0 1 dic 15.54 *PostScript*
Where is the error?
TIA,
Angelo.
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: Using Emacs as PS converter
2014-12-01 15:05 Using Emacs as PS converter Angelo Graziosi
@ 2014-12-01 17:16 ` Doug Lewan
2014-12-01 17:34 ` Angelo Graziosi
2014-12-01 19:58 ` Angelo Graziosi
2014-12-01 17:52 ` Eli Zaretskii
1 sibling, 2 replies; 8+ messages in thread
From: Doug Lewan @ 2014-12-01 17:16 UTC (permalink / raw)
To: Angelo Graziosi, help-gnu-emacs@gnu.org
First, note the following in the documentation for ps-spool-buffer-with-faces:
This command works only if you are using
a window system, so it has a way to determine color values.
If you use --batch or run on a terminal, then there isn't a window system available as far as emacs can tell. Try "emacs --batch --eval='(message window-system)'" to see.
Next, emacs does a *lot* of things to start up, and the environment might not always be good for doing programming kinds of things on the command line.
For example, it's only in step 23 that a buffer is guaranteed to be selected, and that is /after/ it has handled the command line arguments (step 21). See the info for '(elisp) Startup Summary'.
To do anything sophisticated, you should probably really be doing it in lisp where you have real control. Even using --eval '(sample code)' on the command line would probably be more reliable. If you want to use emacs to support shell programming, then maybe starting it --daemon and using emacsclient is the way to go. (On the other hand, you would then affect your whole environment and that might complicate other things.)
--
,Doug
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224 or ext 4335
"This is a slow pup," he said continuing his ascent.
> -----Original Message-----
> Behalf Of Angelo Graziosi
> Sent: Monday, 2014 December 01 10:05
> Subject: Using Emacs as PS converter
>
> Out of curiosity, I wonder if one can use Emacs as a postscript
> converter.. Suppose I have a file foo.txt. If I visit it and the
> I have tried this:
>
> $ emacs --batch foo.txt -f ps-spool-buffer-with-faces --visit
> \*PostScript\* -f save-buffer
>
> Formatting... 0%
> Collecting face information...
> Formatting...100%
> Formatting...done
> Wrote /home/angelo/work/*PostScript*
>
>
> but '*PostScript*' is saved empty...
>
> $ ls -lrt
> ...
> ... 0 1 dic 15.54 *PostScript*
>
>
> Where is the error?
>
> TIA,
> Angelo.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Using Emacs as PS converter
2014-12-01 17:16 ` Doug Lewan
@ 2014-12-01 17:34 ` Angelo Graziosi
2014-12-01 19:58 ` Angelo Graziosi
1 sibling, 0 replies; 8+ messages in thread
From: Angelo Graziosi @ 2014-12-01 17:34 UTC (permalink / raw)
To: Doug Lewan, help-gnu-emacs@gnu.org
Ciao Doug, thanks for clarification.
Ciao,
Angelo.
Il 01/12/2014 18:16, Doug Lewan ha scritto:
> First, note the following in the documentation for ps-spool-buffer-with-faces:
> This command works only if you are using
> a window system, so it has a way to determine color values.
>
> If you use --batch or run on a terminal, then there isn't a window system available as far as emacs can tell. Try "emacs --batch --eval='(message window-system)'" to see.
>
> Next, emacs does a *lot* of things to start up, and the environment might not always be good for doing programming kinds of things on the command line.
>
> For example, it's only in step 23 that a buffer is guaranteed to be selected, and that is /after/ it has handled the command line arguments (step 21). See the info for '(elisp) Startup Summary'.
>
> To do anything sophisticated, you should probably really be doing it in lisp where you have real control. Even using --eval '(sample code)' on the command line would probably be more reliable. If you want to use emacs to support shell programming, then maybe starting it --daemon and using emacsclient is the way to go. (On the other hand, you would then affect your whole environment and that might complicate other things.)
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Using Emacs as PS converter
2014-12-01 15:05 Using Emacs as PS converter Angelo Graziosi
2014-12-01 17:16 ` Doug Lewan
@ 2014-12-01 17:52 ` Eli Zaretskii
1 sibling, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2014-12-01 17:52 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Mon, 01 Dec 2014 16:05:28 +0100
> From: Angelo Graziosi <angelo.graziosi@alice.it>
>
> Out of curiosity, I wonder if one can use Emacs as a postscript
> converter.. Suppose I have a file foo.txt. If I visit it and the
>
> M-x ps-spool-buffer-with-faces
>
> the result is in a *PostScript* buffer that I can save as foo.ps.
>
> But what if one wants use that from command line o shell script?
>
> I have tried this:
>
> $ emacs --batch foo.txt -f ps-spool-buffer-with-faces --visit
> \*PostScript\* -f save-buffer
>
> Formatting... 0%
> Collecting face information...
> Formatting...100%
> Formatting...done
> Wrote /home/angelo/work/*PostScript*
>
>
> but '*PostScript*' is saved empty...
>
> $ ls -lrt
> ...
> ... 0 1 dic 15.54 *PostScript*
>
>
> Where is the error?
>
> TIA,
> Angelo.
>
>
I don't know, but this minor variation works for me:
emacs -batch foo.c -f ps-spool-buffer-with-faces --eval "(progn (switch-to-buffer \"*PostScript*\") (write-file \"foo.ps\"))"
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Using Emacs as PS converter
2014-12-01 17:16 ` Doug Lewan
2014-12-01 17:34 ` Angelo Graziosi
@ 2014-12-01 19:58 ` Angelo Graziosi
2014-12-01 20:09 ` Eli Zaretskii
1 sibling, 1 reply; 8+ messages in thread
From: Angelo Graziosi @ 2014-12-01 19:58 UTC (permalink / raw)
To: help-gnu-emacs@gnu.org
Eli Zaretskii wrote:
> I don't know, but this minor variation works for me:
>
> emacs -batch foo.c -f ps-spool-buffer-with-faces --eval "(progn (switch-to-buffer \"*PostScript*\") (write-file \"foo.ps\"))"
Oh, yes it works! I notice only that foo.ps is black and white... :(
It has lost the syntax colors... sigh..
Thanks,
Angelo.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Using Emacs as PS converter
2014-12-01 19:58 ` Angelo Graziosi
@ 2014-12-01 20:09 ` Eli Zaretskii
0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2014-12-01 20:09 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Mon, 01 Dec 2014 20:58:54 +0100
> From: Angelo Graziosi <angelo.graziosi@alice.it>
>
> Eli Zaretskii wrote:
> > I don't know, but this minor variation works for me:
> >
> > emacs -batch foo.c -f ps-spool-buffer-with-faces --eval "(progn (switch-to-buffer \"*PostScript*\") (write-file \"foo.ps\"))"
>
> Oh, yes it works! I notice only that foo.ps is black and white... :(
>
> It has lost the syntax colors... sigh..
You need to define the ps-print faces, I think. I have something like
this in my .emacs, which works well with black-and-white PS printers:
(setq ps-bold-faces
'(font-lock-comment-face
font-lock-keyword-face
font-lock-builtin-face
font-lock-function-name-face
diff-hunk-header-face
diff-changed-face
diff-removed-face
diff-added-face))
(setq ps-italic-faces
'(font-lock-comment-face
font-lock-variable-name-face
font-lock-string-face
diff-header-face))
(setq ps-underlined-faces
'(font-lock-type-face
font-lock-reference-face
font-lock-builtin-face
diff-file-header-face
diff-function-face))
See the section "How Ps-Print Deals With Faces" in the ps-print.el
commentary for more about setting up faces for ps-print.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Using Emacs as PS converter
@ 2014-12-01 21:05 Angelo Graziosi
2014-12-02 3:32 ` Eli Zaretskii
0 siblings, 1 reply; 8+ messages in thread
From: Angelo Graziosi @ 2014-12-01 21:05 UTC (permalink / raw)
To: help-gnu-emacs@gnu.org
Eli Zaretskii wrote:
> You need to define the ps-print faces, I think. I have something like
> this in my .emacs, which works well with black-and-white PS printers:
> [...]
> See the section "How Ps-Print Deals With Faces" in the ps-print.el
> commentary for more about setting up faces for ps-print.
Hmm.. but when I use "M-x ps-spool-buffer-with-faces" from Emacs, the
postscript file *has* the syntax colors!
In other words:
$ emacs -Q
$ C-x C-f foo.c
foo.c has the syntax with colors (font-lock ON by default, right?)
After loading foo.c, do
M-x ps-spool-buffer-with-faces
and *PostScript* buffer is created. Switching to it (menu Buffers and
clicking on the item '*PostScript*'):
C-x C-w foo.ps
foo.ps has the syntax colors as foo.c when visited by Emacs.
Now if from command line I do:
emacs [-Q] -batch foo.c -f ps-spool-buffer-with-faces --eval "(progn
(switch-to-buffer \"*PostScript*\") (write-file \"foo.ps\"))"
(with or without the option -Q) it produces foo.ps in BW, *not* with
syntax colors.
Does it mean that one, to have foo.ps with syntax colors, when produced
from command lone as above, should setup .emacs as you suggested?
As profane, I would expect that *also* the above command line produces
foo.ps with syntax colors... Why not? After all, that command line
summarize in a single command all the steps I described above after
launching "emacs -Q"... or not?
Ciao,
Angelo.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Using Emacs as PS converter
2014-12-01 21:05 Angelo Graziosi
@ 2014-12-02 3:32 ` Eli Zaretskii
0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2014-12-02 3:32 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Mon, 01 Dec 2014 22:05:32 +0100
> From: Angelo Graziosi <angelo.graziosi@alice.it>
>
> Eli Zaretskii wrote:
> > You need to define the ps-print faces, I think. I have something like
> > this in my .emacs, which works well with black-and-white PS printers:
> > [...]
> > See the section "How Ps-Print Deals With Faces" in the ps-print.el
> > commentary for more about setting up faces for ps-print.
>
> Hmm.. but when I use "M-x ps-spool-buffer-with-faces" from Emacs, the
> postscript file *has* the syntax colors!
Because you are under window-system. In -batch, you aren't.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-12-02 3:32 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-01 15:05 Using Emacs as PS converter Angelo Graziosi
2014-12-01 17:16 ` Doug Lewan
2014-12-01 17:34 ` Angelo Graziosi
2014-12-01 19:58 ` Angelo Graziosi
2014-12-01 20:09 ` Eli Zaretskii
2014-12-01 17:52 ` Eli Zaretskii
-- strict thread matches above, loose matches on Subject: below --
2014-12-01 21:05 Angelo Graziosi
2014-12-02 3:32 ` Eli Zaretskii
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).