emacs :: autocompletion and code-commenting

I’m a believing member in the church of emacs, and in honor of the new release I went looking for solutions to a couple of outstanding issues I’ve had with my emacs installation.

Today’s first emacs find is M-; which, although undocumented, works excellently to comment and uncomment code blocks in Python (it had puzzled me for a while that the comment-block command on the Python menu was C-c # and that there was no mapping for the uncomment command). The M-; command works in a plethora of other modes as well to comment and uncomment blocks.

The second emacs treasure I found today was how to turn on autocompletion. Not the mind-numbingly annoying kind that some editors have that pops up and obscures half your program whenever you type a key, but rather cycling through options when pressing M-RET. To enable it, simply put this in your .emacs file:

(define-key global-map (read-kbd-macro "M-RET") 'hippie-expand)

Searching for some info on hippie-expand, I ran into dabbrev-expand which is bound to M-/. I couldn’t tell you what the difference is, but the ESC-Enter combination is easier to find blindfolded so that’s what I’m going with.

This entry was posted in emacs, Python. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *