From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: PATCH: Processing language support in Babel Date: Mon, 16 Mar 2015 22:51:48 +0100 Message-ID: <87oans1uh7.fsf@nicolasgoaziou.fr> References: <8761a5ys9q.fsf@iki.fi> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXtKF-0005jA-F7 for emacs-orgmode@gnu.org; Tue, 17 Mar 2015 11:22:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YXtK9-0000O3-F6 for emacs-orgmode@gnu.org; Tue, 17 Mar 2015 11:22:35 -0400 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:38841) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXtK9-0000Ns-6D for emacs-orgmode@gnu.org; Tue, 17 Mar 2015 11:22:29 -0400 In-Reply-To: <8761a5ys9q.fsf@iki.fi> (Jarmo Hurri's message of "Fri, 13 Mar 2015 14:51:45 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Jarmo Hurri Cc: emacs-orgmode@gnu.org Hello, Jarmo Hurri writes: > Please find two files attached to this message. Thank you. > +;; This differs from most standard languages in that > +;; > +;; 1) there is no such thing as a "session" in processing > +;; > +;; 2) results can only be exported as html; in this case, the > +;; processing code is embedded via a file into a javascript block > +;; using the processing.js module; the script then draws the > +;; resulting output when the web page is viewed in a browser > +;; > +;; 3) when not exporting html, evaluation of processing code results > +;; in interactive viewing of the results via Processing 2.0 Emacs > +;; mode; note that the user is responsible for making sure that > +;; processing.js is available on the website It is awkward (and fragile) to guess the current export back-end used. Wouldn't it be simpler to do "2" if :results is html and "3" otherwise? > +;; declaration needed because requiring ob does not define the variable > +(eval-when-compile (defvar org-babel-temporary-directory)) Isn't (defvar org-babel-temporary-directory) sufficient? > +;; default header tags depend on whether exporting html or not; if not > +;; exporting html, then no results are produced; otherwise results are > +;; html It shouldn't. > +;; a running index for producing unique ids for processing sketches > +(defvar org-babel-processing-sketch-number 0) > +(add-hook 'org-export-before-processing-hook > + (lambda (backend) (setq org-babel-processing-sketch-number 0))) It pollutes `org-export-before-processing-hook'. What about using sha1 of the contents of the code block instead? > +(defun org-babel-execute:processing (body params) > + "Execute a block of Processing code. > +This function is called by `org-babel-execute-src-block'." > + (let ((sketch-code > + (org-babel-expand-body:generic > + body > + params > + (org-babel-variable-assignments:processing params)))) > + (if (and (not (null org-babel-exp-reference-buffer)) > + (string= org-export-current-backend "html")) This will not work if current back-end is derived from "html". > + ;; results are html if exporting html > + (let ((sketch-canvas-id > + (concat "org-processing-canvas-" > + (number-to-string org-babel-processing-sketch-number)))) (format "org-processing-canvas-%d" org-babel-processing-sketch-number) > + (setq org-babel-processing-sketch-number > + (1+ org-babel-processing-sketch-number)) (incf org-babel-processing-sketch-number) > +(defun org-babel-processing-define-type (data) > + "Determine type of DATA. > + > +DATA is a list. Return type as a symbol. > + > +The type is `String' if any element in DATA is > +a string. Otherwise, it is either `float', if some elements are > +floats, or `int'." > + (let* ((type 'int) > + find-type ; for byte-compiler > + (find-type > + (function Not needed. > + (lambda (row) > + (catch 'exit > + (mapc (lambda (el) > + (cond ((listp el) (funcall find-type el)) > + ((stringp el) (throw 'exit (setq type 'String))) > + ((floatp el) (setq type 'float)))) > + row)))))) (lambda (row) (dolist (el row type) (cond ...))) > + (funcall find-type data) type)) ^^^^ not needed Regards, -- Nicolas Goaziou