A New Emacs Trick

Well, new to me anyway. Xah Lee and the folks over at the ErgoEmacs Google+ Group discovered a nifty Emacs command (apparently from a Sacha Chua tweet) that does something I’ve often wanted to do. Suppose you want to kill some text, move to another part of the buffer and kill some more text and then be able to yank both kills at once. It turns out that there’s a nice way of doing that:

  • Kill the first batch of text
  • Move to the next text to kill
  • Type 【Ctrl+Meta+w
  • Kill the second batch of text

Now when you yank with 【Ctrl+y】 you get both kills together.

The 【Ctrl+Meta+w】 runs the append-next-kill command that causes the kills to be appended. As I say, this is something I often want to do, particularly when I’m moving code around. Thanks to Sacha, Xah, and the ErgoEmacs folks for letting us know about this.

Posted in General | Tagged | Leave a comment

Google: Hardware Manufacturer

Robert McMillan over at Wired Enterprise has an interesting article in which he reports that Google claims to be one of the world’s largest hardware makers. We’ve all heard stories about how Google custom builds much of its equipment but I always imagined a medium sized shop with four or five guys assembling servers. Apparently, it’s much bigger than that.

Google, it seems, designs its own servers, network gear, and possibly other computing equipment and farms out the actual manufacturing to the same Taiwanese and Chinese companies that make machines for Dell and HP. Google is pretty secretive about their hardware work so few details are actually known. Much of the material for McMillan’s report came from Google’s CFO Patrick Pichette during the annual stockholders’ meeting. These details were apparently given to help convince the stockholders that Google has the requisite hardware expertise to handle the Motorola mobile phone acquisition.

McMillan has some interesting speculation as to what this could mean for hardware manufacturers such as Dell, HP, Cisco, and Juniper as more and more companies move to the cloud and consider building out their own data centers. Follow the link to get the full story; it’s pretty interesting.

Posted in General | Leave a comment

Video Chat on Emacs

The ever energetic Sacha Chua has a nice video chat up with John Wiegley about Emacs. Wiegley, the author of eshell, is one of those users who pretty much lives in Emacs and he has spent a lot of time optimizing his work flow to leverage Emacs. In this chat, he and Chua talk about that work flow and how he uses Emacs. Wiegley also talks about some of the Emacs hacks he’s implemented to help with his day to day work. It’s an interesting video and worth 40 minutes of your time.

In addition to the video, Chua has a link to Wiegley’s Github page where you can find his init.el and the associated files he uses. Those are also worth studying because he has a lot of good ideas in them.

Posted in General | Tagged | 3 Comments

Newspapers

As longtime readers of Irreal know, I have a fascination for the various media and how they are coping in the digital age. One of the media sectors about which I haven’t had much to say is newspapers. Mostly that’s because I don’t read newspapers and haven’t for many years. I use to be voracious reader of them, often devouring two a day but I came to see them as broken products. The reporting that wasn’t outright tendentious was flabby and often significantly wrong. Michael Creighton famously described the situation with the Gell-Mann Amnesia Effect. As techies, we’re all familiar with the effect. When was the last time you read a story about a technical subject in a newspaper that didn’t have significant errors and a complete lack of understanding?

The other day I saw an excellent article over at Gigacom by Mathew Ingram on newspapers and their failure to thrive in the digital age. Ingram has a key insight that, while obvious, hadn’t occurred to me. Newspapers’ customers are not their readers but their advertisers. Ingram points out that most often even the newspapers themselves fail to remember this and act as if their readers really were the customers. That explains pay walls and talk about how the readers should be willing to pay for the content they consume. That would make sense if, in fact, the readers were the customers but they’re not. The advertisers are.

That fact, Ingram says, also explains why newspapers in their current form are doomed. Before the Internet, the papers were able to establish monopolies on information delivery but those monopolies were really monopolies on the delivery of printed advertising into targeted areas such as cities or metropolitan areas. Those days are gone. These days, advertisers have a choice of several advertising channels many of which offer more finely targeted advertising than newspapers were ever able to offer. And if an advertiser wants the broad based advertising that newspapers specialized in, Ingram says, they have billions of websites on which they can drop a cheap display banner.

Follow the link to find out what Ingram thinks the future holds for newspapers. Most people can’t imagine a world without newspapers but I can tell you that my little corner of the world has been newspaper free for some time and it’s quite pleasant. As I wrote in Living Without Flash, I was sure I’d miss all the content that Flash brought me but after it was gone, I didn’t miss it at all and hardly noticed its absence.

Posted in General | Leave a comment

Dribble

Nicholas May, on his blog Because two cents wasn’t enough, reminds me of something I’d long forgotten: The dribble command in Common Lisp. What dribble does is record a Lisp session much like the Unix script command or the Scheme transcript-on/transcript-off commands. To start the recording, execute the command

(dribble file-name)

