Skip to content

Instantly share code, notes, and snippets.

@kurohuku
Created September 22, 2010 04:12
Show Gist options
  • Save kurohuku/591128 to your computer and use it in GitHub Desktop.
Save kurohuku/591128 to your computer and use it in GitHub Desktop.
(defun postscript-process ()
(get-buffer-process (get-buffer "*postscript*")))
(defun run-postscript ()
(interactive)
(require 'comint)
(switch-to-buffer (make-comint "postscript" "gs")))
(push '("postscript" . utf-8) process-coding-system-alist)
(defun to-postfix (s)
(if (atom s) `(,s)
`(,@(cdr s)
,(car s))))
(defun send-postscript-no-newline (s &optional ps)
(unless ps
(setf ps (postscript-process)))
(unless ps
(error "no running postscript process"))
(dolist (obj (to-postfix s))
(if (listp obj)
(send-postscript-no-newline obj ps)
(comint-send-string ps (format "%s " obj)))))
(defun send-postscript (s &optional ps)
(unless ps
(setf ps (postscript-process)))
(unless ps
(error "no running postscript process"))
(send-postscript-no-newline s ps)
(comint-send-string ps "\n"))
(defun ps (&rest ss)
(dolist (s ss) (send-postscript-no-newline s))
(unless (postscript-process)
(error "no running postscript process"))
(comint-send-string (postscript-process) "\n"))
(defmacro with-ps-context (&rest body)
`(ps ,@(mapcar (lambda (s) `(quote ,s)) body)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment