Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 7976bc485545b985a89eb751923d4c4b3cdd4703 1 parent adf9654
Chris Wanstrath authored March 07, 2010

Showing 2 changed files with 104 additions and 21 deletions. Show diff stats Hide diff stats

  1. 62  README.md
  2. 63  coffee-mode.el
62  README.md
Source Rendered
@@ -45,7 +45,8 @@ Well, idiomatic CoffeeScript uses two spaces. We can set our
45 45
     (add-hook coffee-mode-hook
46 46
       '(lambda() (coffee-custom)))
47 47
 
48  
-Another example of this hook is given further down.
  48
+For more configuration options and another example of this hook, look
  49
+further down in this README.
49 50
 
50 51
 ### TAB Theory
51 52
 
@@ -209,6 +210,65 @@ Naturally. Example:
209 210
 
210 211
     (add-hook 'coffee-mode-hook '(lambda () (coffee-custom)))
211 212
 
  213
+## Configuration
  214
+
  215
+You can customize any of the following options using `M-x
  216
+customize-group` with "coffee" as the group.
  217
+
  218
+You can also customize then with `coffee-mode-hook`, as demonstrated
  219
+above.
  220
+
  221
+### coffee-debug-mode
  222
+
  223
+Whether to run in debug mode or not. Logs to `*Messages*`.
  224
+
  225
+Default: `t`
  226
+
  227
+### coffee-js-mode
  228
+
  229
+The mode to use when viewing compiled JavaScript.
  230
+
  231
+Default: `'js2-mode`
  232
+
  233
+### coffee-cleanup-whitespace
  234
+
  235
+Should we `delete-trailing-whitespace' on save? Probably.
  236
+
  237
+Default: `t`
  238
+
  239
+### coffee-tab-width
  240
+
  241
+The tab width to use when indenting.
  242
+
  243
+Default: `tab-width`
  244
+
  245
+### coffee-command
  246
+
  247
+The CoffeeScript command used for evaluating code. Must be in your
  248
+path.
  249
+
  250
+Default: `"coffee"`
  251
+
  252
+### coffee-repl-args
  253
+
  254
+The command line arguments to pass to `coffee-command' to start a
  255
+REPL.
  256
+
  257
+Default: `'("-i")`
  258
+
  259
+### coffee-command-args
  260
+
  261
+The command line arguments to pass to `coffee-command' to get it
  262
+toprint the compiled JavaScript.
  263
+
  264
+Default: `'("-s" "-p" "--no-wrap")`
  265
+
  266
+### coffee-compiled-buffer-name
  267
+
  268
+The name of the scratch buffer used when compiling CoffeeScript.
  269
+
  270
+Default: `"*coffee-compiled*"`
  271
+
212 272
 ## Thanks
213 273
 
214 274
 * <http://xahlee.org/emacs/elisp_syntax_coloring.html> for instructions.
63  coffee-mode.el
@@ -66,28 +66,51 @@
66 66
 (defconst coffee-mode-version "0.2.0"
67 67
   "The version of this `coffee-mode'.")
68 68
 
69  
-(defvar coffee-debug-mode nil
70  
-  "Whether to run in debug mode or not. Logs to `*Messages*'.")
71  
-
72  
-(defvar coffee-js-mode 'js2-mode
73  
-  "The mode to use when viewing compiled JavaScript.")
74  
-
75  
-(defvar coffee-cleanup-whitespace t
76  
-  "Should we `delete-trailing-whitespace' on save? Probably.")
77  
-
78  
-(defvar coffee-command "coffee"
  69
+(defgroup coffee nil
  70
+  "A CoffeeScript major mode."
  71
+  :group 'languages)
  72
+
  73
+(defcustom coffee-debug-mode nil
  74
+  "Whether to run in debug mode or not. Logs to `*Messages*'."
  75
+  :type 'boolean
  76
+  :group 'coffee-mode)
  77
+
  78
+(defcustom coffee-js-mode 'js2-mode
  79
+  "The mode to use when viewing compiled JavaScript."
  80
+  :type 'string
  81
+  :group 'coffee)
  82
+
  83
+(defcustom coffee-cleanup-whitespace t
  84
+  "Should we `delete-trailing-whitespace' on save? Probably."
  85
+  :type 'boolean
  86
+  :group 'coffee)
  87
+
  88
+(defcustom coffee-tab-width tab-width
  89
+  "The tab width to use when indenting."
  90
+  :type 'integer
  91
+  :group 'coffee)
  92
+
  93
+(defcustom coffee-command "coffee"
79 94
   "The CoffeeScript command used for evaluating code. Must be in your
80  
-path.")
  95
+path."
  96
+  :type 'string
  97
+  :group 'coffee)
81 98
 
82  
-(defvar coffee-repl-args '("-i")
83  
-  "The command line arguments to pass to `coffee-command' to start a REPL.")
  99
+(defcustom coffee-repl-args '("-i")
  100
+  "The command line arguments to pass to `coffee-command' to start a REPL."
  101
+  :type 'list
  102
+  :group 'coffee)
84 103
 
85  
-(defvar coffee-command-args '("-s" "-p" "--no-wrap")
  104
+(defcustom coffee-command-args '("-s" "-p" "--no-wrap")
86 105
   "The command line arguments to pass to `coffee-command' to get it to
87  
-print the compiled JavaScript.")
  106
+print the compiled JavaScript."
  107
+  :type 'list
  108
+  :group 'coffee)
88 109
 
89  
-(defvar coffee-compiled-buffer-name "*coffee-compiled*"
90  
-  "The name of the scratch buffer used when compiling CoffeeScript.")
  110
+(defcustom coffee-compiled-buffer-name "*coffee-compiled*"
  111
+  "The name of the scratch buffer used when compiling CoffeeScript."
  112
+  :type 'string
  113
+  :group 'coffee)
91 114
 
92 115
 (defvar coffee-mode-hook nil
93 116
   "A hook for you to run your own code when the mode is loaded.")
@@ -420,12 +443,12 @@ For detail, see `comment-dwim'."
420 443
         (coffee-debug "point-at-bol: %s" (point-at-bol))
421 444
 
422 445
         (when (= (point-at-bol) (point))
423  
-          (forward-char tab-width))
  446
+          (forward-char coffee-tab-width))
424 447
 
425 448
         (coffee-debug "New indent: %s" (current-indentation))
426 449
 
427 450
         ;; We're too far, remove all indentation.
428  
-        (when (> (- (current-indentation) prev-indent) tab-width)
  451
+        (when (> (- (current-indentation) prev-indent) coffee-tab-width)
429 452
           (backward-to-indentation 0)
430 453
           (delete-region (point-at-bol) (point)))))))
431 454
 
@@ -451,7 +474,7 @@ For detail, see `comment-dwim'."
451 474
   ;; level as the previous line.
452 475
   (let ((prev-indent (current-indentation)) (indent-next nil))
453 476
     (newline)
454  
-    (insert-tab (/ prev-indent tab-width))
  477
+    (insert-tab (/ prev-indent coffee-tab-width))
455 478
 
456 479
     ;; We need to insert an additional tab because the last line was special.
457 480
     (when (coffee-line-wants-indent)

0 notes on commit 7976bc4

Please sign in to comment.
Something went wrong with that request. Please try again.