Posts Tagged ‘software’

How to Escape a Viper

January 21, 2009

This is kind of a dumb post.* I like to use the viper package for emacs, which mostly works just fine.  I’m in the habit of using C-[ (hold-down control, press '[') instead of <escape> to back into command mode.

Sometimes I run emacs on Mac OS X (be it a Carbon port, in X11, or through a terminal).  Unfortunately, various Mac-compatible emacsen interpret C-[ as Meta and not as <escape>.  So instead of backing into command mode, I see "ESC-" at the bottom of the screen.  I can wait forever and emacs will never parse it into an <escape>.  If I try again, I see "ESC-ESC-".  If I try a third time, the command completes but does nothing, except causing me to scream in agony since I'm still not in command mode.

Fortunately I found that adding a simple (setq viper-ESC-key "^[") to my ~/.viper, where '^[' is literally the <escape> character (i.e., ASCII 27)**, fixes everything (viper-ESC-key is set to "\e" by default, which is supposed to be <escape> but whatever).

And there you have it.

* ... but this took me months to figure out.  I'm posting this so that maybe someone searching for "mac os x emacs meta escape viper fails" finds the help they need...

** If you're editing in emacs, type C-q C-[ to get a literal '^]‘.  If you’re editing in vim, type C-k C-[ to get a literal ‘^[‘.

hlsearch for Emacs

September 19, 2008

Vim has an option called “hlsearch” that highlights every instance of your most recent search term.  Like this:

Searching for "ground" in a text document using Vim.

Searching for "ground" in a document using Vim.

Emacs has the viper and vimpulse plugins that closely emulate vi/vim keyboard commands, but no hlsearch.  If you’re using viper and a version of Emacs later than 22.0, pasting the following into your .viper will give you this functionality.

(defun viper-flash-search-pattern ()
  (hi-lock-mode 0) (hi-lock-mode 1)
  (hi-lock-set-pattern
     (car viper-search-history) 'hi-green)
)

Unfortunately toggling hi-lock mode (line 2) is destructive if you’re using hi-lock mode for anything in addition to highlighting search terms.  In other words, there’s probably a better way to write this function. To solve the problem of clearing highlighting I’m no longer using, I use this (inefficient) snippet:

(viper-record-kbd-macro "//"
  'vi-state
  [(meta x) h i - l o c k - m o d e (control m)
   (meta x) h i - l o c k - m o d e (control m)]
't)

Nerd Stories I

August 25, 2008

In junior high I had a (deserved) reputation as one of those brats who messed around with the school computers.  So when someone stole all of the mouse balls from the computer lab, I was a prime suspect.  The school principal came into the class to scold us…

Read the rest of this entry »

Samizdat

August 23, 2008

Ninjalicious’s Access All Areas is a surprisingly well-written bundle of guidelines, warnings, and stories having to do with Urban Exploration.  Urban Explorers pursue hidden and off-limits areas with the goal of appreciating the spaces (habitable or otherwise) that humans have created.  Destinations include drains, abandoned/construction sites, hotels, and—this was the coolest one by far—ghost ships.  I was saddened to hear that Ninjalicious (Jeff Chapman) died recently due to lung cancer, but his contributions are everywhere (q.v. the Infiltration and Yip e-zines).  8/10 on the enjoy-o-meter.

"A User's Guide to the Art of Urban Exploration" "How to own The Box"

Stealing the Network is a collection of short stories by various authors involving present-day hardware and software.  On the whole, they aren’t very well-written (clearly the authors’ strengths lie elsewhere) but til I discovered this gem I was finding it hard to stomach books on computer crime that had no basis in reality.  These stories feature real software, real hardware, and believable trickery that made me a little nervous about how we exchange data in the real-world.  That, and the overall theme of the collection is that bad guys always win.  6/10.

Ratpoison

February 28, 2008

Ratpoison logoA Window Manager, commonly abbreviated wm, is a program that controls the way your windows appear and behave. A good wm can be likened to an operating system: it provides a necessary service, but you barely know it’s there it because it doesn’t get in the way.

ratpoison is founded on the (apparently drug-induced) notion of a window manager that doesn’t get in the way. It does this by being constraining, inflexible, and primitive.

Read the rest of this entry »