Prosthetic Conscience

Jason McBrayer's weblog; occasional personal notes and commentary

Sun, 12 Oct 2008

Wrapper script for emacs using –daemon

For quite a while, I’ve used a variety of scripts for starting emacs, starting with dtemacs from gnuclient, which I modified in various ways to work the way I wanted it with Gnome and from the command line. The new daemon-mode in CVS emacs, combined with multi-tty, makes it a bit simpler to write a script that you can use to edit files from your desktop environment, from a command-line with or without X available, or as an external editor from a mailer, VCS or web-browser. I’ve re-written the latest version of my emacs wrapper in terms of daemon-mode, and present it here. It’s rather shorter than my pre-daemon-mode script, and does rather more. Apologies for my bad shell-scripting style.

#!/bin/sh  

# em: a script for starting emacs as needed.  

EMACSCLIENT=emacsclient  
EMACS=emacs  

if [ -z "$DISPLAY" ]  
then  
    CLIENTARGS='-t'  
    CLIENTNEWARGS='-t'  
else  
    CLIENTNEWARGS='-c -n'  
fi  

function start_daemon() {  
    echo -n "Starting emacs in the background…"  
    $EMACS –daemon  
    while ! $EMACSCLIENT –eval t >/dev/null 2>&1  
    do  
        sleep 1  
    done  
    echo "ok."  
}  

if [ -z "$@" ]  
then  
    if $EMACSCLIENT $CLIENTNEWARGS >/dev/null 2>&1  
    then  
        exit 0  
    else  
        start_daemon  
        $EMACSCLIENT $CLIENTNEWARGS  
    fi  
else  
    if ! $EMACSCLIENT $CLIENTARGS "$@" >/dev/null 2>&1  
    then  
        start_daemon  
        $EMACSCLIENT $CLIENTARGS "$@"  
    fi  
fi

[ Posted: 19:00] | [ Category: computing] | Permalink | Comments: 0 ]

Wed, 08 Oct 2008

Underappreciated emacs function: just-one-space

I want to very briefly praise the probably-underappreciated emacs command just-one-space. It is on M-SPC by default, and what it does is replace all the spaces and tabs around point with one space (or prefix-arg number of spaces). That’s nothing terribly fancy, but it’s one of those little things that can let you save so many keystrokes when you’re reformatting text. That and transpose-chars are among the little touches that make emacs so much more convenient than a bog-standard text editing control.

[ Posted: 06:10] | [ Category: computing] | Permalink | Comments: 1 ]

Tue, 07 Oct 2008

Links for 2008-10-07

[ Posted: 18:30] | [ Category: web] | Permalink | Comments: 0 ]

Sat, 04 Oct 2008

Links for 2008/10/04

Some of these are a little out of date given the unfortunate passage of the bailout act, but never mind.

  • Commentary: Bankruptcy, not bailout, is the right answer - CNN.com

    An article from an academic economist opposing the bailout.

  • The Outbreak

    A fun interactive zombie movie.

  • The Wall Street bailout and the threat of dictatorship

    Excellent analysis in the WSWS of a very revealing article in the Unquotable Rag (Washington Post) by a member of the CFR. Basically, this guy considers the failure of the Wall Street bailout as showing that “American political elites have lost the ability to quickly respond to a national challenge by imposing their collective will.” And he considers that a bad thing.

    The writer of the analysis does engage in a little Constitutionolatry (unusual for a Commie) in saying that the Constitution did not replace the Articles in order to allow political elites to quickly impose their collective will. Of course it did! Isn’t he aware of the Anti-Federalists‘ objections to the Constitution?

    But it’s nevertheless an important analysis. The conflict over the bailout is the first time in recent memory that the elite media has outright failed in manufacturing the consent of the American people to the consensus of American elites. Representative democracy is pretty weak tea, but we haven’t even properly had that in years; it’s bracing to see what it actually looks like.

[ Posted: 18:00] | [ Category: web] | Permalink | Comments: 0 ]

Thu, 02 Oct 2008

Cheap fountain pen review: Aldo Domain Two Tone fp

