Publishers And DRM

Last week I wrote one of my semi-regular rants about the publishing industry and their bad choices. Yesterday, Charlie Stross, a prominent SF author (Accelerando, Glass House, Halting State, Rule 34, and others) wrote a provocative piece on publishers and DRM. Stross’s thesis is that the biggest threat to publishers is not piracy but Amazon.com.

Amazon, says Stross, has already captured about 80% of the ebook retail market. That didn’t matter a short time ago when ebook sales amounted to about 1% of the publishing market but now ebooks account for somewhere between 20% and 40% of the market and we can, of course, expect that figure to continue growing rapidly. Meanwhile, Amazon is ruthless in the pressure it exerts on publishers for favorable pricing and discounts. This means that they can sell ebooks at very competitive prices and therefore strengthen their near monopoly while at the same time earning more money.

What’s this have to do with DRM? We all know the usual arguments against DRM:

  • It doesn’t stop piracy (at all).
  • It punishes and inconveniences honest buyers.
  • It tells the publishers’ customers that the publishers consider them criminals.
  • It can cause legitimately purchased material to become unavailable when resellers go out of business and abandon their authorization servers.
  • And on and on and on.

Now Stross has another argument against it. By insisting on DRM the publishers help Amazon lock in customers to the Kindle platform and therefore reinforce Amazon’s monopoly. This in turn gives Amazon the ability to demand more concessions from the publishers until they are forced out of business.

If publishers were smart, they’d get rid of DRM and maybe even offer customers who can demonstrate that they own an ebook with DRM an unencrypted copy of the book. That would, at one blow, eliminate Amazon’s lock in and perhaps—perhaps—help break Amazon’s strangle hold on the ebook market. Sadly, of course, the publishers aren’t smart and will doubtless continue to insist on DRM until it’s too late.

Actually, Stross says that many of the publishers do recognize this but that they are all now part of large media conglomerates with many levels of authority above them who most certainly do not understand publishing and its realities. That’s too bad because everyone—except maybe Amazon—is going to suffer from this shortsightedness. Customers will suffer from the inconvenience and lock in that DRM causes, and the publishers will suffer eventual extinction brought on by their continued bad choices.

Posted in General | Leave a comment

Emacs Markers

In a comment to my Emacs comment-box Revisited post, Aaron showed me a nice way to deal with the boundaries of expanding regions. Recall that in that post I wanted to pad the first line of a comment out to the fill column so that comment-box would draw the box across the whole width (more or less) of the window. The problem was that adding those blanks increased the size of the region so the character number of the end of the region was no longer correct. In my code that was easily fixed because I could use (point-max) to locate the end of the region since I had narrowed the buffer to the region.

Aaron’s way of handling this is nice because it feels less ad hoc and because it works for any position in the buffer not just the beginning or end. The idea is to use a marker to point at the end of the region. Conceptually, a marker is just like a position (that is a character index into the buffer) but it has the nice property that if you change the size of the buffer, the marker is adjusted when necessary. It’s as if you planted a flag at the position and the flag moves as the buffer expands or contracts.

Here’s what the revised code looks like

(defun jcs-comment-box (b e)
  "Draw a box comment around the region but arrange for the region
to extend to at least the fill column. Place the point after the
comment box."
  (interactive "r")
  (let ((e (copy-marker e t)))
    (goto-char b)
    (end-of-line)
    (insert-char ?  (- fill-column (current-column)))
    (comment-box b e 1)
    (goto-char e)
    (set-marker e nil)))

As you can see, I’ve replaced the with-region-or-buffer macro with the more sensible (interactive "r"). The copy-marker function will make a copy of an existing marker or if its first argument is a position it will make a marker with that offset. The (optional) second argument says that if text is added at the marker then move the marker ahead. A nil would say the leave the marker where it is. The (set-marker e nil) at the end of the function makes the marker point nowhere. It’s not strictly necessary but it lets Emacs stop worrying about keeping it updated as you further edit the buffer. As you can see, you can treat the marker just you would a position: you can use it as a position, move to it, and even do arithmetic on it.

Chapter 31 of the Emacs Lisp Manual explains markers further. It’s short and interesting so it’s worth a read if you like programming in Emacs Lisp.

Posted in Programming | Tagged | Leave a comment

Emacs Align Functions

