Pannyx

devel

Request #04


	(* Open-Suse Tumbleweed *)

% cdq
~/devel/quickie
% pp sandbox_24001_m.adb
with Ada.Command_Line;
with Ada.Exceptions;
with Ada.Text_IO;
with Aej.Daejana;
procedure Sandbox_24001_m is

use Ada; use Text_IO;
use Aej; use Daejana;

use Int_IO; use Flt_IO; use Flt_G_E_F;

use type Int_T; use type Flt_T;

procedure Xadd (C : in out Int_T; D : in out Int_T) is
   B : Int_T;

begin
   B := D;
   D := C;
   C := C + B;
   return;

end Xadd;

C : Int_T; D : Int_T; N : Int_T;

procedure Probe_01 is

begin
   C := 1; D := 0; N := 0;
   while C < 2**48 loop
      Put(C, Base => 16, Width => 16); Put(", "); Put(C, Width => 15); Put(" ["); Put(N, Width => 2); Put("];"); New_Line;
      Xadd(C, D);
      N := N + 1;
   end loop;
   New_Line;
-- Put(Log(Flt_T( 2 ** 48)) / Log(Phi), Exp => 0, Fore => 2, Aft => 3); Put(" ← Log(2 ** 48) / Log("); Put(Phi, Exp => 0, Fore => 1, Aft => 3); Put(");");
   ↪  New_Line;  -- 69.140 ← Log(2 ** 48) / Log(1.618);
   Put(Int_T( Flt_T'Floor(Log(Flt_T( 2 ** 48)) / Log(Phi) + 0.5)), Width => 1); Put(" ← Int_T( Flt_T'Floor(Log(2 ** 48) / Log("); Put(Phi, Exp => 0, Fore => 1,
   ↪  Aft => 3); Put(" + 0.5)));"); New_Line;
   return;

end Probe_01;

begin
   Command_Line.Set_Exit_Status(Command_Line.Success);
   New_Line;

   Probe_01;

   New_Line;
   return;

exception
   when E : others =>
      New_Line(Standard_Error);
      New_Line(Standard_Error);
      Put(Standard_Error, "** ");
      Put(Standard_Error, Exceptions.Exception_Name(E));
      Put(Standard_Error, "! (");
      Put(Standard_Error, Exceptions.Exception_Message(E));
      Put(Standard_Error, ")");
      New_Line(Standard_Error);
      New_Line;
      Command_Line.Set_Exit_Status(Command_Line.Failure);

end Sandbox_24001_m;
% adb sandbox_24001_m; time ./sandbox_24001_m; gnatclean -q sandbox_24001_m

           16#1#,               1 [ 0];
           16#1#,               1 [ 1];
           16#2#,               2 [ 2];
           16#3#,               3 [ 3];
           16#5#,               5 [ 4];
           16#8#,               8 [ 5];
           16#D#,              13 [ 6];
          16#15#,              21 [ 7];
          16#22#,              34 [ 8];
          16#37#,              55 [ 9];
          16#59#,              89 [10];
          16#90#,             144 [11];
          16#E9#,             233 [12];
         16#179#,             377 [13];
         16#262#,             610 [14];
         16#3DB#,             987 [15];
         16#63D#,            1597 [16];
         16#A18#,            2584 [17];
        16#1055#,            4181 [18];
        16#1A6D#,            6765 [19];
        16#2AC2#,           10946 [20];
        16#452F#,           17711 [21];
        16#6FF1#,           28657 [22];
        16#B520#,           46368 [23];
       16#12511#,           75025 [24];
       16#1DA31#,          121393 [25];
       16#2FF42#,          196418 [26];
       16#4D973#,          317811 [27];
       16#7D8B5#,          514229 [28];
       16#CB228#,          832040 [29];
      16#148ADD#,         1346269 [30];
      16#213D05#,         2178309 [31];
      16#35C7E2#,         3524578 [32];
      16#5704E7#,         5702887 [33];
      16#8CCCC9#,         9227465 [34];
      16#E3D1B0#,        14930352 [35];
     16#1709E79#,        24157817 [36];
     16#2547029#,        39088169 [37];
     16#3C50EA2#,        63245986 [38];
     16#6197ECB#,       102334155 [39];
     16#9DE8D6D#,       165580141 [40];
     16#FF80C38#,       267914296 [41];
    16#19D699A5#,       433494437 [42];
    16#29CEA5DD#,       701408733 [43];
    16#43A53F82#,      1134903170 [44];
    16#6D73E55F#,      1836311903 [45];
    16#B11924E1#,      2971215073 [46];
   16#11E8D0A40#,      4807526976 [47];
   16#1CFA62F21#,      7778742049 [48];
   16#2EE333961#,     12586269025 [49];
   16#4BDD96882#,     20365011074 [50];
   16#7AC0CA1E3#,     32951280099 [51];
   16#C69E60A65#,     53316291173 [52];
  16#1415F2AC48#,     86267571272 [53];
  16#207FD8B6AD#,    139583862445 [54];
  16#3495CB62F5#,    225851433717 [55];
  16#5515A419A2#,    365435296162 [56];
  16#89AB6F7C97#,    591286729879 [57];
  16#DEC1139639#,    956722026041 [58];
 16#1686C8312D0#,   1548008755920 [59];
 16#2472D96A909#,   2504730781961 [60];
 16#3AF9A19BBD9#,   4052739537881 [61];
 16#5F6C7B064E2#,   6557470319842 [62];
 16#9A661CA20BB#,  10610209857723 [63];
 16#F9D297A859D#,  17167680177565 [64];
16#19438B44A658#,  27777890035288 [65];
16#28E0B4BF2BF5#,  44945570212853 [66];
16#42244003D24D#,  72723460248141 [67];
16#6B04F4C2FE42#, 117669030460994 [68];
16#AD2934C6D08F#, 190392490709135 [69];

69 ← Int_T( Flt_T'Floor(Log(2 ** 48) / Log(1.618 + 0.5)));

./sandbox_24001_m  0.00s user 0.00s system 92% cpu 0.003 total
%

	(* Macs *)

% time ocaml -e 'let rec f n = if n < 3 then 1 else (f (n - 1)) + (f (n - 2)) in print_int (f 50); print_newline ()'
12586269025
ocaml -e   166.32s user 0.01s system 99% cpu 2:46.50 total
% time racket -e '(display (let loop ((n 50)) (if (< n 3) 1 (+ (loop (- n 1)) (loop (- n 2)))))) (newline)'
12586269025
racket -e   37.07s user 0.29s system 96% cpu 38.708 total
% pp sandbox_24001_m.ml
#mod_use "aej/daejana.ml" ;; open Daejana

let _ =
   print_newline () ;

   print_int (int_of_float (floor (log (2.0 ** 48.0) /. log phi +. 0.5))); print_string ";" ; print_newline () ;
   print_newline () ;
   ignore ()

(* sandbox_24001_m.ml *)
% ocaml sandbox_24001_m.ml

69;

% pp sandbox_24001_m.ml
#mod_use "aej/daejana.ml" ;; open Daejana

let xadd c d =
   let b = ! c in
      c := b + ! d ;
      d := b ;
      ignore ()

let probe_01 n =
   let c = ref 1
   and d = ref 0 in (
      for l = 1 to n do
         print_int ! c ; print_string ";" ; print_newline () ;
         xadd c d ;
      done
   ) ;
   ignore ()

let _ =
   print_newline () ;

   let n = if 1 < Array.length Sys.argv then int_of_string Sys.argv.(1) else 0 in
      probe_01 (n)
   ;

   print_newline () ;
   ignore ()

(* sandbox_24001_m.ml *)
% ocaml sandbox_24001_m.ml


% ocaml sandbox_24001_m.ml 1

1;

% ocaml sandbox_24001_m.ml 2

1;
1;

% ocaml sandbox_24001_m.ml 3

1;
1;
2;

% ocaml sandbox_24001_m.ml 4

1;
1;
2;
3;

% ocaml sandbox_24001_m.ml 5

1;
1;
2;
3;
5;

% ocaml sandbox_24001_m.ml 6

1;
1;
2;
3;
5;
8;

% ocaml sandbox_24001_m.ml 7

1;
1;
2;
3;
5;
8;
13;

% ocaml sandbox_24001_m.ml 50

…
13;
21;
34;
55;
89;
144;
233;
377;
610;
987;
1597;
2584;
4181;
6765;
10946;
17711;
28657;
46368;
75025;
121393;
196418;
317811;
514229;
832040;
1346269;
2178309;
3524578;
5702887;
9227465;
14930352;
24157817;
39088169;
63245986;
102334155;
165580141;
267914296;
433494437;
701408733;
1134903170;
1836311903;
2971215073;
4807526976;
7778742049;
12586269025;

% pp sandbox_24001_m.rkt
#lang racket

(require aej/daejana)

(define (xadd c d)
   (let (
         (b (mcar d))
      )
      (set-mcar! d (mcar c))
      (set-mcar! c (+ (mcar c) b))
   )
)

(define (probe-01 n)
   (let (
         (c (mcons 1 '()))
         (d (mcons 0 '()))
      )
      (let loop (
            (k n)
         )
         (if… (< 0 k) (then
            (display (mcar c)) (newline)
            (xadd c d)
            (loop (- k 1))
         ))
      )
   )
)

((lambda (n)
      (newline)

      (probe-01 n)
      (newline)
      (exit exit-state)
   ) (let (
            (v (current-command-line-arguments))
         )
         (let (
               (n (if… (< 0 (vector-length v)) (then
                     (or (string->number (vector-ref v 0)) 0)
                  )
                  (else
                     0
                  ))
               )
            )
            (if… (< n 1) (then
               (ouch!)
            ))
            n
         )
      )
)

;* sandbox_24001_m.rkt
% time ocaml sandbox_24001_m.ml 70

…
12586269025;
20365011074;
32951280099;
53316291173;
86267571272;
139583862445;
225851433717;
365435296162;
591286729879;
956722026041;
1548008755920;
2504730781961;
4052739537881;
6557470319842;
10610209857723;
17167680177565;
27777890035288;
44945570212853;
72723460248141;
117669030460994;
190392490709135;

ocaml sandbox_24001_m.ml 70  0.03s user 0.00s system 92% cpu 0.040 total
% time racket sandbox_24001_m.rkt 70

…
190392490709135

racket sandbox_24001_m.rkt 70  0.18s user 0.04s system 89% cpu 0.238 total
% pp sandbox_24001_m.ml
#mod_use "aej/daejana.ml" ;; open Daejana

let probe_01 n =
   let rec f c d n =
      if 0 < n then (
         print_int c ; print_string ";" ; print_newline () ;
         f (c + d) c (n - 1)
      )
   in
      f 1 0 n
   ;
   ignore ()

let _ =
   print_newline () ;

   let n = if 1 < Array.length Sys.argv then int_of_string Sys.argv.(1) else 0 in
      probe_01 (n)
   ;
   print_newline () ;
   ignore ()

(* sandbox_24001_m.ml *)
% pp sandbox_24001_m.rkt
#lang racket

(require aej/daejana)

(define (probe-01 n)
   (let loop (
         (c 1)
         (d 0)
         (k n)
      )
      (if… (< 0 k) (then
         (display c) (newline)
         (loop (+ c d) c (- k 1))
      ))
   )
)

((lambda (n)
      (newline)

      (probe-01 n)
      (newline)
      (exit exit-state)
   ) (let (
            (v (current-command-line-arguments))
         )
         (let (
               (n (if… (< 0 (vector-length v)) (then
                     (or (string->number (vector-ref v 0)) 0)
                  )
                  (else
                     0
                  ))
               )
            )
            (if… (< n 1) (then
               (ouch!)
            ))
            n
         )
      )
)

;* sandbox_24001_m.rkt
% time ocaml sandbox_24001_m.ml 70

…
190392490709135;

ocaml sandbox_24001_m.ml 70  0.03s user 0.01s system 91% cpu 0.038 total
% time racket sandbox_24001_m.rkt 70

…
190392490709135

racket sandbox_24001_m.rkt 70  0.18s user 0.04s system 89% cpu 0.236 total
% pp sandbox_24001_m.c
#include <daejana.h>

static void xadd (int_t *, int_t *);
static int_t probe_01 (int_t);

static void
xadd (int_t * c, int_t * d)
{
   int_t b;

   b = * c;
   * c += * d;
   * d = b;
   return;

}

static int_t
probe_01 (int_t n)
{
   int_t c;
   int_t d;
   int_t k;

   c = 1;
   d = 0;
   k = n;
   while (0 < k) {
      printf("%lld\n", c);
      xadd(& c, & d);
      k -= 1;
   }
   return 0;

}

int
main (int argc, char * argv [])
{
   int_t n;

   error_flag = false;
   printf("\n");

   if (1 < argc) {
      n = atoll(argv[1]);
   }
   else {
      n = 0;
   }
   probe_01(n);

   printf("\n");
   if (error_flag) { exit(EXIT_FAILURE); }

   return EXIT_SUCCESS;

}

// sandbox_24001_m.c
% ccb sandbox_24001_m && { time ./sandbox_24001_m 70; rm ./sandbox_24001_m; }

…
190392490709135

./sandbox_24001_m 70  0.00s user 0.00s system 2% cpu 0.058 total
% pp sandbox_24001_m.c
#include <daejana.h>

static int_t probe_01 (int_t);

static int_t
probe_01 (int_t n)
{
   int_t c;
   int_t d;
   int_t b;
   int_t k;

   c = 1;
   d = 0;
   k = n;
   while (0 < k) {
      printf("%lld\n", c);
      b = c; c += d; d = b;
      k -= 1;
   }
   return 0;

}

int
main (int argc, char * argv [])
{
   int_t n;

   error_flag = false;
   printf("\n");

   if (1 < argc) {
      n = atoll(argv[1]);
   }
   else {
      n = 0;
   }
   probe_01(n);

   printf("\n");
   if (error_flag) { exit(EXIT_FAILURE); }

   return EXIT_SUCCESS;

}

// sandbox_24001_m.c
% ccb sandbox_24001_m && { time ./sandbox_24001_m 70; rm ./sandbox_24001_m; }

…
190392490709135

./sandbox_24001_m 70  0.00s user 0.00s system 1% cpu 0.298 total
%

Really want to see mine, to find something which is useful for you, too…?
Take your pick!


   -- Open-Suse Tumbleweed

% pp ~/.zshenv ~/.zshrc
# printf "~/.zshenv\n"

PATH="${HOME}/opt/bin:${PATH}"

PY="/usr/bin/python3"; export PY

# PLTCONFIGDIR="${HOME}/.config"; export PLTCONFIGDIR
GUILE_AUTO_COMPILE="0"; export GUILE_AUTO_COMPILE
GUILE_LOAD_PATH="${HOME}/devel/proto:${HOME}/opt/script"; export GUILE_LOAD_PATH

CAML_LD_LIBRARY_PATH="${HOME}/devel/proto/aej"; export CAML_LD_LIBRARY_PATH
TMPDIR="${HOME}/tmp"; export TMPDIR

PYTHONPATH="${HOME}/devel/proto"; export PYTHONPATH
PYTHONDONTWRITEBYTECODE="x"; export PYTHONDONTWRITEBYTECODE

OCAMLTOP_INCLUDE_PATH="${HOME}/devel/proto"; export OCAMLTOP_INCLUDE_PATH

ADA_INCLUDE_PATH="${HOME}/devel/proto"; export ADA_INCLUDE_PATH
ADA_OBJECTS_PATH="${HOME}/devel/proto"; export ADA_OBJECTS_PATH

C_INCLUDE_PATH="${HOME}/devel/proto/aej"; export C_INCLUDE_PATH
LIBRARY_PATH="${HOME}/devel/proto/aej"; export LIBRARY_PATH

#  ~/.zshenv
# printf "~/.zshrc\n"

cd ~/draft; cd ~/devel/quickie
printf "\x1b[2J\x1b[H~${PWD#${HOME}}\n"

HISTFILE=~/.zhistory; HISTSIZE=6000; SAVEHIST=15000
set -o APPEND_HISTORY
set -o HIST_IGNORE_DUPS
set -o emacs

umask 002
# VISUAL="$(which vim)"; [[ -x "${VISUAL}" ]] || VISUAL="$(which vi)"; export VISUAL
# EDITOR="${VISUAL}"; export EDITOR
PS1='%# '
# [[ -n "${WAYLAND_DISPLAY}" ]] || setfont "daej12x24"  # "suse12x22"
export COLUMNS LINES

unalias -a; alias qu=alias

alias lsi='ls -AF1'
alias lsl='ls -AFl --block-size=K'
alias lsx='ls -AFx'

alias py="${PY}"
alias pim="${PY} -im 'aej.daejana'"

alias pp="printf 'from string import *\\nfrom sys import *\\nfor i in argv[1:]:\\n\\tfor j in open(i):\\n\\t\\tprint(j.rstrip().expandtabs(3))' |python3 -"

# alias rkt='racket -I "racket/base" -e "(require aej/daejana)" -i'

alias cdd='function { local j k; if [[ ${#} < 1 ]]; then j="${PWD}"; else j=${1}; shift; fi; for k in ${j} ${*}; do if [[ "${k}" == "${k##${HOME}}" ]]; then
   ↪  printf "${k}\n"; elif [[ "${k}" == "${HOME}" ]]; then printf "~/\n"; else printf "~${k##${HOME}}\n"; fi; done; }'
alias cdm='cd -'
alias cdp='cd ~/devel/proto; printf "~${PWD#${HOME}}\n"'
alias cda='cd ~/devel/proto/aej; printf "~${PWD#${HOME}}\n"'
alias cdq='cd ~/devel/quickie; printf "~${PWD#${HOME}}\n"'
alias cdr='cd ~/devel/retro; printf "~${PWD#${HOME}}\n"'
# alias cds='cd ~/devel/sleek; printf "~${PWD#${HOME}}\n"'
alias cdt='cd ~/draft; printf "~${PWD#${HOME}}\n"'
alias cdv='cd ~/draft/vocabulary_cards; printf "~${PWD#${HOME}}\n"'
# alias cdw='cd /srv/www/htdocs; printf "${PWD}\n"'

alias stt='function { local j k; if [[ 0 < ${#} ]]; then for k in $*; do if [[ -r "${k}" ]]; then mv "${k}" "${HOME}/tmp/${k##*/}"; fi; nst "${k}"> "${k}";
   ↪  printf "${k}\n"; done; fi; }'
alias stm='function { local j k; if [[ 0 < ${#} ]]; then for k in $*; do if [[ -r "${k}" ]]; then mv "${k}" "${HOME}/tmp/${k##*/}"; fi; nst -m "${k}"> "${k}";
   ↪  printf "${k}\n"; done; fi; }'

alias cbr='function { local p r t; if [[ 0 < ${#} ]]; then t=${1}; shift; p="${HOME}/devel/proto/aej"; r="${p}/daejana.o"; for k in $*; do r="${r} ${p}/${k}.o";
   ↪  done; if gcc -c "-I${p}" "${t}.c" && gcc -o "${t}" $(printf "${r}\n") "${t}.o"; then "./${t}"; rm "${t}" "${t}".o; fi; fi; }'
alias ccb='function { local p r t; if [[ 0 < ${#} ]]; then t=${1}; shift; p="${HOME}/devel/proto/aej"; r="${p}/daejana.o"; for k in $*; do r="${r} ${p}/${k}.o";
   ↪  done; gcc -c "-I${p}" "${t}.c" && gcc -o "${t}" $(printf "${r}\n") "${t}.o"; rm "${t}" "${t}".o; fi; }'

# alias ccc="gcc -c -I${HOME}/devel/proto/aej"

alias abr='function { local t; if [[ 0 < ${#} ]]; then t=${1}; shift; if gnatmake -q ${t}; then "./${t}"; gnatclean -q ${t}; fi; fi; }'

alias adb='function { local t; if [[ 0 < ${#} ]]; then t=${1}; shift; gnatmake -q ${t}; fi; }'

alias fth='sf include %swift_forth/lib/options/config include'

#  ~/.zshrc
% cdp
~/devel/proto
% pp aej.ads
with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Text_IO;
with Interfaces.C;
package Aej is

use Ada; use Text_IO; use Interfaces;

subtype Int_T is C.ptrdiff_t;
subtype Enum_T is Int_T range 0 .. Int_T'Last;
subtype Index_T is Int_T range 1 .. Int_T'Last;
subtype Uint_T is C.size_t;
subtype Flt_T is C.long_double;

package Int_IO is new Text_IO.Integer_IO(Int_T);
package Uint_IO is new Text_IO.Modular_IO(Uint_T);
package Flt_IO is new Text_IO.Float_IO(Flt_T);
package Flt_G_E_F is new Numerics.Generic_Elementary_Functions(Flt_T);
use Flt_G_E_F;

use type Flt_T;

Phi : constant Flt_T := (Sqrt(5.0) + 1.0) / 2.0;
Pi : constant Flt_T := Arctan(1.0) * 4.0;

type String_Access_T is access all String;

end Aej;
% pp aej-daejana.adb aej-daejana.ads
with Ada.Text_IO;
with Gnat.Source_Info;
package body Aej.Daejana is

use Ada; use Text_IO; use Gnat;

use Int_IO;

use type Int_T;

procedure Ouch (S : String := (1 .. 0 => <>); File : String := Source_Info.File; Line : Integer := Source_Info.Line) is begin
      New_Line(Standard_Error);
      Put(Standard_Error, "** "); Put(Standard_Error, File);
      Put(Standard_Error, " ("); Put(Standard_Error, Int_T( Line), Width => 1); Put(Standard_Error, "): ");
      if S'Length < 1 then
         Put(Standard_Error, "Ouch! " & Character'Val(16#e2#) & Character'Val(16#98#) & Character'Val(16#a0#));
      else
         Put(Standard_Error, S);
      end if;
      New_Line(Standard_Error);
      return; end Ouch;

function Within (L : Int_T; M : Int_T; R : Int_T) return Boolean is begin
      return not ( M < L or R < M); end Within;

procedure Swap (C : in out Int_T; D : in out Int_T) is B : Int_T; begin
      B := C; C := D; D := B;
      return; end Swap;

procedure Rotate_Left (C : in out Int_T; D : in out Int_T; E : in out Int_T) is B : Int_T; begin
      B := C; C := D; D := E; E := B;
      return; end Rotate_Left;

procedure Rotate_Left (C : in out Int_T; D : in out Int_T; E : in out Int_T; F : in out Int_T) is B : Int_T; begin
      B := C; C := D; D := E; E := F; F := B;
      return; end Rotate_Left;

procedure Rotate_Right (C : in out Int_T; D : in out Int_T; E : in out Int_T) is B : Int_T; begin
      B := E; E := D; D := C; C := B;
      return; end Rotate_Right;

procedure Rotate_Right (C : in out Int_T; D : in out Int_T; E : in out Int_T; F : in out Int_T) is B : Int_T; begin
      B := F; F := E; E := D; D := C; C := B;
      return; end Rotate_Right;

function Compare (S : String_Access_T; T : String_Access_T) return Int_T is begin
		if S = null and T = null then return 0; end if; if S = null then return -1; end if; if T = null then return 1; end if;
		return (if S.all = T.all then 0 elsif S.all < T.all then -1 else 1); end Compare;

end Aej.Daejana;
with Gnat.Source_Info;
package Aej.Daejana is

use Gnat;

procedure Ouch (S : String := (1 .. 0 => <>); File : String := Source_Info.File; Line : Integer := Source_Info.Line);

function Within (L : Int_T; M : Int_T; R : Int_T) return Boolean;

procedure Swap (C : in out Int_T; D : in out Int_T);
procedure Rotate_Left (C : in out Int_T; D : in out Int_T; E : in out Int_T);
procedure Rotate_Left (C : in out Int_T; D : in out Int_T; E : in out Int_T; F : in out Int_T);
procedure Rotate_Right (C : in out Int_T; D : in out Int_T; E : in out Int_T);
procedure Rotate_Right (C : in out Int_T; D : in out Int_T; E : in out Int_T; F : in out Int_T);

function Compare (S : String_Access_T; T : String_Access_T) return Int_T;

end Aej.Daejana;

%

   -- Macs

% pp ~/.zshenv ~/.zshrc
# printf "~/.zshenv\n"

PATH="${HOME}/opt/bin:/Applications/Racket v8.12/bin:/opt/local/bin:/opt/local/sbin:${PATH}"; export PATH
MANPATH="${HOME}/opt/man/racket:/opt/local/share/man:${MANPATH}"; export MANPATH; LC_ALL="C"; export LC_ALL
PY="/usr/bin/python3"; export PY
ST='/Users/daejana/opt/apps/Sublime\ Text.app/Contents/SharedSupport/bin/subl'; export ST

PYTHONPATH="${HOME}/devel/proto"; export PYTHONPATH
PYTHONDONTWRITEBYTECODE="x"; export PYTHONDONTWRITEBYTECODE

OCAMLTOP_INCLUDE_PATH="${HOME}/devel/proto"; export OCAMLTOP_INCLUDE_PATH

#  ~/.zshenv

# cd ~/devel/swift/Aej/Sources
# cd ~/draft/vocabulary
cd ~/devel/quickie
cd ~/devel/sleek
printf "\x1b[2J\x1b[H~${PWD#${HOME}}\n"; export COLUMNS LINES

HISTSIZE=6000
SAVEHIST=60000
set -o APPEND_HISTORY
set -o HIST_IGNORE_DUPS
set -o emacs
VISUAL="$(which vim)"; [[ -x "${VISUAL}" ]] || VISUAL="$(which vi)"; export VISUAL
EDITOR="${VISUAL}"; export EDITOR
PS1='%# '
umask 002
unalias -a
alias qu=alias
alias lsx='ls -AFx'
alias lsi='ls -AF1'
alias lsl='ls -AFhl'
alias py="${PY}"
alias pim="${PY} -im 'aej.daejana'"
alias pp="printf 'from string import *\\nfrom sys import *\\nfor i in argv[1:]:\\n\\tfor j in open(i):\\n\\t\\tprint(j.rstrip().expandtabs(3))' |${PY} -"
alias cdd='function { local j k; if [[ ${#} < 1 ]]; then j="${PWD}"; else j=${1}; shift; fi; for k in ${j} ${*}; do if [[ "${k}" == "${k##${HOME}}" ]]; then
   ↪  printf "${k}\n"; elif [[ "${k}" == "${HOME}" ]]; then printf "~/\n"; else printf "~${k##${HOME}}\n"; fi; done; }'
alias cdm='cd -'
alias cdp='cd ~/devel/proto; printf "~${PWD#${HOME}}\n"'
alias cda='cd ~/devel/proto/aej; printf "~${PWD#${HOME}}\n"'
alias cdq='cd ~/devel/quickie; printf "~${PWD#${HOME}}\n"'
alias cdr='cd ~/devel/probes; printf "~${PWD#${HOME}}\n"'
alias cds='cd ~/devel/sleek; printf "~${PWD#${HOME}}\n"'
alias cdt='cd ~/draft; printf "~${PWD#${HOME}}\n"'
alias cdv='cd ~/draft/vocabulary; printf "~${PWD#${HOME}}\n"'
alias cdw='cd ~/devel/swift/Aej/Sources; printf "~${PWD#${HOME}}\n"'
alias cdc='cd "/Users/daejana/Documents/Documents - Armin’s Mac Studio/draft/memo"; printf "~${PWD#${HOME}}\n"'
alias st="${ST} -a"
alias stt='function { local a j k t; if [[ 0 < ${#} ]]; then a=(); for k in $*; do if [[ -r "${k}" ]]; then mv "${k}" "${HOME}/tmp/${k##*/}"; fi; nst "${k}"> "${k}";
   ↪  printf "${k}\n"; a+=("${k}"); done; '"${ST} -a \$a[@]"'; fi; }'
alias stm='function { local a j k t; if [[ 0 < ${#} ]]; then a=(); for k in $*; do if [[ -r "${k}" ]]; then mv "${k}" "${HOME}/tmp/${k##*/}"; fi; nst -m "${k}"> "${k}";
   ↪  printf "${k}\n"; a+=("${k}"); done; '"${ST} -a \$a[@]"'; fi; }'
alias swb='swift run Aej'
alias swr='swift run --skip-build Aej'
alias cbr='function { local a p t; if [[ 0 < ${#} ]]; then t=${1}; shift; p="${HOME}/devel/proto/aej"; a=("${p}/daejana.o"); for k in $*; do a+=("${p}/${k}.o"); done;
   ↪  if gcc -c "-I${p}" "${t}.c" && gcc -o "${t}" $a[@] "${t}.o"; then "./${t}"; rm "${t}" "${t}".o; fi; fi; }'
alias ccb='function { local a p t; if [[ 0 < ${#} ]]; then t=${1}; shift; p="${HOME}/devel/proto/aej"; a=("${p}/daejana.o"); for k in $*; do a+=("${p}/${k}.o"); done;
   ↪  gcc -c "-I${p}" "${t}.c" && gcc -o "${t}" $a[@] "${t}.o"; rm "${t}".o; fi; }'
