It’s Time For Publishers To Get A Clue

Those of you who have been dropping by this blog for a while know that I’ve written several posts about the publishing industry and its consistent failure to accept that things are changing (see The Future Of Books, More Bad News For The Publishing Industry, and More Amazon Disruption). Now, Jon Evans over at Tech Crunch takes up the same theme with Dog Bites Man; Pope Condemns Violence; Publishing Still Doesn’t Get It.

Evans mostly discusses the publishers’ and Authors Guild’s reactions to Amazon’s introduction of the Kindle Owners’ Lending Library but also touches on the publishers’ treatment of ebooks in general. The picture he paints isn’t pretty. It’s a picture of ignoring what their customers want, of refusing to acknowledge that the future is coming, of lost opportunities, and, in general, of behaving stupidly.

He notes all the usual problems: failure to deliver a subscription model desired by their customers, inflated ebook prices, petty behavior when an author shows “disloyalty” by signing a deal with another publisher, and a general failure to deal with the reality of ebooks.

The failure to take ebooks seriously is, to my mind, one of their worst shortcomings. Just as Borders failed to take Internet sales seriously and paid the ultimate price, publishers treat ebooks as a slightly disreputable stepchild, not to be taken as seriously as “real” books; as a problem to be dealt with rather than an opportunity to be seized.

Case in point: the deplorable production values in ebooks. It’s hard to understand how they could do so poorly. The ebook process starts with the same files as a dead tree book but somehow comes out the other end with missing words and letters, poor spacing, fouled up typography, and inconsistent capitalization. Neal Stephenson’s Reamde was so poorly done that it was withdrawn from the Kindle store. Sadly, Stephenson’s book is not a fluke. Thomas Rhiel has a blog post that recounts other examples. (Be sure to follow the ebook typography is terrible link in Rhiel’s post for some graphic examples.)

Rhiel’s post makes a telling point about the publishers’ failure to leverage the opportunities afforded by the ebook format. Historically, publishers print photographs on glossy paper and bind them in the middle of the book because it’s too expensive to bind the individual glossy pages in the proper place. But there’s no excuse for doing the same thing in an ebook. The photo should appear in the logical place in the book or, as Rhiel says, at least at the end of the book in its own section instead of the middle of a chapter to which they bear no relationship.

Clearly, these books are not receiving proper editorial scrutiny. Meanwhile, the publishers are telling us that they have to charge high prices for ebooks because, after all, it’s not the printing and shipping that costs the money but the editorial effort. Please. Produce a competent product that shows some of that editorial effort and we’ll talk. In the mean time you’re just looking clueless and indifferent.

Publishers can continue to pretend that everything is the same as it’s always been, that customers have nowhere else to go, and that there’s no reason—no reason at all—to change their business model but the truth is that things are changing. Amazon is not just threatening to eat their lunch but to steal the crown jewels. Tired of dealing with publishers who don’t want to do anything new or different, they are now offering authors direct deals as I recounted in the More Bad News For The Publishing Industry post. Among the defectors, by the way, is Neal Stephenson. Perhaps he’ll finally get a clean ebook out of the deal.

Posted in General | Leave a comment

Highlighting Regexps, Phrases, And Lines In Emacs

I mostly use isearch-forward, 【Ctrl+s】, and isearch-backward, 【Ctrl+r】, to search for words or phrases in a buffer. Sometimes, though, it’s convenient to see all the matches at once. Emacs has a set of commands that make this easy.

The easiest to use is highlight-phrase, which is bound to the 【Meta+s h p】 sequence. It will ask you for a phrase and highlighting color and then highlight all the matching phrases in the buffer. The nice thing about highlight-phrase is that any whitespace is automatically converted to arbitrary whitespace and initial lower-case letters are made case insensitive so it’s pretty much a “do what I mean” command.

The next command, highlight-regexp, is a little more general. It’s bound to 【Meta+s h r】 and lets you highlight anything that matches an arbitrary regexp.

The command highlight-lines-matching-regexp is similar to highlight-regexp except that it highlights the entire line that contains the match to the regular expression. It is bound to 【Meta+s h l】.

Finally, you can un-highlight the matches with unhighlight-regexp, bound to 【Meta+s h u】.

Summary

Key Sequence Command
Meta+s h p highlight-phrase
Meta+s h r highlight-regexp
Meta+s h l highlight-lines-matching-regexp
Meta+s h u unhighlight-regexp

Update: let → set.

Posted in General | Tagged | 1 Comment

Property Lists In Emacs

Xah Lee has a nice post up with a function that fixes what he sees as some problems with the default Emacs case-changing commands. Apparently, our use cases are different because I’m not bothered by the default behavior. Still, the function is a nice one and you may find that it meets your needs.

One of the techniques that Lee uses is to maintain a bit of state in a property list. Property lists are a feature of many Lisps and although they aren’t used a lot, they are often just what you need. One way of thinking about property lists is that they are very much like association lists (alists) that are attached to a symbol. (You can have more general, free-standing property lists too but we won’t consider them here). They are a list of property-value pairs that can be set with the put command or read with the get command.

