How can I set a new keybind for a command in IPython shell with emacs?

Asked by Juan A Rodriguez

I 've just started working with IPython through emacs, but to run a region of code, in my case, i need to execute the command:

        M-x py-execute-region-ipython

Unfortunately, there's not a keybind for this. I tried with:

        (global-unset-key (kbd "C-c C-r")) # (as I want C-c C-r to execute the order)
        (global-set-key (kbd "C-c C-r") 'py-execute-region-ipython)

...but it's not working.

Does anyone know how to set it?

Best,

Juan

Question information

Language:
English Edit question
Status:
Solved
For:
python-mode.el Edit question
Assignee:
Andreas Roehler Edit question
Solved by:
Andreas Roehler
Solved:
Last query:
Last reply:
Revision history for this message
Best Andreas Roehler (a-roehler) said :
#1

are several ways to do this.
for example

(global-set-key [(control c)(control r)] 'MY-COMMAND)

Revision history for this message
Andreas Roehler (a-roehler) said :
#2

when facing problems with unset-key,

comment like that line in python-mode.el:

# (define-key map [(control c)(control r)] 'py-shift-right)

py-shift-right is also at [(control c)(>)]

Revision history for this message
Andreas Roehler (a-roehler) said :
#3

hmm, we need an Emacs lisp comment, not a Python

;; (define-key map [(control c)(control r)] 'py-shift-right)

Revision history for this message
Juan A Rodriguez (juant-rodri) said :
#4

Great,

It's solved now!

Thank u so much,

Best,
Juan

Revision history for this message
Juan A Rodriguez (juant-rodri) said :
#5

Thanks Andreas Roehler, that solved my question.