alias ccc="gcc -c -I${HOME}/devel/proto/aej"
alias cmr='function { local t u; if [[ 0 < ${#} ]]; then t=${1}; shift; fi; u=""; for k in daejana $*; do if ! make -r --directory="${HOME}/devel/proto/aej" -s
   ↪  "${k}.o"; then make -r --directory="${HOME}/devel/proto/aej" -s clean; break; fi; done; if [[ -r "${HOME}/devel/proto/aej/daejana.o" ]]; then if
   ↪  make -r -s ${t}; then "./${t}"; fi; make -r -s clean; fi; }'
alias cmk='function { local t u; if [[ 0 < ${#} ]]; then t=${1}; shift; fi; u=""; for k in daejana $*; do if ! make -r --directory="${HOME}/devel/proto/aej" -s
   ↪  "${k}.o"; then make -r --directory="${HOME}/devel/proto/aej" -s clean; break; fi; done; if [[ -r "${HOME}/devel/proto/aej/daejana.o" ]]; then
   ↪  if ! make -r -s ${t}; then make -r -s clean; else rm ${t}.o; fi; fi; }'

#  ~/.zshrc
% cda
~/devel/proto/aej
% pp daejana.c daejana.h
#define DAEJANA_C
#include <daejana.h>

bool_t error_flag;