and dribble will start recording your REPL session into the file-name file. You can stop the recording by executing

(dribble)

This functionality is more useful than you might think. The canonical use, I suppose, is for students to record homework sessions. It’s also useful for recording bits of a REPL session that you want to include in a book, report, or blog post. It has the advantage of showing exactly what happened during the session. It’s not something you’ll use everyday, but when you want to capture a session, it’s just what you need.

Posted in Programming | Tagged | Leave a comment

More On Lexical Scoping

Yesterday I posted a reminder about Yoo Box’s excellent article on lexical binding in Emacs 24. I recently came across a post by Sergey M over at On elisp and programming in general that also considers lexical scoping in Emacs 24. This post has additional information from that given by Box so it is also worth a look if you’re trying to figure out how lexical binding works and what it can do for you.

Posted in Programming | Tagged , | Leave a comment

A Reminder About Lexical Scoping in Emacs

Back in January, I wrote a short post recommending Yoo Box’s piece on lexical scoping in Emacs 24. Now that Emacs 24 is officially released, this seems like a good time to remind folks about Box’s post. If the idea of lexical scoping is new to you this is an excellent introduction to its use in Elisp. Recommended (again).

Posted in Programming | Tagged , | Leave a comment

How To Design a Successful Programming Language

Sooner or later, every programmer gets bitten by the “I want to design a programming language” bug. Sadly, most of these efforts, Larry Wall, Guido van Rossum, and Yukihiro Matsumoto notwithstanding, will come to naught. Now Caleb Garling reveals the secret of designing a successful programming language.

Posted in General | Tagged | Leave a comment

A Contrast

From time to time something happens to make me think that maybe big media has caught a clue and is moving to saner policies. The last such example was Tor’s abandonment of DMR—a significant step forward. Sadly, reality inevitably intrudes and the media powers demonstrate that they’ve learned nothing.

As a case in point, I offer these two posts as a contrast in perceptions of reality. Thomas Hambleton writes on his blog that It’s 2012 and this still happens. The post, which documents his unsuccessful attempt to buy Paloma Faith’s new album, bears an uncanny resemblance to one of my favorite Oatmeal comics. Here’s a guy that wants to give the record labels money but they refuse to take it. Yes, yes, they have contracts that restrict distribution by region but you know what? It’s 2012, there’s this thing called the Internet, and maybe it’s time to rethink distribution policies from decades ago.

What does big media think? This. What can you say about a man who simultaneously whines about people pirating his product while opining that his customers are being unreasonable for not wanting to wait for his company to get around to selling their product locally? He’s entitled to his opinion, of course, but he shouldn’t be surprised when people disagree and turn to pirate sites for their instant gratification.

For some insight into the problem from the publishers’ point of view, see this comment from Patrick Nielsen Hayden, one of publishing’s more enlightened executives, on John Scalzi’s site, Whatever.

Posted in General | Leave a comment

Reverting All Buffers

I have two machines on which I do most of my writing and development: a 27″ iMac and a 5 year old MacBook Pro. I use both of these computers everyday so I need to keep them in sync. I do that with Git repositories that live on a separate Linux server. One of those repositories contains all my org files. That includes blog posts, todo and task lists from my org agenda, and various other files that I maintain with org-mode. Those, along with all the other archived files means that I have a lot of files to keep up to date.

The first thing I do when I begin a session is a git pull to make sure I have the latest files from the other machine. Of course that means I have to be religious about pushing any changes to Git but that’s pretty much second nature now. The other thing you need to know is that when I’m finished with a session, I just put the machine in sleep mode. That means my Emacs still has all the open files from the last session when I get back to it. I also have desktop-save-mode on so this happens even if I turn the computer off or reboot it.

Here’s the problem. After the Git pull, those buffers and their underlying files are no longer in sync. I could set Emacs to automatically sync them but I don’t want to deal with the overhead. Thus I have to run revert-buffer by hand for each of the updated files. That’s a pain, of course, and cries out for automation so I wrote a quick bit of Elisp to do it for me. Here’s the code

(defun revert-all-buffers ()
  "Revert all non-modified buffers associated with a file.
This is to update existing buffers after a Git pull of their underlying files."
  (interactive)
  (save-current-buffer
    (mapc (lambda (b)
            (set-buffer b)
            (unless (or (null (buffer-file-name)) (buffer-modified-p))
              (revert-buffer t t)
              (message "Reverted %s\n" (buffer-file-name))))
          (buffer-list))))

The code is pretty simple. It goes through the buffer list looking for buffers with an underlying file. If the buffer is not dirty, I call revert-buffer to get the changes from the Git pull into the buffer. If I’ve made changes to the buffer, then I have to fix things up by hand so I don’t want to do the revert.

It seems to me that there’s nothing special about my work flow so others may have the same problem and find revert-all-buffers useful.

Posted in Programming | Tagged , | 9 Comments