Replacing a Region With the Last Kill

I learned a another neat trick from Aaron Hawley’s Giant Emacs Reference Sheet. This is another of those tricks, like the revert buffer shortcut, that uses keystrokes intended to do something else in a novel way to accomplish something unexpected.

In this case, we want to replace the current region with the last kill. Hawley says to do this with 【Ctrl+w Ctrl+y Meta+y】. This looks odd because the 【Ctrl+w】 is already a complete shortcut.

If you look at the entire sequence carefully, you see that it accomplishes the task in 3 steps:

  1. Ctrl+w】 kill the region
  2. Ctrl+y】 yank it back
  3. Meta+y】 replace the last yank with the penultimate kill

So it’s really just a matter of combining 3 commands to do something new. A very nice trick and easy to remember because it’s not really anything new.

Posted in General | Tagged | 4 Comments

A Page on Emacs 24’s New Features

Xah Lee has started a page on New Features in Emacs 24. He’s promising to add to it every few days so it might be a good place to go to get familiar with some of Emacs 24’s new goodies at a leisurely pace.

Posted in General | Tagged | 3 Comments

Muscle Memory

I can so empathize.

Posted in General | Tagged | 1 Comment

Living Without Flash

Let’s face it: Flash is a mess. Hardly a week goes by without a new exploit and its performance problems are legion. Steve Jobs famously hated Flash and refused to allow its use in iOS. My Linux distribution strongly recommends against its use every time a new version of Flash is installed. In the meantime, HTML5 is poised to replace Flash.

Now Apple has pounded another nail into Flash’s coffin. As of OS X 10.7.4, OS X will disable Flash unless you have the latest version installed. They could have just installed the latest version for you as they have in the past but apparently decided to give their users a nudge by making them consciously choose to install Flash.

I’ve long thought about disabling Flash but it always seemed to me that I’d miss out on too much content that I might want to see. Nonetheless, after the upgrade I didn’t upgrade Flash and have been running Flash-free for the last few weeks. I have to say that not only have I not missed Flash, I’ve hardly noticed it’s gone.

I’m interested in other people’s experiences. I know many folks have stopped using Flash (whether or not they’re OS X users) but I have no idea of how widespread this is. If you’ve stopped using Flash or are thinking about doing so, leave a comment with your thoughts. Likewise, if you’ve consciously decided to continue using Flash, leave a comment with your reasoning.

Posted in General | Tagged | 2 Comments

Emacs 24.1 Has Been Released

Emacs 24.1 is ready for download from the usual places. There’s all kinds of little improvements that we’ve talked about from time to time but the main features, as described by the release notice, are:

  • The new packaging system. This was available in Emacs 23 as the ELPA add on but it’s now built in.
  • Bidirectional text. Probably not a huge item for most users but if you write in Arabic or Hebrew, I’m sure this will be very welcome.
  • Lexical scope in Emacs Lisp. I’ve written about this before.
  • Improved Custom Themes system. Again, this was available as an add on in Emacs 23 but is now built in.
  • Unified and improved completion system in many modes and packages.
  • Support of GnuTLS, GTK+ 3, ImageMagicK, SELinux, and Libxml2.

Those of you using OS X who don’t want to build from source, can get the binary from Emacs For Mac OS X.

Posted in General | Tagged | Leave a comment

Emacs display-battery-mode

I have occasionally run across the Emacs display-battery-mode command—it’s in Aaron Hawley’s excellent reference sheet, for example. I never bothered really looking at it because my MacBook Pro already has an battery status icon on the menu bar. Today, out of curiosity, I played around with it a little and discovered it can actually be useful in my situation. The Mac’s battery icon can display time remaining or percentage charge but not both. I have it display time remaining because that seems the most useful to me but sometimes I click on it and ask it what percentage of the charge remains. By using battery-display-mode I get the percentage displayed in Emacs and the time on the menu bar—the best of both worlds.

Actually, the display-battery-mode command is configurable—it’s Emacs after all—so you can display pretty much whatever information you want by editing the format-like battery-mode-line-format string. If you’d like additional information about your battery status displayed or if you have a Linux system and don’t want to take up room with a battery status widget, this could be just what you need.

Posted in General | Tagged | Leave a comment

Blind Tennis

The next time you’re tempted to whine about how hard a task is; how it’s simply impossible; how obviously no one could be expected to do it: remember this. I know I will.

Posted in General | Leave a comment

Password Advice

