Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm having trouble getting the py-electric-backspace command to execute when I hit backspace at the end of a line of only spaces in python-mode. When I hit backspace it deletes individual spaces, not 4 at a time as it should be.

What confuses me is that if I do M-x py-electric-backspace, it performs the command correctly and tells me I could have invoked the command by using backspace:

You can run the command `py-electric-backspace' with <backspace>

I'm using python-mode.el version 6.0.10, and I've tried reducing my .emacs file to only the few lines required to load python-mode.el.

I'd like backspace to work properly in python-mode, but I don't even know where to start figuring out what's wrong. Any help would be appreciated.

Update:

I've added the following to my .emacs file:

(add-hook 'python-mode-hook
     (lambda () (define-key python-mode-map (kbd "DEL") 'py-electric-backspace)))

which seems to do the trick.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

What is the output of C-h k <backspace>? My guess is that you are running in a terminal and you can't actually type <backspace>, since it gets changed by the terminal to DEL. Running in a GUI, or binding py-electric-backspace to DEL should fix it.

share|improve this answer
    
Thanks! I think this might be a bug in the latest python-mode.el (I've reported it here bugs.launchpad.net/python-mode/+bug/1027100) but this works in the meantime. –  Noah Jul 20 '12 at 14:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.