Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #3266

Re: Which code editor?

From Markus Triska <triska@metalevel.at>
Newsgroups comp.lang.postscript
Subject Re: Which code editor?
Organization man
References <f2cafb21-500d-42dc-86d5-6836371fece8@googlegroups.com> <34f17058-49aa-42f4-b9ce-9385e01d1244@googlegroups.com>
Message-ID <m2muw454me.fsf@metalevel.at> (permalink)
Date 2018-06-09 18:03 +0200

Show all headers | View raw


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

Back to comp.lang.postscript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

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

csiph-web