Permalink
Browse files

Started on an emacs wishlist

  • Loading branch information...
magnars committed Nov 17, 2011
1 parent d406ce3 commit 357998127addb940164d9f05fb39a9f12e20f2dc
View
@@ -19,3 +19,6 @@
[submodule "site-lisp/jade-mode"]
path = site-lisp/jade-mode
url = https://github.com/brianc/jade-mode
+[submodule "site-lisp/coffee-mode"]
+ path = site-lisp/coffee-mode
+ url = https://github.com/defunkt/coffee-mode
Submodule coffee-mode added at 244d4b
@@ -115,73 +115,8 @@
er/mark-inside-pairs
er/mark-outside-pairs))
-;; Add more methods for JavaScript
-
-(defun er/mark-js-function ()
- (interactive)
- (condition-case nil
- (forward-char 8)
- (error nil))
- (word-search-backward "function")
- (set-mark (point))
- (while (not (looking-at "{"))
- (forward-char))
- (forward-list)
- (exchange-point-and-mark))
-
-(defun er/mark-js-outer-return ()
- (interactive)
- (condition-case nil
- (forward-char 6)
- (error nil))
- (word-search-backward "return")
- (set-mark (point))
- (while (not (looking-at ";"))
- (if (looking-at "\\s(")
- (forward-list)
- (forward-char)))
- (forward-char)
- (exchange-point-and-mark))
-
-(defun er/mark-js-inner-return ()
- (interactive)
- (condition-case nil
- (forward-char 6)
- (error nil))
- (word-search-backward "return")
- (search-forward " ")
- (set-mark (point))
- (while (not (looking-at ";"))
- (if (looking-at "\\s(")
- (forward-list)
- (forward-char)))
- (exchange-point-and-mark))
-
-(defun er/mark-js-if ()
- (interactive)
- (condition-case nil
- (forward-char 2)
- (error nil))
- (word-search-backward "if")
- (set-mark (point))
- (while (not (looking-at "("))
- (forward-char))
- (forward-list)
- (while (not (looking-at "{"))
- (forward-char))
- (forward-list)
- (exchange-point-and-mark))
-
-(defun er/more-expansions-in-js2-mode ()
- (make-variable-buffer-local 'er/try-expand-list)
- (setq er/try-expand-list (append
- er/try-expand-list
- '(er/mark-js-function
- er/mark-js-if
- er/mark-js-inner-return
- er/mark-js-outer-return))))
-
-(add-hook 'js2-mode-hook 'er/more-expansions-in-js2-mode)
+;; Mode-specific expansions
+(require 'js-mode-expansions)
;; The magic expand-region method
@@ -0,0 +1,67 @@
+(defun er/mark-js-function ()
+ (interactive)
+ (condition-case nil
+ (forward-char 8)
+ (error nil))
+ (word-search-backward "function")
+ (set-mark (point))
+ (while (not (looking-at "{"))
+ (forward-char))
+ (forward-list)
+ (exchange-point-and-mark))
+
+(defun er/mark-js-outer-return ()
+ (interactive)
+ (condition-case nil
+ (forward-char 6)
+ (error nil))
+ (word-search-backward "return")
+ (set-mark (point))
+ (while (not (looking-at ";"))
+ (if (looking-at "\\s(")
+ (forward-list)
+ (forward-char)))
+ (forward-char)
+ (exchange-point-and-mark))
+
+(defun er/mark-js-inner-return ()
+ (interactive)
+ (condition-case nil
+ (forward-char 6)
+ (error nil))
+ (word-search-backward "return")
+ (search-forward " ")
+ (set-mark (point))
+ (while (not (looking-at ";"))
+ (if (looking-at "\\s(")
+ (forward-list)
+ (forward-char)))
+ (exchange-point-and-mark))
+
+(defun er/mark-js-if ()
+ (interactive)
+ (condition-case nil
+ (forward-char 2)
+ (error nil))
+ (word-search-backward "if")
+ (set-mark (point))
+ (while (not (looking-at "("))
+ (forward-char))
+ (forward-list)
+ (while (not (looking-at "{"))
+ (forward-char))
+ (forward-list)
+ (exchange-point-and-mark))
+
+(defun er/add-js-mode-expansions ()
+ (make-variable-buffer-local 'er/try-expand-list)
+ (setq er/try-expand-list (append
+ er/try-expand-list
+ '(er/mark-js-function
+ er/mark-js-if
+ er/mark-js-inner-return
+ er/mark-js-outer-return))))
+
+(add-hook 'js2-mode-hook 'er/add-js-mode-expansions)
+
+(provide 'js-mode-expansions)
View
@@ -0,0 +1,6 @@
+* JavaScript tweaks [0/1]
+** TODO js-move-line-up/down: fixes commas in object literals
+* HTML-mode [0/3]
+** TODO er/mark-inside-tag
+** TODO er/mark-outside-tag
+** TODO er/mark-attribute

0 comments on commit 3579981

Please sign in to comment.