Aldo Domani Two Tone fountain pen w/mini ballpoint set

I found this at Office Depot for $16, a bit cheaper than the $22 their website lists it as. I was considering getting a new inexpensive fountain pen, as the clip on my Waterman Phileas is sprung, and I was thinking of the Foray Focus fountain pen in black. However, I happened to see this pen set, and my cheap side jumped out and made my try out the Aldo Domani.

  • What it includes:
    • the fountain pen, which I’ll describe in detail below.
    • a rollerball converter for the fountain pen, consisting of a rollerball ink cartridge and point assembly, and a housing for the head end of that which replaces the fountain pen’s section & nib.
    • A mini ballpoint pen with a stylus point on the end.
    • A short standard ink cartridge.

    I haven’t tested the rollerball point, nor the mini ballpoint; I bought this only for the fountain pen. If I had a device that used a stylus, I might carry the mini ballpoint for that, but I don’t, and I don’t really have any reason to carry a ballpoint otherwise.

  • The fountain pen

    The fountain pen, like the rest of the set, is actually made by Yafa, who I’ve noticed before make some cheap fountain pens for calligraphy sets and such. This pen is, according to the packaging, made of brass, covered with lacquer, and with chrome accents. It’s actually a fairly nice-looking pen, with a silver-gray barrel, a glossy black cap, and glossy black ends that look rather like cufflinks. It uses standard ink cartridges, and comes with a short standard cartridge. Note that it does not come with a converter (the Foray Focus I was also considering does).

    On opening the package, I loaded the pen up with a Waterman long standard cartridge, rather than the short standard cartridge it came with. The pen is a very nice substantial weight, much more solid feeling than my Phileas, about the same as my stainless Sheaffer Triumph Imperial. The cap posts very smoothly and solidly, and stays put. The nib is a medium, and is marked with “Aldo Domani” and “Iridium point, Germany”. The clip has a nice shape when looked at head-on, but is not very well constructed – the tip of it is folded metal like you’d see in a decent disposable gel pen, and it is very tight. It would not clip well to thicker fabric.

    One nice feature of this pen, which is not often found in very cheap fountain pens, is that the cap screws on and off. This makes it much more secure for carrying in a pocket or the pen loop of a notebook.

    My first impressions writing with this pen were that it is a very poor starter, but not a bad writer once it got started. On first using it, I had to shake it a bit and press down to get any ink to flow, but after that, it wrote okay, giving a wet line that was slightly wider than I like. After using it for a while, I found that it tended to be slow to start the first time it was used each day. This slow starting made the line quality slightly inconsistent, as it was rather dry starting, then tended toward being fairly wet. Even with these problems, I’ve enjoyed using it over the past couple of weeks as the pen-that-goes-in-my-notebook. The nib is reasonably smooth, and not at all flexible.

    I ordered a standard cartridge converter from PenCity; I had thought I had a spare from somewhere before, but apparently not. I cleaned the nib by soaking in cold water, dryed it on a paper towel, attached the converter, and filled it with Noodler’s Bulletproof Black. I don’t know whether it’s the ink itself, the act of drawing ink in through the feed, or whether I should have cleaned the nib in the first place, but the pen no longer shows the tendency towards slow starting that it did on the cartridge ink.

  • Summary

    I give this pen a B+. It’s an excellent value for the very low price, assuming you can get it as cheaply as I did. Except for the cheap clip, the body of the pen is as nice or nicer than pens I have in the $30-$50 range. The nib is not great (not as good as even the Waterman Phileas, say), but it’s about as good as decent school pens like the Parker Reflex or Vector. The real appeal to me of it is that for hardly any more than a Reflex, I get an all-metal pen that will stand up to a bit more daily abuse than the somewhat flimsy Reflex.

[ Posted: 12:00] | [ Category: productivity] | Permalink | Comments: 0 ]

Tue, 30 Sep 2008

Links for 2008-09-30 Tue

[ Posted: 21:25] | [ Category: web] | Permalink | Comments: 0 ]