So what are property lists used for? One common use is to control disabled commands. For example, in my post on Using The Emacs save-restriction Special Form, I mentioned that narrow-to-region is disabled by default and that you should add

(put 'narrow-to-region 'disabled nil)

in your .emacs or init.el file to enable it. The narrow-to-region symbol has a set of properties, one of which is disabled. The result of the put is to set that property to nil. By default, the property is t. Before narrow-to-region is executed, Emacs checks its property list to see if the disabled property is t. If it is, Emacs tells you that the command is disabled and gives you some choices in how to proceed.

Another example, which I use a lot, is to control indentation. For example, I have a Scheme implementation of the Common Lisp dolist macro that we’ve discussed before. The problem is that Emacs doesn’t know how to indent the macro correctly because it’s not part of standard Scheme. Fortunately, I can tell Emacs what to do by adding the scheme-indent-function property and setting it to 1. I do that by adding

(put 'dotimes 'scheme-indent-function 1)

to my init.el file.

You might think that properties are restricted by Elisp to just those used by Emacs itself but that is not the case. You can attach any property you like to any symbol. That brings us to Lee’s function. Because he wants to be able to step through 3 possibilities (all lower, initial cap, all upper) he needs to remember what the last state was. He does that by adding a state property to his function, toggle-letter-case. Take a look at his post to see the details—the code is pretty easy to follow.

Summary