Tim Visher has a new VimGolf in Emacs up. This time it’s a simple alignment problem using align-regexp, a function that we’ve talked about before. In this case he just used the simple align-regexp case and was done in about 6 keystrokes, much less than the 18 that the best Vim solution took.

It turns out the the align function, of which align-regexp is a special case, is very flexible. It will try to align the region or current group of text in a context dependent way. The action of align is specified by a set of rules that specify context (such as major mode), a regular expression, and some other attributes. The list of rules is in the variable align-rules-list. The documentation for that variable explains the various options and gives its current value. You can also pass in your own list of rules. The align-regexp function basically just prompts you for an ad hoc rule.

Unfortunately, the documentation isn’t very good and the rules can be quite complex. Visher mentions this page from the EmacsWiki that gives some examples but it is by no means a complete explanation. This is a very powerful function and I wish the documentation on it was better. Unfortunately it isn’t even mentioned in the Emacs manual.

Posted in General | Tagged | 1 Comment

Emacs comment-box Revisited

Last week I wrote about Comment Boxes In Emacs and gave some examples of how the comment-box command provides an easy way to draw a box around a comment. The only problem is that I want the boxes to extend almost to the right hand margin. Instead of

##########################################
# get-cred -- Get the user's credentials #
##########################################
(defun get-cred ()
...)

I want

##########################################################################
# get-cred -- Get the user's credentials                                 #
##########################################################################
(defun get-cred ()
...)

One could argue, I suppose, that this adds nothing except some useless blanks to the file but I’ve always done it that way and as Henry Higgins might say, “I’ve grown accustomed to its face.” So, how to do it?

My idea was simple: pad the first line with blanks out to the fill column, and then call comment-box to draw the actual box. There’s nothing special about using the fill column as the right hand edge but it makes the function behave well for any size window.

I thought I’d knock off a quick bit of Elisp and be done. It didn’t work out that way. I kept getting a mysterious error that appeared to come from save-restriction (see the code below). After that lot of mucking about I discovered that the real problem was the call to comment-box. The documentation says that there’s an optional third argument to add extra space and, indeed, the beginning of the function is

(defun comment-box (beg end &optional arg)
...)

so I didn’t bother specifying the third argument. It turns out, though, that in the comment-box function we have this line

(comment-region beg end (+ comment-add arg))

so that the optional argument is always used. It works OK in the interactive case because the call to interactive is

(interactive "*r\np")

which causes the prefix argument to be passed to arg. When no prefix argument is specified, this results in a 1 being passed to arg so arg is never nil the way it is if you call comment-box from Elisp with only two arguments. That’s obviously a bug but it’s a small one. At least it’s a small one once you figure out what’s happening.

In any event, once I solved that problem it was easy to write the function:

(defun jcs-comment-box ()
  "Draw a box comment around the region but arrange for the region
to extend to at least the fill column. Place the point after the
comment box."
  (interactive)
  (with-region-or-buffer (b e)
    (save-restriction
      (narrow-to-region b e)
      (goto-char b)
      (end-of-line)
      (insert-char ?  (- fill-column (current-column)))
      (comment-box b (point-max) 1)
      (goto-char (point-max)))))

As you can see, we first move to the beginning of the first line, then to its end, and then we pad the line with blanks out to fill-column. A few comments on the rest of the code:

  • It would probably be easier to use
    (interactive "r")
    

    rather than the with-region-or-buffer macro but I write that almost automatically when I’m dealing with a possible region so I just kept it.

  • insert-char does nothing if the count is not positive so I didn’t have to worry about whether or not the first line already extended to or past the fill column.
  • Using the narrow-to-region function makes it really easy to move around the buffer and helps deal with the fact that I’m changing the size of the region as I go. This problem was described by Xah Lee.
  • Notice that even the narrow-to-region doesn’t completely insulate me from the effects of changing the buffer size. I have to use (point-max) as the end of the region (instead of b) in the call to comment-box because b no longer points to the end of the region.
Posted in Programming | Tagged | 2 Comments

Xah Lee On Inserting Brackets In Emacs

Xah Lee has an interesting post on inserting bracket pairs in Emacs. This is exactly the same thing that I did using Key Chord Mode as I described in this post. The difference is that Lee uses Elisp code directly and has a function for every imaginable pair of brackets. If you use a lot of brackets in your HTML, as he does, it’s worth while grabbing his code.