const flt_t flt_epsilon = flt_c(DBL_EPSILON * 10.0);

int_t
int_max (int_t l, int_t r) {
      if (l < r) { return r; }
      return l; }

int_t
int_min (int_t l, int_t r) {
      if (l < r) { return l; }
      return r; }

bool_t
int_within (int_t l, int_t m, int_t r) {
      return !( m < l || r < m); }

void int_swap (int_t * c, int_t * d) { int_t b;
      b = * c; * c = * d; * d = b;
      return; }

void int_rol_3 (int_t * c, int_t * d, int_t * e) { int_t b;
      b = * c; * c = * d; * d = * e; * e = b;
      return; }

void int_rol_4 (int_t * c, int_t * d, int_t * e, int_t * f) { int_t b;
      b = * c; * c = * d; * d = * e; * e = * f; * f = b;
      return; }

void int_ror_3 (int_t * c, int_t * d, int_t * e) { int_t b;
      b = * e; * e = * d; * d = * c; * c = b;
      return; }

void int_ror_4 (int_t * c, int_t * d, int_t * e, int_t * f) { int_t b;
      b = * f; * f = * e; * e = * d; * d = * c; * c = b;
      return; }

void vptr_swap (vptr_t * c, vptr_t * d) { vptr_t b;
      b = * c; * c = * d; * d = b;
      return; }

void vptr_rol_3 (vptr_t * c, vptr_t * d, vptr_t * e) { vptr_t b;
      b = * c; * c = * d; * d = * e; * e = b;
      return; }

void vptr_rol_4 (vptr_t * c, vptr_t * d, vptr_t * e, vptr_t * f) { vptr_t b;
      b = * c; * c = * d; * d = * e; * e = * f; * f = b;
      return; }

void vptr_ror_3 (vptr_t * c, vptr_t * d, vptr_t * e) { vptr_t b;
      b = * e; * e = * d; * d = * c; * c = b;
      return; }

void vptr_ror_4 (vptr_t * c, vptr_t * d, vptr_t * e, vptr_t * f) { vptr_t b;
      b = * f; * f = * e; * e = * d; * d = * c; * c = b;
      return; }

flt_t
flt_max (flt_t l, flt_t r) {
      if (flt_compare(l, r) < 0) { return r; }
      return l; }

flt_t
flt_min (flt_t l, flt_t r) {
      if (flt_compare(l, r) < 0) { return l; }
      return r; }

int_t
flt_compare (flt_t l, flt_t r)
{
   flt_t d;

   d = l - r;
   if (flt_epsilon < fabs(d)) {
      if (signbit(d) == 0) {
         return 1;
      }
      return -1;
   }
   return 0;
}

bool_t
flt_within (flt_t l, flt_t m, flt_t r) {
      return !( flt_compare(m, l) < 0 || flt_compare(r, m) < 0); }

int_t
mbs_length (const char * s)
{
   uint8_t h; int_t d; int_t n;

   n = 0;
   d = 0;
   h = s[0];
   while (!( h == 0x00)) {
      n += 1;
      if ((h & 0xf0) == 0xf0) {
         d += 4;
      }
      else if ((h & 0xe0) == 0xe0) {
         d += 3;
      }
      else if ((h & 0xc0) == 0xc0) {
         d += 2;
      }
      else {
         d += 1;
      }
      h = s[d];
   }
   return n;

}

void
mbs_getk (const char * s, int_t * n, uint_t * k)
{
   uint8_t h; int_t d;

   h = s[0];
   if ((h & 0xf0) == 0xf0) {
      d = 4;
   }
   else if ((h & 0xe0) == 0xe0) {
      d = 3;
   }
   else if ((h & 0xc0) == 0xc0) {
      d = 2;
   }
   else if (0x00 < h) {
      d = 1;
   }
   else {
      * n = 0; * k = 0; return;

   }
   * k = 0; strncpy(char_ptr_c( k), s, d); * n = d;
   return;

}

uint_t
rseed (void) { time_t tm = time(NULL); struct tm * now = localtime(&tm);
      return (uint_c( now->tm_sec) << 26 | uint_c( now->tm_min) << 21 | uint_c( now->tm_hour) << 17 | uint_c( now->tm_mday) << 13 | uint_c( now->tm_mon) << 10 |
   ↪  uint_c( now->tm_wday) <<  3 | uint_c( now->tm_year) + uint_c( clock())) & 0x7fffffff; }

// daejana.c
#ifndef DAEJANA_H
#define DAEJANA_H

#include <assert.h>
#include <ctype.h>
#include <float.h>
#include <math.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include <unistd.h>

typedef int64_t int_t;
typedef uint64_t uint_t;
typedef uint8_t uchar_t;

typedef double flt_t;

typedef bool bool_t;

typedef void * vptr_t;

typedef void (* proc_t) (void);
typedef void * (* vptr_proc_t) (void);
typedef void * (* vptr_proc_vptr_t) (vptr_t);

#define int_c(Q) ((int_t)( Q))
#define uint_c(Q) ((uint_t)( Q))
#define uchar_c(Q) ((uchar_t)( Q))
#define flt_c(Q) ((flt_t)( Q))

#define vptr_c(Q) ((vptr_t)( Q))
#define vptr_ptr_c(Q) ((vptr_t *)( Q))
#define int_ptr_c(Q) ((int_t *)( Q))
#define uint_ptr_c(Q) ((uint_t *)( Q))
#define char_ptr_c(Q) ((char *)( Q))
#define const_char_ptr_c(Q) ((const char *)( Q))
#define uchar_ptr_c(Q) ((uchar_t *)( Q))

#define ouch(...) fprintf(stderr, "\n** " __FILE__ " (%d)", __LINE__); fprintf(stderr, strlen("" # __VA_ARGS__) == 0 ? ": Ouch! \xe2\x98\xa0\n" : strlen("" #
   ↪  __VA_ARGS__) == 2 ? ";\n" : ": " __VA_ARGS__); error_flag = true

#define m_pad int_c( 8192)

#ifndef DAEJANA_C

extern bool_t error_flag;
extern const flt_t flt_epsilon;

