Author: | Alexander Schmolck |
---|---|
Date: | 2007-02-13 |
2007-02-13 Added the newer j-mode.el version I've been using for well over a year now, but haven't got around to upload so far; I originially wanted to wait till I could test under J 6.01 (I'm still using 5.04) but unfortunately it looks like I would need a system update to install it, something for which I currently lack the time.
This mode provides editing and interactive evaluation support for the J programming language (freely available from <http://www.jsoftware.com>) under emacs. J is an APL descendant and as such offers very powerful and concise array manipulation facilities. J + j-mode can also be just used as a very fancy graphing calculator (Just keep a M-x j-shell around).
Note
If you lack experience configuring emacs you might first want to have a look here (if you use windows) and here (regardless of OS).
I might add that you don't need to restart emacs: you can just mark the code below and then execute it with M-x eval-region; also if you want to put j-mode.el into /SomeWhere/MyEmacsStuff/ you can add that directory to the load-path like so:
(add-to-list 'load-path "/SomeWhere/MyEmacsStuff/")
Copy j-mode.el to a directory in your emacs load-path.
Add the following to your .emacs file or site-init.el:
(autoload 'j-mode "j-mode.el" "Major mode for J." t) (autoload 'j-shell "j-mode.el" "Run J from emacs." t) (setq auto-mode-alist (cons '("\\.ij[rstp]" . j-mode) auto-mode-alist))
Set j-path to the right value, e.g. by adding something like the following to .emacs:
(setq j-path "/home/foo/j504/")
If you don't need plotting or graphics and want to save ressources you can also
(setq j-command "jconsole")
(the default is now "jee" which connects to a java process to allow plotting from a j shell buffer).
Other things you might find useful:
imenu lets you jump between definition, you could add the following to your .emacs:
(require 'cl) (when (ignore-errors (require 'which-func)) (which-func-mode 1)) ; shows the current function in statusbar
the variable browse-url-browser-function determines which browser is used to browse the J help
There are various options you can customize; do M-x customize-group, then enter j
Here's a simple example you can use to see if everything is installed correctly. Open up a file test.ijs (anything with extension .ijs will do). Paste in the following code:
load 'viewmat' viewmat+/2&>:|((j.~/~(%~i:)99)&+@:*:)^:(i.32)0
If you position the cursor on 'viewmat' and press return it should open the viewmat library. Go back to test.ijs and open a J shell by typing C-! (or M-x j-shell). Press C-c C-c to execute the whole file. You should see the following plot window:
Press C-hm for more info on J mode or have a look at the J menu item.