I'll admit I'm mediocre at emacs. Which is kind of silly because other than a few years of eclipse use it's been my main editor for some 11 years. In an effort to help me start using features I don't normally use, I'm going to go over Jonathon's features of python IDE's in a series of blog posts, but with a focus on emacs. I'm going to base the post's on the features found there, but also might do some other features that I think are handy. If you've got comments, suggestions, by all means let me know. Also, one way to learn is by watching others. Well I can't watch you, but you can drop hints. I've sat in the presence of people who live in a screened session of emacs, and wish I would've taken note of what they did...
Some possible outcomes of this might be updating the content on emacswiki and python wiki both of which seem somewhat disorganized. Another outcome might be a "Teach me how to use emacs...." session in PyCon. (I wouldn't teach it, but would love to see demo's of others using features that I should be using).
Without further ado, here's the first feature on the list:
Keyboard macrosYes! Emacs has keyboard macros. The documentation included in emacs manual (C-h r) and the emacswiki entry on keyboard macros seem simple enough.
This might seem lame for my first entry, since I'm not really expounding on anything new. But I'll admit, I never use macros. It seems like either a search/replace covers most needs, otherwise if it's something more complicated than that I'll write a script or do it by hand (if it's a one time thing). I'll further admit, that most of these are not even when editing python. So my questions to all emacs gurus out there: When do you find macros nice? When do you use them when python programming?
update - I'm using macros more and finding them useful every so often. Also extremely useful in Python are the rectangle commands. I really only use one ,C-x r t (string-rectangle), which is a great combination for inserts and deletes!. Another use for macros is to simplify creating functions. Today I wanted a command to kill the pdb buffer and restart pdb (since I was doing it a lot). I made a macro for it. I named it (C-x C-k n), then I pasted the macro in my .emacs using M-x insert-kbd-macro, then I bound the command to f11 as listed in the emacswiki macro entry (sub heading One-Key Macros).
Looking forward to some more emacs articles. I've just started using it
again after breaking for a year or so jumping from vim to eclipse to komodo
edit amongst others, so any pointers, especially python ones would be
great.
"""Another outcome might be a "Teach me how to use emacs...." session in
PyCon. (I wouldn't teach it, but would love to see demo's of others using
features that I should be using)."""
I find that with python, I don't need code completion much, but it's still
useful at times.
pysmell with emacs is pretty cool. It's by Orestis Markou
I use emacs macros constantly. If you get good at them, you see all sorts
of examples - for example, you often need to make the same change to
several functions, and if you are careful to make your navigation general,
you can do the first one carefully and then use a macro to do the rest.
A "Teach me how to use Emacs" session would be great! Preferably at euro
pycon too.
I love dmacro: http://drewp.quickwitretort.com/2006/05/22/0
I use keyboard macros all the time. Any time I find myself repeating the
same sequence of actions for a second time, and know I'm going to do it a
few more, I pay attention to how I can "generalize" the movements to make
them macroable, and then the third time I do it, I record. After that it's
just C-x e, C-x e -- or even better, C-u 50 C-x e. Keyboard macros rock.