The following file apl.el defines an input method that lets you write Unicode APL programs via ASCII mnemonics in Emacs.
Project page: http://stud4.tuwien.ac.at/~e0225855/unicapl/unicapl.html All the best, Markus Triska ;;; apl.el --- APL input method for Emacs ;; Copyright (C) 2007 Markus Triska ;; Author: Markus Triska <[EMAIL PROTECTED]> ;; Keywords: languages ;; Public domain code. ;;; Commentary: ;; Copy apl.el to your load-path and add to your .emacs: ;; (require 'apl) ;; Enable the APL input method with ;; M-x set-input-method RET apl-ascii RET ;; Then enter {iota}, {times}, {execute}, ... to get ⍳, ×, ⍎ etc. ;;; Code: (defconst apl-version "0.8") (defvar apl-aplus-table ; roughly ordered by keyboard row ; first row '((?þ . ?⋄) (?~ . ?∼) (?¡ . ?¨) (?à . ?⌶) (?¢ . ?¯) (?æ . ?⍫) (?ç . ?⍒) (?¤ . ?≤) (?è . ?⍋) (?¦ . ?≥) (?ô . ?⍉) (?á . ?⊖) (?¨ . ?≠) (?ð . ?⍟) (?© . ?∨) (?¹ . ?⍱) (?^ . ?∧) (?° . ?⍲) (?« . ?×) (?ß . ?÷) (?÷ . ?⌽) (? . ?⌹) ; second row (?× . ?⍵) (?Å . ?∈) (?å . ?⍷) (?Ò . ?⍴) (?Ù . ?↑) (?Õ . ?↓) (?É . ?⍳) (?é . ?⍸) (?Ï . ?○) (?ï . ?⍥) (?* . ?⋆) (?³ . ?⍟) (?û . ?←) (?ý . ?→) (?Ü . ?⍀) (?ü . ?⍙) ; third row (?Á . ?⍺) (?á . ?⊖) (?Ó . ?⌈) (?Ä . ?⌊) (?½ . ?≡) (?Ç . ?∇) (?ç . ?⍒) (?È . ?∆) (?Ê . ?∘) (?ê . ?⍤) (?§ . ?⌼) (?Ì . ?⎕) (?ì . ?⍞) (?- . ?−) (?Û . ?⊢) (?¼ . ?⍂) (?Ý . ?⊣) (?» . ?⌼) ; fourth row (?Ú . ?⊂) (?Ø . ?⊃) (?à . ?∩) (?ã . ?⍝) (?Ö . ?∪) (? . ?⊥) (?â . ?⍎) (?Î . ?⊤) (?î . ?⍕) (?| . ?∣) ; (?| . ?⌶) (?¯ . ?⌿) (?Í . ?∣)) "Translation table mapping A+ characters to Unicode symbols.") (defvar apl-other-symbols '(?⍈ ?⍆ ?⌺ ?⌷ ?⌸ ?⌺ ?⌻ ?⌾ ?⍁ ?⍃ ?⍄ ?⍅ ?⍆ ?⍇ ?⍈ ?⍊ ?⍌ ?⍏ ?⍐ ?⍑ ?⍓ ?⍔ ?⍖ ?⍗ ?⍘ ?⍚ ?⍛ ?⍜ ?⍠ ?⍡ ?⍢ ?⍣ ?⍬ ?⍭ ?⍮ ?⍯ ?⍰ ?⍶ ?⍹ ?∵ ?▯ ?⊼ ?⊽ ?≢ ?⍦ ?⍧ ?⍨ ?⍪ ?⍩) "List of symbols used in some APL dialects.") (defun apl-symbols () "List of all APL special symbols." (append apl-other-symbols (mapcar #'cdr apl-aplus-table))) (defun apl-set-font (font) "Set font for APL characters. FONT is a font as passed to set-fontset-font and should provide glyphs for all APL characters that you want to use. An example is GNU unifont. Try -gnu-unifont-*-r-*--*-*-*-*-*-*-ISO10646-1. Emacs is becoming increasingly better at handling Unicode and may choose the right glyphs for all characters out of the box, sometimes drawing from various fonts. You can use this function to enforce a uniform font for all APL characters in that case." (dolist (s (apl-symbols)) (set-fontset-font "fontset-default" s font))) (defvar apl-aplus-keyboard nil) (defun apl-toggle-aplus-keyboard () "Toogle translation of A+ keyboard input to Unicode characters." (interactive) (setq apl-aplus-keyboard (not apl-aplus-keyboard)) (dolist (pair apl-aplus-table) (keyboard-translate (car pair) (if apl-aplus-keyboard (cdr pair) (car pair))))) (defun apl-aplus-to-unicode (begin end) "Convert A+ symbols in region to Unicode characters." (interactive "r") (translate-region begin end (make-translation-table apl-aplus-table))) (defun apl-flip (f) (cons (cdr f) (car f))) (defun apl-unicode-to-aplus (begin end) "Convert APL Unicode characters in region to A+." (interactive "r") (translate-region begin end (make-translation-table (mapcar #'apl-flip apl-aplus-table)))) (when (require 'quail nil t) (quail-define-package "apl-ascii" "APL" "apl" t "APL ASCII input method. Use {rho} for ⍴, {iota} for ⍳ etc." nil t nil nil nil nil nil nil nil nil t) (quail-define-rules ("{leftbrace}" ?{) ("{rightbrace}" ?}) ("{scan}" ?\\) ("{expand}" ?\\) ("{reduce}" ?/) ("{compress}" ?/) ("{replicate}" ?/) ("{ravel}" ?,) ("{catenate}" ?,) ("{laminate}" ?,) ("{roll}" ??) ("{deal}" ??) ("{diaeresis}" ?¨) ("{each}" ?¨) ("{\"}" ?¨) ("{times}" ?×) ("{signum}" ?×) ("{x}" ?×) ("{reciprocal}" ?÷) ("{divide}" ?÷) ("{%}" ?÷) ("{left-arrow}" ?←) ("{gets}" ?←) ("{assign}" ?←) ("{up-arrow}" ?↑) ("{first}" ?↑) ("{take}" ?↑) ("{right-arrow}" ?→) ("{branch}" ?→) ("{goto}" ?→) ("{down-arrow}" ?↓) ("{diamond}" ?⋄) ("{drop}" ?↓) ("{delta}" ?∆) ("{/\\}" ?∆) ("{del}" ?∇) ("{nabla}" ?∇) ("{epsilon}" ?∈) ("{member-of}" ?∈) ("{member}" ?∈) ("{enlist}" ?∈) ("{type}" ?∈) ("{negative}" ?−) ("{minus}" ?−) ("{-}" ?−) ("{jot}" ?∘) ("{ring}" ?∘) ("{o}" ?∘) ("{nazg}" ?∘) ("{stile}" ?∣) ("{abs}" ?∣) ("{residue}" ?∣) ("{up-caret}" ?∧) ("{and}" ?∧) ("{caret}" ?∧) ("{down-caret}" ?∨) ("{or}" ?∨) ("{inverted-caret}" ?∨) ("{intersection}" ?∩) ("{intersect}" ?∩) ("{up-shoe}" ?∩) ("{union}" ?∪) ("{down-shoe}" ?∪) ("{diaresis-dot}" ?∵) ("{paw}" ?∵) ("{not-equal}" ?≠) ("{/=}" ?≠) ("{match}" ?≡) ("{depth}" ?≡) ("{=_}" ?≡) ("{not-match}" ?≢) ("{/match}" ?≢) ("{/=_}" ?≢) ("{<=}" ?≤) ("{less-than-equal}" ?≤) ("{>=}" ?≥) ("{greater-than-equal}" ?≥) ("{left-shoe}" ?⊂) ("{enclose}" ?⊂) ("{partition}" ?⊂) ("{right-shoe}" ?⊃) ("{disclose}" ?⊃) ("{pick}" ?⊃) ("{circle-dash}" ?⊖) ("{rotate}" ?⊖) ("{O-}" ?⊖) ("{right-tack}" ?⊢) ("{lev}" ?⊢) ("{|-}" ?⊢) ("{left-tack}" ?⊣) ("{dex}" ?⊣) ("{-|}" ?⊣) ("{down-tack}" ?⊤) ("{represent}" ?⊤) ("{T}" ?⊤) ("{encode}" ?⊤) ("{up-tack}" ?⊥) ("{base}" ?⊥) ("{decode}" ?⊥) ("{and-overbar}" ?⊼) ("{nand}" ?⍲) ("{~^}" ?⍲) ("{or-overbar}" ?⊽) ("{nor}" ?⍱) ("{~v}" ?⍱) ("{star}" ?⋆) ("{pow}" ?⋆) ("{exp}" ?⋆) ("{ceiling}" ?⌈) ("{greater-of}" ?⌈) ("{max}" ?⌈) ("{floor}" ?⌊) ("{lesser-of}" ?⌊) ("{min}" ?⌊) ("{I-beam}" ?⌶) ("{I}" ?⌶) ("{squish-quad}" ?⌷) ("{squad}" ?⌷) ("{index}" ?⌷) ("{quad-equal}" ?⌸) ("{#=}" ?⌸) ("{quad-divide}" ?⌹) ("{#%}" ?⌹) ("{mat-inverse}" ?⌹) ("{mat-divide}" ?⌹) ("{domino}" ?⌹) ("{quad-diamond}" ?⌺) ("{#&}" ?⌺) ("{quad-jot}" ?⌻) ("{#o}" ?⌻) ("{quad-circle}" ?⌼) ("{#O}" ?⌼) ("{circle-stile}" ?⌽) ("{reverse}" ?⌽) ("{rotate}" ?⌽) ("{circle-jot}" ?⌾) ("{slash-bar}" ?⌿) ("{compress1}" ?⌿) ("{reduce1}" ?⌿) ("{replicate1}" ?⌿) ("{slope-bar}" ?⍀) ("{expand1}" ?⍀) ("{scan1}" ?⍀) ("{backslash-bar}" ?⍀) ("{quad-slash}" ?⍁) ("{#/}" ?⍁) ("{quad-backslash}" ?⍂) ("{#\\}" ?⍂) ("{quad-less-than}" ?⍃) ("{#<}" ?⍃) ("{quad<}" ?⍃) ("{quad-greater-than}" ?⍄) ("{#>}" ?⍄) ("{quad>}" ?⍄) ("{leftwards-vane}" ?⍅) ("{left-vane}" ?⍅) ("{rightwards-vane}" ?⍆) ("{right-vane}" ?⍆) ("{quad<-}" ?⍇) ("{quad-left-arrow}" ?⍇) ("{quad->}" ?⍈) ("{quad-right-arrow}" ?⍈) ("{circle-backslash}" ?⍉) ("{transpose}" ?⍉) ("{O\\}" ?⍉) ("{uptack-underbar}" ?⍊) ("{delta-stile}" ?⍋) ("{/\\|}" ?⍋) ("{grade-up}" ?⍋) ("{#v}" ?⍌) ("{quad-downcaret}" ?⍌) ("{#/\\}" ?⍍) ("{quad-delta}" ?⍍) ("{uptack-jot}" ?⍎) ("{execute}" ?⍎) ("{upwards-vane}" ?⍏) ("{up-vane}" ?⍏) ("{quad-up-arrow}" ?⍐) ("{downtack-overbar}" ?⍑) ("{del-stile}" ?⍒) ("{grade-down}" ?⍒) ("{#^}" ?⍓) ("{quad-up-caret}" ?⍓) ("{#\\/}" ?⍔) ("{quad-del}" ?⍔) ("{quad-nabla}" ?⍔) ("{format}" ?⍕) ("{downtack-jot}" ?⍕) ("{downwards-vane}" ?⍖) ("{down-vane}" ?⍖) ("{quad-down-arrow}" ?⍗) ("{quote_}" ?⍘) ("{quote-underbar}" ?⍘) ("{'_}" ?⍘) ("{delta_}" ?⍙) ("{delta-underbar}" ?⍙) ("{/\\_}" ?⍙) ("{diamond_}" ?⍚) ("{diamond-underbar}" ?⍚) ("{&_}" ?⍚) ("{jot_}" ?⍛) ("{jot-underbar}" ?⍛) ("{o_}" ?⍛) ("{circle_}" ?⍜) ("{circle-underbar}" ?⍜) ("{O_}" ?⍜) ("{upshoe-jot}" ?⍝) ("{lamp}" ?⍝) ("{comment}" ?⍝) ("{quote-quad}" ?⍞) ("{circle-star}" ?⍟) ("{log}" ?⍟) ("{ln}" ?⍟) ("{O*}" ?⍟) ("{quad-colon}" ?⍠) ("{#:}" ?⍠) ("{snout}" ?⍡) ("{downtack-diaeresis}" ?⍡) ("{frog}" ?⍢) ("{del-diaeresis}" ?⍢) ("{sourpuss}" ?⍣) ("{star-diaeresis}" ?⍣) ("{hoot}" ?⍤) ("{jot-diaeresis}" ?⍤) ("{rank}" ?⍤) ("{o\"}" ?⍤) ("{holler}" ?⍥) ("{circle-diaeresis}" ?⍥) ("{O\"}" ?⍥) ("{downshoe-stile}" ?⍦) ("{leftshoe-stile}" ?⍧) ("{smirk}" ?⍨) ("{tilde-diaeresis}" ?⍨) ("{~\"}" ?⍨) ("{>\"}" ?⍩) ("{greater-than-diaeresis}" ?⍩) ("{comma-bar}" ?⍪) ("{cat-bar}" ?⍪) ("{catenate1}" ?⍪) ("{laminate1}" ?⍪) ("{,-}" ?⍪) ("{del-tilde}" ?⍫) ("{\\/~}" ?⍫) ("{zilde}" ?⍬) ("{0~}" ?⍬) ("{stile-tilde}" ?⍭) ("{|~}" ?⍭) ("{semicolon-underbar}" ?⍮) ("{;_}" ?⍮) ("{#/=}" ?⍯) ("{quad-not-equal}" ?⍯) ("{#?}" ?⍰) ("{quad-question}" ?⍰) ("{downcaret-tilde}" ?⍱) ("{upcaret-tilde}" ?⍲) ("{iota}" ?⍳) ("{index}" ?⍳) ("{index-of}" ?⍳) ("{rho}" ?⍴) ("{shape}" ?⍴) ("{reshape}" ?⍴) ("{omega}" ?⍵) ("{w}" ?⍵) ("{alpha-underbar}" ?⍶) ("{alpha_}" ?⍶) ("{epsilon-underbar}" ?⍷) ("{epsilon_}" ?⍷) ("{find}" ?⍷) ("{iota_}" ?⍸) ("{iota-underbar}" ?⍸) ("{omega_}" ?⍹) ("{omega-underbar}" ?⍹) ("{alpha}" ?⍺) ("{quad}" ?⎕) ("{box}" ?⎕) ("{circle}" ?○) ("{pi-times}" ?○) ("{O}" ?○) ("{tilde}" ?∼) ("{not}" ?∼))) (provide 'apl) ;;; apl.el ends here _______________________________________________ gnu-emacs-sources mailing list [email protected] http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources
