Skip to content

Commit

Permalink
* js-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ran9er committed May 1, 2013
1 parent d5e261a commit d29d116
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 47 deletions.
34 changes: 1 addition & 33 deletions _eval-after-load/js-mode.el
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
;; -*- encoding: utf-8-unix; -*-
;; File-name: <73_js2.el>
;; Create: <2011-12-14 10:23:27 ran9er>
;; Time-stamp: <2012-01-03 15:09:52 ran9er>
;; Mail: <[email protected]>

;; After js2 has parsed a js file, we look for jslint globals decl comment ("/* global Fred, _, Harry */") and
;; add any symbols to a buffer-local var of acceptable global vars
;; Note that we also support the "symbol: true" way of specifying names via a hack (remove any ":true"
Expand All @@ -21,31 +15,5 @@
;; (if (string-match "/\\* *global *\\(.*?\\) *\\*/" btext) (match-string-no-properties 1 btext) "")
;; " *, *" t))
;; )))
(load-once
(require 'snippet)

(define-abbrev-table 'javascript-mode-abbrev-table ())

(snippet-with-abbrev-table
'javascript-mode-abbrev-table
("for" . "$>for (var $${i}=$${0},$${len}=$${i}.length;$${i}<$${len};++$${i}){\n$>$.\n}$>")
("forin" . "$>for (var $${i} in $${var}){\n$>$$;\n}$.$>")
("if" . "$>if ($${cond}){$>\n$>$.;\n}$>")
("ifel" . "$>if ($${cond}){$>\n$>$$;\n} else {$>\n$>$$;\n}$.$>")
("wh" . "$>while ($${i}){\n$>$.\n}$>")
("whinc" . "$>while ($${i}<$${10}){\n$>$.\n$>$${i}++;\n}$>")
("trn" . "$${if}?$${then}:$${else}")
("var" . "var $${variable} = $${value};")
("fun" . "$>function $${name}($${args}){\n$>$.\n}$>")
("lambda" . "$>function ($${args}){\n$>$.\n}$>")
("df" . "document.forms['$${formname}']")
("cl" . "console.log('$${message}');")) ;Firebug logging

(add-hook 'javascript-mode-hook
(lambda ()
(abbrev-mode 1)
;; This line is not in the documentation of snippet.el, but seems to be
;; essential for various modes (not for python-mode though, which serves as
;; the example mode in said documentation)
(setq local-abbrev-table javascript-mode-abbrev-table)))
)
(add-hook 'javascript-mode-hook 'my-auto-pair)
19 changes: 10 additions & 9 deletions _lib/_loaddefs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
(loaddefs-eval
'(("script.el"
(20863 50879 411000 0)
(autoload 'run-current-file "script" "Execute or compile the current file.\nFor example, if the current buffer is the file x.pl,\nthen it'll call “perl x.pl” in a shell.\nThe file can be php, perl, python, bash, java.\nFile suffix is used to determine what program to run.\n\n(fn)" t nil)
(autoload 'x-shell "script" "Not documented.\n\n(fn prog)" nil nil)
(autoload 'lua-shell "script" "make a lua shell\n\n(fn)" t nil)
(autoload 'node\.js "script" "make a node.js shell\n\n(fn)" t nil)
(autoload 'run-ruby "script" "Run an inferior Ruby process" t))
("zenburn-theme.el"
(20832 47667 130000 0)
'(("zenburn-theme.el"
(20864 36441 651000 0)
(and load-file-name
(boundp 'custom-theme-load-path)
(add-to-list 'custom-theme-load-path
(file-name-as-directory
(file-name-directory load-file-name)))))
("script.el"
(20864 36441 601000 0)
(autoload 'run-current-file "script" "Execute or compile the current file.\nFor example, if the current buffer is the file x.pl,\nthen it'll call “perl x.pl” in a shell.\nThe file can be php, perl, python, bash, java.\nFile suffix is used to determine what program to run.\n\n(fn)" t nil)
(autoload 'x-shell "script" "Not documented.\n\n(fn prog)" nil nil)
(autoload 'lua-shell "script" "make a lua shell\n\n(fn)" t nil)
(autoload 'node\.js "script" "make a node.js shell\n\n(fn)" t nil)
(autoload 'coffee "script" "make a coffee-script shell\n\n(fn)" t nil)
(autoload 'run-ruby "script" "Run an inferior Ruby process" t))
("search.el"
(20808 64911 791000 0)
(autoload 'search-str "search" "Not documented.\n\n(fn regexp str &rest sub)" nil nil)
Expand Down
7 changes: 7 additions & 0 deletions _lib/script.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
("java" . "javac")
("hs" . "hugs")
("js" . "node")
("coffee" . "coffee")
))

;;;###autoload
Expand Down Expand Up @@ -63,6 +64,12 @@ File suffix is used to determine what program to run."
(interactive)
(switch-to-buffer (make-comint "node.js" "node" nil "-i")))

;;;###autoload
(defun coffee ()
"make a coffee-script shell"
(interactive)
(switch-to-buffer (make-comint "coffee" "coffee" nil "-i")))

;;;###autoload
(autoload 'run-ruby "inf-ruby"
"Run an inferior Ruby process" t)
9 changes: 6 additions & 3 deletions liny/snippets/_keywords_index
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@
"head"
(("head")
("top"))
"js#cl"
(nil nil)
"js#func"
(("nohol")
nil)
"js#func2"
(("nohol")
nil)
"js#function"
(nil nil)
(("hol")
nil)
"js#var"
(nil nil)
"let"
Expand All @@ -67,7 +70,7 @@
"autoload"
("emacs-lisp-mode#autoload")
"cl"
("emacs-lisp-mode#closure")
("emacs-lisp-mode#closure" "js#cl")
"closure"
("emacs-lisp-mode#closure")
"cd"
Expand Down Expand Up @@ -138,6 +141,6 @@
"c-mode"
("for")
"js-mode"
("for" "js#func" "js#func2" "js#function" "js#var")
("for" "js#cl" "js#func" "js#func2" "js#function" "js#var")
"org-mode"
("org-mode#head"))))
2 changes: 1 addition & 1 deletion liny/snippets/for
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ js-mode c-mode
<------environment

<------snippet
for (${$(if (eq major-mode 'js-mode)(insert-string "var "))}${1:i} = ${2:1}; $1 ${3:i < 10}; $1++)
for (${$(if (eq major-mode 'js-mode)(insert-string "var "))}${1:i} = ${2:1}; $1 ${3:< 10}; $1++)
{
$0
}
Expand Down
10 changes: 10 additions & 0 deletions liny/snippets/js#cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<------alias
cl
<------modes
js-mode
<------keywords

<------environment

<------snippet
console.log($0)
2 changes: 1 addition & 1 deletion liny/snippets/js#function
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ f
<------modes
js-mode
<------keywords

+hol
<------environment

<------snippet
Expand Down

0 comments on commit d29d116

Please sign in to comment.