Archive for the ‘mcclim’ Category

With knobs on

Friday, September 28th, 2007

Reading Sutherland’s incredible 1963 Sketchpad thesis I was struck by the following passage:

We will issue specific commands with a set of push buttons, turn functions on and off with switches, indicate position information and point to existing drawing parts with the light pen, rotate and magnify picture parts by turning knobs, and observe the drawing on the display system.

Where are my knobs and buttons? Why is the great advance of recent decades in widely available physical human-computer interaction the click-wheel mouse?

Sutherland opens his thesis by observing:

Heretofore, most interaction between men and computers has been slowed down by the need to reduce all communication to written statements that can be typed; in the past, we have been writing letters to rather than conferring with our computers.

Isn’t it time the epistolary model of interaction evolved?1,2

1. Yes, I know this seems at odds with my admiration for CLIM.

2. Yes, I am being deliberately provocative – this is the web – but I can imagine zipping through a document accepting and rejecting edits with my PS2 control being a lot more productive (and fun) than the mouse+keyboard experience.

Climacs and Java

Wednesday, May 2nd, 2007

Hot on the heels of the rudiments of a C syntax for Climacs, I’m about to commit a Java(TM) syntax. This one is slightly better, and should lead to improvements in the C syntax, too. (And, eventually, some refactoring of the – many – common elements.) Like the C syntax, this one does not yet try to parse too much Java grammar, but in the absence of a preprocessing stage, I have less excuse. On the other hand, the progressive layering of things like annotations (which look to this non-Java person like an afternoon’s work with a thin macro layer over symbol plists) and generics make the Java grammar distinctly grody. It’s a pity about infix, too…

“Java” is a trademark or registered trademark of Sun Microsystems, Inc. in the United States and other countries. They have an awful lot.

C and Lisp and Climacs and stuff

Thursday, April 26th, 2007

As a diversion from all the things I promised myself I’d be doing after ilc07, I’ve ended up playing with a C language syntax (mode) for Climacs.

When previewing on #lisp, the first question everyone had was “how accurately does this parse C?” Well, the answer is: at the moment, not at all. And I thought that, in the presence of C’s textual preprocessing facility*, that’s the way it would have to be. But looking briefly at emacs’ cc-mode, it looks like it ends up doing the closest thing to a full parse anyway, so I have some way to go…

More seriously, the C syntax uses the same LR parsing infrastructure that the existing Lisp syntax uses, so I’ve begun to abstract that out into its own LR-parsing mixin syntax. (I love mixins.) But it’s early days yet.

(This posted to shame me into actually delivering a patch to McClim reasonably soon rather than waiting for things to bit-rot. Which is the other thing — the wonder that is Drei means that this syntax is available to all text gadgets in McClim. Think of the possibilities…)

* “Many other changes occurred around 1972-3, but the most important was the introduction of the preprocessor. … Its original version was exceedingly simple, and provided only included files and simple string replacements: #include and #define of parameterless macros. Soon thereafter, it was extended … to incorporate macros with arguments and conditional compilation. The preprocessor was originally considered an optional adjunct to the language itself. … This attitude persisted, and explains both the incomplete integration of the syntax of the preprocessor with the rest of the language and the imprecision of its description in early reference manuals.” Ritchie, The Development of the C Language, 1993, in History of Programming Languages-II ed. Thomas J. Bergin, Jr. and Richard G. Gibson, Jr. ACM Press (New York) and Addison-Wesley (Reading, Mass), 1996

FTD projectified

Sunday, November 5th, 2006

Following overwhelming[*] demand, FTD, the Flexi Trivial Directory editor, is now a project on

FTD is now available via
darcs get
or here.

Thanks to mailing lists are at:

