diary @ telent

Error Messages, Rule 0#

Mon Dec 30 19:54:37 2002

Topics:
:; phoenix
:;

Writing Error Messages, Rule 0: failing silently is not acceptable

:; phoenix --display :0
Fontconfig error: Cannot load default config file
:;

Writing Error Messages, Rule 1: when the problem is with an external file, print the file name. Rule 2: if there's an OS error of some kind, print the errno information.

:; sudo apt-get install fontconfig
[...]
:; phoenix
.. and suddenly, it works. There's some comment to be made here also about Debian packaging, but the package was labelled experimental anyway, so I'm probbaly not going to be too harsh there.

First impressions:

  • it works
  • it works with emacs' browser stuff, so I can use it for hyperspec lookup
  • It has a weird unlabelled extra dialog box beside the url bar, with an icon that looks like a lollipop. Clicking on this gives a dropdown menu which allows the selection of 'Find in this Page', dmoz.org or Google, so I would guess it's intended as some kind of search box. There's no way of activating it that I can see, though - certainly, typing into it and pressing Return doesn't seem to do much. Maybe it's displaying into a hidden sidebar? From the release notes it looks like this program appears to like sidebars. This user, however, doesn't.
  • It supports that new-fangled font stuff that looks pretty but is actually harder to read than the apps I was using five years ago

Here's a screenshot. You may need to shift-click and save it if apache mod_proxy is interfering with my content-types again. Need to get that looked at, yes.

I started writing this entry the other day, but it was killed due to a#

Sat Jan 11 04:43:03 2003

Topics: lisp

I started writing this entry the other day, but it was killed due to a kernel problem.

My phone didn't come back, as such. Instead they gave me a new one, so that really ought to fix the problem. Thank you, Botley Road Oxford branch of Carphone Warehouse

All things considered, less done this week than I might have hoped to do. Having got the phone back, I obviously needed to get the numbers back into it - having cut and pasted the first two into cu, I decided to write a short perl program to do the rest automatically. Whee. Flashing caps lock light time. OK, let's do (almost) what I should have done instead and write it in lisp (I say "almost" because it's actually a shell script starting #!/usr/bin/clisp). Flash bang wallop #2. Hmm. Some poking around reveals that the device objects to having close() called, but as the oops is actually a full-blown kernel panic (in sched.c) and even stuff like magic sysrq only just about works, it's not going to be easy to get a log for.

(Some IRC people did recommend a serial console. Well, yes, but . If I had a serial port, I'd have plugged the phone in there in the first place and wouldn't need to be screwing around with USB.)

So I (forward ported to 2.4.21-pre3, wrote debian init scripts for, and) installed LKCD to get some kind of crash dump I could actually use. That seems to fixed things all by itself - at least, now I cannot replicate the problem.

The upside of all this is that 2.4.21-pre3 has some kind of sane memory usage patterns and once again I have a laptop that doesn't thrash itself for tens of seconds at a time on simple operations. My spies tell me that these days ac kernels are using some variant of the rmap VM, and nonac kernels are not. So, probably going to blame rmap. Maybe it's badly tuned. I still have LKCD installed for when I do manage to crash the machine using USB serial, but let's upload this diary entry first, shall we?

New (betaish) releases of araneida, cliki, db-sockets#

Sun Jan 12 04:13:25 2003

Topics: sbcl cliki lisp
Bcc: dan
To: lispweb@red-bean.com
Subject: New (betaish) releases of araneida, cliki, db-sockets
--text follows this line--

* CLiki is the collaborative community content creation system that
  most people here have probably heard of already.

* Araneida is the web server it runs on

* db-sockets is the socket library that Araneida uses

SBCL and CMUCL (the latter untested recently) are the implementations
this all runs on

New versions of the asterisked items are all (at last) now
available from cCLan, or will be as soon as the mirrors propagate.
See https://ww.telent.net/cclan-choose-mirror for your nearest.

These are labelled `betaish' because, although the basic code they
contain has been running on the real CLiki site for some time, there
may be packaging, portability and other issues that prevent them from
actually working out of the box.  Any bugs you do find are either
known or probably trivial, though.  Feedback sought.

Happy New Year, if you mark the occasion at or around this time.  I
wish you a happy next 12 months anyway, even if you don't.

[ updated for elisp syntax error, 13:01:52 GMT ]#

Tue Jan 14 07:55:15 2003

Topics: lisp

[ updated for elisp syntax error, 13:01:52 GMT ]

This is what I mean by a scriptable user interface...

So, it's not completely unheard of for me to write "Please find attached ..." in an email message, then forget to actually attach the file. Apparently I'm not the only person this happens to, either. SO, the other day I decided to sit down and sort it out.

I use Gnus for my email and news reading. Gnus, I happen to know, uses the default message composer in Emacs, which is known as Message. What I want is for something to run when I attempt to send mail, that warns me when I send a mail using the word "attach" if I haven't actually added an attachment.

  1. Enter The Dragon^Wscratch buffer

  2. Emacs has hooks everywhere. Probability is that there's a hook that runs just before a message is sent. We can find out with apropos:

    (apropos "message.+hook") C-j
    ...
    message-send-hook
      Variable: Hook run before sending messages.
      Plist: standard-value variable-documentation custom-options custom-type custom-requests
    

    Looks good to me

  3. Middle-clicking on Variable tells me I can customize this. Middle-clicking on that gets me the Customize buffer. There's nothing on the hook at the moment, but apparently I could add ispell-message if I wanted to. Putting the cursor on ispell-message and pressing C-h f (describe function) tells me

    Check the spelling of a mail message or news post.
    Don't check spelling of message headers except the Subject field.
    Don't check included messages.
    
    To abort spell checking of a message region and send the message anyway,
    use the `x' command.  (Any subsequent regions will be checked.)
    The `X' command aborts the message send so that you can edit the buffer.
    

  4. Not exactly what I want to do, but close enough that I can be pretty sure that what I do want to do (check for the string "attach", check for an attachment, query whether to send if a but not b found, abort sending if user says no) is implementable.

  5. Following the link to "ispell" takes me directly to the function's source code. Now, let's play with it. Copy and paste the entire ispell-message function into scratch, change its name to, say, check-attachments-attached, and start hacking it about a bit. Here's what I ended up with

    (defun check-attachments-attached ()
      (interactive)
      (save-excursion
        (goto-char (point-min))
        (let* (
               ;; Nil when message came from outside (eg calling emacs as editor)
               ;; Non-nil marker of end of headers.
               (internal-messagep
                (re-search-forward
                 (concat "^" (regexp-quote mail-header-separator) "$") nil t))
               (end-of-headers              ; Start of body.
                (copy-marker
                 (or internal-messagep
                     (re-search-forward "^$" nil t)
                     (point-min))))
               (limit 
                (or (re-search-forward "^-- $" nil t) 
                    (point-max)))              
               (old-case-fold-search case-fold-search))
          (unwind-protect
              (progn
                (goto-char end-of-headers)
                (when (search-forward "attach" limit t)
                  (goto-char end-of-headers)
                  ;; the word 'attach' has been used, can we find an
                  ;; attachment?
                  (unless 
                      (or (re-search-forward "^<#/" limit t)
                          (y-or-n-p
                           "Found the word `attach' but no MIME attachment: send anyway?"
                          )
                         (error "Aborted send")))))
            (set-marker end-of-headers nil)))))
    

  6. and add it to the hook:
    (add-hook 'message-send-hook 'check-attachments-attached)
    

