* apl: from X to gnu emacs
@ 2010-08-11 14:09 rustom
0 siblings, 0 replies; only message in thread
From: rustom @ 2010-08-11 14:09 UTC (permalink / raw)
To: help-gnu-emacs
Heres some progress with apl mode in gnu emacs.
The xemacs stuff I earlier mentioned was unusable (at least by me) but
I found a nice apl mode for gnu emacs by Markus Triska.
It handles the characters of apl but did not have any comint
functionality ie it could wirte program(files) but not interact with
the interpreter.
So below is some code that tweaks some hooks for comint to do this. I
was hoping some (more experienced) lipsers could test this and see if
its the right direction...
If the direction is ok I can clean it up and put it on the wiki.
To Test:
1. Aplus. On debian the package is Aplus-fsf (Aplus-fsf-dev will pull
in all the xemacs stuff which is not needed). This should make the a+
binary available.
Starting a+ at the shell should give you a prompt
type 2+3
If it gives 5, a+ is working but char-encoding-issues at the shell
level prevent anything more here.
2. Markus Triska's apl.el from http://stud4.tuwien.ac.at/~e0225855/unicapl/apl.el
Load it into emacs
set-input-method to apl-ascii (perhaps in a fresh buffer)
Typing {rho} {iota} {is} should give you rho iota and left arrow: ⍴ ⍳
←
3. Load the code below (with suitable change to the load-path line)
This will directly start apl in a comint buffer
Type A {is} 2 3 {rho} {iota} 6
The {rho} and {iota} should immediately convert to ⍴ ⍳
Type A and a 2x3 matrix should be there.
Elisp code
--------------------------------------------------------------------------------
;; Basic Aplus (Apl) comint functionality (very incomplete)
;; Uses Markus Triska's apl.el for encodings, input-methods etc
;; Make sure apl.el is on emacs' load path and a+ on execution path
(add-to-list 'load-path "wherever apl.el is") ;; where apl.el is
(require 'apl)
(defun apl-unicode2aplus-char (c)
"Converts unicode char to an Aplus single char string
All bets off when its not convertile :-)"
(let ((c2 (rassq c apl-aplus-table)))
(string (if c2 (car c2) c))))
(defun apl-unicode2aplus-str (s)
"Converts a unicode string to an Aplus string"
(mapconcat (function apl-unicode2aplus-char) s ""))
(defun apl-comint-send (process s)
"`comint-simple-send' with string preprocessed with `apl-unicode2aplus-
str'"
(comint-simple-send process (apl-unicode2aplus-str s)))
;;replace comint-simple-send
(setq comint-input-sender 'apl-comint-send)
(defun apl-aplus2unicode-char (c)
"Converts Aplus char to a unicode single char string
All bets off when its not convertile :-)"
(let ((c2 (assq c apl-aplus-table)))
(string (if c2 (cdr c2) c))))
(defun apl-aplus2unicode-str (s)
"Converts a Aplus string to a unicode string"
(mapconcat (function apl-aplus2unicode-char) s ""))
(add-hook 'comint-preoutput-filter-functions 'apl-aplus2unicode-str)
;;; The following should be put into some kind of
;;; apl-inferior mode making function
;;; But there are more important lacunae: such as when encoding fails
(make-comint "a+" "a+")
(set-buffer "*a+*")
(set-input-method "apl-ascii")
(switch-to-buffer "*a+*")
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-08-11 14:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-11 14:09 apl: from X to gnu emacs rustom
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).