Function: org-babel-processing-view-sketch

org-babel-processing-view-sketch is an interactive and byte-compiled function defined in ob-processing.el.gz.

Signature

(org-babel-processing-view-sketch)

Documentation

Show the sketch of the Processing block under point in an external viewer.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/ob-processing.el.gz
(defun org-babel-processing-view-sketch ()
  "Show the sketch of the Processing block under point in an external viewer."
  (interactive)
  (org-require-package 'processing-mode)
  (let ((info (org-babel-get-src-block-info)))
    (if (string= (nth 0 info) "processing")
	(let* ((body (nth 1 info))
	       (params (org-babel-process-params (nth 2 info)))
	       (sketch-code
		(org-babel-expand-body:generic
		 body
		 params
		 (org-babel-variable-assignments:processing params))))
	  ;; Note: sketch filename can not contain a hyphen, since it
	  ;; has to be a valid java class name; for this reason
	  ;; make-temp-file is repeated until no hyphen is in the
	  ;; name; also sketch dir name must be the same as the
	  ;; basename of the sketch file.
	  (let* ((temporary-file-directory (org-babel-temp-directory))
		 (sketch-dir
		  (let (sketch-dir-candidate)
		    (while
			(progn
			  (setq sketch-dir-candidate
				(make-temp-file "processing" t))
			  (when (string-match-p
				 "-"
				 (file-name-nondirectory sketch-dir-candidate))
			    (delete-directory sketch-dir-candidate)
			    t)))
		    sketch-dir-candidate))
		 (sketch-filename
		  (concat sketch-dir
			  "/"
			  (file-name-nondirectory sketch-dir)
			  ".pde")))
	    (with-temp-file sketch-filename (insert sketch-code))
	    (find-file sketch-filename)
	    (processing-sketch-run)
	    (kill-buffer)))
      (message "Not inside a Processing source block."))))