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

Another VimGolf in Emacs Challenge

Here’s another VimGolf in Emacs from a recent challenge on the VimGolf site. Your task is to replace the blanks between the letters with 4 blanks and to do it for each line. Here’s the starting file

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

and the ending file

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

Disregarding the keystrokes necessary to save the buffer to a file, the best Vim solution is 13 keystrokes. I can do it in 7 with Emacs. Can you beat that? I’ll post my solution in the next day or two.

Posted in General | Tagged | 5 Comments

Exploratory Data Analysis with Unix

Seth Brown over at Dr. Bunsen has a great post on how the ordinary Unix coreutils can be used for exploratory data analysis. His first example

(head -5; tail -5) < data

to show the first and last 5 lines of a file is something that we all understand immediately but might not think of doing ourselves.

He moves on to showing how to change the shape of data using utilities like paste, and to enumerate data with wc and simple awk scripts. Then he has some examples that show how to massage data into useful forms for input to statistical analysis and plotting programs.

There are a lot of Unix utilities that many of us have forgotten or have only dim remembrances of. That’s too bad because as Brown demonstrates, they can be extraordinarily useful. As one of the commenters remarked, “…far more people need to get back to basics and learn coreutils.” I couldn’t agree more.

Posted in General | Tagged | Leave a comment

Is The TSA Finished?

I know, I know: I’m courting a comeuppance from Betteridge’s Law but this is too good to ignore. Christopher Elliot at Linked in has an interesting post in which he posits that the TSA, as we know it today, can’t continue to exist.

The central theme of the post is a hearing of the House Aviation subcommittee. A hearing which TSA head John Pistole refused to attend. The striking thing about the hearing is the hostility of the panel members to the TSA and the near universal consensus that the mission of the TSA needs to be radically revamped.

Anyone who knows anything about security realizes that what the TSA is currently engaged in is security theater. While providing no realistic protection from terrorists, the TSA is actually increasing our chances of being killed. I don’t know if Elliot is correct but I certainly hope so. The sooner the current TSA is eliminated the better off and safer we will all be. Take a look at Elliot’s post; it’s short and very interesting.

Posted in General | Tagged | Leave a comment

Let’s Play Ivmgolf

After my last VimGolf post I thought it would be fun to try another so I headed over to the VimGolf site to find a challenge. The first one I stumbled across was Let’s play some Imvgolf. The challenge is simple: starting with

Ivm is an awesome text editor based on
Iv, and is used to play a game called
Ivmgolf. A challenge, simple for many
Ivmgolfers, can still hide secrets.

transform it to

Vim is an awesome text editor based on
Vi, and is used to play a game called
Vimgolf. A challenge, simple for many
Vimgolfers, can still hide secrets.

in the smallest number of keystrokes possible.

My first thought was that it was too simple. Surely, it would hard to beat a simple query-replace: 【Meta+%】 iv 【Return】 vi 【Return】 【!】 for a total of 8 keystrokes. Hard to see how you could do much better than that. Except that the winning VimGolf entries solved it in only 5 keystrokes1

Using Magnor Sveen’s awesome multiple-cursors package, which should and probably will be part of Emacs core, I was able to get that down to 6 keystrokes.

It’s easy to see what you need to do: switch the first two characters of each line and adjust the capitalization. I tried that using keyboard macros and even apply-macro-to-region-lines but I couldn’t do better than query-replace using core Emacs functionality. The problem is that any macro that requires typing in Vi has already used 4 keystrokes, and if you use a macro and something like 【Ctrl+t】 to switch characters you’ve used 3 keystrokes and still have to adjust the capitalization, get to the start of the next line, and run the macro on the rest of the lines. If you can do better than 8 keystrokes with stock Emacs, be sure to leave a comment.

Footnotes:

1 The VimGolf rules say you have to save the file too so that adds an extra 2 keystrokes in both Vim and Emacs but I’m ignoring them since they add nothing useful to the challenge. All scores in this post are without saving the file.

Posted in General | Tagged | 5 Comments

Autocompleting

Xah Lee has a nice post on the various methods of autocompleting in Emacs (search for 2012-12-01). Most Emacs users will be familiar with the majority of the material but it’s helpful to have it all written down in one place. For most of the methods he gives pointers to additional material that he’s written for that particular mode or package. Very helpful.

Of the minibuffer methods that he mentions, I use ido and smex and I’m experimenting with icomplete. For the general methods, I use hippie-expand, dabbrev-expand, and abbrev-mode. I couldn’t live without ido and smex and I use the others regularly. I find them all very handy so if you aren’t already using them you should give them a try.

I don’t use YASnippet but I’ve been meaning to install it. When guys like Lee and Magnar Sveen keep recommending it, that’s a pretty good indication that I’d find it useful. What do you think? If you have any strong feelings about the above packages or use something else that really works for you, leave a comment.

Update:

Lee has made the post a standalone page.

Posted in General | Tagged | 3 Comments

New Emacs Movie: Dired

Noufal Ibrahim has started “season two” of his Emacs Movies. This is the second section that will describe various Emacs modes and tools such as

  1. Dired
  2. Org-mode
  3. Eshell
  4. Diary
  5. Calc
  6. Ediff
  7. Gnus
  8. Vmail
  9. Erc
  10. BBDB
  11. Info

His latest movie is an excellent summary of Dired. He covers all the usual Dired tricks but includes a few that I didn’t know. For example, it’s possible to bring up a thumbnail of an image in Dired and then, if you like, open the image in another window The video is about 20 minutes long and well worth watching. Unless you’re already very familiar with Dired, you’re sure to learn something new. Definitely recommended.

Posted in General | Tagged | 1 Comment