Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Keybindings for enh-ruby-mode, too #19

Closed
wants to merge 1 commit into from

2 participants

@danielsz

This patch makes the keybindings work in enhanced-ruby-mode.
The patch is rough because of ugly duplication, but the idea is that inf-ruby should work with other modes aside of ruby-mode. So maybe this is a start of a discussion.

@dgutov
Collaborator

Here's an alternative suggestion: create a minor mode, and put all bindings on its keymap.

@danielsz

I like the idea. Can you maybe elaborate on what exactly you envision? How will inf-ruby interact with the minor mode, who is calling who, things like that...

@dgutov
Collaborator

The minor mode will be just for the sake of the keymap.

  • The minor mode will be on in ruby-mode buffers, but not in inf-ruby-mode buffers.
  • inf-ruby-setup-keybindings body will go to the inf-ruby-minor-mode-map definition.
  • inf-ruby-setup-keybindings body will be (add-hook 'ruby-mode 'inf-ruby-minor-mode), for backward compatibility (otherwise we'd just replace the eval-after-load form at the bottom with add-hook).
  • The body of (define-minor-mode inf-ruby-minor-mode will be empty (I think?).
  • As far as enh-ruby-mode goes, you'll either add a second add-hook call to inf-ruby-setup-keybindings, or add it under ;;;###autoload at the bottom of the file.
  • The minor mode could use a more descriptive name, but even this one should do.
@dgutov dgutov closed this pull request from a commit
@dgutov dgutov Move keys to a new minor mode
* Add `enh-ruby-mode` to `ruby-source-modes`.
* Hook it up in `inf-ruby-setup-keybindings`.
* Fixes #19.
33e17e0
@dgutov dgutov closed this in 33e17e0
@dgutov
Collaborator

@danielsz I've committed the changes described above. Please test that they work for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 6, 2013
  1. @danielsz
This page is out of date. Refresh to see the latest.
Showing with 19 additions and 0 deletions.
  1. +19 −0 inf-ruby.el
View
19 inf-ruby.el
@@ -91,6 +91,21 @@ next one.")
(define-key ruby-mode-map "\C-c\C-l" 'ruby-load-file)
(define-key ruby-mode-map "\C-c\C-s" 'inf-ruby))
+;;;###autoload
+(defun inf-enh-ruby-setup-keybindings ()
+ "Set local key defs to invoke inf-ruby from ruby-mode."
+ (define-key enh-ruby-mode-map "\M-\C-x" 'ruby-send-definition)
+ (define-key enh-ruby-mode-map "\C-x\C-e" 'ruby-send-last-sexp)
+ (define-key enh-ruby-mode-map "\C-c\C-b" 'ruby-send-block)
+ (define-key enh-ruby-mode-map "\C-c\M-b" 'ruby-send-block-and-go)
+ (define-key enh-ruby-mode-map "\C-c\C-x" 'ruby-send-definition)
+ (define-key enh-ruby-mode-map "\C-c\M-x" 'ruby-send-definition-and-go)
+ (define-key enh-ruby-mode-map "\C-c\C-r" 'ruby-send-region)
+ (define-key enh-ruby-mode-map "\C-c\M-r" 'ruby-send-region-and-go)
+ (define-key enh-ruby-mode-map "\C-c\C-z" 'ruby-switch-to-inf)
+ (define-key enh-ruby-mode-map "\C-c\C-l" 'ruby-load-file)
+ (define-key enh-ruby-mode-map "\C-c\C-s" 'inf-ruby))
+
(defvar inf-ruby-buffer nil "Current irb process buffer.")
(defun inf-ruby-mode ()
@@ -371,5 +386,9 @@ Module used by readline when running irb through a terminal"
(eval-after-load 'ruby-mode
'(inf-ruby-setup-keybindings))
+;;;###autoload
+(eval-after-load 'enh-ruby-mode
+ '(inf-enh-ruby-setup-keybindings))
+
(provide 'inf-ruby)
;;; inf-ruby.el ends here
Something went wrong with that request. Please try again.