Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #3254 > unrolled thread
| Started by | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| First post | 2018-04-22 05:18 -0700 |
| Last post | 2018-06-06 14:27 -0700 |
| Articles | 5 — 3 participants |
Back to article view | Back to comp.lang.postscript
Which code editor? jdaw1 <jdawiseman@gmail.com> - 2018-04-22 05:18 -0700
Re: Which code editor? luser droog <luser.droog@gmail.com> - 2018-04-23 17:29 -0700
Re: Which code editor? Markus Triska <triska@metalevel.at> - 2018-06-09 18:03 +0200
Re: Which code editor? Markus Triska <triska@metalevel.at> - 2018-05-29 21:31 +0200
Re: Which code editor? luser droog <luser.droog@gmail.com> - 2018-06-06 14:27 -0700
| From | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| Date | 2018-04-22 05:18 -0700 |
| Subject | Which code editor? |
| Message-ID | <f2cafb21-500d-42dc-86d5-6836371fece8@googlegroups.com> |
With which code editor do you write PostScript? For me it used to be Alpha, but maintenance of that ceased a while ago, so is now Sublime Text. (I ought to make a key press for ‘compile via GhostScript’ and another for ‘compile via Distiller’, but don’t know how — help gratefully received.)
[toc] | [next] | [standalone]
| From | luser droog <luser.droog@gmail.com> |
|---|---|
| Date | 2018-04-23 17:29 -0700 |
| Message-ID | <34f17058-49aa-42f4-b9ce-9385e01d1244@googlegroups.com> |
| In reply to | #3254 |
On Sunday, April 22, 2018 at 7:18:58 AM UTC-5, jdaw1 wrote:
> With which code editor do you write PostScript?
>
> For me it used to be Alpha, but maintenance of that ceased a while ago, so is now Sublime Text. (I ought to make a key press for ‘compile via GhostScript’ and another for ‘compile via Distiller’, but don’t know how — help gratefully received.)
I was a longtime user of vi/vim/gvim but recently took the plunge into
emacs at the strong urging of a friend. In vi you can type
:!gs %
followed by Return to run gs against the current file. You can make macros
to do this (because of course, they can do whatever). But I used macros so
rarely that I've forgotten the syntax. You can also do stuff like capture
the output and paste the results right back into the file.
So if I wanted to check some value from the stack, I can insert
dup ==
some where in the source, find (or create) a blank line and do
!!gs %
or even
!!gs % | sed 's/^/\%'
to add % to the start of each line before pasting it back into
the file.
Emacs has much the same ability, but I now use a macro which runs
'make' in the directory of the current file. So I now don't have
to type the filename or even vi's % shortcut if I add the file
to the makefile.
For example, I'm currently working on some postscript code to
produce pdf output. So I have this makefile in the same directory
with my postscript code (and several sample documents for testing).
my PDF writer Makefile:
OUTPUTS= \
dancingmen.pdf \
printdata.pdf \
teamath.pdf \
hugofrac.pdf
it: all
%.pdf: %.ps pw.ps
echo quit | \
gsnd -q -dNOSAFER pw.ps $< | \
cat > $@
identify $@
all: $(OUTPUTS)
So with this ./Makefile in the same directory, I can type
^x^m in emacs and it runs the code to produce the 4 outputs that
the "all" rule depends on.
For your case of wanting to use two different paths to create
the same kind of output file might require some slight of hand
with the makefile rules. My first thought is to briefly have
either the distiller or gs rule make a different extension and
then change the extension later.
Or (duh) you could easily make two different named rules and not
use pattern-matching or dependency analysis at all. You can also
use make to organize a series of shell calls.
distiller:
<TAB>acrowhatever other arguments
gs:
<TAB>gswin32c -sOutputFile=out.pdf -sDEVICE=pdfwrite in.ps
Then 'make distiller' or 'make gs' become shortcuts to the
longer commands. Even if you don't go with emacs, I commend
the makefile approach for organizing project builds. It can
get complicated, like everything else. But it can also be
done rather simply and it can help a lot.
[toc] | [prev] | [next] | [standalone]
| From | Markus Triska <triska@metalevel.at> |
|---|---|
| Date | 2018-06-09 18:03 +0200 |
| Message-ID | <m2muw454me.fsf@metalevel.at> |
| In reply to | #3255 |
luser droog <luser.droog@gmail.com> writes:
> some where in the source, find (or create) a blank line and do
>
> !!gs %
>
> or even
>
> !!gs % | sed 's/^/\%'
>
> to add % to the start of each line before pasting it back into
> the file.
Here are two small Emacs definitions that give you comparable
functionality in Emacs:
(defun run-region-and-insert-gs-output ()
(interactive)
(let* ((start (if (and transient-mark-mode mark-active)
(region-beginning) (point-min)))
(end (if (and transient-mark-mode mark-active)
(region-end) (point-max)))
(str (buffer-substring-no-properties start end)))
(let ((proc (start-process "ghostscript" nil "gs" "-q" "-dNOPROMPT")))
(set-process-filter proc 'gs-output-filter)
(process-send-string proc str))))
(defun gs-output-filter (proc str)
(insert str))
It should be reasonably clear how to use other PostScript interpreters.
You can add this to your ~/.emacs, and bind it (for example) to F10
with:
(global-set-key [f10] 'run-region-and-insert-gs-output)
When you then select for example:
1 2 =
and press F10, you get:
1 2 =
2
i.e., the process's output is inserted at point. If the region is not
active and you press F10, then the whole buffer is run.
I hope this serves as a useful starting point for more elaborate
definitions. In general, to reason about process output in Emacs, a good
approach is to first insert everything into a dedicated buffer that
keeps track of everything the process emits. In this buffer, you can
selectively remove text you do not need, and copy interesting parts into
your main buffer (or elsewhere), driven by regular expressions etc.
Especially for highly interactive languages such as PostScript,
configuring Emacs as you need it can significantly improve productivity.
Please let me know any time if you have any questions about this
approach, or ideas that you would like to implement.
Thank you and all the best,
Markus
[toc] | [prev] | [next] | [standalone]
| From | Markus Triska <triska@metalevel.at> |
|---|---|
| Date | 2018-05-29 21:31 +0200 |
| Message-ID | <87a7sip8bn.fsf@metalevel.at> |
| In reply to | #3254 |
jdaw1 <jdawiseman@gmail.com> writes: > With which code editor do you write PostScript? One neat feature when using GNU Emacs to edit PostScript: You can press C-c C-c (to invoke doc-view-toggle-display), and this lets you preview the rendered output *inside* the Emacs buffer! When you then press C-c C-c again, you get back to the code. How cool is that?? Also, when you use C-c C-s, you get an interactive PostScript shell inside Emacs that supports *history* (use M-p and M-n). You can run a PostScript file in that buffer with C-c C-b. All the best! Markus
[toc] | [prev] | [next] | [standalone]
| From | luser droog <luser.droog@gmail.com> |
|---|---|
| Date | 2018-06-06 14:27 -0700 |
| Message-ID | <15fb158e-a0b5-49ac-b54d-bf25e2363056@googlegroups.com> |
| In reply to | #3264 |
On Tuesday, May 29, 2018 at 2:34:31 PM UTC-5, Markus Triska wrote: > jdaw1 <jdawiseman@gmail.com> writes: > > > With which code editor do you write PostScript? > > One neat feature when using GNU Emacs to edit PostScript: > > You can press C-c C-c (to invoke doc-view-toggle-display), and this lets > you preview the rendered output *inside* the Emacs buffer! When you then > press C-c C-c again, you get back to the code. How cool is that?? > > Also, when you use C-c C-s, you get an interactive PostScript shell > inside Emacs that supports *history* (use M-p and M-n). You can run a > PostScript file in that buffer with C-c C-b. > Now that is pretty cool. I expect it won't quite work with my cygwin emacs since the display is an xterm. But my msys2 emacs has a regular window. So that one may be able to do it once I `pacman -Ss ghostscript` and `pacman -Su <big-long-string>`.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.postscript
csiph-web