Conclicts with keyboard bindings

Asked by James Jong

When I type C-x C-f, Emacs executes my buffer in a python shell. Is there any way to unbind this? Where are python-mode keyboard bindings defined? C-x C-f clashes with other definitions associated with the package helm that I have.

Question information

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

Am 06.02.2013 00:21, schrieb James Jong:
> New question #221144 on python-mode.el:
> https://answers.launchpad.net/python-mode/+question/221144
>
> When I type C-x C-f, Emacs executes my buffer in a python shell. Is there any way to unbind this? Where are python-mode keyboard bindings defined? C-x C-f clashes with other definitions associated with the package helm that I have.
>

Can't see where C-x C-f is set by python-mode. This should call find-file. Please check your init-file.

Revision history for this message
Georg Brandl (gbrandl) said :
#2

James, you probably have ffap.el (find-file-at-point) loaded, to which Python adds hooks that try to find the Python module file under the point. I have that disabled in a custom python-mode hook since I hate that behavior (it makes C-x C-f take ages).

Andreas, it would be good to have a custom switch to switch off all ffap-related hooks. Interestingly, there are two places where ffap-alist is changed:

(eval-after-load "ffap"
  '(progn
     (push '(python-mode . py-ffap-module-path) ffap-alist)
     (push '(inferior-python-mode . py-ffap-module-path) ffap-alist)))

(eval-after-load "ffap"
  '(push '(python-mode . py-module-path) ffap-alist))

Maybe this should also be consolidated?

Revision history for this message
James Jong (ribonucleico) said :
#3

Georg. That definitely seems to be associated with my problem. Do you know how I can disable ffap (or those particular hooks) in these particular cases in python-mode?

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

Commenting out the part should solve it for the moment.

BTW if you wanna see the code python-mode defines most of its keys

its following line 12032 - (setq python-mode-map

Revision history for this message
Georg Brandl (gbrandl) said :
#5

Check what C-x C-f is bound to (with C-h k). It should be find-file-at-point.

If that is the case, add this to .emacs / init.el:

(add-hook 'python-mode-hook (lambda ()
  ;; remove python-mode's ffap things that slow down find-file
  (setq ffap-alist (remove '(python-mode . py-ffap-module-path) ffap-alist))
  (setq ffap-alist (remove '(python-mode . py-module-path) ffap-alist))
  (setq ffap-alist (remove '(inferior-python-mode . py-ffap-module-path) ffap-alist))
))

Revision history for this message
Georg Brandl (gbrandl) said :
#6

Andreas, this is not about python-mode binding keys. It is about python-mode adding something to ffap-alist, which evaluates the whole buffer on C-x C-f (because find-file-at-point calls the functions in ffap-alist).

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

Okay, at least understood the hooks stuff so far as a fix will need. ;) Thanks.

Revision history for this message
Am00 (amelio-vazquez) said :
#8

I am having a somewhat of a similar problem when I press `<TAB>` to fix the indentation of a region. I have a question on StackOverflow on this: http://stackoverflow.com/questions/15767481/python-mode-in-emacs-tab-results-in-never-ending-processs in case it helps.

Can you help with this problem?

Provide an answer of your own, or ask James Jong for more information if necessary.

To post a message you must log in.