They are not strongly related to each other, but rather evolve around access to documentation and ease of use.

Some of them are based on the previous documentation update idea proposed by Elias Mårtenson, the author of the excellent GNU APL Emacs mode, to move the documentation from Emacs GNU APL Mode to the interpreter itself.

Finnapl - support for FinnAPL idioms list

While trying the IBM APL2 interpreter there was one feature which I particularly liked: the quick help with a list of APL idioms.

Knowing that the list of FinnAPL idioms is available online, I’ve decided to implement the narrowing search in this list with ability to insert the idiom into the GNU APL buffer without leaving Emacs. Naturally the Emacs Helm narrowing framework is the best choice for this task. I’ve only needed to dowload the list of idioms, parse it and setup the parsed list as a source to Helm. Hitting Enter will paste the idiom into the GNU APL (either interpreter buffer or editor buffer wherever it was called using the hotkey Ctrl-c Ctrl-i):

For those not using the Helm package (seriously why? its awesome!) I’ve implemented the simple tabular view:

The buffer on this screenshot has the custom idioms choice mode activated, based on Emacs standard’s tabulated-list-mode, which is used for example to present the list of packages (via list-packages interactive command).

I’ve already used the same idea in the C/C++ Find File package to present a list with a multiple selection. The idea is the same: if Helm available and some variable (dont-use-helm or something like this) is not set use Helm to present choices, otherwise use the custom mode derived from the tabulated-list-mode.

Access to the build-in help from Emacs

The idea to move the documentation on symbols from Emacs to GNU APL was implemented only partly. The lacking part was a way to get this documentation back to the Emacs mode from GNU APL. This job requires 2 parts: the native part (on GNU APL side) and elisp side (on Emacs), since GNU APL and GNU Emacs communicate via sockets. The native part of the job consisted of implementing a “help” remote command which will return all the documentation (or only information on requested symbol), as it can be seen here.

Since the data flow is from C to Lisp, the natural choice of a data format was S-expressions, where the list looks like (a b c), so the data protocol is basically a list of lists containing all the data.

The only “complication” was to prepare a string for sending - surround by quotes, escape quotes and slashes and convert newlines, as in prepare_string function:

This code is an altered version of some stack overflow answer to the related topic.

On elisp side parsing is rather trivial. As it can be seen in the function gnu-apl–load-help the main work is done by elisp reader via read-from-string which naturally parses the S-expressions from the string:

(0 "⍬" "Zilde" "Zilde is the empty numeric vector (aka. ⍳0)" "Not a function but rather an alias for the empty
vector:
⍬≡⍳0
1")

which could be interpreted as arity, symbol, symbol name, short description, long description. The mapping for arity is described in the Help.def file in GNU APL sources as

0: niladic function

1: monadic function

2: dyadic function

-1: monadic operator taking one argument

-2: monadic operator taking two arguments

-3: dyadic operator taking one argument

-4: dyadic operator taking two arguments

-5: quasi-dyadic operator (outer product)

Customize keyboard layout for Dvorak users

Next point in the journey to get convenient GNU APL environment was the possibility to provide custom keyboard layouts in the GNU APL Emacs mode. Now I was able to define exactly the same keys locations as on my old Macbook with Dvorak layout.

One can just “draw” the layout and set the variable gnu-apl-keymap-template as in Readme (by the way to show/hide keyboard in Emacs GNU APL mode just use the C-c C-k hotkey).

The variable gnu-apl--symbols has to be modified to provide mapping between letters in the layout and APL symbols which will be available on this key if prefixed with the “Super” key (i.e. Win key or Cmd on OSX).

For Dvorak layout with Macbook’s keyboard I’ve designed the following corresponding APL layout:

And with the Shift key:

After designing the layout I’ve just typed all the characters in (with some modifications of the layout above):

;; our layout - see above. basically
;; just typeing all the keys consequently,
;; without and with modifier, row by row
(defvar txm-apl-layout
'(("§1234567890[]" .
"◊¨¯⍒⍋⌽⍉⊖⍟∨∧←→")
("±!@#$%^&*(){}" .
" ⌶⍫ ⍱⍲⍞⍬")
("',.pyfgcrl/=" .
"⍕≤≥⊢↑⊥∇⊣⍴⎕⌿≠")
("\"<>PYFGCRL?+" .
"⍎⍪ ⍣ ⌷⍠⌹")
("aoeuidhtns-\\" .
"⍺○∊↓⍳⌊∆÷⊤⌈×⍀")
("AOEUIDHTNS_|" .
" ⍥⍷ ⍸ ⍨ ")
("`;qjkxbmwvz" .
"⋄⍝⌸∘≡≢⊃∩⍵∪⊂")
("~:QJKXBMWVZ" .
" ⍤ "))
"Simple layout description. It is a list of conses, where each cons represents the row on a keyboard. car of the cons are the characters in layout, while cdr of the cons is the APL characters of the same key.")

Each row we can convert to the structure corresponding to the entries in gnu-apl--symbols, which we store as gnu-apl--symbols-old. We need to get the short name out of the old table.

Tooltips on a keyboard in GNU APL Emacs mode

One feature I particularly like in Dyalog IDEs (both classic and RIDE) is the toolbar with all APL symbols. One could just move a mouse cursor over any symbol to get a tooltip with the information about this symbol. It makes it extremely convenient while studying and to just quickly recap the symbol meaning.

It could be helpful to have the same feature in GNU APL especially now since we have a documentation available directly from the interpreter. So this pull request does exactly that.

It provides tooltips with the documentation while moving the mouse over the APL symbol:
(Too bad I couldn’t take a screenshot since on any keypress the tooltip disappears. Oh well)

Additionally the mouse click behavior was changed. Then the user clicks on a symbol on a popup keyboard the symbol is getting inserted into the last active buffer with GNU APL mode enabled.

For this in the mouse action callback we get the list of current visible windows for the buffer

(get-buffer-window-list session nil 'visible)

and after inserting the character into the current APL buffer we select the corresponding window and advance cursor position:

Appendix A: Compiling GNU APL on OSX 10.6

Recently I’ve revived my old white MacBook (late 2006 model, pre-unibody). Since the last version of OSX available for it is 10.6.8, not a lot of modern software could be installed on it. Hopefully with a free and open source software there is at least a chance to compile it on your own.

One of the tools I’m missing on this laptop is Dyalog APL interpreter. It installs but crashes on a startup.

Still it is possible to install the GNU APL interpreter on this machine. It is not available in Macports but one can easily checkout the bleeding edge version from the SVN repository:

svn co http://svn.savannah.gnu.org/svn/apl/trunk gnu-apl

In order to compile I had to modify 2 files since the function strndup is not available on this version of OSX 10.6:

Conclusion

These small features hopefully not the last of the usability contributions to the GNU APL and GNU APL Emacs mode. It is well-known fact that the tooling and environment are one of the major contributors to the success/popularity of the programming language. Hopefully the stable and convenient tooling could increase attractiveness of the APL within the small community of the Emacs users.

The next steps as I see could be the following:

Investigate ways to setup a project with GNU APL, maybe with some sort of source generator. I dont see advantages of the GNU APL for scripting, however the data processing/data mining are the fields where APL is traditionally strong, but these tasks typically require more code and more interactive approach than simple scripting could provide.

Work on a documentation for APL functions and operators. There is an excellent documentation from IBM, Dyalog, MicroAPL etc, but better community-owned documentation will ensure liveability of the language

Make it possible to edit 2 dimentional APL arrays in Emacs.

As one of the side notes - working with Emacs lisp is a pleasure, dont hesitate to dive in and make your work environment even more comfortable with ELisp!