Skip to content

Commit

Permalink
Turn er/enable-mode-expansions into a function.
Browse files Browse the repository at this point in the history
 - needless macro tomfoolery.

Fixes #81
  • Loading branch information
magnars committed Oct 25, 2012
1 parent 8a526a0 commit 2c3779c
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 38 deletions.
14 changes: 7 additions & 7 deletions cc-mode-expansions.el
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ This function captures identifiers composed of multiple
er/c-mark-statement-block-1 er/c-mark-statement-block-2
er/c-mark-vector-access-1 er/c-mark-vector-access-2))))

(er/enable-mode-expansions c-mode er/add-cc-mode-expansions)
(er/enable-mode-expansions c++-mode er/add-cc-mode-expansions)
(er/enable-mode-expansions objc-mode er/add-cc-mode-expansions)
(er/enable-mode-expansions java-mode er/add-cc-mode-expansions)
(er/enable-mode-expansions idl-mode er/add-cc-mode-expansions)
(er/enable-mode-expansions pike-mode er/add-cc-mode-expansions)
(er/enable-mode-expansions awk-mode er/add-cc-mode-expansions)
(er/enable-mode-expansions 'c-mode 'er/add-cc-mode-expansions)
(er/enable-mode-expansions 'c++-mode 'er/add-cc-mode-expansions)
(er/enable-mode-expansions 'objc-mode 'er/add-cc-mode-expansions)
(er/enable-mode-expansions 'java-mode 'er/add-cc-mode-expansions)
(er/enable-mode-expansions 'idl-mode 'er/add-cc-mode-expansions)
(er/enable-mode-expansions 'pike-mode 'er/add-cc-mode-expansions)
(er/enable-mode-expansions 'awk-mode 'er/add-cc-mode-expansions)

(provide 'cc-mode-expansions)

Expand Down
4 changes: 2 additions & 2 deletions clojure-mode-expansions.el
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ If point is inside the parens, they will be marked first anyway."
er/mark-clj-regexp-literal
er/mark-clj-function-literal))))

(er/enable-mode-expansions clojure-mode er/add-clojure-mode-expansions)
(er/enable-mode-expansions nrepl-mode er/add-clojure-mode-expansions)
(er/enable-mode-expansions 'clojure-mode 'er/add-clojure-mode-expansions)
(er/enable-mode-expansions 'nrepl-mode 'er/add-clojure-mode-expansions)

(provide 'clojure-mode-expansions)

Expand Down
2 changes: 1 addition & 1 deletion css-mode-expansions.el
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
er/try-expand-list
'(er/mark-css-declaration))))

(er/enable-mode-expansions css-mode er/add-css-mode-expansions)
(er/enable-mode-expansions 'css-mode 'er/add-css-mode-expansions)

(provide 'css-mode-expansions)

Expand Down
2 changes: 1 addition & 1 deletion erlang-mode-expansions.el
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
'(erlang-mark-function
erlang-mark-clause))))

(er/enable-mode-expansions erlang-mode er/add-erlang-mode-expansions)
(er/enable-mode-expansions 'erlang-mode 'er/add-erlang-mode-expansions)

(provide 'erlang-mode-expansions)

Expand Down
15 changes: 7 additions & 8 deletions expand-region-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -456,14 +456,13 @@ remove the keymap depends on user input and KEEP-PRED:
(eq (point) (point-min)))
(memq (char-after) er--blank-list)))