For guys like me who use mainly parentheses, square brackets, and the occasional pair of braces, the Key Chord Mode solution works well and is easier to implement. The only pairs I have implemented are the angle brackets for HTML tags and double quotes. I’d definitely do parentheses too except that the Paredit minor mode takes care of that for me.

Lee has 22 little functions to insert these pairs so you might wonder where he finds enough key sequences to bind to them. The answer is the hyper key. None of the standard Emacs functions use the hyper key (or at least don’t use it exclusively) so it’s an ideal modifier to use with private functions. The question for most people is: what key is the hyper key?

That depends on what type of system you’re using. Windows, OS X, and Linux can all be configured with a hyper key but the key and the configuration steps differ. Fortunately, Lee’s post has a section that shows you how to configure it for all three system types. To my mind, that section is probably the most valuable part of his post. If you’d like an extra modifier key, be sure to check it out. He also has a separate page on how to set up the hyper and super keys.

Posted in General | Tagged | Leave a comment

And The Winner Is…

password. SplashID has a list of 2011’s 25 most popular passwords as culled from the various exploits of LulzSec, Anonymous, and others. As expected, the runner up is 123456. Readers of this blog will find none of this surprising but it sure is depressing.

Follow the link and see for yourself. Sadly, I’m sure these people think they’re being clever in their choices. I suppose in a way it makes them low hanging fruit and therefore makes sensible folks marginally safer but that’s small comfort when you look at the list. It’s not as if this was some esoteric subject known only to experts. It doesn’t seem to matter how often the sermon is preached, people just aren’t going to be sensible about their password choices.

Posted in General | Tagged | Leave a comment

Another Emacs Cheat Sheet

Artur Hefczyc has an nice table of the Emacs keybindings. They are listed alphabetically by command name, not by action, so you need to know a good approximation to the name of the command you’re trying to run. It’s a nice table and worth bookmarking or even printing out if you’re inclined to use paper cheat sheets.

Of course, you can always get a complete list of the current keybindings for your Emacs with 【Ctrl+h b】 but I find it difficult to locate the command I’m looking for with it.

Posted in General | Tagged | 1 Comment

Text Replacement In Several Files With Emacs

Just a quickie. I was browsing around in Aaron Hawley’s Giant Emacs Reference Sheet when I came across this little ditty:

C-x d *.c RET Q int RET long    

It was described as “replace ‘long’ for ‘int’ in .c files.” I thought, “Boy, that’s really handy” and then I realized that it’s just

  1. Enter dired and list all the .c files
  2. Do a query replace substituting long for int

something that I’ve probably blogged about in the past.

Still, it does seem to gain power when you think of it as one command. And, if for only a moment, I thought I’d found something new and wonderful.

Posted in General | Tagged | 5 Comments

Administrivia

The scum spammers, who doubtless describe themselves as SEO consultants, have discovered a new way to get links into forum comments: trackbacks and pingbacks. Irreal does have the occasional legitimate trackback and I enjoy them as they give me a sense of who’s reading the blog and what they have to say about the topics we consider here. Lately, though, they’ve all been phony trackbacks designed to get Google to notice a link to some site or another that has nothing to do with Irreal or the things we talk about here.

Therefore, I’ve turned off trackbacks/pingbacks. Comments will remain as they were: unmoderated but requiring a CAPTCHA or registration.

Posted in Blogging | 1 Comment

Comment Boxes In Emacs

Here’s a neat little hack that can save a bit of time. Emacs has the comment-box command that will put a mode-specific comment box around a region. For example, suppose you have the Elisp

A function to do something very profound.
It is called from the top level.
(defun be-profound ()
...)

and that you select the first two lines and call comment-box. You get

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; A function to do something very profound. ;
; It is called from the top level.          ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun be-profound ()
...)

Similarly if you have some C code like

Here is the the main function
that does something or another

int main ( int argc, char **argv)

and select the first two lines and call comment-box you get

/**********************************/
/* Here is the the main function  */
/* that does something or another */
/**********************************/

int main ( int argc, char **argv)

Back when I was writing a lot of C code I used to put a comment box like that in front of every function. I did it by hand so it was sort of pain. I wish I’d had, or known about, something like comment-box to help me out (that was when I was using Vim).

Posted in Programming | Tagged | 3 Comments