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

I used it (aplwrap) and use it from time to time especially when I have to make 
a lot of mods to a function,
but aplwrap tend to coredump too often, forgetting my whole evening 
modifications too many times.

I like the interface and would be able to live with it, but near every long 
session end up with a coredump and
nothing being saved. (doing ")save" every 2 minutes is not really a solution 
when your brain is concentrating on a problem, near solved)

aplwrap is good if not excellent if it would not abort so often.

Xtian.

On 2016-03-21 21:50, Elias Mårtenson wrote:
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 
<mailto:address@hidden>> wrote:

    Kacper,

    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.

    Xtian.


    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.


        ]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
        ∇





reply via email to

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