Command Action
(put 'symbol 'prop val) Set the prop property of symbol to val
(get 'symbol 'prop) Get the value of symbol‘s property prop
(symbol-plist 'symbol) Return the property list of symbol
Posted in Programming | Tagged | Leave a comment

Installing Emacs 24

As I mentioned in my Emacs 24 Features post, Bozhidar Batsov over at (think) has been using Emacs 24 with great success. He has a new post up that describes how to get Emacs 24 installed on OS X, Linux, and Windows.

For OS X, he recommends just getting the pretest from Emacs for OSX, but I like to compile it from sources. I tried that but had a problem with the libcurses-dev not being found. I haven’t had that problem before but this is the first time I’ve compiled Emacs since I installed Lion so I probably just need to download the sources and compile the library. Leave a comment if you’ve run into this problem and tell us what you did to resolve it.

In any event, after you’ve installed Emacs 24 you may want to look at Batsov’s Emacs Prelude. It’s “an advanced Emacs setup specifically for Emacs 24.” It works with OS X, Linux, and Windows.

Batsov notes that although Emacs 24 is not scheduled for release until Spring 2012, he has been using it for several months and found it to be rock solid. He concludes by saying that there really is no excuse not to switch to Emacs 24 now so if you’re inclined, see Batsov’s post that I linked above to get the details on how to get it installed.

Posted in General | Tagged | 2 Comments

Beautifying JSON In Emacs

I really like JSON. It’s the perfect mechanism for serializing data; much better, in my opinion, than the typical XML solution. That said, I don’t use it enough to justify installing one of the really nice packages that deal with it such as Steve Yegge’s js2-mode or Edward O’Connor’s json.el. Still, I thought it would be nice to have an Emacs utility that could transform JSON into a standard, readable format.

The other day I came across a post in Richard Ketteierij’s richardlog blog about pretty-printing JSON and XML on Mac OSX. His post had nothing to do with Emacs; it was merely a way of writing reformatted JSON to a file. It occurred to me that this was just what I needed for the occasional lightweight reformatting of JSON. It should work for any system with Python 2.6 or greater installed.

It turns out that the Python distribution comes with a json.tool module that does the work of reformating JSON. For example, here

{"father":{"name":"John Smith", "age":45, "employer":"YoYodyne, inc."},
"mother":{"name":"Wilma Smith", "age":42},
"children":[{"name":"William Smith", "age":15},
         {"name":"Sally Smith","age":17}]}

is some JSON that I used when I first wrote about JSON back in 2009 on my old blog. It’s easy to run this through json.tool by selecting the code and typing 【Ctrl+u Meta+|python -m json.tool. Doing that yields

{
    "children": [
        {
            "age": 15, 
            "name": "William Smith"
        }, 
        {
            "age": 17, 
            "name": "Sally Smith"
        }
    ], 
    "father": {
        "age": 45, 
        "employer": "YoYodyne, inc.", 
        "name": "John Smith"
    }, 
    "mother": {
        "age": 42, 
        "name": "Wilma Smith"
    }
}

which is more readable and standardized in the sense that the items are in alphabetical order. As I said, it’s a simple and lightweight solution but quite handy if you deal with JSON only occasionally. If you use JSON a lot you probably have one of the packages mentioned above installed already (or should have).

Update: an example of to get rid of redundant “example.”

Posted in General | Tagged | 5 Comments

Using Key Chords In Emacs

Last week I wrote about David Andersson’s Key Chord Mode that I discovered in the latest Emacs Rocks video. I thought it was interesting and I enabled it in my Emacs by adding

(require 'key-chord)
(key-chord-mode 1)
(key-chord-define-global "dq" 'dq)

to my scratch buffer and evaluating it just to play around with it a little. I thought it was pretty nifty but I didn’t think I would actually use it so I didn’t add it to my init.el file.

Yesterday, as I was writing the Automatic Lookup From Emacs post, I wanted to set the function names in the first column of the table in a constant width font. In Org mode you do that by surrounding the name with equal signs like so

=lookup-google=

But the equal sign has a special meaning in an Org-mode table and it causes an error when you try to use it to mark an entry as constant width. So I set the first couple of names by hand like this

@<code>lookup-google@</code>

where the @ tells the Org exporter to treat the following tag as an actual tag and not translate it to &lt; and so on. The problem is that it’s a pain to type the tags because they’re shifted and the 【@】 key is way at the top of the keyboard.

I thought about writing a quick little function to do it for me but it hardly seemed worth the effort. Then I remembered key-chord.el, which was still enabled, so I added

(key-chord-define-global "<>" "@<>\C-b")

to the scratch buffer and evaluated it. It seems like a small thing but it really made doing the rest of the table a snap. I just typed 【Shift+<+>】 and

@<|>

where | represents the point, was inserted into the buffer. That’s handy enough that I am going to enable chord-mode in my init.el and add the <> chord for those, admittedly rare, times when I need to insert some HTML tags by hand.

Posted in General | Tagged | 4 Comments

VimGolf In Emacs Episode 20 Is Up

Tim Visher has another VimGolf in Emacs video up. This one has some interesting applications of the Emacs calc function. As I mentioned on my old blog, I use a Scheme REPL as my calculator so I’ve never bothered to learn much about calc, and use it only indirectly with Org-mode tables. Visher’s video makes me think that it might be worthwhile to learn some more about it.

Posted in General | Tagged | Leave a comment

Automatic Lookup From Emacs

Xah Lee has released an interesting package called lookup-word-on-internet.el, which he describes on his Web site here. It will take the word at point or a phrase in an active region and look it up in Google, Wikipedia, Dict.org, Answers.com, Wiktionary, or PHP.net.

Lee doesn’t really describe how to use the package on his site so you have to look at lookup-word-on-internet.el to get the details. Basically, there is a little service-specific routine you can call for each service and they1, in turn, call a worker function to do the real work. The service-specific routines are

Function Site Called
lookup-google Google
lookup-wikipedia Wikipedia
lookup-word-dict-org Dict.org
lookup-word-definition Answers.com
lookup-wiktionary Wiktionary.org
lookup-php-ref PHP.net

Of course, for these to be useful, you should bind them to convenient key sequences.

I have a couple of functions like these in my init.el file but this package gives you a fairly comprehensive set in one convenient package and also provides a framework that makes it easy to add your own service-specific functions for sites not in the list.

Footnotes:

1 Except for lookup-php-ref, which does all the work itself.

Posted in General | Tagged | 4 Comments

Emacs Init Time

Just a quickie today. If you have a large and complicated Emacs init file you might wonder how long it takes to process it. Perhaps you should compile it. Maybe it doesn’t matter. How are you to know? It turns out that—to borrow a phrase—Emacs has a command for that.

If you run 【Meta+xemacs-init-time, it will tell you in the echo area (and the *Messages* buffer) how long Emacs took to process your .emacs or init.el file. In my case, it was 1.5 seconds and since my Emacs has been running for 26 days, 23 hours, 47 minutes, 14 seconds (【Meta+xemacs-uptime), I’m not too worried about the 1.5 seconds.

My init.el is fairly long and loads several packages so the 1.5 seconds is reasonable even if I were starting Emacs anew each day. Does anyone have a time significantly larger (say an order of magnitude or more)? Leave a comment if you do.

Posted in General | Tagged | 23 Comments

Reverting In Emacs

One of the things about Emacs is that buffers tend to hang around for a long time. This is especially true if you’re using desktop-save-mode. Most of the time this isn’t a problem but every once in a while the file underneath a buffer changes. Most of the time Emacs will notice this and can run 【Meta+xrevert-buffer to sync things up again. Of course, you can also use revert-buffer to erase all changes to the buffer since the last save.

Sometimes, though, there is another process making frequent changes to the visited file and you’d like to keep the buffer current. For this, there is auto-revert-mode. With a positive argument, auto-revert-mode will track the visited file and automatically update the corresponding Emacs buffer. This mode affects only the current buffer but you can, if necessary, track all open buffers with global-auto-revert-mode. You’ll probably take a performance hit (although I haven’t verified this) if you have a lot of buffers open and turn on global-auto-revert-mode so be careful out there.

A related mode is auto-revert-tail-mode. This mode tracks appends to the file in the manner of tail -f. It needs only check if the size of the file has changed so it’s more efficient when you’re just worried about additions to the file.

Posted in General | Tagged | 2 Comments