Fri, 26 Sep 2008

Links for 2008-09-26 Fri

[ Posted: 17:45] | [ Category: web] | Permalink | Comments: 0 ]

Thu, 25 Sep 2008

Using Windows Search with anything.el

In a previous post, I said that I wished there were a command-line client for Windows Desktop Search (or Windows Search, or whatever M$ is calling it this week) that would give back filenames in a way useful to anything.el. Well, that comment was not entirely ingenuous, because in the time between when I wrote that article and when I posted it, I wrote one. It’s written in Python, and uses the win32com module, so you’ll need regular w32 Python installed (not Cygwin python).

The script itself is here. I recommend that you install it somewhere on your PYTHONPATH. This is because command-line argument handling is very dodgy on w32, particularly when the program is interpreted, the interpreter is a native w32 program (not cygwin), and you may be calling it from a cygwin program (such as cygwin bash). More details on installing it and its limitations on its own page.

Integrating it into anything: use the following elisp code:

(defvar w32-windows-search-program
  "python.exe -m DesktopSearch"
  "Command to pass a search string to Windows Search.
Will be split on spaces to pass to start-process.")

(defvar anything-c-source-w32-windows-search
  '((name . "Windows Search")
    (candidates . (lambda ()
                    (apply 'start-process "w32-windows-search-process" nil
                           (append
                            (split-string w32-windows-search-program)
                            (list anything-pattern)))))
    (type . file)
    (requires-pattern . 3)
    (delayed))
  "Source for retrieving files matching the current input pattern
with windows desktop search.")

The given value for w32-windows-search-program depends on DesktopSearch.py being in your PYTHONPATH. With the above in your .emacs, you can add the source it provides (anything-c-source-w32-windows-search) to anything-sources just like any other anything source.

This generally works well enough for my needs. Hopefully it will be useful to other people using emacs on w32.

[ Posted: 20:00] | [ Category: computing] | Permalink | Comments: 0 ]

Mon, 22 Sep 2008

[ Posted: 19:20] | [ Category: web] | Permalink | Comments: 0 ]

Fri, 19 Sep 2008

anything.el and “open with default tool” on w32

My job doesn’t often offer the opportunity to “hack the good hack.” A little while ago during toolsmithing time, I got to make a neat little hack to ‘anything’, an emacs package for locating files (or buffers, or info pages, or … anything) and acting on them. Normally, use of ‘anything’ works like this: C-x C-a to start, then start typing something to search for, arrow down through the matches, and either select the default action (open the file or switch to the buffer) with RET, or hit TAB to switch to a list of actions to select.

Here’s where the hack comes in. One of the actions you can perform on files is ‘open with default command’. The catch: this is not implemented on W32, which I have to use at work. On unix and MacOS, it this action is implemented by calling an external program — ‘xdg-start’ on unix, or ‘open’ on Mac-OS — with the filename as an argument. There is no equivalent command on W32 – the closest is the cmd.exe shell internal ‘start’. But because ‘start’ is a cmd internal, it is hard to call from emacs; the quoting may be badly messed up, for example, depending on whether you use cmd.exe or cygwin sh as your shell, etc. But here’s a better approach: leave it up to emacs. Emacs on W32 has a function ‘w32-shell-execute’ that works like cmd.exe’s ‘start’ internal.

The code to integrate this is now added to anything-config.el, a package of sample configurations for Anything. I’m now co-maintaining anything-config.el.

The practical upshot of this is that I can use ‘anything’ to find my playlist files while in emacs, and start them with Windows Media Player. Now if only Windows Desktop Search let you get text-mode search results back, or if there were a version of Tracker for W32…

[ Posted: 17:30] | [ Category: computing] | Permalink | Comments: 0 ]

Thu, 18 Sep 2008

Links for 2008-09-18 Thu

[ Posted: 18:30] | [ Category: web] | Permalink | Comments: 0 ]

What I’m missing in Google Chrome: fast proxy switching

