Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replace "C-c" with "C-c ," and "C-c C-c" with "C-c , ,"

This change also allows separate configuration of the "local" and
"global" prefix sequences.

This means /most/ of the key bindings are now in accordance with the Emacs key
binding Conventions by default.

http://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html
http://www.gnu.org/software/emacs/manual/html_node/elisp/Keymaps-and-Minor-Modes.html

 You can set `rails-minor-mode-local-prefix-key` to "C-c" and
`rails-minor-mode-global-prefix-key` to "C-c C-c" if you want to
retain most of the original key bindings.
  • Loading branch information...
commit 860c57642f03bd8b4f1327dc2cdb7ff260961ff4 1 parent ac69a8d
@joodie joodie authored
View
14 rails-controller-layout.el
@@ -142,13 +142,13 @@ If the action is nil, return all views for the controller."
rails-controller-layout:switch-to-unit-test
:enable (rails-core:current-mailer))))
(define-keys map
- ((rails-key "g") 'rails-controller-layout:switch-to-migration)
- ((rails-key "m") 'rails-controller-layout:switch-to-model)
- ((rails-key "h") 'rails-controller-layout:switch-to-helper)
- ((rails-key "f") 'rails-controller-layout:switch-to-functional-test)
- ((rails-key "c") 'rails-controller-layout:switch-to-controller)
- ((rails-key "u") 'rails-controller-layout:switch-to-unit-test)
- ((rails-key "r") 'rails-controller-layout:switch-to-rspec-controller)
+ ((rails-local-key "g") 'rails-controller-layout:switch-to-migration)
+ ((rails-local-key "m") 'rails-controller-layout:switch-to-model)
+ ((rails-local-key "h") 'rails-controller-layout:switch-to-helper)
+ ((rails-local-key "f") 'rails-controller-layout:switch-to-functional-test)
+ ((rails-local-key "c") 'rails-controller-layout:switch-to-controller)
+ ((rails-local-key "u") 'rails-controller-layout:switch-to-unit-test)
+ ((rails-local-key "r") 'rails-controller-layout:switch-to-rspec-controller)
([menu-bar rails-controller-layout] (cons name menu))))
map))
View
6 rails-lib-layout.el
@@ -13,8 +13,8 @@
:enable (and (not (eq (rails-core:buffer-type) :rspec-lib))
(rails-core:rspec-lib-exist-p (rails-core:current-lib))))))
(define-keys map
- ((rails-key "l") 'rails-lib-layout:switch-to-lib)
- ((rails-key "r") 'rails-lib-layout:switch-to-unit-test)
+ ((rails-local-key "l") 'rails-lib-layout:switch-to-lib)
+ ((rails-local-key "r") 'rails-lib-layout:switch-to-unit-test)
([menu-bar rails-lib-layout] (cons name menu))))
map))
@@ -58,4 +58,4 @@
(symbol (rails-lib-layout:switch-to item))
(string (rails-core:find-file-if-exist item))))))
-(provide 'rails-lib-layout)
+(provide 'rails-lib-layout)
View
16 rails-model-layout.el
@@ -65,14 +65,14 @@
rails-model-layout:switch-to-mailer
:enable (rails-core:mailer-exist-p (rails-core:current-mailer)))))
(define-keys map
- ((rails-key "m") 'rails-model-layout:switch-to-model)
- ((rails-key "u") 'rails-model-layout:switch-to-unit-test)
- ((rails-key "r") 'rails-model-layout:switch-to-rspec-model)
- ((rails-key "g") 'rails-model-layout:switch-to-migration)
- ((rails-key "c") 'rails-model-layout:switch-to-controller)
- ((rails-key "x") 'rails-model-layout:switch-to-fixture)
- ((rails-key "z") 'rails-model-layout:switch-to-rspec-fixture)
- ((rails-key "n") 'rails-model-layout:switch-to-mailer)
+ ((rails-local-key "m") 'rails-model-layout:switch-to-model)
+ ((rails-local-key "u") 'rails-model-layout:switch-to-unit-test)
+ ((rails-local-key "r") 'rails-model-layout:switch-to-rspec-model)
+ ((rails-local-key "g") 'rails-model-layout:switch-to-migration)
+ ((rails-local-key "c") 'rails-model-layout:switch-to-controller)
+ ((rails-local-key "x") 'rails-model-layout:switch-to-fixture)
+ ((rails-local-key "z") 'rails-model-layout:switch-to-rspec-fixture)
+ ((rails-local-key "n") 'rails-model-layout:switch-to-mailer)
([menu-bar rails-model-layout] (cons name menu))))
map))
View
8 rails-refactoring.el
@@ -366,10 +366,10 @@ file is available."
(require 'rails-ui)
(define-keys rails-minor-mode-map
- ((rails-key "\C-c R q") 'rails-refactoring:query-replace)
- ((rails-key "\C-c R m") 'rails-refactoring:rename-model)
- ((rails-key "\C-c R c") 'rails-refactoring:rename-controller)
- ((rails-key "\C-c R l") 'rails-refactoring:rename-layout))
+ ((rails-global-key "R q") 'rails-refactoring:query-replace)
+ ((rails-global-key "R m") 'rails-refactoring:rename-model)
+ ((rails-global-key "R c") 'rails-refactoring:rename-controller)
+ ((rails-global-key "R l") 'rails-refactoring:rename-layout))
(provide 'rails-refactoring)
View
183 rails-ui.el
@@ -205,14 +205,21 @@
([rails ws default] '(menu-item "Start/Stop Web Server (With Default Environment)" rails-ws:toggle-start-stop))
)
-(defcustom rails-minor-mode-prefix-key "\C-c"
- "Key prefix for rails minor mode."
+(defcustom rails-minor-mode-local-prefix-key "\C-c ,"
+ "Key prefix for rails commands that depend on current file (controller, migratione tc)."
:group 'rails)
-(defmacro rails-key (key)
- `(kbd ,(concat rails-minor-mode-prefix-key " " key)))
+(defmacro rails-local-key (key)
+ `(kbd ,(concat rails-minor-mode-local-prefix-key " " key)))
-(defconst rails-minor-mode-test-current-method-key (rails-key "\C-c ,"))
+(defcustom rails-minor-mode-global-prefix-key "\C-c , ,"
+ "Key following `rails-minor-mode-prefix-key` prefixing global rails-mode commands."
+ :group 'rails)
+
+(defmacro rails-global-key (key)
+ `(kbd ,(concat rails-minor-mode-global-prefix-key " " key)))
+
+(defconst rails-minor-mode-test-current-method-key (rails-global-key ", ,"))
(defvar rails-minor-mode-map
(make-sparse-keymap))
@@ -223,116 +230,116 @@
([menu-bar rails-db] (cons "Database" rails-minor-mode-db-menu-bar-map))
;; Goto
- ((rails-key "\C-c g m") 'rails-nav:goto-models)
- ((rails-key "\C-c g c") 'rails-nav:goto-controllers)
- ((rails-key "\C-c g o") 'rails-nav:goto-observers)
- ((rails-key "\C-c g n") 'rails-nav:goto-mailers)
- ((rails-key "\C-c g h") 'rails-nav:goto-helpers)
- ((rails-key "\C-c g l") 'rails-nav:goto-layouts)
- ((rails-key "\C-c g s") 'rails-nav:goto-stylesheets)
- ((rails-key "\C-c g j") 'rails-nav:goto-javascripts)
- ((rails-key "\C-c g g") 'rails-nav:goto-migrate)
- ((rails-key "\C-c g p") 'rails-nav:goto-plugins)
- ((rails-key "\C-c g x") 'rails-nav:goto-fixtures)
- ((rails-key "\C-c g f") 'rails-nav:goto-functional-tests)
- ((rails-key "\C-c g u") 'rails-nav:goto-unit-tests)
- ((rails-key "\C-c g r c") 'rails-nav:goto-rspec-controllers)
- ((rails-key "\C-c g r f") 'rails-nav:goto-rspec-fixtures)
- ((rails-key "\C-c g r l") 'rails-nav:goto-rspec-lib)
- ((rails-key "\C-c g r m") 'rails-nav:goto-rspec-models)
+ ((rails-global-key "g m") 'rails-nav:goto-models)
+ ((rails-global-key "g c") 'rails-nav:goto-controllers)
+ ((rails-global-key "g o") 'rails-nav:goto-observers)
+ ((rails-global-key "g n") 'rails-nav:goto-mailers)
+ ((rails-global-key "g h") 'rails-nav:goto-helpers)
+ ((rails-global-key "g l") 'rails-nav:goto-layouts)
+ ((rails-global-key "g s") 'rails-nav:goto-stylesheets)
+ ((rails-global-key "g j") 'rails-nav:goto-javascripts)
+ ((rails-global-key "g g") 'rails-nav:goto-migrate)
+ ((rails-global-key "g p") 'rails-nav:goto-plugins)
+ ((rails-global-key "g x") 'rails-nav:goto-fixtures)
+ ((rails-global-key "g f") 'rails-nav:goto-functional-tests)
+ ((rails-global-key "g u") 'rails-nav:goto-unit-tests)
+ ((rails-global-key "g r c") 'rails-nav:goto-rspec-controllers)
+ ((rails-global-key "g r f") 'rails-nav:goto-rspec-fixtures)
+ ((rails-global-key "g r l") 'rails-nav:goto-rspec-lib)
+ ((rails-global-key "g r m") 'rails-nav:goto-rspec-models)
;; Switch
((kbd "<M-S-up>") 'rails-lib:run-primary-switch)
((kbd "<M-S-down>") 'rails-lib:run-secondary-switch)
- ((rails-key "<up>") 'rails-lib:run-primary-switch)
- ((rails-key "<down>") 'rails-lib:run-secondary-switch)
- ((kbd "<C-return>") 'rails-goto-file-on-current-line)
+ ((rails-global-key "<up>") 'rails-lib:run-primary-switch)
+ ((rails-global-key "<down>") 'rails-lib:run-secondary-switch)
+ ((rails-global-key "<return>") 'rails-goto-file-on-current-line)
;; Scripts & SQL
- ((rails-key "\C-c k") 'rails-script:kill-script)
- ((rails-key "\C-c e") 'rails-script:generate)
- ((rails-key "\C-c x") 'rails-script:destroy)
- ((rails-key "\C-c s c") 'rails-script:console)
+ ((rails-global-key "k") 'rails-script:kill-script)
+ ((rails-global-key "e") 'rails-script:generate)
+ ((rails-global-key "x") 'rails-script:destroy)
+ ((rails-global-key "s c") 'rails-script:console)
((kbd "C-c C-s") 'rails-script:console)
((kbd "C-c C-z") 'rails-script:console)
- ((rails-key "\C-c s b") 'rails-script:breakpointer)
- ((rails-key "\C-c s s") 'rails-run-sql)
- ((rails-key "\C-c w s") 'rails-ws:toggle-start-stop)
- ((rails-key "\C-c w d") 'rails-ws:start-development)
- ((rails-key "\C-c w p") 'rails-ws:start-production)
- ((rails-key "\C-c w t") 'rails-ws:start-test)
- ((rails-key "\C-c w i") 'rails-ws:print-status)
- ((rails-key "\C-c w a") 'rails-ws:auto-open-browser)
+ ((rails-global-key "s b") 'rails-script:breakpointer)
+ ((rails-global-key "s s") 'rails-run-sql)
+ ((rails-global-key "w s") 'rails-ws:toggle-start-stop)
+ ((rails-global-key "w d") 'rails-ws:start-development)
+ ((rails-global-key "w p") 'rails-ws:start-production)
+ ((rails-global-key "w t") 'rails-ws:start-test)
+ ((rails-global-key "w i") 'rails-ws:print-status)
+ ((rails-global-key "w a") 'rails-ws:auto-open-browser)
;; Rails finds
- ((rails-key "\C-c f m") 'rails-find:models)
- ((rails-key "\C-c f c") 'rails-find:controller)
- ((rails-key "\C-c f h") 'rails-find:helpers)
- ((rails-key "\C-c f l") 'rails-find:layout)
- ((rails-key "\C-c f s") 'rails-find:stylesheets)
- ((rails-key "\C-c f j") 'rails-find:javascripts)
- ((rails-key "\C-c f g") 'rails-find:migrate)
- ((rails-key "\C-c f b") 'rails-find:lib)
- ((rails-key "\C-c f t") 'rails-find:tasks)
- ((rails-key "\C-c f v") 'rails-find:view)
- ((rails-key "\C-c f d") 'rails-find:db)
- ((rails-key "\C-c f p") 'rails-find:public)
- ((rails-key "\C-c f f") 'rails-find:fixtures)
- ((rails-key "\C-c f o") 'rails-find:config)
+ ((rails-global-key "f m") 'rails-find:models)
+ ((rails-global-key "f c") 'rails-find:controller)
+ ((rails-global-key "f h") 'rails-find:helpers)
+ ((rails-global-key "f l") 'rails-find:layout)
+ ((rails-global-key "f s") 'rails-find:stylesheets)
+ ((rails-global-key "f j") 'rails-find:javascripts)
+ ((rails-global-key "f g") 'rails-find:migrate)
+ ((rails-global-key "f b") 'rails-find:lib)
+ ((rails-global-key "f t") 'rails-find:tasks)
+ ((rails-global-key "f v") 'rails-find:view)
+ ((rails-global-key "f d") 'rails-find:db)
+ ((rails-global-key "f p") 'rails-find:public)
+ ((rails-global-key "f f") 'rails-find:fixtures)
+ ((rails-global-key "f o") 'rails-find:config)
;; Spec finds
- ((rails-key "\C-c f r s") 'rails-find:spec)
- ((rails-key "\C-c f r c") 'rails-find:spec-controllers)
- ((rails-key "\C-c f r m") 'rails-find:spec-models)
- ((rails-key "\C-c f r h") 'rails-find:spec-helpers)
- ((rails-key "\C-c f r v") 'rails-find:spec-views)
- ((rails-key "\C-c f r f") 'rails-find:spec-fixtures)
-
- ((rails-key "\C-c d m") 'rails-rake:migrate)
- ((rails-key "\C-c d v") 'rails-rake:migrate-to-version)
- ((rails-key "\C-c d p") 'rails-rake:migrate-to-prev-version)
- ((rails-key "\C-c d u") 'rails-rake:migration-version-up)
- ((rails-key "\C-c d d") 'rails-rake:migration-version-down)
- ((rails-key "\C-c d t") 'rails-rake:clone-development-db-to-test-db)
+ ((rails-global-key "f r s") 'rails-find:spec)
+ ((rails-global-key "f r c") 'rails-find:spec-controllers)
+ ((rails-global-key "f r m") 'rails-find:spec-models)
+ ((rails-global-key "f r h") 'rails-find:spec-helpers)
+ ((rails-global-key "f r v") 'rails-find:spec-views)
+ ((rails-global-key "f r f") 'rails-find:spec-fixtures)
+
+ ((rails-global-key "d m") 'rails-rake:migrate)
+ ((rails-global-key "d v") 'rails-rake:migrate-to-version)
+ ((rails-global-key "d p") 'rails-rake:migrate-to-prev-version)
+ ((rails-global-key "d u") 'rails-rake:migration-version-up)
+ ((rails-global-key "d d") 'rails-rake:migration-version-down)
+ ((rails-global-key "d t") 'rails-rake:clone-development-db-to-test-db)
;; Tests
- ((rails-key "\C-c r") 'rails-rake:task)
- ((rails-key "\C-c t") 'rails-test:run)
- ((rails-key "\C-c .") 'rails-test:run-current)
- ((rails-key "\C-c /") 'rails-test:rerun-single)
- ((rails-key "\C-c y i") 'rails-test:run-integration)
- ((rails-key "\C-c y u") 'rails-test:run-units)
- ((rails-key "\C-c y f") 'rails-test:run-functionals)
- ((rails-key "\C-c #") 'rails-test:run-recent)
- ((rails-key "\C-c y a") 'rails-test:run-all)
+ ((rails-global-key "r") 'rails-rake:task)
+ ((rails-global-key "t") 'rails-test:run)
+ ((rails-global-key ".") 'rails-test:run-current)
+ ((rails-global-key "/") 'rails-test:rerun-single)
+ ((rails-global-key "y i") 'rails-test:run-integration)
+ ((rails-global-key "y u") 'rails-test:run-units)
+ ((rails-global-key "y f") 'rails-test:run-functionals)
+ ((rails-global-key "#") 'rails-test:run-recent)
+ ((rails-global-key "y a") 'rails-test:run-all)
;; RSpec
- ((rails-key "\C-c z f") 'rails-spec:run-files)
- ((rails-key "\C-c z .") 'rails-spec:run-current)
- ((rails-key "\C-c z a") 'rails-spec:run-all)
- ((rails-key "\C-c z l") 'rails-spec:run-last)
- ((rails-key "\C-c z s") 'rails-spec:run-this-spec)
+ ((rails-global-key "z f") 'rails-spec:run-files)
+ ((rails-global-key "z .") 'rails-spec:run-current)
+ ((rails-global-key "z a") 'rails-spec:run-all)
+ ((rails-global-key "z l") 'rails-spec:run-last)
+ ((rails-global-key "z s") 'rails-spec:run-this-spec)
;; Log files
- ((rails-key "\C-c l") 'rails-log:open)
- ((rails-key "\C-c o t") 'rails-log:open-test)
- ((rails-key "\C-c o p") 'rails-log:open-production)
- ((rails-key "\C-c o d") 'rails-log:open-development)
+ ((rails-global-key "l") 'rails-log:open)
+ ((rails-global-key "o t") 'rails-log:open-test)
+ ((rails-global-key "o p") 'rails-log:open-production)
+ ((rails-global-key "o d") 'rails-log:open-development)
;; Tags
- ((rails-key "\C-c \C-t") 'rails-create-tags)
+ ((rails-global-key "\C-t") 'rails-create-tags)
;; Documentation
- ((rails-key "/") 'rails-script:toggle-output-window)
+ ((rails-global-key "/") 'rails-script:toggle-output-window)
;; Other
- ((rails-key "s") 'rails-grep-project)
- ((rails-key "C-M-z") 'rails-shell)
- ((rails-key "M-z") 'rails-shell)
+ ((rails-global-key "s") 'rails-grep-project)
+ ((rails-global-key "C-M-z") 'rails-shell)
+ ((rails-global-key "M-z") 'rails-shell)
([f9] 'rails-scm-status-into-root))
;; Global keys and menubar
-(global-set-key (rails-key "\C-c j") 'rails-script:create-project)
+(global-set-key (rails-global-key "j") 'rails-script:create-project)
(when-bind (map (lookup-key global-map [menu-bar file]))
(define-key-after
View
8 rails-view-minor-mode.el
@@ -105,10 +105,10 @@
(setq rails-secondary-switch-func 'rails-controller-layout:menu)
(if (boundp 'mmm-mode-map)
(progn
- (define-key mmm-mode-map (rails-key "p") 'rails-view-minor-mode:create-partial-from-selection)
- (define-key mmm-mode-map (rails-key "b") 'rails-view-minor-mode:create-helper-from-block))
+ (define-key mmm-mode-map (rails-local-key "p") 'rails-view-minor-mode:create-partial-from-selection)
+ (define-key mmm-mode-map (rails-local-key "b") 'rails-view-minor-mode:create-helper-from-block))
(progn
- (local-set-key (rails-key "p") 'rails-view-minor-mode:create-partial-from-selection)
- (local-set-key (rails-key "b") 'rails-view-minor-mode:create-helper-from-block))))
+ (local-set-key (rails-local-key "p") 'rails-view-minor-mode:create-partial-from-selection)
+ (local-set-key (rails-local-key "b") 'rails-view-minor-mode:create-helper-from-block))))
(provide 'rails-view-minor-mode)
View
2  rails.el
@@ -485,7 +485,7 @@ necessary."
(lambda ()
(when (rails-project:root)
(require 'rails-ruby)
- (local-set-key (rails-key "f") '(lambda()
+ (local-set-key (rails-global-key "f") '(lambda()
(interactive)
(mouse-major-mode-menu (rails-core:menu-position))))
(local-set-key (kbd "C-:") 'ruby-toggle-string<>simbol)
Please sign in to comment.
Something went wrong with that request. Please try again.