[Top][All Lists]

[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: Christian Robert
Subject: Re: [Bug-apl] Near Proof of concept of an )edit somefunction_name
Date: Mon, 21 Mar 2016 21:38:38 -0400
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0


I love the way ∇EDIT⍙OPEN solve the problem of "input is not a tty" said by ")host 
vi function_file"

I *still* think that this ")edit function_name" should be right into the 
interpretor functionnality.

Ideally it should invoke EDITOR in a new terminal window (fork() and 
exec(EDITOR,parms,...)) and
do things into the main interpretor like (but not limited to):

 a) check for the modification timestamp of the edited files and if they are 
modified, try Quad-FX thems
 b) check if the EDITOR processes (I assume you may edit several files at a 
time in several windows) are still alive;
    if not, stop watching for modification timestamp of the edited file by this 
EDITOR process
 c) wait for event from the keyboard and execute thems if any (permitting to async 
")reset" if needed while EDITOR(s) is/are still running)
 d) sleep a few millisec(at least 10 to 100) and goto (a)

the goal would be to:

 the main interpretor is still running and not blocked by the invoking of the 
EDITOR(s) (but watching thems for saved file or exit)
 permitting to be able to issue commands and make some tests in the main interpretor 
window. Even issuing other ")edit"

 Asynchroniously try to Quad-FX the files. If it fail, leave a chance to EDITOR 
to fix the syntax error
 rather than completely forgot the last modifications.

you get the idea ?

that would be in an ideal world.


On 2016-03-19 16:30, Kacper Gutowski wrote:
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.


  ⍝ Edit a function or operator in external editor.
   ⍎(2>≡S)/"']EDIT NAME' ⋄ →0"
   ⍎(~(⎕NC S)∊0 3 4)/"'Bad name ',S ⋄ →0"
   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 ⎕FIO[23]FD
   ⊣ ⎕FIO[4]FD
   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

  ⍝ Open a file in external editor.
   STTY←⎕IO⊃⍎')HOST stty -g'
   ⊣⍎')HOST >/dev/tty stty sane'
   ⊣⍎')HOST >/dev/tty ',EDIT⍙EDITOR,' ',FILE
   ⊣⍎')HOST >/dev/tty stty ',STTY

reply via email to

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