Permalink
Browse files

Make config options available from `customize-group`, document in README

  • Loading branch information...
1 parent adf9654 commit 7976bc485545b985a89eb751923d4c4b3cdd4703 @defunkt committed Mar 8, 2010
Showing with 104 additions and 21 deletions.
  1. +61 −1 README.md
  2. +43 −20 coffee-mode.el
View
@@ -45,7 +45,8 @@ Well, idiomatic CoffeeScript uses two spaces. We can set our
(add-hook coffee-mode-hook
'(lambda() (coffee-custom)))
-Another example of this hook is given further down.
+For more configuration options and another example of this hook, look
+further down in this README.
### TAB Theory
@@ -209,6 +210,65 @@ Naturally. Example:
(add-hook 'coffee-mode-hook '(lambda () (coffee-custom)))
+## Configuration
+
+You can customize any of the following options using `M-x
+customize-group` with "coffee" as the group.
+
+You can also customize then with `coffee-mode-hook`, as demonstrated
+above.
+
+### coffee-debug-mode
+
+Whether to run in debug mode or not. Logs to `*Messages*`.
+
+Default: `t`
+
+### coffee-js-mode
+
+The mode to use when viewing compiled JavaScript.
+
+Default: `'js2-mode`
+
+### coffee-cleanup-whitespace
+
+Should we `delete-trailing-whitespace' on save? Probably.
+
+Default: `t`
+
+### coffee-tab-width
+
+The tab width to use when indenting.
+
+Default: `tab-width`
+
+### coffee-command
+
+The CoffeeScript command used for evaluating code. Must be in your
+path.
+
+Default: `"coffee"`
+
+### coffee-repl-args
+
+The command line arguments to pass to `coffee-command' to start a
+REPL.
+
+Default: `'("-i")`
+
+### coffee-command-args
+
+The command line arguments to pass to `coffee-command' to get it
+toprint the compiled JavaScript.
+
+Default: `'("-s" "-p" "--no-wrap")`
+
+### coffee-compiled-buffer-name
+
+The name of the scratch buffer used when compiling CoffeeScript.
+
+Default: `"*coffee-compiled*"`
+
## Thanks
* <http://xahlee.org/emacs/elisp_syntax_coloring.html> for instructions.
View
@@ -66,28 +66,51 @@
(defconst coffee-mode-version "0.2.0"
"The version of this `coffee-mode'.")
-(defvar coffee-debug-mode nil
- "Whether to run in debug mode or not. Logs to `*Messages*'.")
-
-(defvar coffee-js-mode 'js2-mode
- "The mode to use when viewing compiled JavaScript.")
-
-(defvar coffee-cleanup-whitespace t
- "Should we `delete-trailing-whitespace' on save? Probably.")
-
-(defvar coffee-command "coffee"
+(defgroup coffee nil
+ "A CoffeeScript major mode."
+ :group 'languages)
+
+(defcustom coffee-debug-mode nil
+ "Whether to run in debug mode or not. Logs to `*Messages*'."
+ :type 'boolean
+ :group 'coffee-mode)
+
+(defcustom coffee-js-mode 'js2-mode
+ "The mode to use when viewing compiled JavaScript."
+ :type 'string
+ :group 'coffee)
+
+(defcustom coffee-cleanup-whitespace t
+ "Should we `delete-trailing-whitespace' on save? Probably."
+ :type 'boolean
+ :group 'coffee)
+
+(defcustom coffee-tab-width tab-width
+ "The tab width to use when indenting."
+ :type 'integer
+ :group 'coffee)
+
+(defcustom coffee-command "coffee"
"The CoffeeScript command used for evaluating code. Must be in your
-path.")
+path."
+ :type 'string
+ :group 'coffee)
-(defvar coffee-repl-args '("-i")
- "The command line arguments to pass to `coffee-command' to start a REPL.")
+(defcustom coffee-repl-args '("-i")
+ "The command line arguments to pass to `coffee-command' to start a REPL."
+ :type 'list
+ :group 'coffee)
-(defvar coffee-command-args '("-s" "-p" "--no-wrap")
+(defcustom coffee-command-args '("-s" "-p" "--no-wrap")
"The command line arguments to pass to `coffee-command' to get it to
-print the compiled JavaScript.")
+print the compiled JavaScript."
+ :type 'list
+ :group 'coffee)
-(defvar coffee-compiled-buffer-name "*coffee-compiled*"
- "The name of the scratch buffer used when compiling CoffeeScript.")
+(defcustom coffee-compiled-buffer-name "*coffee-compiled*"
+ "The name of the scratch buffer used when compiling CoffeeScript."
+ :type 'string
+ :group 'coffee)
(defvar coffee-mode-hook nil
"A hook for you to run your own code when the mode is loaded.")
@@ -420,12 +443,12 @@ For detail, see `comment-dwim'."
(coffee-debug "point-at-bol: %s" (point-at-bol))
(when (= (point-at-bol) (point))
- (forward-char tab-width))
+ (forward-char coffee-tab-width))
(coffee-debug "New indent: %s" (current-indentation))
;; We're too far, remove all indentation.
- (when (> (- (current-indentation) prev-indent) tab-width)
+ (when (> (- (current-indentation) prev-indent) coffee-tab-width)
(backward-to-indentation 0)
(delete-region (point-at-bol) (point)))))))
@@ -451,7 +474,7 @@ For detail, see `comment-dwim'."
;; level as the previous line.
(let ((prev-indent (current-indentation)) (indent-next nil))
(newline)
- (insert-tab (/ prev-indent tab-width))
+ (insert-tab (/ prev-indent coffee-tab-width))
;; We need to insert an additional tab because the last line was special.
(when (coffee-line-wants-indent)

0 comments on commit 7976bc4

Please sign in to comment.