Function: ebnf-generate-eps

ebnf-generate-eps is a byte-compiled function defined in ebnf2ps.el.gz.

Signature

(ebnf-generate-eps TREE)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/ebnf2ps.el.gz
(defun ebnf-generate-eps (tree)
  (let* ((ebnf-tree tree)
         (ps-color-p           (and ebnf-color-p (display-color-p)))
	 (ps-print-color-scale (if ps-color-p
				   (float (car (color-values "white")))
				 1.0))
	 (ebnf-total           (length ebnf-tree))
	 (ebnf-nprod           0)
	 (eps-buffer           (get-buffer-create ebnf-eps-buffer-name))
	 ebnf-debug-ps horizontal
	 prod prod-name prod-width prod-height prod-list file-list)
    ;; generate EPS file
    (unwind-protect
        ;; redefines `ps-output' and `ps-output-string'
        (cl-letf (((symbol-function 'ps-output) #'ebnf-eps-output)
                  ((symbol-function 'ps-output-string) #'ps-output-string-prim))
          (save-excursion
	    (while ebnf-tree
	      (setq prod        (car ebnf-tree)
		    prod-name   (ebnf-node-name prod)
		    prod-width  (ebnf-max-width prod)
		    prod-height (ebnf-node-height prod)
		    horizontal  (memq (ebnf-node-action prod)
				      ebnf-action-list))
	      ;; generate production in EPS buffer
	      (with-current-buffer eps-buffer
		(setq ebnf-eps-upper-x    0.0
		      ebnf-eps-upper-y    0.0
		      ebnf-eps-max-width  prod-width
		      ebnf-eps-max-height prod-height)
		(ebnf-generate-production prod))
	      (if (setq prod-list (cdr (assoc prod-name
					      ebnf-eps-production-list)))
		  ;; insert EPS buffer in all buffer associated with production
		  (ebnf-eps-production-list
                   prod-list (gv-ref file-list) horizontal
		   prod-width prod-height eps-buffer)
		;; write EPS file for production
		(ebnf-eps-finish-and-write eps-buffer
					   (ebnf-eps-filename prod-name)))
	      ;; prepare for next loop
	      (with-current-buffer eps-buffer
		(erase-buffer))
	      (setq ebnf-tree (cdr ebnf-tree)))
	    ;; write and kill temporary buffers
	    (ebnf-eps-write-kill-temp file-list t)
	    (setq file-list nil)))
      ;; kill temporary buffers
      (kill-buffer eps-buffer)
      (ebnf-eps-write-kill-temp file-list nil))
    (message " ")))