Shallow Thoughts : : Sep

Akkana's Musings on Open Source Computing and Technology, Science, and Nature.

Fri, 30 Sep 2005

Set C Styles Automatically in Emacs

I just figured out a nifty emacs trick: how to set C styles automatically based on the location of the file I'm editing. That way, emacs will autoindent with the proper style whether I'm editing my own code, GIMP code, Linux kernel code, etc. assuming that I keep the source for these projects in predictable places.

First, define a derived mode for each style you might want to use. Each minor mode inherits from c-mode, but adds a c-set-style call. (Obviously, this assumes that the styles you want to use are already defined.)

(define-derived-mode gnu-c-mode c-mode "GNU C mode"
  (c-set-style "gnu"))
(define-derived-mode linux-c-mode c-mode "GNU C mode"
  (c-set-style "linux"))

Then add entries to your auto-mode-alist for each directory you want to treat specially:

(setq auto-mode-alist
[ . . . ]
      (cons '("gimp.*/" . gnu-c-mode)
      (cons '("linux-.*/" . linux-c-mode)
            auto-mode-alist) ) )

Your normal default style will still work for any files not matching the patterns specified in auto-mode-alist.

It might be possible to skip the step of defining derived modes by switching on the file's pathname in the C mode hook, but I've never figured out how to get the pathname of the file being loaded in any reliable way.

[ 13:42 Sep 30, 2005    More programming | permalink to this entry | comments ]

Mon, 26 Sep 2005

Exorcising the Evil Alternate Screen

I've long wondered why people like the "alternate screen" misfeature which has become mandatory in so many Linux terminals. That's the one where you want to find out the options to ls, so you do man ls, get to the option you were curious about, hit q to get out of man so that you can run ls with the right option -- and the man page disappears, clearing the screen so you can't see the documentation you were just trying to read! What's up with that?

(Sigh ... just another addition to the list of clever innovations that make Linux terminal programs harder to use than any other system's ... like the page up key that doesn't actually page up.)

Anyway, a long time ago I worked out how to get around this irritating misfeature (referred to as "rmcup" on newer terminfo systems; the workaround on older termcap systems was called "tite inhibit"). It's easy in xterm-based programs, but harder in more "modern" terminal programs that don't make it configurable. I guess I never got around to writing it up publically.

Tonight someone asked about it on Linuxchix Techtalk, so I resurrected the old terminfo entry I wrote for use with gnome-terminal (which I'm not actually using because rxvt doesn't need it), and wrote up a sketchy page on it: Exorcising the Evil Alternate Screen.

Tags: ,
[ 20:18 Sep 26, 2005    More linux | permalink to this entry | comments ]

Fri, 16 Sep 2005

Rude Users Sometimes Beget Rude Developers

On the Linuxchix grrltalk list, someone was bothered by the tone of Eric Raymond's How to Ask Questions the Smart Way. And certainly, the tone is a bit brusque (like much of ESR's writing), though it's full of useful advice.

The discussion hinged around user demands such as "YOU SUCK! YOU MUST FIX THIS NOW!" This is obviously rude, and just as obviously has little chance of getting a positive reaction from developers.

The problem is that after twenty or so of these demands, even a polite user coming in to ask for a feature may be snapped at. I've seen developers get touchy after reading a slew of this sort of bug reports, and snap at someone who wasn't being particularly rude.

Really, a lot of users have no idea how many of these rude, demanding, "YOU SUCK -- FIX THIS IMMEDIATELY!" messages some developers get. Try "watching" a category or developer in bugzilla for some major project like Mozilla for a month to get an idea of the volume of email that streams in. It's easy to get ten or more of these in one day's morning mail before you've even finished your coffee. Lots of developers just stop reading their bug mail after a while. I hate that and think it's wrong, but I can understand why they do it.

Sometimes problems that twenty users comment on, even if they're real issues, are hard to fix, or the fix would conflict with some other important aspect of the program.

