Created
September 22, 2010 04:12
-
-
Save kurohuku/591128 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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