Some Oldies but Goodies

When I find a useful Emacs package or tip, I almost always write about it so others can take advantage of them too. The other day I was using one of those packages and thought, “Gee, this is really neat. Everybody should be using it.” That coupled with the fact that I keep seeing posts or tweets asking about how to do some of these things made me think that it would be worth revisiting some of them. These tips/packages are ones that I use almost everyday and wouldn’t want to live without.

Without further ado, here’s a list of tips/packages that I find very useful along with the original Irreal post that discussed them:

  1. Looking up a word from Emacs. Abo-abo has a very nice small package, Defining the Word at Point, that will look up the word at point and give you the definition in the minibuffer. It’s incredibly useful; I’ve already used it in this post.
  2. Everyone agrees that zap-to-char is useful but then go on to complain that it should really zap up to the character. It turns out that there’s already an Emacs function that lets you Zap Up To A Character. Read the post to see how to enable it.
  3. We all know about 【Ctrl+h f】 and 【Ctrl+h k】 to bring up documentation about a specified function or a function bound to a key. One of Irreal’s frequent commenters, Phil, notes that you can also bring up the source for those functions too (Help From Phil) using the functions:

    • find-function
    • find-function-on-key
    • find-variable
    • find-library

    I bind these to the keys corresponding to the documentation functions but with the letter after the 【Ctrl+h】 modified with 【Ctrl】 so that find-function, for example, is bound to the 【Ctrl+h Ctrl+f】 shortcut.

  4. A trick I learned from Tim Visher is evaluating an sexp in an Emacs buffer and replacing the sexp by the result. I wrote about that and the code I used to accomplish it in Eval and Replace in Emacs. I’ve since replaced the code with

    ;; From Lars Tveito: https://github.com/larstvei/dot-emacs/blob/master/init.org
    ;; This avoids overloading C-c C-e in org-mode
    (defadvice eval-last-sexp (around replace-sexp (arg) activate)
      "Evaluate and replace when called with a prefix argument."
      (if arg
          (let ((pos (point)))
            ad-do-it
            (goto-char pos)
            (backward-kill-sexp)
            (forward-sexp))
        ad-do-it))
    
  5. From one of Sacha’s chats, Sacha Chats with Steve Purcell, I learned about one of the most useful packages I have: whole-line-or-region. It lets you use certain commands, like 【Meta+w】 that normally work on a region, on the entire current line if no region is defined. I can’t tell you how useful this is. I use it every single day including several times in writing this post.
  6. I often want to do a ping or traceroute and used to switch to a terminal to run them. Then I found out about the Emacs Net Utilities that lets me run them from within Emacs. Later I improved that a bit by making them run in a temporary screen: Running Ping in Emacs.

I hope you find some or all of these tips/packages as useful as I do.

This entry was posted in General and tagged . Bookmark the permalink.