More Bad News For The Publishing Industry

I’ve written before on The Future Of Books and how the publishing industry is in peril. The latest move from Amazon is apparently terrorizing the publishers and with good reason. According to articles in the New York Times and TechFlash, Amazon is recruiting authors—including established authors—directly and cutting out the traditional publishing houses. In some cases even agents are getting cut out of the loop. Talk about disintermediation.

Amazon appears to be serious about this. They’ve hired former agent and publisher Laurence J. Kirshbaum to head their publishing division. The Times reports that they paid Penny Marshall $800,000 for a memoir, which they will publish both as an ebook and a traditional dead tree book. If you Google amazon imprints you’ll see that Amazon is regularly adding imprints.

It’s often been said that the only necessary players in the publishing game are the writers and the readers. With this move, Amazon has reduced the chain to only 3 links. Cory Doctorow has already demonstrated that it’s possible to reduce that chain to just the two necessary links but most authors won’t have the skills or desire to do everything themselves and even Doctorow uses Amazon’s print-on-demand service to help with distribution. If Amazon offers authors more than the typical 15% of sale price, they could cut into the publisher’s business in a serious way.

What can the traditional publishers do? I don’t know but they are certainly going to have to change their business models and their relationships with their authors. They could—finally—learn from the music industry and get rid of DRM on ebooks. They could stop pretending that printing and shipping is essentially free and sell ebooks directly to consumers at a decent price. They could cut deals with Apple and other Amazon competitors to offer their entire catalogs in ebook format. Most of all, they must come to grips with the reality that printing press is rapidly becoming a thing of the past. The threat to their traditional business model is no longer theoretical; Amazon is storming the ramparts in a very real way.

Posted in General | 2 Comments

Making The Emacs Minibuffer Recursive

Mickey, over at Mastering Emacs, has a great post on Executing Shell Commands in Emacs and does his usual excellent job of explaining the fine points of his subject matter. I’ve written about some of this material here, but there’s lot of stuff I haven’t covered so you should definitely go read the post.

One of the things that was new to me was recursive minibuffers. What that means is that you can interrupt what you’re doing in the minibuffer to run some other command and then use it’s output in the original command. The need to do this doesn’t come up often—at least for me—but when it does it’s frustrating not to be able to do it. By default, the recursion is turned off but all you need do to enable it is to add

(setq enable-recursive-minibuffers t)

to your .emacs or init.el file.

Here’s a (slightly contrived) example of how you might use the capability. Suppose you’re one of those annoying bloggers who, unlike me, has a backlog of posts ready to publish and that you keep their file names in a file called scheduled. You want to load the top file into Emacs so that you can publish it with org2blog. You type 【Ctrl+x Ctrl+f】 to call find-file but realize you don’t know the first file on the list. You can load its name into the minibuffer for find-file (or ido-find-file) by typing 【Ctrl+u Meta+!】 and then head -1 scheduled. As Mickey explains, the output of most shell commands will have a newline at the end so you’ll need to delete it before pressing 【Return】.

Mickey gives another example of its use but I don’t want to step on his post by reiterating it here so, again, you should go read his post. If you have an interesting use case for this capability, leave a comment.

Posted in General | Tagged | 2 Comments

A Common Lisp Quick Reference

Bert Burgemeister has a very nice Common Lisp Quick Reference available for download. The idea is that you print it out, fold the pages, and staple them to form a little booklet. He’s got copies for A4 and letter size paper and also files for nesting or stacking the pages. There’s also a version for reading on screen that has the pages in the natural order.

This is an excellent little reference containing short descriptions of the symbols—functions, special operators, macros, variables, and constants—defined in the ANSI Common Lisp standard. If you use CL, you should give it a look. I am going to include at least the on-screen version in my documentation set and, despite my aversion to data on dead trees I might also print a copy.

Posted in Programming | Tagged | 1 Comment

Multiplication Table In Emacs Revisited

