Showing posts with label mac. Show all posts
Showing posts with label mac. Show all posts

Saturday, March 14, 2009

Fix dired under Fink xemacs (Mac annoyance Saturday)

Tonight I literally spent a couple of hours grappling with an uber-annoying bug under XEmacs in current Fink: dired-mode chokes on directories containing symbolic links. The symptom is that when you try to open a directory in dired, a cryptic "no file on this line" error appears in the minibuffer and dired fails to open.

To make a long story short: this fix from the Apple support forums is (unbelievably) the fastest and most foolproof way to fix this error. Step by step:

  1. sudo xemacs /sw/lib/xemacs/xemacs-packages/lisp/dired/dired.el
  2. Find the line containing the regex
    "[^ ][-r][-w][^ ][-r][-w][^ ][-r][-w][^ ][-+ 0-9+]"
    and change the regex to
    "[^ ][-r][-w][^ ][-r][-w][^ ][-r][-w][^ ][@\+]?[-+ 0-9+]"
  3. C-x C-s
  4. M-x byte-compile-file
  5. C-x C-c
  6. Quit and restart XEmacs.

Of course, you will need to do this again whenever Fink decides to overwrite dired.el; unless the Fink maintainers merge in the upstream fix.

Gory details below.


Under Mac OS X, unlike every other Unix in recorded history, ls inserts an @ or + sign after the permissions list on certain types of files (symlinks and files with "extended security information"). The dired.el code is brittle with respect to this oddity. Furthermore, it does not provide any way to customize the regular expression that matches and parses the output of ls (which, incidentally, is my primary evidence that Mac OS X is the first Unix in history to behave this way; it's essentially impossible that a Unix could have existed for any length of time like this without a patch being fed upstream to Emacs).

Now, it turns out that this bug was fixed in Dired 7.15. So the real problem is that Fink XEmacs has not pulled down the latest Dired; it's currently stuck on 7.13.

So, what's a hacker to do? Let me count the frustrations.

1. XEmacs has a built-in elisp package manager called pui. Maybe I can upgrade Dired that way?

I use M-x pui-list-packages; then I set a package mirror from the Tools > Packages menu; finally, I select the Dired package and type I to install:

(error/warning) Error in process filter: (ftp-error FTP Error: CWD 550 /pub/packages/editors/xemacs/packages/.: No such file or directory failed: )

Oh great. I try a half-dozen different package mirrors and every motherfucking one gives me this error (except when it dies even earlier due to some other FTP problem).

2. Aha, MacPorts has a more recent XEmacs! Screw Fink, maybe the MacPorts guys know what they're doing:

$ sudo fink remove xemacs
. . . long console spew . . . 
$ sudo port install xemacs
. . . long console spew . . . 
$ xemacs
Error: attempt to add non-widget child "*scratch*"
to parent "Buffers" which supports only widgets
[xemacs crashes]

The current MacPorts package of xemacs doesn't even start up. Bloody motherfucker.

3. Maybe I should just switch to FSF Emacs, which I already use on all my other boxes. I mean, Fink has emacs22-gtk now. Yeah, right:

$ sudo fink install emacs22-gtk
Information about 8097 packages read in 1 seconds.

. . . [deletia] . . .
The following package will be installed or updated:
 emacs22-gtk
. . . [deletia; making a long story short:] . . .
sed: /usr/X11/lib/libfontconfig.la: No such file or directory
### execution of /var/tmp/tmp.1.UdYe2K failed, exit code 1
Removing runtime build-lock...
Removing build-lock package...
/sw/bin/dpkg-lockwait -r fink-buildlock-fontconfig2-dev-2.4.1-106
(Reading database ... 42622 files and directories currently installed.)
Removing fink-buildlock-fontconfig2-dev-2.4.1-106 ...
Failed: phase installing: fontconfig2-dev-2.4.1-106 failed

4. So, I finally gave Carbon Emacs a try. Carbon Emacs runs, and dired actually works fine. Miracle of miracles.

Unfortunately, fonts are completely busted under Carbon Emacs. You get a slick anti-aliased font out of the box, but you can look forward to a hair-pulling exercise in frustration if you attempt to change that font to anything that's (a) legible and (b) fits more than 50 vertical lines of text on a Macbook Pro screen. Anti-aliased Courier looks even more terrible at 8pt than Courier usually looks. And Carbon Emacs is the first windowed Emacs I've used where no variant of the "Clean" font works out-of-the-box. Congratulations Apple! You've broken a piece of software that's basically worked for twenty years. So Carbon Emacs is out.

5. About twenty minutes of screwing around trying to install dired from CVS into a user-local directory, and have it override the one in the system directory, yields no progress.

6. I could try to install the latest dired package by hand, but I am sort of scared of what else might break if I do this. So, as much as I dislike manually twiddling with system files that should be under my package manager's control, I grit my teeth and did the voodoo noted at the top of this post. Which finally gets me everything I want, but my mouth is left with the distinct bitter residue of time sucked away from my life that I'll never get back.


My conclusions from this whole experience are as follows.

First, package maintainers for Fink and MacPorts aren't as good as the maintainers for Debian or Ubuntu. At any given time, a fair number of important packages will simply be nonfunctional. So the package situation will always be a pain in the ass on Mac compared to Linux.

Second, Mac OS X's random gratuitous differences from other *nix flavors will continue to suck away at least as much time from my life as I spent getting wireless and other random hardware widgets to work on a Linux laptop. Truly, for a programmer, there's no such thing as a laptop where you don't spend a significant amount of time fiddling with random bullshit just so you can get work done.

Saturday, February 28, 2009

Option key as Alt in KDE apps on Mac (Mac annoyance Saturday)

The default keyboard setup of Apple's X11.app for Mac OS X doesn't support Alt- shortcuts in KDE apps (at least not when KDE's installed via current fink, e.g. by sudo /sw/bin/fink install kdebase). This makes konsole just about unusable, as konsole translates Alt events into Meta keypresses on the underlying terminal, and discards true Meta events. To fix this, assign the keycodes as follows in your ~/.Xmodmap:

keycode 66 = Alt_L
keycode 69 = Alt_R

Then, ensure that your X11 "Preferences..." are as follows (dialogue box is from Leopard):

Finally, restart X11.

For completeness, here's the keyboard layout kcontrol module (you shouldn't have to do anything here, as these are the default settings):

Credit to this macosxhints.com post, which took an astonishing amount of searching to sift from the vast oceans of trash and non-working solutions that you get when you search for X11 issues for Mac. I post this in the hope that it will serve as more efficient Google-food.

(Background: I recently killed the hard drive on my ~2.5-year-old work MacBook, and so I've been reconstructing my work environment on the shiny new MacBook they requisitioned for me. Running emacs in a screen session on a remote Linux box is one of my most common activities, so having konsole with no Alt/Meta makes Mac usage just about unbearable. I could not for the life of me remember the magical incantation I did to fix Alt last time, so I literally spent about half a workday intermittently typing random permutations of "kde", "fink", "alt", "meta", "konsole", and "leopard" into my web search box. Blech.)

Saturday, June 21, 2008

Stop X11 from launching xterm (Mac annoyance Saturday)

In short, type the following at a command prompt:

defaults write org.x.X11 app_to_run /usr/bin/true

Wow, it's so intuitive! Mac UI genius scores again.

Via this macosxhints.com thread, although the recipe at the top is broken, at least in Leopard. The suggestion at the bottom of the thread is the winner.

(I'm going to start posting my Mac annoyances on Saturdays. From my experiences so far with Mac, I think my only problem will be limiting myself to one per week.)

Saturday, December 09, 2006

Mac OS X: Not just Unix with a pretty face

...and I mean that in a bad way.

I was issued a Macbook Pro when I started work, and I've been using it pretty regularly for the past few months. I had a choice of either a Macbook or a Thinkpad, and I chose the former because I hoped that it would be a more "real" Unix than Cygwin under Windows.

And the friction's certainly less than it would be under Cygwin. Just off the top of my head:

  • The OS X filesystem behaves like a real Unix filesystem, so you don't have to remember a mental mapping between native filesystem paths and paths as seen by your *nix applications (as you would under Cygwin).
  • Fink's package management tool more closely resembles apt or yum, and is therefore easier to use, than Cygwin's GUI package browser.
  • Fink includes ports of most big complex *nix software packages, whereas KDE (for example) simply isn't stable under Cygwin yet.
  • Xquartz "rootless" window mode works better than Cygwin's XFree86 (although Reflection X, if you're willing to pay for it, is better than either).

Still, there are a few nagging issues that make OS X distinctly inferior to a native Linux installation:

  • Copy and paste between native ("Aqua") applications and X applications is spotty to nonexistent. Googling reveals at least one tip for working around the problem --- keep xclipboard perpetually open --- but I don't want to keep an extra app open just to make my clipboard work.
  • Option-tab switching among X applications and native OS X applications is broken. The Quartz window manager just doesn't raise X applications to the front when you Command-Tab to them. You have to Command-Tab to X11, and then Command-backquote to cycle among X11 windows. Extremely disruptive to my workflow. Exposé only partly compensates for this problem.
  • I cannot figure out any combination of Xquartz, Xmodmap, System Preferences -> Keyboard, KDE Control Center, and xemacs/init.el settings that makes the Command key behave like Meta in XEmacs and Alt in KDE applications. Through some twiddling, I have managed to map Option to Alt and Command to Meta, but it's pretty annoying to switch between using Option-[key] under Konsole and Command-[key] under XEmacs.
  • There is no insert key, which makes Shift-Insert (a common keyboard shortcut for "Paste") impossible.

Rumor has it that some of the above problems may go away if I install a different X server, but I suspect that doing so will merely cause other things to break.

Anyway, don't get me wrong, the Macbook is a very nice machine: it's fast, it's well-designed (except for the single mouse button and lack of Trackpoint pointing device), it's sturdy, and the UI is pretty. But I was hoping that the Macbook would be strictly superior to Linux on my old Thinkpad --- that I'd have everything I used to have, plus some additional nice stuff --- and that's not the case. My next personal workstation will most likely be a Linux box, like the main workstation in my office at work.

Thursday, June 15, 2006

Computers are terrible

I just spent an hour of my life on the phone, talking my family through the process of connecting my sister's iBook to the family's wireless network. This involved relaying the WEP key multiple times over the phone, resetting the router, checking with the ISP to re-enter the network settings into the router, and downloading, unpacking, and upgrading the router firmware. Ultimately the router's broken-ass firmware was at fault, and hence upgrading it to version 5.3 was the solution. Curse you, Netgear MR814v2 router, and curse the horse you rode in on.

But although the router was at fault, it can't take all the blame for the situation. The crufty complexity of all the surrounding systems made it hard to isolate the problem. I could write an arbitrary amount on how broken all this was, but I don't have time. Suffice it to say I am annoyed.