[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: Elias Mårtenson
Subject: Re: [Bug-apl] Near Proof of concept of an )edit somefunction_name
Date: Tue, 22 Mar 2016 09:50:02 +0800

I have to admit that the discussion about )edit misses the greater point, one that I believe is at least partially solved by gnu-apl-mode, which is better integration with development environments.

If you want to have an easy way of editing functions, or even getting realtime code navigation, why not use exiting tools to do that? It's a lot better than opening vi externally anyway.

OK, enough blowing my own horn here. There was another project that aimed to provide something similar, using a dedicated application called aplwrap. What happened to that?

On 22 Mar 2016 09:39, "Christian Robert" <address@hidden> wrote:

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]