(defmacro er/enable-mode-expansions (mode add-fn)
`(progn
(add-hook ',(intern (format "%s-hook" mode)) ',add-fn)
(save-window-excursion
(dolist (buffer (buffer-list))
(with-current-buffer buffer
(when (derived-mode-p ',mode)
(,add-fn)))))))
(defun er/enable-mode-expansions (mode add-fn)
(add-hook (intern (format "%s-hook" mode)) add-fn)
(save-window-excursion
(dolist (buffer (buffer-list))
(with-current-buffer buffer
(when (derived-mode-p mode)
(funcall add-fn))))))

(provide 'expand-region-core)

Expand Down
2 changes: 1 addition & 1 deletion expand-region.el
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
;; '(mark-paragraph
;; mark-page))))

;; (er/enable-mode-expansions text-mode er/add-text-mode-expansions)
;; (er/enable-mode-expansions 'text-mode 'er/add-text-mode-expansions)

;; Add that to its own file, and require it at the bottom of this one,
;; where it says "Mode-specific expansions"
Expand Down
2 changes: 1 addition & 1 deletion feature-mode-expansions.el
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@
'(er/mark-feature-scenario
er/mark-feature-step))))

(er/enable-mode-expansions feature-mode er/add-feature-mode-expansions)
(er/enable-mode-expansions 'feature-mode 'er/add-feature-mode-expansions)

(provide 'feature-mode-expansions)
8 changes: 4 additions & 4 deletions html-mode-expansions.el
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ around the equal sign or unquotes attributes atm."
er/mark-inner-tag
er/mark-outer-tag))))

(er/enable-mode-expansions html-mode er/add-html-mode-expansions)
(er/enable-mode-expansions rhtml-mode er/add-html-mode-expansions)
(er/enable-mode-expansions nxhtml-mode er/add-html-mode-expansions)
(er/enable-mode-expansions web-mode er/add-html-mode-expansions)
(er/enable-mode-expansions 'html-mode 'er/add-html-mode-expansions)
(er/enable-mode-expansions 'rhtml-mode 'er/add-html-mode-expansions)
(er/enable-mode-expansions 'nxhtml-mode 'er/add-html-mode-expansions)
(er/enable-mode-expansions 'web-mode 'er/add-html-mode-expansions)

(provide 'html-mode-expansions)

Expand Down
6 changes: 3 additions & 3 deletions js-mode-expansions.el
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ If point is inside the value, that will be marked first anyway."
er/mark-js-inner-return
er/mark-js-outer-return))))

(er/enable-mode-expansions js-mode er/add-js-mode-expansions)
(er/enable-mode-expansions js2-mode er/add-js-mode-expansions)
(er/enable-mode-expansions js3-mode er/add-js-mode-expansions)
(er/enable-mode-expansions 'js-mode 'er/add-js-mode-expansions)
(er/enable-mode-expansions 'js2-mode 'er/add-js-mode-expansions)
(er/enable-mode-expansions 'js3-mode 'er/add-js-mode-expansions)

(provide 'js-mode-expansions)

Expand Down
2 changes: 1 addition & 1 deletion js2-mode-expansions.el
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
er/try-expand-list
'(js2-mark-parent-statement))))

(er/enable-mode-expansions js2-mode er/add-js2-mode-expansions)
(er/enable-mode-expansions 'js2-mode 'er/add-js2-mode-expansions)

(provide 'js2-mode-expansions)

Expand Down
2 changes: 1 addition & 1 deletion jsp-expansions.el
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ If point is inside the brackets, they will be marked first anyway."
er/try-expand-list
'(er/mark-jstl-escape))))

(er/enable-mode-expansions html-mode er/add-jsp-expansions)
(er/enable-mode-expansions 'html-mode 'er/add-jsp-expansions)

(provide 'jsp-expansions)

Expand Down
2 changes: 1 addition & 1 deletion latex-mode-expansions.el
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Skips past [] and {} arguments to the environment."
er/mark-LaTeX-inside-environment
er/mark-LaTeX-math))))

(er/enable-mode-expansions latex-mode er/add-latex-mode-expansions)
(er/enable-mode-expansions 'latex-mode 'er/add-latex-mode-expansions)

(provide 'latex-mode-expansions)

Expand Down
2 changes: 1 addition & 1 deletion nxml-mode-expansions.el
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
(remove 'er/mark-symbol-with-prefix
(remove 'er/mark-symbol er/try-expand-list))))))

(er/enable-mode-expansions nxml-mode er/add-nxml-mode-expansions)
(er/enable-mode-expansions 'nxml-mode 'er/add-nxml-mode-expansions)

(provide 'nxml-mode-expansions)

Expand Down
2 changes: 1 addition & 1 deletion org-mode-expansions.el
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@
er/mark-sentence
er/mark-paragraph))))

(er/enable-mode-expansions org-mode er/add-org-mode-expansions)
(er/enable-mode-expansions 'org-mode 'er/add-org-mode-expansions)

(provide 'org-mode-expansions)
2 changes: 1 addition & 1 deletion python-el-expansions.el
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
(remove 'er/mark-outside-quotes
(append er/try-expand-list try-expand-list-additions))))))

(er/enable-mode-expansions python-mode er/add-python-mode-expansions)
(er/enable-mode-expansions 'python-mode 'er/add-python-mode-expansions)

(provide 'python-el-expansions)

Expand Down
2 changes: 1 addition & 1 deletion python-el-fgallina-expansions.el
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ Command that wraps `er/mark-python-block'."
(remove 'er/mark-outside-quotes
(append er/try-expand-list try-expand-list-additions))))))

(er/enable-mode-expansions python-mode er/add-python-mode-expansions)
(er/enable-mode-expansions 'python-mode 'er/add-python-mode-expansions)

(provide 'python-el-fgallina-expansions)

Expand Down
2 changes: 1 addition & 1 deletion python-mode-expansions.el
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ line and selecting the surrounding block."
(remove 'er/mark-outside-quotes
(append er/try-expand-list try-expand-list-additions))))))

(er/enable-mode-expansions python-mode er/add-python-mode-expansions)
(er/enable-mode-expansions 'python-mode 'er/add-python-mode-expansions)

(provide 'python-mode-expansions)

Expand Down
2 changes: 1 addition & 1 deletion ruby-mode-expansions.el
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,6 @@ This moves point to the next line to include the end of the block"
er/try-expand-list
'(er/mark-ruby-block-up))))

(er/enable-mode-expansions ruby-mode er/add-ruby-mode-expansions)
(er/enable-mode-expansions 'ruby-mode 'er/add-ruby-mode-expansions)

(provide 'ruby-mode-expansions)
2 changes: 1 addition & 1 deletion text-mode-expansions.el
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ text-mode-expansions don't work well in `html-mode'."
er/mark-text-paragraph
mark-page)))))

(er/enable-mode-expansions text-mode er/add-text-mode-expansions)
(er/enable-mode-expansions 'text-mode 'er/add-text-mode-expansions)

(provide 'text-mode-expansions)

Expand Down

0 comments on commit 2c3779c

Please sign in to comment.