Permalink
Browse files

Customize args for compiling files and display the first compiler error

Repurpose the unused custom variable 'coffee-args-compile' and the unused
function 'coffee-command-full'. 'coffee-args-compile' now gives extra arguments
to the 'coffee-command' when a file is compiled.

'coffee-args-compile' defaults to just '-c' (the same behaviour as v0.3.0) and
an example of using '--no-wrap' is added to the coffee-mode-hook example in the
README.

If compilation fails, the first compiler error is displayed in the message
buffer.
  • Loading branch information...
1 parent cd06e4e commit 227a3608cd89eefcb79453ffc646027bcbe791bd @orlandohill orlandohill committed with Aug 11, 2010
Showing with 14 additions and 14 deletions.
  1. +5 −3 README.md
  2. +9 −11 coffee-mode.el
View
@@ -202,6 +202,9 @@ Naturally. Example:
;; If you don't have js2-mode
(setq coffee-js-mode 'javascript-mode)
+ ;; If you don't want your compiled files to be wrapped
+ (setq coffee-args-compile '("-c" "--no-wrap"))
+
;; *Messages* spam
(setq coffee-debug-mode t)
@@ -267,10 +270,9 @@ Default: `'("-i")`
### coffee-args-compile
-The command line arguments to pass to `coffee-command' to get it
-toprint the compiled JavaScript.
+The command line arguments to pass to `coffee-command' when compiling a file.
-Default: `'("-s" "-p" "--no-wrap")`
+Default: `'("-c")`
### coffee-compiled-buffer-name
View
@@ -104,9 +104,8 @@ path."
:type 'list
:group 'coffee)
-(defcustom coffee-args-compile '("-s" "-p" "--no-wrap")
- "The command line arguments to pass to `coffee-command' to get it to
-print the compiled JavaScript."
+(defcustom coffee-args-compile '("-c")
+ "The command line arguments to pass to `coffee-command' when compiling a file."
:type 'list
:group 'coffee)
@@ -160,11 +159,10 @@ print the compiled JavaScript."
(defun coffee-compile-file ()
"Compiles and saves the current file to disk. Doesn't open in a buffer.."
(interactive)
- (shell-command (concat coffee-command " -c " (buffer-file-name)))
- (message "Compiled and saved %s"
- (concat
- (substring (buffer-file-name) 0 -6)
- "js")))
+ (let ((compiler-output (shell-command-to-string (coffee-command-compile (buffer-file-name)))))
+ (if (string= compiler-output "")
+ (message "Compiled and saved %s" (concat (substring (buffer-file-name) 0 -6) "js"))
+ (message (car (split-string compiler-output "[\n\r]+"))))))
(defun coffee-compile-buffer ()
"Compiles the current buffer and displays the JS in another buffer."
@@ -308,9 +306,9 @@ For detail, see `comment-dwim'."
(let ((deactivate-mark nil) (comment-start "#") (comment-end ""))
(comment-dwim arg)))
-(defun coffee-command-full ()
- "The full `coffee-command' complete with args."
- (mapconcat 'identity (append (list coffee-command) coffee-args-compile) " "))
+(defun coffee-command-compile (file-name)
+ "The `coffee-command' with args to compile a file."
+ (mapconcat 'identity (append (list coffee-command) coffee-args-compile (list file-name)) " "))
;;
;; imenu support

0 comments on commit 227a360

Please sign in to comment.