Points of note -

First off, we didn't need to restart emacs. In fact, we didn't even need to load any files. All of this was done on the fly. Second, we didn't at any point have to read an info manual, fiddle around in the filesystem, or search a web site to get to the documentation for anything. We had a little help from customize to tell us that ispell-message was a suitable function for this hook, but aside from that, all we needed to know was in function and variable docstrings. And when we went to look for the source code to ispell-message, there it was, one mouse-click away. No cvs trees to check out, no source packages to download and puzzle over the autobreak incantations for.

The function is a hack. That's the difference between scripting and programming. If I were doing it properly, then instead of looking for that funny <#/ string I'd read the appropriate bits of whatever MIME attachment stuff I'm using (that's right, I don't actually know) and find out what it does to detect the presence of attachments.

The whole exercise took under an hour. Although I consider myself a competent Lisp programmer, that's Common Lisp, not elisp. I touch emacs customization about once a year on average - I may have a head start over someone whose programming experience is entirely with, say, C or Perl, but I'm by no means a guru.

This is what I mean by a scriptable user interface. This is the opportunity that GNOME (as far as I can determine) missed. This is the opportunity that Mozilla, as far as I can see, missed. (This is the opportunity that presently-mythical-environment-based-on-McCLIM had damned well better not miss).

People believe they're being funny when they compare Emacs to an operating system. Frankly, they're nearer the truth than they think: it may not have a pre-emptive scheduler, but it's still a better desktop environment than anything else I've used.

:; cu -l /dev/ttyUSB0
Connected.
AT+CLIP?
+CLIP: 0,1

OK
AT+CLIP=1
OK

RING

+CLIP: "01865423320",129

RING

+CLIP: "01865423320",129

Next up, maybe, mobile phone book/BBDB integration, with caller id on incoming calls.

I was going to send a pointer to the preceding (lexically following)#

Tue Jan 14 08:48:47 2003

Topics:

I was going to send a pointer to the preceding (lexically following) entry to David Mason, long-time Emacs user and (former?) GNOME project person. But his web site's been replaced by a "coming soon" page, and his Livejournal site (to get the url of which I had to dig his previous web site out of Google cache) doesn't display his email address anywhere. I'd try his old Red Hat address, but I think it's a matter of principle now.

On the genreal subject of hiding email addresses, ifile has now classified 81550 non-spam messages and 637 spam messages. It gets about a couple wrong each day - almost always spam that it lets through into non-spam. This is a massively better result than spamassassin already. So far so good.

OK, a single session transcript doesn't really capture the kewlness#

Fri Jan 17 02:17:22 2003

Topics: lisp sbcl

OK, a single session transcript doesn't really capture the kewlness aspect of this, so, my turn to put some Lisp pr0n up. Caution: actually not that visually stimulating after all. Also, it's a big (as in, 1280x960 pixels) picture.

Clockwise from top right:

Well, I think it's cool. I'm not about to start producing mpegs, though; you may just have to take my word for it that all of this is updating at once.

(Or you could check the cvs branch out and try it yourself, of course)

Again, the new machine comes with Red Hat, and after ascertaining that#

Wed Jan 29 15:17:51 2003

Topics: sbcl

Again, the new machine comes with Red Hat, and after ascertaining that it boots using grub and an initrd I really don't fancy replacing it with Debian remotely. But nor, to be honest, do I want to continue depending on a probably-soon-to-be-unsupported Red Hat version for anything beyond a bare minimum set of services.

Some slightly cool URLs :

and another useless error message for the collection:

Jan 29 15:16:52 eval sshd[878]: PAM rejected by account configuration[9]: Authentication service cannot retrieve authentication info.

(In this case, it turns out to mean "when you renamed the user you're trying to ssh in as, you forgot to update the shadow file")

Most of my time lately has been wrestling with posix job control stuff, so that multithreaded SBCL behaves somewhat less than completely stupidly when two threads want to read from the same tty at once. Not incredibly exciting, although I might some time soon be persuaded to write a few words about the xterm -S option before I forget how it works again.