While FTD has a lot of dependencies, they are pretty common libraries[] and it would be nice to know if it built and was able to get a directory listing on your system. Feedback to the devel list, please (:

* Not really.

I know, it’s that old ‘Common Lisp has too many libraries’ complaint…

… on a stick

Sunday, November 5th, 2006

Climacs on Windows

What do you get when you put SBCL‘s windows port (helpfully packaged by Nikodemus Siivola), EmacsW32, Slime, McClim and Xming on a USB stick?

A nice little portable development environment with cross-platform GUI, of course!

FTD 0.0.3

Friday, October 20th, 2006

FTD screenshot

I resurrected FTD, the Flexi Trivial Dired, after some months’ hiatus. When I started the project last year it was to provide another ESA (Emacs Style Application) example, and to provide a test-bed for McCLIM application integration. Well, ESA was split out of Climacs anyway, and Clim Desktop made its appearance without a directory editor.

Still, it’s fun to see how much of the Emacs Dired functionality can be obtained by putting together a bunch of common lisp libraries. Documentation and downloading instructions can be found here.

Being an ESA, FTD inherits all of the cool help functionality built into the ESA framework. Unfortunately, ESA won’t write the documentation for you yet…

Help Apropos 'Mark'

A couple of things makes FTD actually usable (from a UI point of view) in this revision. First, I remembered to specify :allow for the :end-of-line- and :end-of-page-actions. And, second, Troels Henriksen pointed out, after a few seconds of looking at the code, that I was using the default #'eql cache test, even though I was comparing cache-values of freshly consed lists each time through the display loop. Correcting this test (to :cache-test #'equal) prevented McClim from redrawing everything each time I moved the cursor…

Comments and patches welcome (splittist at splittist com). If there is any real interest I’ll set up a proper project.

Climacs Search

Saturday, May 27th, 2006

Climacs Search: Multiple Query Replace From Buffer

Climacs has a bunch of search commands, but it needs more!

What it has at the moment are many of the standard ones:

  • Incremental Search (forward and back) – C-s and C-r
  • String Search (and Reverse String Search)
  • Word Search (and Reverse Word Search)
  • Regex Search Forward and Regex Search Backward
  • How Many (lines after point match some regex)
  • Replace String (unconditionally)
  • Query Replace – M-%

and a few less common:

  • Multiple Query Replace
  • Query Exchange
  • Multiple Query Replace From Buffer

Incremental Search and Query Replace have a fair subset of the GNU emacs functionality in their loops. While in an incremental search you can switch direction, add a newline to the search string (C-j), snarf the next word into the search string (C-w), or the remainder of the line (C-y), or the top of the kill ring (M-y) etc. While in a query replace loop you can replace, skip, exit, replace and exit, or just replace the rest of the matches.

So far so good for the normal stuff. You’ll see that some functionality isn’t there yet. Partially this is just that no-one has gotten around to it (and if your favourite functionality is missing patches are appreciated!). But partially this is because climacs isn’t emacs, and we’re still feeling our way towards what is the best way to use the command-loop, in which a lot of CLIMy magic happens.

As an example of the issues, take the emacsly-traditional way of invoking a string search – C-s immediately followed by the command to exit the search (RET in GNU emacs, Altmode in TWENEX EMACS, etc). The Incremental Search command works by setting up a special command table (a CLIM object imaginatively named isearch-climacs-table) that maps gestures to commands (so that, for instance, C-j is mapped to com-isearch-append-newline). The gesture #\Newline invokes com-isearch-exit. But when the search string is empty, #\Newline should run the command String Search (or Reverse String Search, if we’re isearching backward). String Search prompts the user for a string to search for (!), and one of the beauties of CLIM is that the system handles this automatically. But not here, where we are inside another command (and, indeed, inside another command loop – but that’s another story), so for the moment I have to reach behind the curtain and pull a few levers myself:

(execute-frame-command *application-frame*
                        (frame-command-table *application-frame*)
                        (frame-standard-input *application-frame*)
                        (if search-forward-p
                            `(com-string-search ,*unsupplied-argument-marker*)
                            `(com-reverse-string-search ,*unsupplied-argument-marker*))

Obviously this is uglyrific, but the moral of the story isn’t that CLIM makes normal things hard (although there are some things about command tables that the CLIM 2 spec leaves rather underspecified), but that I don’t yet know the best way to get this (admittedly rather special) behaviour out of the existing command loop. (One possibility: have a pending-commands slot that the command-loop checks, analogous to the remaining-keys slot used by the keyboard macro machinery.)

Another thing I don’t understand is why GNU emacs doesn’t have a command like Multiple Query Replace. This prompts for pairs of strings and then goes through the buffer asking if you want to replace any of the first strings of the pairs with the corresponding second string. Since this happens essentially in parallel, you can replace FOO with BAR, BAR with BAZ, BAZ with QUUX and QUUX with FOO in one invocation, without any messing around with temporary strings or abbrevs (as suggested as workarounds in the GNU emacs documentation). (The command Query Exchange is specialised for the case when you want to swap each FOO with a BAR and vice versa.) If you think entering the search and replacement strings in the minibuffer is prone to mistake, you can put them in a buffer and use Multiple Query Replace From Buffer. An essential refactoring tool, I would have thought.

Well, essential once climacs gets Tag Files (the Zmacs name for a collection of buffers or files, whether named in a TAG file, or all the open buffers, or all the files in a system etc.). Then various searching commands can be run over all the files in a Tag File. Which means the ability to suspend and resume a given search, and to visualise pending operations, becomes important.

And then there are the syntax specific searches that climacs should really have – things that allow you to ask for all lists of length 3 with CL:IF as the first element…

But all that is for another day.

Climacs Help

Sunday, May 14th, 2006

Climacs Help

Climacs has quite a few help commands now. The picture above shows Apropos Command (in the lower panel) and Describe Command (in the upper panel).

The interesting thing is that the upper panel was obtained by clicking on the “Kill Line” heading below. And the magic involved?

(present command
         `(command-name :command-table ,command-table)
         :stream out-stream)

when printing and

(define-presentation-to-command-translator describe-command
    (command-name com-describe-command help-table
                  :gesture :select
                  :documentation "Describe command")
    (list object))

to make it clickable.

Which just goes to show some of the cool things you get for free if you use CLIM.

The full list of help commands currently available is:

  • Apropos Command (C-h a)
  • Describe Bindings (C-h b)
  • Describe Key Briefly (C-h c)
  • Describe Command (C-h f)
  • Describe Key (C-h k)
  • Where Is (C-h w)

In fact, all these commands are part of ESA, and should therefore be available to any Emacs Style Application written using that framework.