Yesterday, I wrote about generating a 10 × 10 multiplication table in Emacs Lisp. The solution I gave involved using the dolist macro with a list of the numbers 1–10 like this

(dolist (r '(1 2 3 4 5 6 7 8 9 10)) ...)

That’s a little contrived and obviously doesn’t scale well but I couldn’t find a better way. Fortunately jpkotta knew just what to do. He suggested using number-sequence so that the solution becomes

(dolist (r (number-sequence 1 10))
  (dolist (c (number-sequence 1 10))
    (insert (format "%2d " (* r c))))
  (insert "\n"))

As I said in the previous post, none of this is very important so it wouldn’t be worth the followup post except that number-sequence is essentially like the Python range function (number-sequence includes its upper bound while range doesn’t) so together dolist and number-sequence provide a nice Elisp idiom for operating on a sequence of numbers. Thus a construct such as

for x in range(i,j):
    do_something(x)

in Python could be rendered as

(dolist (x (number-sequence i j))
  (do-something x))

in Emacs Lisp. That’s a handy thing to know and I thought it was worth a followup so that jpkotta’s wisdom didn’t get lost in the comments.

Posted in Programming | Tagged , | 2 Comments

Multiplication Table In Emacs Lisp

Xah Lee saw my post about Tim Visher’s video on building a multiplication table in Emacs and decided to experiment. Visher’s video was in the context of VimGolf where the goal was to build the table in the minimum number of keystrokes. Lee wasn’t interested in building the table in the minimum number of keystrokes; he wanted to see how you could do it in various programming languages. He gives solutions in Emacs Lisp, Python, and Perl. That was interesting but then he says

Lisp is a bit verbose for this kinda thing due to the nested syntax.
But you can write it in perl, python, ruby, bash, or any dynamic lang
quickly, and press a button to have emacs call it and insert the
result.

To a Lisper like me this is a challenge that can’t go unanswered. Therefore I started to think about how I could code this concisely with Emacs Lisp. My first thought was to use the dotimes macro but that starts with 0, which complicates things. Then I realized that since we only needed to deal with the numbers 1–10, I could just use dolist like this

(dolist (r '(1 2 3 4 5 6 7 8 9 10))
  (dolist (c '(1 2 3 4 5 6 7 8 9 10))
    (insert (format "%2d " (* r c))))
  (insert "\n"))

Now put the point at the beginning of the next line, type 【Ctrl+x Ctrl+e】 and the table is inserted into the buffer.

None of this is of any importance, of course, but it is fun and instructive. My solution can be criticized on the grounds that it’s really a Common Lisp solution but it does work in Emacs due to the cl.el package. It’s also slightly objectionable to have to list the numbers explicitly but I couldn’t think of a better way. Leave a comment if you have a nicer solution.

Update: Added link to Xah Lee’s post.

Posted in Programming | Tagged , | 10 Comments

The Emacs Help Function

Most Emacs users are familiar with the “common” help functions

Key Function
f Describe function
v Describe variable
k Describe key sequence
a Apropos
i Info

and perhaps a few others such as 【Ctrl+a】 to display the Emacs start page.

It turns out, though, that there are 37 help commands. Some of these, like 【Ctrl+a】, you’ll rarely use and others, like 【Ctrl+m】 (How to order printed manuals) and 【Ctrl+c】 (Display GPL), you’ll probably never use. That still leaves many useful help commands that you may not know about.

You can get a list of the all the options with 【Ctrl+h ?】 but here are some of the more useful ones

key Function
b Display all key bindings
c】 SEQ Show the name of the command that SEQ runs
d】 TOPIC Display commands & variables whose documentation matches TOPIC
e Display the *Messages* buffer
l Display your last 300 keystrokes
m Display documentation of current major mode
p Find packages by topic keyword
r Display Emacs manual in Info
s Display current syntax table
w】 CMD Show which keys run command CMD
C Describe current coding system
F】 CMD Goto Info node documenting CMD
I Describe input method
K】 SEQ Goto Info node documenting command run by SEQ
L Describe language environment

As I said, there are others that may be just what you’re looking for so be sure to check the documentation.

Posted in General | Tagged | 2 Comments

Dennis Ritchie

As I said yesterday, I was on the road last week so I’m late with this post about the death of dmr but I can’t let his passing and accomplishments go unremarked. As he was for many, dmr was one of my heroes. Before he retired, I used to check his homepage at the labs every day. I never failed to learn (a lot) from the papers he posted there and, of course, I loved the stories from the old days when Unix was being built.

Many people have pointed to how Steve Jobs’ death was a big story for many days but hardly anyone outside our community even knows who Ritchie was, let alone that he had died. I wrote about Steve Jobs that his work touches me on a daily basis; the same is true of Ritchie, only more so. Ritchie invented C and was the co-inventor of Unix. For years I earned a living writing C code on Unix systems so the impact of his work on me is profound. The thing is, his impact on your Aunt Millie is nearly as large. Practically every technology has some C or Unix components in them; Rob Pike has a nice summary on the reach of dmr’s influence that’s worth reading. The New York Times Technology section has a good retrospective on his life and death.

I’ve seen many variations on this

#include <stdio.h>
#include <stdlib.h>

int main()
{
    printf( "Goodbye, world\n" );
    exit( EXIT_SUCCESS );
}

tribute in the last week and while it might be trite it seems to me a perfect way of saying goodbye to a remarkable man and for thanking him for everything he has given us.

Posted in General | Leave a comment

Replace Digits By Subscripts In Emacs

Xah Lee had an interesting Emacs Lisp problem last week but I was away and unable to join the fun. The problem is to replace any occurrence of a digit in a string by the equivalent subscript. Thus 1, 2 and so on. As soon as I saw the problem the following solution popped into my mind

(defun replace-digits-by-subscript (str)
  (replace-regexp-in-string
   "[0-9]"
   (lambda (v) (format "%c" (+ (string-to-number v) 8320))) str))

This works because the difference between a digit’s codepoint and the corresponding subscript’s codepoint is always 8320. As each digit is found, it is converted to a number, added to 8320, and then output as a string by the format function.

Someone else has a similar, though slightly more complicated, solution but Lee didn’t like it because it depends on the particular coding of the character sets. I disagree with that. Although it’s a good rule in general not to depend on a character’s encoding, with Unicode there is only one, fixed encoding so there is no harm in making use of the structure of that encoding.

If you wanted to do this interactively on some buffer, a similar solution uses query-replace-regexp with a regular expression of \([0-9]\) and the replacement string

\,(format "%c" (+ \#1 8320))

Actually, it’s too bad replace-regexp-in-string doesn’t support the \, construct as that would make the solution to the original problem even easier.

Posted in Programming | Tagged | 2 Comments

A Screencast on Emacs Dired Basics

If you’re new to Dired and like to learn visually (as compared to, say, reading about a subject), Kenny Meyer has an interesting screencast on Dired basics that you may enjoy. He covers

  • Copying files
  • Deleting files
  • Renaming files
  • Creating new directories
  • Compression and decompression of files
  • Changing file modes
  • Changing other file metadata
  • Marking and unmarking files
  • Operations on multiple files

Meyer is promising further screencasts so if you like this one, you may want to subscribe.

Posted in General | Tagged , | Leave a comment

Delete Backwards To BOL in Emacs

This is another short Emacs tip that’s really a note to myself. The other day, I found myself in the middle of a line and needed to delete everything back to the beginning-of-line. I was sure there was some way to do that but I didn’t know what it was so I just sat on the 【Delete】 key until I reached the beginning of the line.

For the record, the correct way to do that is 【Ctrl+0 Ctrl+k】. That has a certain tractive logic since 0 suggests the beginning-of-line (at least to those of us with vi experience) and, of course, 【Ctrl+k】 means kill the rest of the line. It also has the advantage that it’s easy to type.

Posted in General | Tagged | 6 Comments