Skip to content

Commit

Permalink
Merge pull request defunkt#25 from knu/master
Browse files Browse the repository at this point in the history
Add a minor mode coffee-cos-mode
  • Loading branch information
defunkt committed Jul 1, 2011
2 parents 74a9135 + 5ecae75 commit 2c3d17b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ Bind it:

(define-key coffee-mode-map [(meta R)] 'coffee-compile-region)

### Compile-on-save

Hitting the key sequence `C-c C-o C-s` turns on (toggles) the
compile-on-save minor mode in `coffee-mode`. To enable it by default:

(add-hook 'coffee-mode-hook '(lambda () (coffee-cos-mode t)))

### coffee-repl

Starts a repl in a new buffer using `coffee-command`.
Expand Down
17 changes: 17 additions & 0 deletions coffee-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ line? Returns `t' or `nil'. See the README for more details."
(define-key coffee-mode-map (kbd "A-M-r") 'coffee-repl)
(define-key coffee-mode-map [remap comment-dwim] 'coffee-comment-dwim)
(define-key coffee-mode-map "\C-m" 'coffee-newline-and-indent)
(define-key coffee-mode-map "\C-c\C-o\C-s" 'coffee-cos-mode)

;; code for syntax highlighting
(setq font-lock-defaults '((coffee-font-lock-keywords)))
Expand Down Expand Up @@ -601,6 +602,22 @@ line? Returns `t' or `nil'. See the README for more details."
;; hooks
(set (make-local-variable 'before-save-hook) 'coffee-before-save))

;;
;; Compile-on-Save minor mode
;;

(defvar coffee-cos-mode-line " CoS")
(make-variable-buffer-local 'coffee-cos-mode-line)

(define-minor-mode coffee-cos-mode
"Toggle compile-on-save for coffee-mode."
:group 'coffee-cos :lighter coffee-cos-mode-line
(cond
(coffee-cos-mode
(add-hook 'after-save-hook 'coffee-compile-file nil t))
(t
(remove-hook 'after-save-hook 'coffee-compile-file t))))

(provide 'coffee-mode)

;;
Expand Down

0 comments on commit 2c3d17b

Please sign in to comment.