Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use js2-mode fork from https://github.com/mooz/js2-mode.git

  • Loading branch information...
commit 982a0f22c827fab8a5e946cfbc62c76b0b74306e 1 parent 27241a0
@langmartin authored
Showing with 39 additions and 14 deletions.
  1. +3 −0  .gitmodules
  2. +1 −0  js2-mode
  3. +0 −4 rc-hyper-keymap.el
  4. +35 −10 rc-javascript.el
View
3  .gitmodules
@@ -25,3 +25,6 @@
[submodule "ace-jump-mode"]
path = ace-jump-mode
url = git://github.com/winterTTr/ace-jump-mode.git
+[submodule "js2-mode"]
+ path = js2-mode
+ url = https://github.com/mooz/js2-mode.git
1  js2-mode
@@ -0,0 +1 @@
+Subproject commit 858b079d3ee5bf8ab7623b817f73cf958e684e02
View
4 rc-hyper-keymap.el
@@ -26,10 +26,6 @@
(progn
(define-key (current-global-map) (kbd "H-l")
(lambda-insert-with-point "(lambda ()" ")"))
-
- (if (boundp 'js2-mode-map)
- (define-key js2-mode-map (kbd "H-l")
- (lambda-insert-with-point "function () {" "}")))
)
(provide 'rc-hyper-keymap)
View
45 rc-javascript.el
@@ -1,20 +1,46 @@
(defvar rc-javascript-mode)
+(defun js-insert-lambda ()
+ (interactive)
+ (let ((before "function() {")
+ (after "}"))
+ (insert before)
+ (insert after)
+ (backward-char (length after))))
+
(defun rc-js2-mode-setup ()
(interactive)
(require 'js2-mode)
(custom-set-variables
- '(js2-basic-offset 2)
- '(js2-bounce-indent-flag t)
- '(js2-mirror-mode nil))
- (add-hook 'js2-mode-hook 'turn-off-tabs)
- ;; (add-hook 'js2-mode-hook 'turn-on-js-paredit-mode)
- ;; (add-hook 'js2-mode-hook 'turn-on-c-subword-mode)
- ;; (add-hook 'js2-mode-hook 'turn-on-moz-minor-mode)
- (define-key js2-mode-map "\C-x\C-s" 'cleanup-untabify-save))
+ '(js2-bounce-indent-p t)
+ '(js2-mirror-mode nil)
+ '(js2-cleanup-whitespace t)
+ '(js2-global-externs (quote (require exports))))
+ (add-hook 'js2-mode-hook 'turn-on-c-subword-mode)
+ (define-key js2-mode-map (kbd "H-l") 'js-insert-lambda)
+ (eval-after-load 'js2-mode
+ '(progn
+ (require 'js2-imenu-extras)
+ (js2-imenu-extras-setup))))
+
+(defun rc-js2-mode-spaces ()
+ "Configure js2 mode without tabs and with js2-basic-offset: 2"
+ (interactive)
+ (require 'js2-mode)
+ (set-default 'js2-basic-offset 2)
+ (add-hook 'js2-mode-hook 'turn-off-tabs))
+
+(defun rc-js2-mode-tabs ()
+ "Configure js2 mode with tabs and with js2-basic-offset: 4"
+ (interactive)
+ (require 'js2-mode)
+ (set-default 'js2-basic-offset 4)
+ (add-hook 'js2-mode-hook 'turn-on-tabs)
+ (add-hook 'js2-mode-hook 'set-tab-width-4))
(defun rc-js2-mode ()
(rc-js2-mode-setup)
+ (rc-js2-mode-tabs)
(add-to-auto-mode-alist '(("\\.js\\'" . js2-mode)))
(defalias 'rc-javascript-mode 'js2-mode))
@@ -40,8 +66,7 @@
;; (require 'flymake-jshint)
(add-to-auto-mode-alist '(("\\.js\\'" . js-mode)))
- (define-key js-mode-map (kbd "H-l")
- (lambda-insert-with-point "function () {" "}"))
+ (define-key js-mode-map (kbd "H-l") 'js-insert-lambda)
(defalias 'rc-javascript-mode 'js-mode))
(rc-js2-mode)

0 comments on commit 982a0f2

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