Hi Chris,
thank you for contributing this. I have added a link on our
community page
http://www.gnu.org/software/apl/Community.html.
I believe the function would be even more useful it could create or
modify
an APL function in a running workspace rather than writing the
function to a file.
/// Jürgen
On 07/15/2018 10:47 PM, Chris Moller
wrote:
After battling for decades with the ancient
nabla editor, I finally did something I should have done years
ago and write a simple native function that let's you use
emacs or vi from inside an APL session. It's not even close
to Elias Mårtenson's cool emacs APL mode--it's just a quick
thing to bring up a friendlier editor. It's alpha-level
code--if it melts your computer, it's not my fault--and there
are a few things on the TODO list, but I thought I'd put it
out there and get some feedback if anyone's interested.
Here's the README:
edif is a GNU APL native function that allows
the use of external editors
from within an APL session.
Usage:
edif 'function_name'
This will open an editor, typically vi or emacs, containing
the present
definition of the specified function, or, if the function
doesn't exist,
a boilerplate function header consisting of the function
name. After saving
the edited definition and exiting the editor, the function
will appear in
the APL workspace. While the editor is open, APL is
suspended.
edif will look for the environment variable EDIF and will
use the string
specified by that variable as the command line to invoke the
chosen editor.
For example:
export EDIF="emacs --geometry=40x20 -background
'#ffffcc' -font 'DejaVu Sans Mono-10'"
will invoke emacs with a fairly small window, a light yellow
background, and
using the DejaVu Sans Mono-10 font. (That's also the
default if no EDIF
variable is found.)
edif has only been tested with emacs and vi.
Future work may also allow edif to edit APL variables and
operators, but no
guarantees I'll ever get around to it.
edif may be included in the workspace with:
'libedif.so' ⎕fx 'edif'
Implimentation note:
edif works by storing an editable version of the specified
function in:
/var/run/user/<uid>/<pid>/<name>.apl
where <uid> is the user's userid, <pid> is the
process id of the APL
session, and <name> is the function name. This allows
multiple users
each to have multiple simultaneous APL sessions with
workspaces with
identical names. No locking is done by edif and I've no
idea if APL
itself has any protection against a writable workspace being
open in
multiple simultaneous sessions, but it opens up the
possibility that
you can hose the workspace. So while, as far as edif is
concerned
you can have multiple simultaneous sessions aimed at the
same lib0
workspace, you probably shouldn't do it.
Also, I've no idea if Windows or any Linux distribution other
than
Fedora has a /var directory, so using this directory may be
non-portable.
So far as I can tell, edif doesn't interfere with Elias
Mårtenson's
emacs APL mode, but I haven't thoroughly tested that.
It's at https://github.com/ChrisMoller/edif
(BTW, "edif" is short for "editor interface.")
|
signature.asc
Description: OpenPGP digital signature