There’s been a lot of snark going around the last few days over this password help screen from the Texas Attorney General’s Child Support Services Web Page. Child Support Services are, of course, doing the best they can to preserve the privacy of the children involved but their rules for passwords display some fundamental flaws:

  • An entropy limiting hard limit of exactly 8 characters.
  • Limiting special characters to @, #, and $.
  • Additional rules that are there ostensibly to increase entropy but actually decrease it by limiting the number of patterns a legal password can have.
  • Not hashing the passwords so they can enforce password reuse rules.

All this is standard stuff that I and many many others have written about before.

Sadly, those of us writing about the issue are not blameless either. In an otherwise excellent post, Rituraj over at Random Ramblings says that the scheme, recommended by the famous xkcd cartoon, of using random dictionary words is “…surely difficult to crack using brute force. But can be cracked using dictionary attacks.” Presumably he thinks this because the words are in a dictionary and hence known1.

But it’s not true that knowing the dictionary from which the words are drawn makes the password vulnerable to a dictionary attack anymore than knowing the letters from which a “normal” password is composed makes it vulnerable to a dictionary attack. Suppose you had a list of 94 words that you use to make your multiword password and suppose that you use 6 words in your password. Then you have 946=689,869,781,056 possible passwords. Now suppose you choose a six character password from the 94 possible characters on the typical keyboard. Again, you have 946 possibilities so there’s no difference between the systems. But, you say, you know the 94 words so you can mount a “dictionary attack,” whatever that means. The same is true of the second method: you know the 94 characters so you could mount an exactly analogous dictionary attack if one existed. In the first case you have an alphabet of 94 words (just think of them as symbols) and in the second you have an alphabet of 94 characters. It’s exactly the same thing.

Now let’s be a bit more realistic. The Unix list of dictionary words (/usr/share/dict/words) on my machine is 235,886 words long. After folding case and eliminating duplicates it’s 234,371 words long. If we choose 131,072 (=217, the highest power of 2 less than 234,371) of those words, a password of 4 random words from the list would have 72 bits of entropy as compared to just over 26 for a 4 character password (remember that increasing the entropy by 1 doubles the strength so this is a big difference). If we use the more realistic 6 symbols for each password we get 102 bits of entropy for 6 words as compared to just under 40 bits for the 6 characters. We’d need a password of about 16 character to match the strength of the six word password.

Rituraj rightly notes that one of the problems with the Child Support Services password policy is that it tends to require hard to remember passwords and so the user faced with several such passwords will pull out the Post-its and completely destroy all security. Troy Hunt has posted on this problem (my commentary here) and says that the only viable method is to use a password manager and a single high-entropy password for it. This is, I think, correct but good luck trying to get your average user to implement it; password and 123456 are so much easier.

Footnotes:

1 I’m not picking on Ritaraj here. His post is, by and large, a good one and this mistake is distressingly common.

Posted in General | Tagged | Leave a comment

Error and Restarts in Common Lisp

Robert Smith over at Symbo1ics Ideas has a very nice introduction to restarts in Common Lisp. Restarts are a part of the CL error system (more accurately, part of the CL condition system) and provide a way to recover from errors even if they happen in code that is far away from where the error is handled. The example that Smith gives assumes that the code where the error occurs is in a third party library but that the vendor has provided scaffolding to allow graceful recovery from errors.

If you’re new to Lisp or if you aren’t a Lisp user but want to see how error handling can be done right, head on over and take a look at Smith’s post. If you want more after reading Smith’s post, Chapter 19 of Peter Seibel’s excellent Practical Common Lisp gives a reasonably comprehensive introduction to the Common Lisp condition system.

Posted in Programming | Tagged | Leave a comment

The Emacs comment-dwim Command

I really like the Emacs comment-dwim command. The dwim—do what I mean—neatly captures the idea of the command. It looks at the context in which it is called and then does the right thing™. Most often, I highlight a region that I want to comment or uncomment and then just call 【Meta+xcomment-dwim to comment or uncomment the region. It’s very handy for temporarily commenting out a block of code or for turning a paragraph of explanation into a comment without having to worry about adding a comment indicator on each line. The correct comment character, as determined by the mode, is used to mark the comment.

I use the excellent smex so I normally just start typing dwim and the proper command comes up. There’s also a keyboard shortcut, 【Meta+;】, that’s pretty easy to remember and that I’m trying to use more often.

Although I find comment-dwim most useful for working with regions, it also does the right thing on single lines or even empty lines. See the documentation for the details. If you use the keyboard shortcut, it’s a one-size-fits-all method for inserting or deleting comments.

Posted in General | Tagged | 1 Comment