From f0bfc94261317484b2f483c2ae0c9d8ee9d5d188 Mon Sep 17 00:00:00 2001 From: slava Date: Sat, 21 Oct 2006 05:54:24 +0000 Subject: [PATCH] Clean up contrib/vim and contrib/process --- contrib/README.txt | 2 +- contrib/process/load.factor | 1 - contrib/process/os-unix.factor | 5 ++++- contrib/process/os-windows.factor | 14 ++++++++------ contrib/process/process.factor | 3 --- contrib/vim/generate-vim-syntax.factor | 10 ++++++++++ contrib/vim/load.factor | 2 +- contrib/vim/vim.factor | 15 ++++++--------- contrib/vim/vim.facts | 10 +++++++--- 9 files changed, 37 insertions(+), 25 deletions(-) delete mode 100644 contrib/process/process.factor create mode 100644 contrib/vim/generate-vim-syntax.factor diff --git a/contrib/README.txt b/contrib/README.txt index 3bba500626..bdcd884c64 100644 --- a/contrib/README.txt +++ b/contrib/README.txt @@ -37,7 +37,7 @@ Available libraries: - math -- extended math library (Doug Coleman, Slava Pestov) - parser-combinators -- Haskell-style parser combinators (Chris Double) - postgresql -- PostgreSQL binding (Doug Coleman) -- process -- Run external programs (Slava Pestov) +- process -- Run external programs (Slava Pestov, Doug Coleman) - random-tester -- Random compiler tester (Doug Coleman) - rss -- Code to retrieve and parse an RSS2 file (Chris Double) - sequences -- Non-core sequence words (Eduardo Cavazos) diff --git a/contrib/process/load.factor b/contrib/process/load.factor index 0610e62f28..4a32d2dfb8 100644 --- a/contrib/process/load.factor +++ b/contrib/process/load.factor @@ -3,5 +3,4 @@ USING: kernel ; PROVIDE: contrib/process { { "os-unix.factor" [ unix? ] } { "os-windows.factor" [ windows? ] } - "process.factor" } ; diff --git a/contrib/process/os-unix.factor b/contrib/process/os-unix.factor index 821abc1ddd..5ee05aed74 100644 --- a/contrib/process/os-unix.factor +++ b/contrib/process/os-unix.factor @@ -1,5 +1,6 @@ IN: process -USING: compiler io io-internals kernel parser generic ; +USING: compiler io io-internals kernel parser generic +sequences ; LIBRARY: libc FUNCTION: int system ( char* command ) ; @@ -9,6 +10,8 @@ FUNCTION: int pclose ( void* file ) ; : run-process ( string -- ) system io-error ; : run-detached ( string -- ) " &" append run-process ; +! Help me implement the equivalent feature on Windows, please... + TUPLE: process-stream pipe ; C: process-stream ( command mode -- stream ) diff --git a/contrib/process/os-windows.factor b/contrib/process/os-windows.factor index 126e604296..a71eba989d 100644 --- a/contrib/process/os-windows.factor +++ b/contrib/process/os-windows.factor @@ -1,13 +1,15 @@ IN: process -USING: alien compiler io io-internals kernel math parser generic win32-api ; +USING: alien compiler io io-internals kernel math parser generic +win32-api ; : (run-process) ( string flag -- ) - >r f swap - f f 0 r> f f - "STARTUPINFO" "STARTUPINFO" c-size over set-STARTUPINFO-cb - "PROCESS_INFORMATION" CreateProcess zero? [ win32-error ] when ; + >r f swap f f 0 r> f f + "STARTUPINFO" + "STARTUPINFO" c-size over set-STARTUPINFO-cb + "PROCESS_INFORMATION" CreateProcess + win32-error=0 ; -: run-process +: run-process ( string -- ) 0 (run-process) ; : run-detached ( string -- ) diff --git a/contrib/process/process.factor b/contrib/process/process.factor deleted file mode 100644 index 16b68b005c..0000000000 --- a/contrib/process/process.factor +++ /dev/null @@ -1,3 +0,0 @@ -IN: process -USING: compiler io io-internals kernel parser generic ; - diff --git a/contrib/vim/generate-vim-syntax.factor b/contrib/vim/generate-vim-syntax.factor new file mode 100644 index 0000000000..5becf3507c --- /dev/null +++ b/contrib/vim/generate-vim-syntax.factor @@ -0,0 +1,10 @@ +! Generate a new factor.vim file for syntax highlighting +REQUIRES: contrib/httpd ; + +IN: vim + +USING: embedded io ; + +"contrib/vim/factor.vim.fgen" resource-path +"contrib/vim/factor.vim" resource-path +embedded-convert diff --git a/contrib/vim/load.factor b/contrib/vim/load.factor index f321cc4b8f..2aabad9fae 100644 --- a/contrib/vim/load.factor +++ b/contrib/vim/load.factor @@ -1,4 +1,4 @@ -REQUIRES: contrib/httpd contrib/process ; +REQUIRES: contrib/process ; PROVIDE: contrib/vim { "vim.factor" "vim.facts" diff --git a/contrib/vim/vim.factor b/contrib/vim/vim.factor index 0372ec13f4..c49e2fa829 100644 --- a/contrib/vim/vim.factor +++ b/contrib/vim/vim.factor @@ -1,8 +1,9 @@ IN: vim -USING: definitions embedded io kernel namespaces parser prettyprint process -sequences ; +USING: definitions io kernel namespaces parser prettyprint +process sequences ; SYMBOL: vim-path +SYMBOL: vim-detach "vim" vim-path set-global @@ -10,15 +11,11 @@ SYMBOL: vim-path [ "\"" % vim-path get % "\" \"" % swap % "\" +" % # ] "" make ; : vim-location ( file line -- ) - vim-command run-process ; + vim-command + vim-detach get-global + [ run-detached ] [ run-process ] if ; : vim ( spec -- ) - #! Edit the file in vim. Rerun the file if the timestamp is changed. where first2 vim-location ; [ vim-location ] edit-hook set-global - -: vim-syntax - #! Generate a new factor.vim file for syntax highlighting - "contrib/vim/factor.vim.fgen" "factor.vim" embedded-convert ; - diff --git a/contrib/vim/vim.facts b/contrib/vim/vim.facts index d78eb25d75..a6a54527d7 100644 --- a/contrib/vim/vim.facts +++ b/contrib/vim/vim.facts @@ -2,12 +2,16 @@ IN: vim USING: definitions help io words ; ARTICLE: { "vim" "vim" } "Vim support" -"This module makes the " { $link edit } " word work with Vim. The " -{ $link vim-path } " variable contains the name of the vim executable. The default " { $link vim-path } " is \"vim\". For Windows, place the following example .factor-boot-rc in the directory returned by " { $link home } ":" +"This module makes the " { $link edit } " word work with Vim by setting the " { $link edit-hook } " global variable to call " { $link vim-location } ". The " { $link vim-path } " variable contains the name of the vim executable. The default " { $link vim-path } " is " { $snippet "\"vim\"" } "." +$terpri +"If you intend to use this module regularly, it helps to have it load during stage 2 bootstrap. On Windows, place the following example " { $snippet ".factor-boot-rc" } " in the directory returned by " { $link home } ":" { $code "USING: modules namespaces ;" "REQUIRES: contrib/vim ;" "USE: vim" "\"d:\\program files\\vim\\vim70\\gvim\" vim-path set-global" -} ; +} +"On Unix, you may omit the last line if " { $snippet "\"vim\"" } " is in your " { $snippet "$PATH" } "." +$terpri +"If you are running the terminal version of Vim, you want it to block Factor until exiting, but for GVim the opposite is desired, so that one can work in Factor and GVim concurrently. The " { $link vim-detach } " global variable can be set to " { $link t } " to detach the Vim process. The default is " { $link f } "." ;