Commit 305478a27651ef522839b435c52786bb56d4f047

Initial commit of ChangeLog. Changed structure of compilation commands.
ChangeLog
(18 / 0)
  
12009-02-06 Rudolf Olah <omouse@gmail.com>
2
3 * processing-mode.el: Added proper licensing notice for GPLv3 to
4 top of file. Added a hook to for processing-mode that sets the
5 buffer-local compile-command.
6 (concat-with-delims): Removed function. Was only used in one
7 location.
8 (make-java-classpath): Replaced 'apply call to 'concat-with-delims
9 with a lambda version. Added a documentation string explaining the
10 function.
11 (make-java-classpath): The delimiter is now dependent on the
12 platform. Patch by kantide@yahoo.com.
13 (processing-make-compile-command): New function. Creates a
14 compile-command that's used in the processing-mode-hook.
15 (processing-commander): Relocated code for compile-command
16 construction.
17
18 * README: Added instructions on how to setup processing-mode.el
  
55;; Allows compilation of buffers and "sketches" from within Emacs but
66;; only for more recent versions of Processing.
77
8;; Copyright (C) 2008 Rudolf Olah <omouse@gmail.com>
9;; Licensed under the GNU GPL version 3 or later
8;; Copyright (C) 2008, 2009 Rudolf Olah <omouse@gmail.com>
109
11(require 'compile)
12(require 'cl)
10;; This program is free software: you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
1314
15;; This program is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
21;; along with this program. If not, see <http://www.gnu.org/licenses/>.
22
23(eval-when-compile
24 (require 'compile)
25 (require 'cl))
26
1427(define-derived-mode processing-mode
1528 java-mode "Processing"
1629 "Major mode for Processing.
4444 "The platform that Processing is running on. It can be `linux', `macosx' or `windows'.")
4545
4646;; Functions
47(defun concat-with-delim (delim &rest strings)
48 "Returns a string that is the concatenation of all ``strings''
49separated by the delimiter ``delim''.
50For example,
51 (concat-with-delim \".\" \"hello\" \"world\")
52returns
53 \"hello.world\"
54"
55 (reduce (lambda (x y) (concat x delim y)) strings))
56
5747(defun make-java-classpath (&rest args)
58 (apply 'concat-with-delim ":" args))
48 "Returns a string that is a Java CLASSPATH. Each arg is a
49folder containing .class files or a .jar. The delimiter is based
50on the platform, with MS Windows using \";\", and other platforms
51using \":\"."
52 (reduce (lambda (x y) (concat x (if (string= processing-platform "windows") ";" ":")
53 y))
54 args))
5955
6056(defvar processing-import-libraries
6157 '((minim "jl1.0" "mp3spi1.9.4" "tritonus_share" "tritonus_aos"
6262strings.")
6363
6464(defun processing-import-library (library-name)
65 "Generates a STRING that is a Java classpath, delimited by
66colons (\":\"). The paths are constructed from the REST of the
67library found in the alist ``processing-import-libraries''. The
68suffix \".jar\" is added to each string."
65 "Generates a STRING that is a Java classpath. The paths are
66constructed from the REST of the library found in the alist
67``processing-import-libraries''. The suffix \".jar\" is added to
68each string."
6969 (make-java-classpath (mapcar (lambda (x) (expand-file-name (concat processing-location
7070 "libraries/"
7171 (symbol-name library-name)
9999 (kill-buffer temp-buf)))
100100 nil)))
101101
102(defun processing-commander (sketch-dir output-dir cmd &optional platform)
103 "Runs the Processing compiler targetting the sketch files found
104in ``sketch-dir'', with the output being stored in
105``output-dir''. The command flag that is executed on the sketch
106depends on the type of ``cmd''. Valid types of commands are:
102(defun processing-make-compile-command (sketch-dir output-dir cmd &optional platform)
103 "Returns a string which is the compile-command for Processing
104sketches, targetting the sketch files found in ``sketch-dir'',
105with the output being stored in ``output-dir''. The command flag
106that is executed on the sketch depends on the type of ``cmd''.
107
108Valid types of commands are:
109
107110 - \"preprocess\"
108111 - \"build\"
109112 - \"run\"
118118must be set to one of \"windows\", \"macosx\", or \"linux\". If
119119no platform is selected, the default platform that Emacs is
120120running on will be selected."
121 (concat processing-location "java/bin/java -classpath \""
122 (apply 'make-java-classpath
123 (mapcar (lambda (x) (expand-file-name (concat processing-location x)))
124 '("java/lib/rt.jar"
125 "java/lib/tools.jar"
126 "lib/antlr.jar" "lib/core.jar"
127 "lib/ecj.jar" "lib/jna.jar"
128 "lib/pde.jar")))
129 "\" processing.app.Commander"
130 " --sketch=\"" (expand-file-name sketch-dir)
131 "\" --output=\"" (expand-file-name output-dir)
132 ;; Remove this comment when Processing implements the --preferences=??? command-line option.
133 ;;"\" --preferences=\"" (expand-file-name "~/.processing/preferences.txt")
134 "\" --" cmd
135 (if (string= cmd "export-application")
136 (concat " --platform="
137 (if platform platform (processing-platform))))))
138
139(defun processing-commander (sketch-dir output-dir cmd &optional platform)
140 "Runs the Processing compiler, using a compile-command
141constructed using the ``processing-make-compile-command''
142function."
121143 (let ((compilation-error-regexp-alist '(processing)))
122 (compile (concat processing-location "java/bin/java -classpath \""
123 (apply 'make-java-classpath
124 (mapcar (lambda (x) (expand-file-name (concat processing-location x)))
125 '("java/lib/rt.jar"
126 "java/lib/tools.jar"
127 "lib/antlr.jar" "lib/core.jar"
128 "lib/ecj.jar" "lib/jna.jar"
129 "lib/pde.jar")))
130 "\" processing.app.Commander"
131 " --sketch=\"" (expand-file-name sketch-dir)
132 "\" --output=\"" (expand-file-name output-dir)
133 ;; Remove this comment when Processing implements the --preferences=??? command-line option.
134 ;;"\" --preferences=\"" (expand-file-name "~/.processing/preferences.txt")
135 "\" --" cmd
136 (if (string= cmd "export-application")
137 (concat " --platform="
138 (if platform platform (processing-platform))))))))
144 (compile (processing-make-compile-command sketch-dir output-dir cmd platform))))
139145
140146(defun processing-sketch-compile (&optional cmd)
141147 "Runs the Processing Commander application with the current
157157 (processing-sketch-compile "present"))
158158
159159(defun processing-sketch-build ()
160 "Runs the build command for a Processing sketch. Processing
161will process the sketch into .java files and then compile them
162into .class files."
160163 (interactive)
161164 (processing-sketch-compile "build"))
162165
169169on."
170170 t)
171171
172;; Add hook so that when processing-mode is loaded, the local variable
173;; 'compile-command is set.
174(add-hook 'processing-mode-hook
175 (lambda ()
176 (let ((sketch-dir (file-name-directory buffer-file-name)))
177 (set (make-local-variable 'compile-command)
178 (processing-make-compile-command sketch-dir
179 (concat sketch-dir "output")
180 "build")))))
181
172182;; Key bindings
173183(define-key processing-mode-map "\C-c\C-r" 'processing-sketch-compile)
174184(define-key processing-mode-map "\C-c\C-p" 'processing-sketch-present)
195195;; Font-lock, keywords
196196(defconst processing-font-lock-keywords-1
197197 (eval-when-compile
198 `(;; Shape functions
198 `( ;; Shape functions
199199 (,(concat
200200 (regexp-opt '("triangle" "line" "arc" "point" "quad" "ellipse"
201201 "rect" "curve" "bezier")
243243 ("ell" "ellipse(${x}, ${y}, ${width}, ${height});" "ellipse" nil)
244244 ("rect" "rect(${x}, ${y}, ${width}, ${height});" "rect" nil)
245245
246 ;; Color
247 ;;; Setting
246 ;; Color Setting
248247 ("background" "background(${gray_or_color_or_hex});" "background .." nil)
249248 ("background.ca" "background(${gray_or_color_or_hex}, ${alpha});"
250249 "background .. alpha" nil)
270270 (progn
271271 (message "processing-mode: YASnippets not installed. Not defining any snippets.")
272272 nil))
273
274(provide 'processing-mode)