Unintended Consequences

Although it might seem so, this post is not about politics, the evils of socialism or anything like that. Irreal doesn’t do politics. Rather, this is a post about what happens when you fail to consider unintended consequences.

Like most developers I’m always acutely aware of possible unintended consequences. Or maybe it was my years working on security software that taught me to think about how things could go wrong. Or maybe I’ve just always been that way. In any event, this made me laugh. The unintended consequences are so easy to foresee that one is suspicious that the Hollande government did see them but just didn’t care.

The TL;DR of the story at the link is that after the new French Socialist government imposed a 75% surtax on the rich, the rich started leaving France. What did they think was going to happen? The fact that this mass exodus resulted in howls of outrage from the French government only makes the whole thing funnier.

Again, this isn’t a political post and it takes no stand on socialism versus capitalism or any of the rest of it. Nor is it about how foolhardy those silly French are; after all, in the U.S., California is experiencing essentially the same thing. It’s merely to point out that whatever your beliefs, it’s dangerous to indulge in magical thinking and fail to consider how things might go wrong.

Posted in General | Tagged | Leave a comment

Magnar Sveen’s New Blog

I notice from the Emacs Rocks twitter feed that Magnar Sveen has started a new blog called What the .emacs.d!? It’s about setting up Emacs and each post features a bit of code from Sveen’s .emacs.d directory. You can, of course, see his entire .emacs.d setup at any time by visiting GitHub but these posts explain what each bit is doing and why he is doing it.

It’s brand new and has only 3 posts so far but as you would expect from Sveen, it’s excellent. I’m looking forward to seeing more posts.

Posted in General | Tagged | Leave a comment

A Solution to the VimGolf in Emacs Riff

Recall that the last VimGolf in Emacs challenge was to convert

abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz

to

a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z

I found this harder than I expected. It’s pretty easy to put a space after each character but then you have to deal with the spaces after the z in each line. The previous challenge was easier because all we had to do was find the blanks and replace each of them with four blanks. In this case we want to insert a blank after each character unless it’ the last character in the line.

Here’s my solution:

Ctrl+Meta+% Invoke query-replace-regexp
. \ B Return Match every character except the last in the line
\ & Space Return Replace with the match followed by a space
! Run for the entire buffer

That’s a total of 10 keystrokes. Not too bad, but Aaron Culich managed to shave off 3 (!) more keystrokes by realizing that you don’t have to match the letters, just the empty spaces between them. Thus the regexp for the FROM string is just \B, which means that the TO string is just SPACE for a total of 7 keystrokes. If you can do better, be sure to leave a comment. If you’re a Vim expert, how many keystrokes does it take you?

Posted in General | Tagged | 2 Comments

Copyright Redux

Another post on copyright. I’m sure that most of you are tired of it by now. I sure am. But copyright is out of control and the copyright industry is an insatiable and rapacious beast that will happily gobble up our freedoms and destroy the Internet if we let it.

This week I found two excellent articles addressing these problems. One, The Surprising History of Copyright and The Promise of a Post-Copyright World, explains how copyrights aren’t and never were meant to benefit authors, musicians, or other content producers. They were developed explicitly to protect the distributors of artistic content. That is, the publishers and record companies. The article is long and detailed but is mandatory reading. The TL;DR is that copyright began as a means of censoring authors in sixteenth-century England and then as a way of continuing the power and profit of the London Company of Stationers to whom the task of censorship had been outsourced. The article makes the case that the largest fear of the copyright industry is that people will discover this truth. Really, you must read this article.

The second article, The Declared Value System: Managing Monopolies for the Public Good, was written by Karl Fogel over at Falkvinge & Co. on INFOPOLICY. Fogel proposes a fix for the copyright mess. The idea is simple. If the creator does not register a copyright, the work simply enters the public domain. The copyright owner can choose instead to declare a value for the work and register it for a one year copyright for a fixed percentage, 1% say, of the declared value. The copyright could be renewed a limited number of times. At any time a third party can pay the owner the declared value and at that point the work enters the public domain. Read the article for a thorough explanation of the plan and how it balances the rights of creators and the public.