#endif

int_t int_max (int_t, int_t);
int_t int_min (int_t, int_t);
bool_t int_within (int_t, int_t, int_t);

void int_swap (int_t *, int_t *);
void int_rol_3 (int_t *, int_t *, int_t *);
void int_rol_4 (int_t *, int_t *, int_t *, int_t *);
void int_ror_3 (int_t *, int_t *, int_t *);
void int_ror_4 (int_t *, int_t *, int_t *, int_t *);

void vptr_swap (vptr_t *, vptr_t *);
void vptr_rol_3 (vptr_t *, vptr_t *, vptr_t *);
void vptr_rol_4 (vptr_t *, vptr_t *, vptr_t *, vptr_t *);
void vptr_ror_3 (vptr_t *, vptr_t *, vptr_t *);
void vptr_ror_4 (vptr_t *, vptr_t *, vptr_t *, vptr_t *);

flt_t flt_max (flt_t, flt_t);
int_t flt_compare (flt_t, flt_t);
flt_t flt_min (flt_t, flt_t);
bool_t flt_within (flt_t, flt_t, flt_t);

int_t mbs_length (const char *);
void mbs_getk (const char *, int_t *, uint_t *);

uint_t rseed (void);

#endif
// daejana.h
% pp daejana.make makefile

SHELL = zsh
PROTO = $(HOME)/devel/proto/aej

#  ~/devel/proto/aej/daejana.make
include $(HOME)/devel/proto/aej/daejana.make

daejana.o : daejana.c
      gcc -c -I$(PROTO) $<

xxx.o : xxx.c
      gcc -c -I$(PROTO) $<

.PHONY clean :
      @for k in daejana.o xxx.o; do if [[ -r $$k ]]; then rm $$k; fi; done

#  ~/devel/proto/aej/makefile
% pp daejana.rkt
#lang racket/base
(provide exit-state ouch! elsif if… within swap)

(define exit-state 0)