It’s nice that Chrome has Incognito Mode. But how incognito is it when your network admin can monitor the content of your traffic? Wouldn’t it be nice to be able to switch your network traffic to a secure channel – like an SSH tunnel to an http proxy under your control, or TOR?

Firefox has the ‘Distrust’ extension that provides the same protections as Chrome’s Incognito Mode (other than the v. stylish fedora-wearing spy logo). And it also has your choice of extensions that let you switch proxies without going into the depths of the advanced settings menu: QuickProxy, SwitchProxy, FoxyProxy, and several TOR-specific extensions. Now if only Distrust had a setting that let one turn on their proxy for the duration of the Distrust session…

[ Posted: 18:15] | [ Category: computing] | Permalink | Comments: 1 ]

What I’m Missing in Google Chrome: Mouseless browsing

In Firefox, I have the Mouseless Browsing plugin installed, which lets me hit a key to label links with numbers, then type the number to follow the link. But even without MLB, you can browse mouselessly with the typeahead search – type ‘/’, then start typing the text of the link, and when the link you want is highlighted, hit enter. In Chrome, you can only tab between links, not jump directly to the one you want (even with the search function). That is, you can search for link text, and it will highlight it, but you cannot then select the link without tabbing to it from the beginning.

[ Posted: 16:00] | [ Category: computing] | Permalink | Comments: 1 ]

Mon, 15 Sep 2008

Links for 2008-09-15 Mon

[ Posted: 20:00] | [ Category: web] | Permalink | Comments: 0 ]

Sun, 14 Sep 2008

Links for 2008-09-14 Sun

[ Posted: 14:00] | [ Category: web] | Permalink | Comments: 0 ]

Tue, 09 Sep 2008

Links for 2008-09-09 Tue

[ Posted: 19:30] | [ Category: web] | Permalink | Comments: 0 ]

Mon, 08 Sep 2008

Links for 2008-09-08 Mon

[ Posted: 19:30] | [ Category: web] | Permalink | Comments: 0 ]

Fri, 05 Sep 2008

Links for 2008-09-05 Fri

  • Palin: Iraq war ‘a task that is from God’ - Yahoo! News
    I have promised someone important to stop bagging on Obama in public (I will leave that to Kevin Gray, who is better qualified than I am to do so), and to focus my poison pen on the republicans. So here you go. Bad stuff about Sarah Palin that’s not even personal slime on her dysfunctional family.
  • BBC - The history of diaries in code

    Via Schneier on Security.

    Sadly, it seems as if there is almost no point in writing a diary in code anymore. If you wrote it by hand (using a shorthand, a monoalphabetic substitution cipher, or, at the extreme, the Vigenère cipher or an autokey cipher), then it would be trivially susceptible to modern cryptanalytic techniques. But to use a strong encryption scheme, you’d have to write your journal on the computer, which takes all the fun out of it.

  • BBC NEWS | UK | More fish off the ‘green’ menu

    Oh noes, not anchovies! How will I make pasta alla putanesca now?

  • Can We Escape

    A libertarian class analysis by Roderick Long. In general, I am less sanguine about private power than Long, and less comfortable with public power than Chomsky. But I consider Long’s “reasons for pessimism” in this article very insightful.

  • Slingshot! Organizer

    A pocket organizer for radicals. I wonder if I can get an unbound one and add it to my rollabind journal, rather than adding a bound one to my pile of kit to lug around.

  • Women of Steel to McCain: Palin wrong choice for working women, families
  • Stevey’s Blog Rants: Business Requirements are Bullshit

    Summary as I understand it: If you don’t want something yourself, don’t build it on the assumption that someone else will want it. You’ll probably be wrong.

[ Posted: 17:30] | [ Category: web] | Permalink | Comments: 0 ]

Thu, 04 Sep 2008

Links for 2008-09-04 Thu

[ Posted: 07:35] | [ Category: web] | Permalink | Comments: 0 ]

Tue, 26 Aug 2008

Links for 2008-08-26 Tue

[ Posted: 18:30] | [ Category: web] | Permalink | Comments: 0 ]

 

Page 0 of 43  >>


Powered by PyBlosxom