Fogel notes that exactly the same plan would also work to clean up the patent mess which, if anything, is in even worse shape than copyright. The copyright industry, of course, will not like this idea; it’s not in accord with their business plan. And they sure don’t want people going around talking about the dirty little secret of copyright’s history and real purpose. That’s why it’s important that you spread the word.

Posted in General | Leave a comment

A Riff on the Last VimGolf in Emacs Challenge

Here’s a small variation on the last VimGolf in Emacs challenge. Given

abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz

transform it into the starting buffer from the last challenge

a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z

Note that there are no spaces after the zs. I’ll post my solution in the next day or two.

Posted in General | Tagged | 3 Comments

A Nice Folding Trick for Emacs

jao over at Minor Emacs Wizardry has a nice post on folding in Emacs. As he points out, there are several packages to do folding but there is also a built-in method that may handle many of the cases where you want folding. The command set-selective-display will cause any lines with an indentation greater than or equal to its argument to be hidden. This is useful (depending on your coding style) when you want to see only function headers and global data declarations. You need only call set-selective-display with an argument of 1.

The command is bound to 【Ctrl+x $】 so you can hide everything but your top level definitions by typing 【Ctrl+1 Ctrl+x $】. To turn off the folding, just call 【Ctrl+x $】.

You may find the key sequence a little clumsy, so jao offers a couple of short cuts. It’s a nice post so you should take a look if you have an interest in this sort of thing.

Posted in General | Tagged | Leave a comment

Attention Troff Users

If, like me, you continue to be a Troff holdout, there’s good news from O’Reilly: They are now offering a free download of the original Unix Text Processing. The book has long been out of print and, I believe, the source code was lost. Now, however, a PDF file has been created, apparently with OCR, and the authors, Dale Dougherty and Tim O’Reilly, have generously made it available for free download.

Previously, the authors had found some PBM files for the book and released those. That gave rise to a project on the part of some of the Groff mailing list denizens to recreate the book from scratch. You can even get the source code for that effort, if you like.

This book is a real treasure and one that every Troff user wanted to own. I hunted for years before I found a used copy. Now you can just download the PDF.

Posted in General | 1 Comment

A Nice Emacs Trick

In the comments to my Another VimGolf in Emacs Challenge post, Aaron Culich points out something that I didn’t know. It is possible to enter query-replace or query-replace-regexp directly from isearch. When you do this, query-replace and query-replace-regexp will use the search string for the FROM string and only ask you for the TO string. You invoke the query-replace functions from isearch by typing 【Meta+%】 or 【Ctrl+Meta+%】 before quitting isearch.

Why would you want to do this? Here’s an example. Suppose you have code like

(defun anothercase ()
  ...)
...
(anothercase)
...
(anothercase)
...
etc

and that your cursor is at the defun. You decide you want to change the name of the anothercase function to make-new-instance. If you type 【Ctrl+s a Ctrl+w】 the search string will be anothercase and you can type 【Meta+%】 to start query replace with the FROM string already set.

A final note. You don’t have to do anything to enable this functionality. In particular, it is not controlled by the query-replace-interactive variable. That, if non-nil, always uses the last isearch string as the FROM string for the query-replace functions, which is probably not what you want.

Posted in General | Tagged | Leave a comment

Wonderful

This is just wonderful. Reuters is reporting that for the first time NPEs (more commonly known as Patent Trolls) are bringing the majority of U.S. patent lawsuits. Can someone please explain that part about the public interest to me again? Can we have a serious discussion on patent reform now? If not, what will it take?

Posted in General | Leave a comment

Solution To Yesterday’s Challenge

Yesterday’s post asked you to turn 26 lines of

a b c d e f g h i j k l m n o p q r s t u v w x y z

into 26 lines of

a    b    c    d    e    f    g    h    i    j    k    l    m    n    o    p    q    r    s    t    u    v    w    x    y    z

by replacing the blanks with a series of 4 blanks.

The best Vim solution (13 keystrokes ignoring the file saving) on the VimGolf site uses a substitute operation to replace a single blank with 4 blanks. If we use the same strategy in Emacs we get

Meta+%
Return
Return
!

for 9 keystrokes. That’s good but if we replace 【 】 with 【Ctrl+4 】 we get it down to 7.

Update: 【Ctrl】 → 【Meta

Posted in General | Tagged | 5 Comments