"Hard to fix" or "Hard to find a way to fix the bug without breaking another important feature" is not an adequate solution when you're developing software professionally. But when you're volunteering your own evenings, weekends and vacations to contribute to open source software, and some user who probably spent his evenings watching TV and last weekend skiing, who doesn't seem to have spent any time contributing to the project beyond filing a few bugs, shows up and demands that you drop the work you're currently interested in and instead devote the next eight weekends to fixing HIS feature ... well, after that happens a few times it's easy to get a little touchy. When it happens day after day, it's even easy to stop caring so much about user input in general, and to (incorrectly) lump all users, not just the rude ones, into this category.

I wish users, before making a request, would remind themselves that developers are spending their spare time on the project, instead of going skiing or watching TV or whatever -- and no, that's not because developers are troglodyte geeks who have no other hobbies. DO make suggestions, but remember when you do that you're probably not talking to someone who's paid to maintain the program forty hours a week. You're talking to someone who donated spare time to create a program that you now find usable enough to care about.

No, rudeness doesn't solve anything. Developers being rude doesn't improve this situation -- it won't make the users stop being rude, it won't help the polite users, it won't even make the developers feel better. But sometimes people get irritable when they're taken for granted. Developers are only human. Whatever users might think.

[ 11:30 Sep 16, 2005    More tech | permalink to this entry | comments ]

Wed, 14 Sep 2005

It's Walnut Season

It's walnut season. The neighborhood is full of crows, making rattling calls, flying from place to place with walnuts in their beaks, and dropping walnuts on roads to try to crack them. It's always entertaining to watch the crows' antics. Walnuts are hard to crack, even when you're a professional.

Meanwhile, the squirrels are going crazy. In addition to running around carrying walnuts the size of their heads, burying, digging up, and re-burying, we've also seen squirrels fighting with each other, threatening each other, whirling around in trees for no apparent reason, and perching on wires barking at invisible enemies below.

I had assumed that they were barking at cats or other squirrels in neighbors' yards, but this morning I saw a squirrel on the power line above the driveway, barking and threatening and staring intently at ... the empty driveway. If there was anything there, it must have been the size of an ant.

Makes me wonder ... do walnuts ever ferment? Am I seeing a neighborhood full of drunken squirrels?

Tags: ,
[ 12:16 Sep 14, 2005    More nature | permalink to this entry | comments ]

Sun, 11 Sep 2005

Changing User Agent to Pretend to be MSIE6

In the wake of the Hurricane Katrina devastation, one of FEMA's many egregious mistakes is that their web site requires IE 6 in order for victims to register for relief.

It's mostly academic. The Katrina victims who need help the most didn't own computers, have net access, or, in many cases, even know how to use the web. Even if they owned computers, those computers are probably underwater and their ISP isn't up.

Nevertheless, some evacuees, staying with friends or relatives, or using library or other public access computers, may need to register for help using FEMA's web site.

It turns out that it's surprisingly difficult to google for the answer to the seemingly simple question, "How do I make my browser spoof IE6?" Here's the simple answer.

Opera: offers a menu to do this, and always has.

Mozilla or Firefox: the easiest way is to install the User Agent Switcher extension. Install it, restart the browser and you get a user-agent switching menu which includes an IE6 option.

To change the user agent on Mozilla-based browsers without the extension:

  1. type about:config into your urlbar
  2. Right-click in the window (on Mac I think that's cmd-click to get a context menu?) and select New->String
  3. Use general.useragent.override for the preference name, and Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) for the value.
I think this takes effect immediately, no need to restart the browser.

Safari (thanks to Rick Moen on svlug:

  1. Exit Safari. Open Terminal.
  2. Type defaults write IncludeDebugMenu -boolean true
  3. Restart Safari.
Safari's menu bar will now include Debug, which has an option to change the user agent.

If you do change your user agent, please change it back after you've finished whatever business required it. Otherwise, web site administrators will think you're another IE user, and they they'll use that as justification for making more ridiculous IE-only pages like FEMA's. The more visits they see from non IE browsers, the more they'll realize that not everyone uses IE.

Tags: ,
[ 13:35 Sep 11, 2005    More tech/web | permalink to this entry | comments ]