bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] Near Proof of concept of an )edit somefunction_name


From: Alexey Veretennikov
Subject: Re: [Bug-apl] Near Proof of concept of an )edit somefunction_name
Date: Fri, 23 Dec 2016 00:14:07 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (darwin)

Hi,

Resurrecting the old thread just to say thanks and what this solution
works for me on my Sharp Zaurus C3000, where I don't have enough 
CPU/RAM/keyboard
to run the modern Emacs. I've done couple of changes since I'm on X and
can start vim in the external terminal (separate session of rxvt) as
well as some more error-handlings, but I believe your approach is a way
to go and could be included as an extension to original GNU APL.
Even better if it could be used with some ')ed' command without the
neccessity to create custom command.


Kacper Gutowski <address@hidden> writes:

> I recall there being some similar attempts presented on this list but
> I couldn't find working example so I hacked up the following.  It has
> few rough edges and wasn't tested thoroughly but appears to work.
>
>
> ]USERCMD ]EDIT EDIT⍙ 1
>
> ∇S EDIT⍙ Q;FN;FD
>  ⍝ Edit a function or operator in external editor.
>   ⍎(2>≡S)/"']EDIT NAME' ⋄ →0"
>   S←(⎕IO+1)⊃S
>   ⍎(~(⎕NC S)∊0 3 4)/"'Bad name ',S ⋄ →0"
>   FN←'/tmp/',S,'.',⍕↑⎕AI
>   FD←'w'⎕FIO[3] 18⎕CR FN
>   ⍎(0>FD)/"'Can''t open file ',FN ⋄ →0"
>   Q←(⎕IO+0≠⎕NC S)⊃(⍉⍪S)(⎕CR S)
>   Q←{⍵↓⍨-+/∧\⌽' '=⍵}¨⊂[⎕IO+1]Q
>   Q←∊Q,¨⊂"\n"
>   ⊣ Q ⎕FIO[23]FD
>   ⊣ ⎕FIO[4]FD
>   EDIT⍙OPEN FN
>   Q←⎕FIO[26] 18⎕CR FN
>   ⊣ ⎕FIO[19] 18⎕CR FN
>   ⍎(~' '≡↑0⍴Q)/"'Filed to read ',FN ⋄ →0"
>   ⍎(0=⍴Q)/"'Empty' ⋄ →0"
>   ⍎(0=⍴Q←19⎕CR Q)/"'Encoding error' ⋄ →0"
>   ⎕FX (~"\n"=Q)⊂Q
>
>
> ⍝ External editor to use; defaults to $EDITOR or vi
> EDIT⍙EDITOR←,⎕ENV'EDITOR'
> EDIT⍙EDITOR←(1+EDIT⍙EDITOR⍳⊂'EDITOR')⊃EDIT⍙EDITOR,⍬'vi'
>
> ∇EDIT⍙OPEN FILE;STTY
>  ⍝ Open a file in external editor.
>   ((''''=FILE)/FILE)←⊂"'\''"
>   FILE←'''',∊FILE,''''
>   STTY←⎕IO⊃⍎')HOST stty -g'
>   ⊣⍎')HOST >/dev/tty stty sane'
>   ⊣⍎')HOST >/dev/tty ',EDIT⍙EDITOR,' ',FILE
>   ⊣⍎')HOST >/dev/tty stty ',STTY
>

-- 
Br,
/Alexey



reply via email to

[Prev in Thread] Current Thread [Next in Thread]