(define (ouch! . t)
      (let ((p (current-error-port))) (display "\n** Ouch! " p) (display #\u2620 p) (for-each (lambda (s) (display " " p) (display s p)) t) (newline p))
      (set! exit-state 128))

(define-syntax elsif (syntax-rules (then else)
      ((_ I (then II ...))                (if I (begin II ...) (void)))
      ((_ I (then II ...) (else III ...)) (if I (begin II ...) (begin III ...)))
      ((_ I (then II ...) (_ III ...))    (if I (begin II ...) (elsif III ...)))))

(define-syntax if… (syntax-rules ()
      ((_ I ...) (elsif I ...))))

(define (within l m r)
   (not (or (< m l) (< r m)))
)

(define (swap c d . t)
   (let loop (
         (e c)
         (f d)
         (r t)
      )
      (let (
            (b (mcar e))
         )
         (set-mcar! e (mcar f))
         (set-mcar! f b)
      )
      (if… (not (null? r)) (then
         (loop f (car r) (cdr r))
      ))
   )
)

;  daejana.rkt
% pp daejana.ml
open Float

let phi = (sqrt 5.0 +. 1.0) /. 2.0
let pi = atan 1.0 *. 4.0

(* daejana.ml *)
% pp daejana.py
import sys
from math import *

phi = (sqrt(5.0) + 1.0) / 2.0
pi = atan(1.0) * 4.0

#  daejana.py
% cds
~/devel/sleek
% pp makefile
include $(HOME)/devel/proto/aej/daejana.make

.SILENT usage :
      printf "Usage:\n\n      make target\n      make clean\n\n"

xxx_m.o : xxx_m.c
      gcc -c -I$(PROTO) $<

xxx_m : xxx_m.o
      gcc -o $@ $(PROTO)/daejana.o $(PROTO)/xxx.o $<

.PHONY clean :
      @for k in xxx_m xxx_m.o; do if [[ -r $$k ]]; then rm $$k; fi; done

#  ~/devel/sleek/makefile
% pp ~/opt/bin/nst
#!/usr/bin/python3

import os.path
import sys
import sysconfig

if __name__ == '__main__':
   if len(sys.argv) < 2:
      sys.exit()

   h = os.environ['HOME']
   r = "/Users/daejana/Documents/Documents - Armin’s Mac Studio/Templates/"
   is_main = False
   i_argv = 1
   if sys.argv[i_argv] == "-m":
      is_main = True
      i_argv += 1

   while i_argv < len(sys.argv):
      t = os.path.basename(sys.argv[i_argv]).split(".")
      if 1 < len(t):
         if t[0] != "":
            f, e = ".".join(t[:-1]), "." + t[-1]
         else:
            f, e = "." + t[1], ""
      else:
         f, e = t[0], ""

      if e == ".adb":
         if is_main:
            b = "ada_main"
            d = "_".join([x.capitalize() for x in b.split("_")])
            a = []
            for l in [x.capitalize() for x in f.split("-")]:
               a += ["_".join([x.capitalize() for x in l.split("_")])]
            c = ".".join(a)
            for k in open(r + b + e):
            #  print(k.rstrip().replace(d, c).replace(b, f))
               print(k.rstrip().replace(d, c))

         else:
            b = "ada_body"
            d = "_".join([x.capitalize() for x in b.split("_")])
            a = []
            for l in [x.capitalize() for x in f.split("-")]:
               a += ["_".join([x.capitalize() for x in l.split("_")])]
            c = ".".join(a)
            for k in open(r + b + e):
            #  print(k.rstrip().replace(d, c).replace(b, f))
               print(k.rstrip().replace(d, c))

      elif e == ".ads":
         b = "ada_spec"
         d = "_".join([x.capitalize() for x in b.split("_")])
         a = []
         for l in [x.capitalize() for x in f.split("-")]:
            a += ["_".join([x.capitalize() for x in l.split("_")])]
         c = ".".join(a)
         for k in open(r + b + e):
         #  print(k.rstrip().replace(d, c).replace(b, f))
            print(k.rstrip().replace(d, c))

      elif e == ".asm":
			…

      elif e == ".inc":
			…

      elif e == ".bat":
			…

      elif e == ".c":
         if is_main:
            b = "c_main"
         #  d = b.upper()
         #  c = f.upper()
            for k in open(r + b + e):
            #  print(k.rstrip().replace(d, c).replace(b, f))
               print(k.rstrip().replace(b, f))

         else:
            b = "c_body"
            d = b.upper()
            c = f.upper()
            for k in open(r + b + e):
               print(k.rstrip().replace(d, c).replace(b, f))

      elif e == ".h":
         b = "c_spec"
         d = b.upper()
         c = f.upper()
         for k in open(r + b + e):
            print(k.rstrip().replace(d, c).replace(b, f))

      elif e == ".css":
			…

      elif e == ".emf":
			…

      elif e == ".forth" or (e == ".sf" or e == ".f") and is_main:
			…

      elif e == ".sf":
			…

      elif e == ".html":
			…

      elif e == ".l":
			…

      elif f == "makefile" or f == "Makefile" or e == ".make" or e == ".mak" or e == ".wmk":
         c = os.path.dirname(r).replace(h, "~") + "/"
         d = os.path.dirname(sys.argv[i_argv]).replace(h, "~") + "/"
         for k in open(r + "makefile"):
            print(k.rstrip().replace(c, d))

      elif e == ".ocaml" or e == ".ml" and is_main:
         if e == ".ocaml":
            print("#!/opt/local/bin/ocamlrun /opt/local/bin/ocaml\n")
         b = "ocaml_script"
         for k in open(r + b + ".ocaml"):
            print(k.rstrip().replace(b, f).replace(".ocaml", e))

      elif e == ".ml":
         b = "ocaml_imple"
         for k in open(r + b + e):
            print(k.rstrip().replace(b, f))

      elif e == ".php":
			…

      elif e == ".python" or e == ".py" and is_main:
         if e == ".python":
            print("#!/usr/bin/python3\n")
         b = "python_script"
         for k in open(r + b + ".python"):
            print(k.rstrip().replace(b, f))

      elif e == ".py":
         b = "python_imple"
         for k in open(r + b + e):
            print(k.rstrip().replace(b, f))

      elif e == ".raku" or e == ".pm" and is_main:
			…

      elif e == ".pm":
			…

      elif e == ".racket" or e == ".rkt" and is_main:
         if e == ".racket":
            print("#!/Users/daejana/opt/bin/racket")
         b = "racket_script"
         for k in open(r + b + ".racket"):
            print(k.rstrip().replace(b, f).replace(".racket", e))

      elif e == ".rkt":
         b = "racket_imple"
         for k in open(r + b + e):
            print(k.rstrip().replace(b, f))

      elif e == ".guile" or e == ".scm" and is_main:
         if e == ".guile":
            print("#!/opt/local/bin/guile -s")
            print("!#")
         b = "guile_script"
         for k in open(r + b + ".guile"):
            print(k.rstrip().replace(b, f).replace(".guile", e))

      elif e == ".scm" or e == "sld":
         b = "guile_imple"
         for k in open(r + b + ".scm"):
            print(k.rstrip().replace(b, f).replace(".scm", e))

      elif e == ".sql":
			…

      elif e == ".swift":
         if is_main:
            b = "swift_main"
         else:
            b = "swift_imple"
         for k in open(r + b + e):
            print(k.rstrip().replace(b, f))

      elif e == ".txt" or e == ".log":
         b = "text_file"
         for k in open(r + b + ".txt"):
            print(k.rstrip().replace(b, f).replace(".txt", e))

      elif e == ".vim":
			…

      elif e == ".xml":
			…

      elif e == ".y":
			…

      elif e == ".zsh" or e == "":
         if e == ".zsh":
            print("#!/usr/bin/zsh\n")
         b = "zsh_script"
         for k in open(r + b + ".zsh"):
            print(k.rstrip().replace(b, f))

      else:
         d = os.path.dirname(sys.argv[i_argv]).replace(h, "~")
         if not (d == ""):
            d += "/"
         print("\n\n;*\t" + d + f + e)

      i_argv += 1

#  nst
% pp "/Users/daejana/Documents/Documents - Armin?<0080><0099>s Mac Studio/Templates"/ada_body.adb
with Ada.Text_IO;
with Aej.Daejana;
package body Ada_Body is

use Ada; use Text_IO;
use Aej; use Daejana;


end Ada_Body;
% pp "/Users/daejana/Documents/Documents - Armin?<0080><0099>s Mac Studio/Templates"/ada_spec.adb
Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/Users/daejana/Documents/Documents - Armin’s Mac Studio/Templates/ada_spec.adb'
% pp "/Users/daejana/Documents/Documents - Armin?<0080><0099>s Mac Studio/Templates"/ada_spec.ads
with Ada.Text_IO;
with Aej.Daejana;
package Ada_Spec is

use Ada; use Text_IO;
use Aej; use Daejana;


-- private
end Ada_Spec;
% pp "/Users/daejana/Documents/Documents - Armin?<0080><0099>s Mac Studio/Templates"/ada_main.adb
with Ada.Command_Line;
with Ada.Exceptions;
with Ada.Text_IO;
with Aej.Daejana;
procedure Ada_Main is

use Ada; use Text_IO;
use Aej; use Daejana;

use Int_IO;
-- use Uint_IO;
-- use Flt_IO;
-- use Flt_G_E_F;

use type Int_T;
-- use type Uint_T;
-- use type Flt_T;


begin
   Command_Line.Set_Exit_Status(Command_Line.Success);
   New_Line;

   Put(";");
   New_Line;

   New_Line;
   return;

exception
   when E : others =>
      New_Line(Standard_Error);
      New_Line(Standard_Error);
      Put(Standard_Error, "** ");
      Put(Standard_Error, Exceptions.Exception_Name(E));
      Put(Standard_Error, "! (");
      Put(Standard_Error, Exceptions.Exception_Message(E));
      Put(Standard_Error, ")");
      New_Line(Standard_Error);
      New_Line;
      Command_Line.Set_Exit_Status(Command_Line.Failure);

end Ada_Main;
% pp "/Users/daejana/Documents/Documents - Armin?<0080><0099>s Mac Studio/Templates"/c_body.c
#define C_BODY_C
#include <c_body.h>


// c_body.c
% pp "/Users/daejana/Documents/Documents - Armin?<0080><0099>s Mac Studio/Templates"/c_spec.h
#ifndef C_SPEC_H
#define C_SPEC_H
#include <daejana.h>


#ifndef C_SPEC_C
#endif


#endif
// c_spec.h
% pp "/Users/daejana/Documents/Documents - Armin?<0080><0099>s Mac Studio/Templates"/c_main.c
#include <chars.h>


static void probe_01 (void);


static void
probe_01 (void)
{

   printf(";\n");

   return;

}

int
main (int argc, char * argv [])
{

   error_flag = false;
   printf("\n");

   probe_01();

   printf("\n");
   if (error_flag) { exit(EXIT_FAILURE); }

   return EXIT_SUCCESS;

}

// c_main.c
% pp "/Users/daejana/Documents/Documents - Armin?<0080><0099>s Mac Studio/Templates"/racket_imple.rkt
#lang racket/base

;(provide )


;  racket_imple.rkt
% pp "/Users/daejana/Documents/Documents - Armin?<0080><0099>s Mac Studio/Templates"/racket_script.racket
#lang racket/base

(require aej/daejana)

((lambda ()
      (newline)
      (display ";") (newline)
      (newline)
      (exit exit-state)
   )
)

;* racket_script.racket
% pp "/Users/daejana/Documents/Documents - Armin?<0080><0099>s Mac Studio/Templates"/ocaml_imple.ml


(* ocaml_imple.ml *)
% pp "/Users/daejana/Documents/Documents - Armin?<0080><0099>s Mac Studio/Templates"/ocaml_script.ocaml
#mod_use "aej/daejana.ml" ;; open Daejana

let _ =
   ignore ()

(* ocaml_script.ocaml *)
% pp "/Users/daejana/Documents/Documents - Armin?<0080><0099>s Mac Studio/Templates"/python_imple.py


if __name__ == '__main__':
   pass

#  python_imple.py
% pp "/Users/daejana/Documents/Documents - Armin?<0080><0099>s Mac Studio/Templates"/python_script.python

from aej.daejana import *


#  ~/opt/bin/python_script
% pp "/Users/daejana/Documents/Documents - Armin?<0080><0099>s Mac Studio/Templates"/swift_imple.swift


// swift_imple.swift
% pp "/Users/daejana/Documents/Documents - Armin?<0080><0099>s Mac Studio/Templates"/swift_main.swift
enum swift_main {

   static let main = { (_ t : [String]) -> Void in
      print(t.reduce("swift_main", { x, y in x + "\u{20}" + y }) + " \u{2026}")
      print()

      return
   }
}

// swift_main.swift
% pp "/Users/daejana/Documents/Documents - Armin?<0080><0099>s Mac Studio/Templates"/zsh_script.zsh


#  ~/opt/bin/zsh_script
% pp "/Users/daejana/Documents/Documents - Armin?<0080><0099>s Mac Studio/Templates"/text_file.txt
;* ***********************************************************************************************************************************************************


;* ***********************************************************************************************************************************************************

;* text_file.txt
% cd "/Users/daejana/Library/Application Support/Sublime Text/Packages/User"
% pp Preferences.sublime-settings Default\ \(OSX\).sublime-keymap Cut\ to\ Hard\ EOL.sublime-macro Plain\ text.sublime-settings snippet.py
{
   "color_scheme": "Lunatized (dark).sublime-color-scheme",
   "dark_color_scheme": "Lunatized (dark).sublime-color-scheme",
   "light_color_scheme": "Lunatized (light).sublime-color-scheme",
   "font_face": "Andale Mono",
   "font_size": 22,
   "auto_complete": false,
   "auto_indent": false,
   "auto_match_enabled": false,
   "copy_with_empty_selection": false,
   "detect_indentation": false,
   "draw_centered": false,
   "ensure_newline_at_eof_on_save": true,
   "gutter": false,
   "highlight_line": true,
   "indent_subsequent_lines": true,
   "line_numbers": false,
   "scroll_past_end": false,
   "shift_tab_unindent": true,
   "show_definitions": false,
   "show_tab_close_buttons": false,
   "tab_completion": false,
   "tab_size": 3,
   "translate_tabs_to_spaces": false,
   "trim_trailing_white_space_on_save": true,
   "use_tab_stops": true,
   "word_wrap": false,
   "wrap_width": 159,
}
[
   { "keys": ["alt+space"], "command": "snippet" },
   { "keys": ["ctrl+shift+k"], "command": "run_macro_file", "args": { "file": "res://Packages/User/Cut to Hard EOL.sublime-macro"} }
]
[
   {
      "args":
      {
         "extend": true,
         "to": "hardeol"
      },
      "command": "move_to"
   },
   {
      "args": null,
      "command": "cut"
   }
]
{
   "extensions":
   [
      "adb", "ads", "c", "h", "rkt", "ml", "swift", "py", "php", "html", "log", "sublime-settings", "sublime-keymap", "sublime-macro"
   ]
}
import sublime
import sublime_plugin

import os.path
import re
import time

class snippetCommand(sublime_plugin.TextCommand):
   def run(self, edit):
      t = os.path.basename(self.view.file_name()).split(".")
      if 1 < len(t):
         if t[0] != "":
            f, e = ".".join(t[:-1]), "." + t[-1]
         else:
            f, e = "." + t[1], ""
      else:
         f, e = t[0], ""
      s0 = self.view.line(self.view.sel()[0].begin())

      #  {} → block, braces
      #  () → block, parentheses
      #  [] → block, brackets

      mr = re.search("^([\t ]*)\\{\\}[\t ]*$", self.view.substr(s0))  # block, braces
      if mr:
         s1 = mr.group(1)
         self.view.replace(edit, s0, "")
         self.view.run_command('insert_snippet', {'contents': s1 + "{\n" + s1 + "\t${0}\n" + s1 + "}"})
         return None

      mr = re.search("^([\t ]*)\\(\\)[\t ]*$", self.view.substr(s0))  # block, parentheses
      if mr:
         s1 = mr.group(1)
         self.view.replace(edit, s0, "")
         self.view.run_command('insert_snippet', {'contents': s1 + "(\n" + s1 + "\t${0}\n" + s1 + ")"})
         return None

      mr = re.search("^([\t ]*)\\[\\][\t ]*$", self.view.substr(s0))  # block, brackets
      if mr:
         s1 = mr.group(1)
         self.view.replace(edit, s0, "")
         self.view.run_command('insert_snippet', {'contents': s1 + "[\n" + s1 + "\t${0}\n" + s1 + "]"})
         return None

      if not ( e == ".html" or e == ".php"):

         #  ^l → right
         #  ^k → up
         #  ^h → left
         #  ^j → down

         mr = re.search("^([\t ]*)\\^l[\t ]*$", self.view.substr(s0))  # right
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "\u2192${0}"})
            return None

         mr = re.search("^([\t ]*)\\^k[\t ]*$", self.view.substr(s0))  # up
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "\u2191${0}"})
            return None

         mr = re.search("^([\t ]*)\\^h[\t ]*$", self.view.substr(s0))  # left
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "\u2190${0}"})
            return None

         mr = re.search("^([\t ]*)\\^j[\t ]*$", self.view.substr(s0))  # down
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "\u2193${0}"})
            return None

      if e == ".adb":

         #  ada

         #  ; → procedure, no params
         #  k; → procedure, k int params; (k := 1 .. 9)
         #  : → int function, no params
         #  k: → int function, k int params; (k := 1 .. 9)
         #  = → int function, inline, no params
         #  k= → int function, inline, k int params; (k := 1 .. 9)
         #  , → int_t
         #  ? → if
         #  ?: → if, else
         #  ?? → if, elsif
         #  ??: → if, elsif, else
         #  ?! → if not
         #  ?= → if null
         #  | → switch
         #  @+ → loop, plus
         #  @- → loop, minus
         #  @~ → loop, exit
         #  @_ → loop, for

         mr = re.search("^([\t ]*)([1-9]?);[\t ]*$", self.view.substr(s0))  # ; → procedure, no params  # k; → procedure, k int params; (k := 1 .. 9)
         if mr:
            s1 = mr.group(1)
            s2 = ""
            if not mr.group(2) == "":
               s2 = " ( : Int_T"
               n = int( mr.group(2))
               k = 1
               while k < n:
                  s2 += ";  : Int_T"
                  k += 1
               s2 += ")"
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "procedure ${0}" + s2 + ";\n" + s1 + "procedure ${0}" + s2 + " is\n" + s1 + "\n" + s1
   ↪  + "begin\n" + s1 + "\n" + s1 + "\treturn;\n\n" + s1 + "end ${0};"})
            return None

         mr = re.search("^([\t ]*)([1-9]?):[\t ]*$", self.view.substr(s0))  # : → int function, no params  # k: → int function, k int params; (k := 1 .. 9)
         if mr:
            s1 = mr.group(1)
            s2 = ""
            if not mr.group(2) == "":
               s2 = " ( : Int_T"
               n = int( mr.group(2))
               k = 1
               while k < n:
                  s2 += ";  : Int_T"
                  k += 1
               s2 += ")"
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "function ${0}" + s2 + " return Int_T;\n" + s1 + "function ${0}" + s2 + " return Int_T is\n"
   ↪  + s1 + "\n" + s1 + "begin\n" + s1 + "\n" + s1 + "\treturn 0;\n\n" + s1 + "end ${0};"})
            return None

         mr = re.search("^([\t ]*)([1-9]?)=[\t ]*$", self.view.substr(s0))  # = → int function, inline, no params  # k= → int function, inline, k int params;
   ↪  (k := 1 .. 9)
         if mr:
            s1 = mr.group(1)
            s2 = ""
            if not mr.group(2) == "":
               s2 = " ( : Int_T"
               n = int( mr.group(2))
               k = 1
               while k < n:
                  s2 += ";  : Int_T"
                  k += 1
               s2 += ")"
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "function ${0}" + s2 + " return Int_T;\n" + s1 + "function ${0}" + s2 + " return Int_T is
   ↪  begin\n" + s1 + "\t" + s1 + "\t\treturn 0; end ${0};"})
            return None

         mr = re.search("^([\t ]*),[\t ]*$", self.view.substr(s0))  # , → int_t
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "${0} : Int_T;"})
            return None

         mr = re.search("^([\t ]*)\\?[\t ]*$", self.view.substr(s0))  # ? → if
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "if ${0} then\n" + s1 + "\t;\n" + s1 + "end if;"})
            return None

         mr = re.search("^([\t ]*)\\?:[\t ]*$", self.view.substr(s0))  # ?: → if, else
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "if ${0} then\n" + s1 + "\t;\n" + s1 + "else\n" + s1 + "\t;\n" + s1 + "end if;"})
            return None

         mr = re.search("^([\t ]*)\\?\\?[\t ]*$", self.view.substr(s0))  # ?? → if, elsif
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "if ${0} then\n" + s1 + "\t;\n" + s1 + "elsif  then\n" + s1 + "\t;\n" + s1 + "end if;"})
            return None

         mr = re.search("^([\t ]*)\\?\\?:[\t ]*$", self.view.substr(s0))  # ??: → if, elsif, else
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "if ${0} then\n" + s1 + "\t;\n" + s1 + "elsif  then\n" + s1 + "\t;\n" + s1 + "else\n" + s1
   ↪  + "\t;\n" + s1 + "end if;"})
            return None

         mr = re.search("^([\t ]*)\\?![\t ]*$", self.view.substr(s0))  # ?! → if not
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "if not( ${0}) then Ouch; return; end if;\n"})
            return None

         mr = re.search("^([\t ]*)\\?=[\t ]*$", self.view.substr(s0))  # ?= → if null
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "if ${0} == null then Ouch; return; end if;\n"})
            return None

         mr = re.search("^([\t ]*)\\|[\t ]*$", self.view.substr(s0))  # | → switch
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "case ${0} is\n" + s1 + "\twhen  =>\n" + s1 + "\t\t;\n" + s1 + "\twhen  =>\n" + s1
   ↪  + "\t\t;\n" + s1 + "\twhen others =>\n" + s1 + "\t\t;\n" + s1 + "end case;"})
            return None

         mr = re.search("^([\t ]*)@\\+[\t ]*$", self.view.substr(s0))  # @+ → loop, plus
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "K := 0;\n" + s1 + "while K < ${0} loop\n" + s1 + "\t;\n\n" + s1 + "\tK := K + 1;\n" + s1
   ↪  + "end loop;"})
            return None

         mr = re.search("^([\t ]*)@-[\t ]*$", self.view.substr(s0))  # @- → loop, minus
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "K := ${0};\n" + s1 + "while -1 < K loop\n" + s1 + "\t;\n\n" + s1 + "\tK := K - 1;\n" + s1
   ↪  + "end loop;"})
            return None

         mr = re.search("^([\t ]*)@~[\t ]*$", self.view.substr(s0))  # @~ → loop, exit
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "Ll: loop\n" + s1 + "\t;\n" + s1 + "\texit Ll when ${0};\n\n" + s1 + "\t;\n" + s1
   ↪  + "end loop Ll;"})
            return None

         mr = re.search("^([\t ]*)@_[\t ]*$", self.view.substr(s0))  # @_ → loop, for
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "for K in ${0} loop\n" + s1 + "\t;\n\n" + s1
   ↪  + "end loop;"})
            return None

         pass

      elif e == ".asm":

         #  asm

         #  : → proc, no params
         #  k: → proc, k params; (k := 1 + 3)
         #  , → int
         #  ? → if
         #  ?: → if, else
         #  ??: → if, elsif, else
         #  ?! → if not
         #  ?= → if null
         #  | → switch
         #  @+ → loop, plus
         #  @- → loop, minus
         #  @~ → loop, exit

         mr = re.search("^([1-3]?):[\t ]*$", self.view.substr(s0))  # : → proc, no params  # k: → proc, k params; (k := 1 .. 3)
         if mr:
            s1 = "extern ${0}:proc  ; ()\n" + "${0} proc public  ; ()\n" + "\t\t\tpush bp\n" + "\t\t\tmov bp,sp\n"
            if not mr.group(1) == "":
               n = int(mr.group(1))
               k = 0
               while k < n:
                  s1 += chr(88 + k) + "=" + chr(48 + 4 + 2 * k) + "\n"
                  k += 1
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "\t\t;\tsub sp,0\n" + "\t\t\tpush bx\n\n" + "\t\t\t;\n\n" + "\t\t\tpop bx\n"
   ↪  + "\t\t\tmov sp,bp\n" + "\t\t\tpop bp\n" + "\t\t\tret\n\n" + "${0} endp"})
            return None

         mr = re.search("^([\t ]+),[\t ]*$", self.view.substr(s0))  # , → int
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + ",[${0}+bp]"})
            return None

      #  mr = re.search("^([\t ]*)\?[\t ]*$", self.view.substr(s0))  # ? → if
      #  mr = re.search("^([\t ]*)\?:[\t ]*$", self.view.substr(s0))  # ?: → if, else
      #  mr = re.search("^([\t ]*)\?\?:[\t ]*$", self.view.substr(s0))  # ??: → if, elsif, else
      #  mr = re.search("^([\t ]*)\?![\t ]*$", self.view.substr(s0))  # ?! → if not
      #  mr = re.search("^([\t ]*)\?=[\t ]*$", self.view.substr(s0))  # ?= → if null
      #  mr = re.search("^([\t ]*)\|[\t ]*$", self.view.substr(s0))  # | → switch

         mr = re.search("^[\t ]*@\\+[\t ]*$", self.view.substr(s0))  # @+ → loop, plus
         if mr:
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': "\t\t\txor cx,cx\n" + "\t\t\tjmp Lll\\$xxx\n\n" + "Ll\\$xxx:\n" + "\t\t\t;\n" + "\t\t\tinc cx\n\n"
   ↪  + "Lll\\$xxx:\n" + "\t\t\tcmp cx,${0}\n" + "\t\t\tjl Ll\\$xxx"})
            return None

         mr = re.search("^[\t ]*@-[\t ]*$", self.view.substr(s0))  # @-  loop, minus
         if mr:
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': "\t\t\tmov cx,${0}\n" + "\t\t\tjmp Lll\\$xxx\n\n" + "Ll\\$xxx:\n" + "\t\t\t;\n\n" + "Lll\\$xxx:\n"
   ↪  + "\t\t\tdec cx\n" + "\t\t\tcmp cx,0\n" + "\t\t\tjnl Ll\\$xxx"})
            return None

         mr = re.search("^[\t ]*@~[\t ]*$", self.view.substr(s0))  # @~  loop, exit
         if mr:
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': "\t\t\tmov cx,1\n" + "Ll\\$xxx:\n" + "\t\t\t;${0}\n" + "\t\t;\txor cx,cx\n" + "\t\t\t;\n"
   ↪  + "\t\t\tcmp cx,0\n" + "\t\t\tje Lll\\$xxx\n" + "\t\t\t;\n" + "\t\t\tjmp Ll\\$xxx\n\n" + "Lll\\$xxx:"})
            return None

         pass

      elif e == ".bat":

         #  dosbatch

         pass

      elif e == ".c":

         #  c

         #  s → static
         #  ; → void function, no params
         #  k; → void function, k int params; (k := 1 + 9)
         #  : → int function, no params
         #  k: → int function, k int params; (k := 1 + 9)
         #  = → int function, inline, no params
         #  k= → int function, inline, k int params; (k := 1 + 9)
         #  , → int_t
         #  * → struct
         #  ? → if
         #  ?: → if, else
         #  ?? → if, elsif
         #  ??: → if, elsif, else
         #  ?! → if not
         #  ?= → if null
         #  | → switch
         #  @+ → loop, plus
         #  @- → loop, minus
         #  @~ → loop, exit

         mr = re.search("^s[\t ]*$", self.view.substr(s0))  # s → static
         if mr:
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': "static "})
            return None

         mr = re.search("^([1-9]?);[\t ]*$", self.view.substr(s0))  # ; → void function, no params  # k; → void function, k int params; (k := 1 .. 9)
         if mr:
            s1 = " ("
            if mr.group(1) == "":
               s1 += "void"
            else:
               s1 += "int_t"
               n = int( mr.group(1))
               k = 1
               while k < n:
                  s1 += ", int_t"
                  k += 1
            s1 += ")"
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': "void ${0}" + s1 + ";\n" + "void\n" + "${0}" + s1 + "\n" + "{\n\n" + "\t;\n\n" + "\treturn;\n\n"
   ↪  + "}"})
            return None

         mr = re.search("^([1-9]?);[\t ]*$", self.view.substr(s0))  # ; → void function, no params  # k; → void function, k int params; (k := 1 .. 9)
         if mr:
            s1 = " ("
            if mr.group(1) == "":
               s1 += "void"
            else:
               s1 += "int_t"
               n = int( mr.group(1))
               k = 1
               while k < n:
                  s1 += ", int_t"
                  k += 1
            s1 += ")"
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': "void ${0}" + s1 + ";\n" + "void\n" + "${0}" + s1 + "\n" + "{\n\n" + "\t;\n\n" + "\treturn;\n\n"
   ↪  + "}"})
            return None

         mr = re.search("^([1-9]?):[\t ]*$", self.view.substr(s0))  # : → int function, no params  # k: → int function, k int params; (k := 1 .. 9)
         if mr:
            s1 = " ("
            if mr.group(1) == "":
               s1 += "void"
            else:
               s1 += "int_t"
               n = int( mr.group(1))
               k = 1
               while k < n:
                  s1 += ", int_t"
                  k += 1
            s1 += ")"
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': "int_t ${0}" + s1 + ";\n" + "int_t\n" + "${0}" + s1 + "\n" + "{\n\n" + "\t;\n\n"
   ↪  + "\treturn 0;\n\n" + "}"})
            return None

         mr = re.search("^([1-9]?)=[\t ]*$", self.view.substr(s0))  # = → int function, inline, no params  # k= → int function, inline, k int params; (k := 1 .. 9)
         if mr:
            s1 = " ("
            if mr.group(1) == "":
               s1 += "void"
            else:
               s1 += "int_t"
               n = int( mr.group(1))
               k = 1
               while k < n:
                  s1 += ", int_t"
                  k += 1
            s1 += ")"
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': "int_t ${0}" + s1 + ";\n" + "int_t\n" + "${0}" + s1 + " {\n" + "\t\t;\n"
   ↪  + "\t\treturn 0; }"})
            return None

         mr = re.search("^([\t ]*),[\t ]*$", self.view.substr(s0))  # , → int_t
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "int_t ${0}"})
            return None

         mr = re.search("^([\t ]*)\\*[\t ]*$", self.view.substr(s0))  # * → struct
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "typedef struct {\n" + s1 + "\t;\n" + s1 + "} ${0}_st, * ${0}_t;"})
            return None

         mr = re.search("^([\t ]*)\\?[\t ]*$", self.view.substr(s0))  # ? → if
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "if (${0}) {\n" + s1 + "\t;\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)\\?:[\t ]*$", self.view.substr(s0))  # ?: → if, else
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "if (${0}) {\n" + s1 + "\t;\n" + s1 + "}\n" + s1 + "else {\n" + s1 + "\t;\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)\\?\\?[\t ]*$", self.view.substr(s0))  # ?? → if, elsif
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "if (${0}) {\n" + s1 + "\t;\n" + s1 + "}\n" + s1 + "else if () {\n" + s1 + "\t;\n" + s1
   ↪  + "}"})
            return None

         mr = re.search("^([\t ]*)\\?\\?:[\t ]*$", self.view.substr(s0))  # ??: → if, elsif, else
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "if (${0}) {\n" + s1 + "\t;\n" + s1 + "}\n" + s1 + "else if () {\n" + s1 + "\t;\n" + s1
   ↪  + "}\n" + s1 + "else {\n" + s1 + "\t;\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)\\?![\t ]*$", self.view.substr(s0))  # ?! → if not
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "if (!( ${0})) { ouch(); return; }\n"})
            return None

         mr = re.search("^([\t ]*)\\?=[\t ]*$", self.view.substr(s0))  # ?= → if null
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "if (( ${0}) == NULL) { ouch(); return; }\n"})
            return None

         mr = re.search("^([\t ]*)\\|[\t ]*$", self.view.substr(s0))  # | → switch
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "switch (${0}) {\n\n" + s1 + "\tcase :\n" + s1 + "\t\t;\n" + s1 + "\t\tbreak;\n\n" + s1
   ↪  + "\tcase :\n" + s1 + "\t\t;\n" + s1 + "\t\tbreak;\n\n" + s1 + "\tdefault:\n" + s1 + "\t\t;\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)@\\+[\t ]*$", self.view.substr(s0))  # @+ → loop, plus
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "k = 0;\n" + s1 + "while (k < ${0}) {\n" + s1 + "\t;\n" + s1 + "\tk += 1;\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)@-[\t ]*$", self.view.substr(s0))  # @- → loop, minus
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "k = ${0};\n" + s1 + "while (-1 < k) {\n" + s1 + "\t;\n" + s1 + "\tk -= 1;\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)@~[\t ]*$", self.view.substr(s0))  # @~ → loop, exit
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "while (true) {\n" + s1 + "\t;\n" + s1 + "\tif (${0}) {\n" + s1 + "\t\tgoto Ll;\n\n" + s1
   ↪  + "\t}\n" + s1 + "\t;\n" + s1 + "}\n" + "Ll:"})
            return None

         pass

      elif e == ".css":

         #  css

         pass

      elif e == ".emf":

         #  emf

         pass

      elif e == ".sf" or e == ".f":

         #  forth

         pass

      elif e == ".wf" or e == ".fth":

         #  wforth

         pass

      elif e == ".lex":

         #  lex

         pass

      elif f == "makefile" or f == "Makefile" or e == ".mak" or e == ".wmk":

         #  make

         pass

      elif e == ".ocaml" or e == ".ml":

         #  ocaml

         pass

      elif e == ".python" or e == ".py":

         #  python

         pass

      elif e == ".raku" or e == ".pm":

         #  raku

         pass

      elif e == ".racket" or e == ".rkt"  or e == ".scheme" or e == ".ss" or e == ".sps" or e == ".sls" or e == ".guile" or e == ".scm" or e == ".sld":

         #  racket, scheme, guile

         #  : → define
         #  = → lambda
         #  , → let
         #  ? → if
         #  ?: → if, else
         #  ?? → if, elsif
         #  ??: → if, elsif, else
         #  @+ → loop, plus
         #  @- → loop, minus
         #  @~ → loop, cdr

         mr = re.search("^([\t ]*):[\t ]*$", self.view.substr(s0))  # : → define
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "(define (${0})\n" + s1 + "\t;\n" + s1 + ")"})
            return None

         mr = re.search("^([\t ]*)=[\t ]*$", self.view.substr(s0))  # = → lambda
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "(lambda (${0})\n" + s1 + "\t;\n" + s1 + ")"})
            return None

         mr = re.search("^([\t ]*),[\t ]*$", self.view.substr(s0))  # , → let
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "(let (\n" + s1 + "\t\t(${0})\n" + s1 + "\t)\n" + s1 + "\t;\n" + s1 + ")"})
            return None

         mr = re.search("^([\t ]*)\\?[\t ]*$", self.view.substr(s0))  # ? → if
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "(if… (${0}) (then\n" + s1 + "\t;\n" + s1 + "))"})
            return None

         mr = re.search("^([\t ]*)\\?:[\t ]*$", self.view.substr(s0))  # ?: → if, else
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "(if… (${0}) (then\n" + s1 + "\t;\n" + s1 + ")\n" + s1 + "(else\n" + s1 + "\t;\n" + s1
   ↪  + "))"})
            return None

         mr = re.search("^([\t ]*)\\?\\?[\t ]*$", self.view.substr(s0))  # ?? → if, elsif
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "(if… (${0}) (then\n" + s1 + "\t;\n" + s1 + ")\n" + s1 + "(elsif () (then\n" + s1 + "\t;\n"
   ↪  + s1 + ")))"})
            return None

         mr = re.search("^([\t ]*)\\?\\?:[\t ]*$", self.view.substr(s0))  # ??: → if, elsif, else
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "(if… (${0}) (then\n" + s1 + "\t;\n" + s1 + ")\n" + s1 + "(elsif () (then\n" + s1 + "\t;\n"
   ↪  + s1 + ")\n" + s1 + "(else\n" + s1 + "\t;\n" + s1 + ")))"})
            return None

         mr = re.search("^([\t ]*)@\\+[\t ]*$", self.view.substr(s0))  # @+ → loop, plus
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "(let loop (\n" + s1 + "\t\t(k 0)\n" + s1 + "\t)\n" + s1 + "\t(if… (< k ${0}) (then\n" + s1
   ↪  + "\t\t;\n" + s1 + "\t\t(loop (+ k 1))\n" + s1 + "\t)\n" + s1 + "\t(else\n" + s1 + "\t\t;\n" + s1 + "\t))\n" + s1 + ")"})
            return None

         mr = re.search("^([\t ]*)@-[\t ]*$", self.view.substr(s0))  # @- → loop, minus
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "(let loop (\n" + s1 + "\t\t(k ${0})\n" + s1 + "\t)\n" + s1 + "\t(if… (< 0 k) (then\n" + s1
   ↪  + "\t\t;\n" + s1 + "\t\t(loop (- k 1))\n" + s1 + "\t)\n" + s1 + "\t(else\n" + s1 + "\t\t;\n" + s1 + "\t))\n" + s1 + ")"})
            return None

         mr = re.search("^([\t ]*)@~[\t ]*$", self.view.substr(s0))  # @~ → loop, cdr
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "(let loop (\n" + s1 + "\t\t(r ${0})\n" + s1 + "\t)\n" + s1 + "\t(if… (not (null? r))
   ↪  (then\n" + s1 + "\t\t;\n" + s1 + "\t\t(loop (cdr r))\n" + s1 + "\t)\n" + s1 + "\t(else\n" + s1 + "\t\t;\n" + s1 + "\t))\n" + s1 + ")"})
            return None

         pass

      elif e == ".sql":

         #  sql

         pass

      elif e == ".swift":

         #  swift

         #  p → private
         #  s → static
         #  ; → void function, no params
         #  k; → void function, k int params; (k := 1 + 9)
         #  : → int function, no params
         #  k: → int function, k int params; (k := 1 + 9)
         #  = → int function, inline, no params
         #  k= → int function, inline, k int params; (k := 1 + 9)
         #  , → int_t
         #  e → enum
         #  * → struct
         #  c → class
         #  ? → if
         #  ?: → if, else
         #  ?? → if, elsif
         #  ??: → if, elsif, else
         #  ?! → if not
         #  ?= → if null
         #  | → switch
         #  @+ → loop, plus
         #  @- → loop, minus
         #  @~ → loop, exit
         #  @_ → loop, for

         mr = re.search("^([\t ]*)p[\t ]*$", self.view.substr(s0))  # p → private
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "private "})
            return None

         mr = re.search("^([\t ]*)s[\t ]*$", self.view.substr(s0))  # s → static
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "static "})
            return None

         mr = re.search("^([\t ]*)([1-9]?);[\t ]*$", self.view.substr(s0))  # ; → void function, no params  # k; → void function, k int params; (k := 1 .. 9)
         if mr:
            s1 = mr.group(1)
            s2 = "("
            if mr.group(2) != "":
               s2 += "_  : Int"
               n = int( mr.group(2))
               k = 1
               while k < n:
                  s2 += ", _  : Int"
                  k += 1
            s2 += ")"
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "func ${0} " + s2 + " -> Void\n" + s1 + "{\n\n" + s1 + "\treturn\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)([1-9]?):[\t ]*$", self.view.substr(s0))  # : → int function, no params  # k: → int function, k int params; (k := 1 .. 9)
         if mr:
            s1 = mr.group(1)
            s2 = "("
            if mr.group(2) != "":
               s2 += "_  : Int"
               n = int( mr.group(2))
               k = 1
               while k < n:
                  s2 += ", _  : Int"
                  k += 1
            s2 += ")"
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "func ${0} " + s2 + " -> Int\n" + s1 + "{\n\n" + s1 + "\treturn 0\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)([1-9]?)=[\t ]*$", self.view.substr(s0))  # = → int function, inline, no params  # k= → int function, inline, k int params;
   ↪  (k := 1 .. 9)
         if mr:
            s1 = mr.group(1)
            s2 = "("
            if mr.group(2) != "":
               s2 += "_  : Int"
               n = int( mr.group(2))
               k = 1
               while k < n:
                  s2 += ", _  : Int"
                  k += 1
            s2 += ")"
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "func ${0} " + s2 + " -> Int {\n" + s1 + "\t\t;\n" + s1 + "\t\treturn 0 }"})
            return None

         mr = re.search("^([\t ]*),[\t ]*$", self.view.substr(s0))  # , → Int
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "var ${0} : Int"})
            return None

         mr = re.search("^([\t ]*)e[\t ]*$", self.view.substr(s0))  # e → enum
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "enum ${0} {\n" + s1 + "\t;\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)\\*[\t ]*$", self.view.substr(s0))  # * → struct
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "struct ${0} {\n" + s1 + "\t;\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)c[\t ]*$", self.view.substr(s0))  # c → class
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "class ${0} {\n" + s1 + "\t;\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)\\?[\t ]*$", self.view.substr(s0))  # ? → if
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "if ${0} {\n" + s1 + "\t;\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)\\?:[\t ]*$", self.view.substr(s0))  # ?: → if, else
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "if ${0} {\n" + s1 + "\t;\n" + s1 + "}\n" + s1 + "else {\n" + s1 + "\t;\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)\\?\\?[\t ]*$", self.view.substr(s0))  # ?? → if, elsif
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "if ${0} {\n" + s1 + "\t;\n" + s1 + "}\n" + s1 + "else if  {\n" + s1 + "\t;\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)\\?\\?:[\t ]*$", self.view.substr(s0))  # ??: → if, elsif, else
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "if ${0} {\n" + s1 + "\t;\n" + s1 + "}\n" + s1 + "else if  {\n" + s1 + "\t;\n" + s1 + "}\n"
   ↪  + s1 + "else {\n" + s1 + "\t;\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)\\?![\t ]*$", self.view.substr(s0))  # ?! → guard
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "guard ${0} else { ouch(); return }\n"})
            return None

         mr = re.search("^([\t ]*)\\?=[\t ]*$", self.view.substr(s0))  # ?= → do try
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "do { try ${0} } catch { ouch(); return }\n"})
            return None

         mr = re.search("^([\t ]*)\\|[\t ]*$", self.view.substr(s0))  # | → switch
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "switch (${0}) {\n\n" + s1 + "\tcase :\n" + s1 + "\t\t;\n\n" + s1 + "\tcase :\n" + s1
   ↪  + "\t\t;\n\n" + s1 + "\tdefault:\n" + s1 + "\t\t;\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)@\\+[\t ]*$", self.view.substr(s0))  # @+ → loop, plus
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "k = 0\n" + s1 + "while k < ${0} {\n" + s1 + "\t;\n" + s1 + "\tk += 1\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)@-[\t ]*$", self.view.substr(s0))  # @- → loop, minus
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "k = ${0}\n" + s1 + "while -1 < k {\n" + s1 + "\t;\n" + s1 + "\tk -= 1\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)@~[\t ]*$", self.view.substr(s0))  # @~ → loop, exit
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "Ll: while true {\n" + s1 + "\t;\n" + s1 + "\tif ${0} {\n" + s1 + "\t\tbreak Ll;\n" + s1
   ↪  + "\t}\n" + s1 + "\t;\n" + s1 + "}"})
            return None

         mr = re.search("^([\t ]*)@_[\t ]*$", self.view.substr(s0))  # @_ → loop, for
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "for k in ${0} {\n" + s1 + "\t;\n" + s1 + "}"})
            return None

         pass

      elif e == ".vim" or f == ".vimrc":

         #  vim

         pass

      elif e == ".xml":

         #  xml

         pass

      elif e == ".yacc":

         #  yacc

         pass

      elif e == ".zsh" or f == ".zlogin" or f == ".zshrc":

         #  zsh

         pass

      elif e == ".html" or e == ".php" or e == ".txt" or e == ".log":

         #  text, html, php

         #  …\\ → …¯
         #  a¯ → ā
         #  A¯ → Ā
         #  e¯ → ē
         #  E¯ → Ē
         #  i¯ → ī
         #  I¯ → Ī
         #  o¯ → ō
         #  O¯ → Ō
         #  u¯ → ū
         #  U¯ → Ū
         #  y¯ → ȳ
         #  Y¯ → Ȳ
         #  oe| → œ

         mr = re.search("^(.*)([aAeEiIoOuUyY])\\\\\\\\[\t ]*$", self.view.substr(s0))  # macron
         if mr:
            s1 = mr.group(1)
            s2 = mr.group(2)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + s2 + "¯${0}"})
            return None

         mr = re.search("^(.*)a¯[\t ]*$", self.view.substr(s0))  # a macron
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "ā${0}"})
            return None

         mr = re.search("^(.*)A¯[\t ]*$", self.view.substr(s0))  # A macron
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "Ā${0}"})
            return None

         mr = re.search("^(.*)e¯[\t ]*$", self.view.substr(s0))  # e macron
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "ē${0}"})
            return None

         mr = re.search("^(.*)E¯[\t ]*$", self.view.substr(s0))  # E macron
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "Ē${0}"})
            return None

         mr = re.search("^(.*)i¯[\t ]*$", self.view.substr(s0))  # i macron
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "ī${0}"})
            return None

         mr = re.search("^(.*)I¯[\t ]*$", self.view.substr(s0))  # I macron
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "Ī${0}"})
            return None

         mr = re.search("^(.*)o¯[\t ]*$", self.view.substr(s0))  # o macron
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "ō${0}"})
            return None

         mr = re.search("^(.*)O¯[\t ]*$", self.view.substr(s0))  # O macron
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "Ō${0}"})
            return None

         mr = re.search("^(.*)u¯[\t ]*$", self.view.substr(s0))  # u macron
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "ū${0}"})
            return None

         mr = re.search("^(.*)U¯[\t ]*$", self.view.substr(s0))  # U macron
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "Ū${0}"})
            return None

         mr = re.search("^(.*)y¯[\t ]*$", self.view.substr(s0))  # y macron
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "ȳ${0}"})
            return None

         mr = re.search("^(.*)Y¯[\t ]*$", self.view.substr(s0))  # Y macron
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "Ȳ${0}"})
            return None

         mr = re.search("^(.*)oe\\|[\t ]*$", self.view.substr(s0))  # o-e ligat
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "œ${0}"})
            return None

         #      ┌───────┬───────┐
         #      │ Ü → Ă │ * → Î │
         #      │ ü → ă │ + → î │
         #  ┌───┴───┬───┴───┬───┴───┐
         #  │ Ö → Ș │ Ä → Ț │ ' → Â │
         #  │ ö → ș │ ä → ț │ # → â │
         #  └───────┴───────┴───────┘

         #  # → â
         #  ' → Â
         #  ü → ă
         #  Ü → Ă
         #  + → î
         #  * → Î
         #  ö → ș
         #  Ö → Ș
         #  ä → ț
         #  Ä → Ț

         mr = re.search("^(.*)#[\t ]*$", self.view.substr(s0))  # a circumflex
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "â${0}"})
            return None

         mr = re.search("^(.*)'[\t ]*$", self.view.substr(s0))  # A circumflex
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "Â${0}"})
            return None

         mr = re.search("^(.*)ü[\t ]*$", self.view.substr(s0))  # a breve
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "ă${0}"})
            return None

         mr = re.search("^(.*)Ü[\t ]*$", self.view.substr(s0))  # A breve
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "Ă${0}"})
            return None

         mr = re.search("^(.*)\\+[\t ]*$", self.view.substr(s0))  # i circumflex
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "î${0}"})
            return None

         mr = re.search("^(.*)\\*[\t ]*$", self.view.substr(s0))  # I circumflex
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "Î${0}"})
            return None

         mr = re.search("^(.*)ö[\t ]*$", self.view.substr(s0))  # s comma
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "ș${0}"})
            return None

         mr = re.search("^(.*)Ö[\t ]*$", self.view.substr(s0))  # S comma
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "Ș${0}"})
            return None

         mr = re.search("^(.*)ä[\t ]*$", self.view.substr(s0))  # t comma
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "ț${0}"})
            return None

         mr = re.search("^(.*)Ä[\t ]*$", self.view.substr(s0))  # T comma
         if mr:
            s1 = mr.group(1)
            self.view.replace(edit, s0, "")
            self.view.run_command('insert_snippet', {'contents': s1 + "Ț${0}"})
            return None

         #    [   [[  [\  []  [|  \   \[  \\  \]  \|  ]   ][  ]\  ]]  ]|  aa| ae| dh| ij| nh| oe| s|  th| :
         #  - --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- :
         #  a á   ã       â       ä       a¯          à           ă       å                               ;
         #  A Á   Ã       Â       Ä       A¯          À           Ă       Å                               ;
         #  c         ç                                   č                                               ;
         #  C         Ç                                   Č                                               ;
         #  d                                                                     ð                       ;
         #  D                                                                     Ð                       ;
         #  e é           ê       ë       e¯          è   ě       ĕ           æ                           ;
         #  E É           Ê       Ë       E¯          È   Ě       Ĕ           Æ                           ;
         #  i í                   ï       i¯                      ĭ                                       ;
         #  I Í                   Ï       I¯                      Ĭ                                       ;
         #  j                                                                         ij                   ;
         #  J                                                                         IJ                   ;
         #  n                                                                             ñ               ;
         #  N                                                                             Ñ               ;
         #  o ó   õ       ô       ö   ő   o¯      ø               ŏ                           œ           ;
         #  O Ó   Õ       Ô       Ö   Ő   O¯      Ø               Ŏ                           Œ           ;
         #  r                                             ř                                               ;
         #  R                                             Ř                                               ;
         #  s             ŝ   ș                           š                                       ß       ;
         #  S             Ŝ   Ș                           Š                                               ;
         #  t                 ț                                                                       þ   ;
         #  T                 Ț                                                                       Þ   ;
         #  u ú           û       ü   ű   u¯                      ŭ                                       ;
         #  U Ú           Û       Ü   Ű   U¯                      Ŭ                                       ;
         #  y                     ÿ       y¯                                                              ;
         #  Y                     Ÿ       Y¯                                                              ;
         #  z                                             ž                                               ;
         #  Z                                             Ž                                               ;

         if e == ".html" or e == ".php":

            #  html, php

            #  nbsp
            #  … → ellipsis
            #  – → non-breaking hyphen
            #  ^l → right
            #  ^k → up
            #  ^h → left
            #  ^j → down
            #  ^n → line-break
            #  <> → quotes
            #  -- → timestamp
            #  $… → p, pre, p

            mr = re.search("^([\t ]*) [\t ]*$", self.view.substr(s0))  # nbsp
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "&nbsp;${0}"})
               return None

            mr = re.search("^([\t ]*)…[\t ]*$", self.view.substr(s0))  # ellipsis
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "&#8230;${0}"})
               return None

            mr = re.search("^([\t ]*)–[\t ]*$", self.view.substr(s0))  # non-breaking hyphen
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "&#8209;${0}"})
               return None

            mr = re.search("^([\t ]*)\\^l[\t ]*$", self.view.substr(s0))  # right
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "&#8594;${0}"})
               return None

            mr = re.search("^([\t ]*)\\^k[\t ]*$", self.view.substr(s0))  # up
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "&#8592;${0}"})
               return None

            mr = re.search("^([\t ]*)\\^h[\t ]*$", self.view.substr(s0))  # left
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "&#8593;${0}"})
               return None

            mr = re.search("^([\t ]*)\\^j[\t ]*$", self.view.substr(s0))  # down
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "&#8595;${0}"})
               return None

            mr = re.search("^([\t ]*)\\^n[\t ]*$", self.view.substr(s0))  # line-break
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "&#8618;${0}"})
               return None

            mr = re.search("^([\t ]*)<>[\t ]*$", self.view.substr(s0))  # quotes
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "&#2849;&nbsp;${0}&nbsp;&#2850;"})
               return None

            mr = re.search("^([\t ]*)--[\t ]*$", self.view.substr(s0))  # timestamp
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "<p class=\"timestamp\">\n" + s1 + "\t" + "&#8212;&nbsp;" + time.strftime("%Y")
   ↪  + "&#8209;" + time.strftime("${0}%m%d," + "&nbsp;") + time.strftime("%Hh%M") + ";\n" + s1 + "</p>"})
               return None

            mr = re.search("^([\t ]*)(\\$+)(#(\\$+))?[\t ]*$", self.view.substr(s0))  # p, pre, p
            if mr:
               s1 = mr.group(1)
               s2 = s1 + "<p class=\"first\">\n" + s1 + "\t;\n" + s1 + "</p>\n"
               n = len(mr.group(2))
               k = 1
               while k < n:
                  s2 += s1 + "\t<p>\n" + s1 + "\t;\n" + s1 + "</p>\n"
                  k += 1
               s3 = ""
               if not mr.group(3) == "":
                  s3 = s1 + "<pre>\n\n&<>\n${0}\n&<>\n" + "</pre>\n" + s1 + "<p class=\"first\">\n" + s1 + "\t;\n" + s1 + "</p>"
                  n = len(mr.group(4))
                  k = 1
                  while k < n:
                     s3 += "\n" + s1 + "<p>\n" + s1 + "\t;\n" + s1 + "</p>"
                     k += 1
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s2 + s3})
               return None

            pass

         elif e == ".txt" or e == ".log":

            #  text

            #  ι\ → ϊ
            #  Ι\ → Ϊ
            #  υ\ → ϋ
            #  Υ\ → Ϋ
            #  ί\ → ΐ
            #  ύ\ → ΰ

            mr = re.search("^(.*)oe\\|[\t ]*$", self.view.substr(s0))  # o-e ligat
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "œ${0}"})
               return None

            mr = re.search("^(.*)([aAeEiIoOuUyY])\\\\\\\\[\t ]*$", self.view.substr(s0))  # macron
            if mr:
               s1 = mr.group(1)
               s2 = mr.group(2)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + s2 + "¯${0}"})
               return None

            mr = re.search("^(.*)ι\\\\[\t ]*$", self.view.substr(s0))  # iota dialytika
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "ϊ${0}"})
               return None

            mr = re.search("^(.*)Ι\\\\[\t ]*$", self.view.substr(s0))  # upper iota dialytika
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "Ϊ${0}"})
               return None

            mr = re.search("^(.*)υ\\\\[\t ]*$", self.view.substr(s0))  # upsilon dialytika
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "ϋ${0}"})
               return None

            mr = re.search("^(.*)Υ\\\\[\t ]*$", self.view.substr(s0))  # upper upsilon dialytika
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "$Ϋ{0}"})
               return None

            mr = re.search("^(.*)ί\\\\[\t ]*$", self.view.substr(s0))  # iota tonos dialytika
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "ΐ${0}"})
               return None

            mr = re.search("^(.*)ύ\\\\[\t ]*$", self.view.substr(s0))  # upsilon tonons dialytika
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "ΰ${0}"})
               return None

            #  nbsp
            #  – → non-breaking hyphen
            #  ^n → line-break
            #  <> → quotes
            #  -- → timestamp

            mr = re.search("^([\t ]*) [\t ]*$", self.view.substr(s0))  # nbsp
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "\u00a0${0}"})
               return None

            mr = re.search("^([\t ]*)–[\t ]*$", self.view.substr(s0))  # non-breaking hyphen
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "\u2011${0}"})
               return None

            mr = re.search("^([\t ]*)\\^n[\t ]*$", self.view.substr(s0))  # line-break
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "\u21aa${0}"})
               return None

            mr = re.search("^([\t ]*)<>[\t ]*$", self.view.substr(s0))  # quotes
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "\u2039 ${0} \u203a"})
               return None

            mr = re.search("^([\t ]*)--[\t ]*$", self.view.substr(s0))  # timestamp
            if mr:
               s1 = mr.group(1)
               self.view.replace(edit, s0, "")
               self.view.run_command('insert_snippet', {'contents': s1 + "\u2014" + time.strftime(" %Y") + "\u2011" + time.strftime("%m%d, %Hh%M") + ";${0}"})
               return None

            pass

