Emacs ups and downs

Every month or so I try to learn a new Emacs feature or extension – something beyond the usual buffer juggling and programming-language modes. Of course when you’re trying new things so frequently some of them are going to work better than others. Things I’ve tried that stuck:

  • Keyboard Macros – probably the first “advanced” Emacs feature I learned and I use it all the time. I don’t save and name my macros as often as I should though.
  • Tramp – tramp-mode allows me to run a fast local Emacs and edit files remotely with no setup required. Just open /server.example.com: and go. Underneath it uses SSH to access the files, and you can set it to use alternate methods (scp, sftp, rsync, etc). I do wish it was a little faster though, or multi-threaded so it didn’t block Emacs when saving over a slow link.
  • Bookmarks – I bind M-b to bookmark-jump and I use it all the time. I have bookmarks for each project I’m working on and I use them with tramp-mode to get me onto the appropriate server.
  • Yasnippet – a recent add, this is a module which provides a template system for Emacs. It comes with some useful boilerplate templates for various programming languages and you can easily add more. I use the class and def ones for Python periodically as well as ones I’ve added to set up a warn() call.
  • browse-kill-ring – super useful to be able to pull up the full kill-ring and search for what you need. I have my kill-ring set to hold 100,000 entries, so if I’ve killed it in the current session I can be pretty sure I can get it back!
  • auto-complete – mode-aware auto-completion. I’m still not sure this one is going to last, but it does help a lot sometimes, particularly when I’m coding deep in a Python file and I need to accurately type the name of an imported identifier from the top of the file. And I’m getting more used to hitting C-g when I need to keep what I’ve typed and not accept a completion. I think it’s most likely a keeper.

Of course, not every experiment is a success. Here’s a few notable recent ones that I’ve since abandoned:

  • ido-mode – I wanted to like this one. Sometimes it’s a big time-saver, quickly navigating to files I’m trying to open in just a few keypresses. But just as often I’d find myself fighting with it, particularly when trying to create new files or navigate up a few levels. Ultimately I decided that the benefits of having a file path that’s editable the same way as normal text is just too much to give up.
  • registers – this still seems like something I should be using. Surely the ability to remember locations and little bits of text and then replay them should come in handy. Alas, not often enough to actually remember the keystrokes on the rare occasions when I think to use them.
  • rectangular selections – again, potentially very useful but I don’t need it often enough to remember the bindings. It doesn’t help that the default binds are so verbose, possibly I could learn to love this feature if I rebound it.
  • Tags – I’ve setup TAG file generation for several projects now, and each time I use it for a while and then fall back to grep and ack. I think the way TAG searches work just doesn’t match the way I want to search for things – I want to quickly browse through a list of hits, not jump from file to file. Still, being able to jump from the use of a function directly to its definition seems like it should be very useful!

I’m always curious about how other people use Emacs – what features do you use most and what have you tried that didn’t work out?

You may also like

13 Comments

  1. I don’t use bookmarks yet, but this post makes me want to give it a try.

    On things that didn’t stuck for you:
    Ido is just plain awesome. What you say is true and perturbing at the beginning, until you learn that when Idoing in the minibuffer, C-f let you edit the path like if Ido wasn’t here (that’s the one you want), C-d open the current dir in your ido path in a dired buffer, and one of the most awesome: C-SPC “validate” your current filter and let you start a new fuzzy matching in it. And I’m pretty sure there are other stuff I don’t yet…

    Rectangulars selections: that’s something really useful if you do some html for instance for manipulating lists etc. But I agree with you that by default it miss some stuff: You can’t say “add this text at the end of my rectengular selection” or “add this text at the end of all the line in my selection” (not really a rectangle feature but really similar). So I coded two little function that does that (that was my first emacs lisp code apart from basic configuration in my init.el file, it’s very simple and can certainly be optimized a lot). You can find it here : http://gitorious.org/gnu-emacs-config/mainline/blobs/master/rect-missing-features.el
    Put it in your load-path then add this to your init.el file :
    (global-set-key (kbd “C-x r a”) ‘string-insert-rectangle)
    (load “rect-missing-features”)
    (global-set-key (kbd “C-x r z”) ‘string-insert-after-rectangle)
    (global-set-key (kbd “C-x r e”) ‘string-insert-rectangle-eol)
    And you’re good to go :-).

    Like you, I still don’t use registers and Tags. I give Tags a try and it’s really cool, but I don’t know why I don’t think of generating tags file for my projects.

  2. Rectangular selections always seem really helpful, but I don’t use it enough to remember the keybindings. What I do remember is cua-mode’s rectangle support. You can C-RET and start moving to get a real deal rectangle selection. You can also move down a set of lines and start typing to write on multiple lines at the same time. I’ve found it to be insanely helpful for quick edits on text that lines up vertically.

    Here is a helpful screencast http://www.vimeo.com/1168225?pg=embed&sec=1168225

  3. @mifrai
    A few more ido things that might help:
    When using ido for files C-w moves up a directory level.
    And if ido mode is too annoying for file browsing, you can tell it to be buffer only by setting the variable ido-mode to ‘buffer

  4. I had the same problem with ido-mode. But that’s easy to fix. If you just want to open a new file or use * for opening everything you can fall back to the normal find file with C-x-f

  5. I had initial reaction to ido-mode.. but I use it for everything now. Thumbs up.

    For TAGS, while I use TAGS and find them useful.. I use idutils a lot more. It’s basically a full-text index.. It’s very fast to create and searching is nearly instant. Very useful on large projects. There is a corresponding idutils.el you can load and you are off.. Simply run “mkid” on any directory.. it will index recursively. Then “M-x gid” and a keyword… I bind to M-,

    you can control what gets indexed and how via /usr/local/share/id-lang.map

    worth checking out.. just look for idutils rpm

  6. @Pete
    If idutils can work over Tramp I may just check it out. If it’s local only it won’t be too useful for me – 90% of my projects are remote. Thanks for the tip either way!

  7. I agree with you about tags – the I find the default tag search behaviour a bit annoying. I use etags-select. It displays a buffer with the all the tag matches and you can choose the one you meant. I love it.

  8. I also find ido-mode a little too un-Emacs-like, but I do like the help it provides in quickly navigating to files. Have you looked at iswitchb-mode? It does some similar things as ido-mode but seems to be better at getting the hell out of my way when I don’t want its results.

  9. @Jeramey Looking at my .emacs I see that I did try iswitchb-mode – the config for it is commented out. I think I stopped using it when I switched to ido-mode! I should turn it back on now. Thanks!

Leave a Reply

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