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.

Posted in General | Tagged | Leave a comment

Inserting Underscores

John Kitchin offers a nice tip for Emacs users who write in Python, C, or some other language that makes heavy use of underscores.

You’ll need key-chord.el (available from Melpa) but it’s so useful you should have it installed anyway. Don’t take my word for it, ask Magnar.

Posted in General | Tagged | 6 Comments

Note Taking with Org Mode

I thought I’d written about Tony Pelaez’s video on Taking Notes in Emacs Org-Mode before but I couldn’t find the post. Even if I did write about it, it’s a nice introduction to one of Org mode’s most useful functionalities and worth mentioning again. This is especially true since I’ve been seeing a lot of tweets lately from people just discovering Org mode.

Pelaez’s introduction is very elementary in the sense that he mostly ignores the standard keyboard shortcuts and uses menus or 【Meta+x】 command sequences instead. When he gets to demonstrating the outlining functionality—in the guise of making a TODO list—he does use the shortcuts. If you don’t use Org mode everyday, it’s easy to forget these so it serves as a nice review even if you’re not a n00b.

If you’re just starting with Org, this video will introduce you to one of its major use cases. Be warned though: you’ll soon be using Org for an ever increasing portion of your workflow.

Posted in General | Tagged , | Leave a comment

USB versus the U.S. Government

Posted in General | Tagged | Leave a comment

The Reality of Key Escrow

Back in 2000 PGP, a mature and capable company with significant experience in encryption and security, decided that it would be a good idea to provide key escrow for its corporate users.

It did not, of course, end well.

The feature ended up making all PGP keys vulnerable. Here’s a thread describing the bug. If you read through the posts, you’ll see that the problem was that a programmer essentially neglected to check a return value. Also notice how easy the vulnerability is for anyone to exploit. Once again we have confirmation that security is hideously hard to get right.

This was supposed to be a benign feature that Network Associates—owner of PGP—added to assist with key recovery. The result was a devastating, unfixable bug that could only be eliminated by retiring two versions of PGP. What possible reason is there to believe that a government mandated key escrow would do any better?

Posted in General | Tagged , | 2 Comments

Using reveal.js with Org Mode

For those looking for a way to produce slides with Emacs and Org mode, there are two popular options: Beamer and reveal.js. Each solution has its partisans but if you’re in the reveal.js camp, Yujie Wen has an org-reveal package that allows reveal.js slide decks to be produced with Org mode.

The process is pretty simple. By default, each top level heading is a new slide containing the content of that heading. Subheadings are child slides that sit logically below the parent slide. You can add options to the entire deck or individual slides to control how the slides display.

Wen’s readme.org that comes with the package is a complete manual for using org-reveal and can also be exported to a slide deck. In that way, it serves not only as a manual for using the org-reveal package but as a go-by for writing your own slides.

If you give talks, are an instructor, or otherwise need to generate presentations, this is a nice package that’s easy to use and doesn’t take very much effort to get up to speed with. Definitely worth checking out.

Posted in General | Tagged , | Leave a comment

Dotfile Management

Haoyang Xu has a really nice idea for managing your dotfiles. The idea is a generalization of using Org mode to configure Emacs, a strategy that many people have written about (here’s a pointer to a video about it). Using Org mode has the advantage that it’s easy to document your choices in a way that’s much harder to do by just adding comments. Grant Rettke has an example of this idea on steroids: he documents everything about his Emacs configuration including why he chose one configuration item over another.

Xu extends this concept to all your configuration files. You collect your configuration data in an Org file with a header for each subject area—mail, say—and have subheadings for particular dotfiles—like .mbsync, .msmtprc, and so on. Xu’s post has the details and some examples. He also shows how to extend the idea.

This may not be worth the trouble if you have a single machine but if you maintain two or more machines that have similar configurations, this is a real win. You can have a single (versioned) Org file that has all your configuration data, making it easy to maintain consistent configurations from a single file. Xu even shows how to configure remote machines.

I really like this idea and will probably implement it the next time I have to set up a new machine. Of course, it’s easy to start slow and keep adding additional dotfiles. That’s probably what I’ll do. When I get around to that new machine, I’ll already have my Org file ready to go and tested.

Posted in General | Tagged , | Leave a comment

The FBI Begs Off

This is what you do when you think you’re going to lose and set the wrong precedent.

Posted in General | Tagged , | Leave a comment

Ensime Hacks

Over at Ensime they have a page dedicated to Emacs Hacks. Although it’s written from the point of view of a Scala developer, the hacks are useful for any Emacs user.

There three sections, one each for

  • General hacks
  • Scala hacks
  • Elisp hacks

there is also a section for Java but it’s not yet completed.

Each of the items either describes a useful package or a bit of Elisp that is too small for a package but which performs some useful task. Unless you’re a complete n00b, you probably already have many of the packages installed but it’s useful to read through the list in case you’re missing something.

The page is a nice resource and well worth taking a look at. If you find just one package that you didn’t already have useful, it will easily pay for the time you spend on it.

Posted in General | Tagged | Leave a comment

Matt Blaze on Adtech

Countless pixels have died in the battle over adtech. I’ve long held the view that I’m happy to view the ads but I object strongly to being tracked and having arbitrary scripts run on my machine. Some time ago, I installed Ghostery as a compromise that would block the trackers but allow legitimate ads through. Of course, since virtually all ads are tracking ads that had the happy side benefit of blocking almost all ads.

After the latest example of malware being delivered by the ad networks at legitimate—and presumably safe—sites like the New York Times and the BBC, I’m considering adding another blocker to filter everything. I do understand the legitimate concerns of sites that depend on advertising but enough is enough. The ad networks have lost all claims on our sympathy and good will and those depending on them had better find better solution because I’m sure I’m not alone on being fed up. Clean up your acts or stay the hell off my machines.

Here are three tweets from Matt Blaze that capture the situation nicely:

Posted in General | Tagged , | Leave a comment