#  snippet.py
%

As an experienced user, you know that with things like that, one can only see a current snapshot.  They are meant to adjust over time to better meet your habits and tastes.
I'm glad that now it is once mentioned.  What I did not show you, are the notes I have made to make it easy when using a new device for the first time; or, in case of one which does not happen to be a Mac, when a new distribution is installed.
Hey, this looks nice, too.


% mkdir -p ~/Library/Racket/8.12
% cd !$
% ln -s ~/devel/proto collects
% lsl
…
% racket -v
Welcome to Racket v8.12 [cs].
% racket -e '(display #\;) (newline)'
;
% racket -e '(display #\u26b8) (newline)'
⚸
% port search --name --line --glob ocaml
ocaml	4.14.1	lang ocaml	Compiler and libraries for the OCaml programming language
% port info ocaml
…
% sudo port install ocaml
…
% sudo port upgrade outdated
…
% sudo port clean --dist ocaml
…
% port installed
The following ports are currently installed:
  ocaml @4.14.1_0 (active)
% whereis ocaml
ocaml: /opt/local/bin/ocaml /opt/local/share/man/man1/ocaml.1.gz
% ocaml --version
The OCaml toplevel, version 4.14.1
% ocaml -e 'print_string ";"; print_newline ();'
;
% alias py
py=/usr/bin/python3
% py -V
Python 3.9.6
% py -c 'print(";")'
;
% alias pim
pim='/usr/bin/python3 -im '\''aej.daejana'\'
% pim
>>> phi
1.618033988749895
>>> phi-1
0.6180339887498949
>>> 1/phi
0.6180339887498948
>>> 100/phi
61.80339887498948
>>> 100-100/phi
38.19660112501052
>>> 100/phi/(100-100/phi)
1.6180339887498947
>>> "{0:.1f}".format(floor( (phi-0.995)*100))
'62.0'
>>> "{0:d}".format(int( (phi-0.995)*100))
'62'
>>> "{0:.1f}".format(floor( (100-(phi-0.995)*100)+0.5))
'38.0'
>>> "{0:d}".format(int( (100-(phi-0.995)*100)+0.5))
'38'
>>> ^D
%