Skip to content

Instantly share code, notes, and snippets.

@nfunato
Last active September 19, 2021 10:18
Show Gist options
  • Select an option

  • Save nfunato/43f8117594fdc99af37e46afbfec9133 to your computer and use it in GitHub Desktop.

Select an option

Save nfunato/43f8117594fdc99af37e46afbfec9133 to your computer and use it in GitHub Desktop.
\ Usage:
\ - In xxx.fth, the first three lines are something like:
\ anew --MODULE-NAME--
\ : SRCFILE s" xxx.fth" ;
\ ' SRCFILE set-srcfile
\ -----------------------------------------------------------------------
\ "ANEW" from Wil Baden's "ToolBelt 2002" at www.wilbaden.com/neil_bawd/,
\ where the index describes the code is sharable
: possibly ( "name" -- ) bl word find ?dup and if execute then ;
: anew ( "name" -- ) >in @ possibly >in ! marker ;
\ -----------------------------------------------------------------------
\ "EDITOR" which I wrote, using gforth words "INCLUDED" and "SYSTEM"
\ (forth.vim is from www.vim.org/scripts/script.php?script_id=1564)
defer (srcfile) ( -- c-addr u )
: set-srcfile ( xt -- ) is (srcfile) ;
: append' ( fr u2 to u1 -- to u1+u2 ) over >r tuck + -rot over + >r move 2r> ;
\ append ( fr u2 to-cs -- ) count append' swap c! ; \ update to-cs len
: concat ( to u1 fr u2 -- to u1+u2 ) 2swap append' ;
: edcmd0 s" vim -S ~/home/vim/forth.vim " ;
: edcmd pad 0 edcmd0 concat (srcfile) concat ;
: ZZ (srcfile) included ; \ load editor target
: editor edcmd system ZZ ; \ do ZZ after quiting the editor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment