CWB and Emacs

There's an emacs mode, cwb.el, for interacting with the CWBv7.1: please try it. I've been using it under XEmacs 20.4, 19.1x and various others, and others have used it under FSF emacs 19.3x. Minor versions shouldn't matter, but you do need a version 19 emacs or later.

To set up the CWB mode

  1. Make sure you've got cwb.el. You might like to byte-compile it to cwb.elc.
  2. Alter either the position of cwb.el[c] or the value of your Emacs load path so that cwb.el is in your emacs load path. For example. if cwb.el is in ~me/emacsstuff, one way to do this is to add this line to the top of your .emacs: (setq load-path ; Look in my own library first. (cons (expand-file-name "~me/emacsstuff") load-path))
  3. Arrange for cwb.el[c] to be loaded when it's required. For example, you could add the following to your .emacs: (autoload 'cwb "cwb" "Run a CWB process." t) (autoload 'cwb-file-mode "cwb" "Major mode for editing CWB source." t)
  4. Make sure that cwb.el will be able to find your copy of the CWB. By default, cwb.el will look in your path for a program called cwb. If your copy is called something different you need to add something like: (add-hook 'cwb-load-hook (function (lambda () (setq cwb-program-name "cwb7")))) ;; only necessary if your v7 isn't ;; called cwb
  5. You may also like to add: (setq auto-mode-alist (append '( ("\\.cwb$" . cwb-file-mode) ; Concurrency Workbench mode ) auto-mode-alist))

To use the CWB under emacs

You start the CWB with M-x cwb. The crucial points are: M-p and M-n cycle through previous commands, forwards and backwards. There is completion on command names using TAB. C-c C-l lets you load a CWB file, with normal emacs completion on filenames. C-c C-b sets you up to submit a bug report -- please do!

Lots more needed here....

TIP:

To use cwb mode in an emacs running on one machine, whilst running the cwb itself on another, make cwb-program-name be the name of an executable script in your path which contains something like rsh craro "(cd /home/pxs/cwb/test/tests; cwb7)" suitable altered.

To view transition graphs

This facility is experimental. There are several reasons why it's unlikely to be possible unless you're running under SunOS 4 or Solaris; sorry about that. It may become more widely available in future.

Besides the contents of this distribution, you will need:

Once you have daVinci in your path, start it up as normal (just by typing daVinci) and accept the licence. (You only need do this once; it's just so that you don't get the licence window coming up when you first use daVinci from emacs, which can be confusing.)

Make sure that the translation script cwb2daVinci is somewhere in your path and is executable

From the cwb-mode, use C-c C-x to start the viewer. You can then interact with the viewer using the emacs menu. Look at the top of your emacs window towards the right hand end of the menu. Choose CWB, then Graph display, to get a list of possibilities. (There are also a few options on the daVinci Edit menu.)

As I've said, this facility is experimental. Please let me know what you'd like to see in it. (No promises though: I'm very short of time.)

To customise the emacs mode

You can of course customise the capabilities, add key bindings etc. in the usual way. For example, my cwb-load-hook uses the line (define-key cwb-mode-map "\C-c\C-a" 'cwb-graph-graph) to bind C-c C-a to cwb-graph-graph, the function which prompts for an agent and then displays it in daVinci. This allows me to type C-c C-a instead of choosing the Show graph... option from the Display graphs part of the CWB menu.

My whole cwb-load-hook reads:

(add-hook 'cwb-load-hook (function (lambda () (define-key cwb-mode-map "\C-c\C-a" 'cwb-graph-graph) (setq cwb-program-name (expand-file-name "~/cwb/src/cwb")))))

Enjoy!

Back to CWB home page


Perdita.Stevens@ed.ac.uk