From ddfea0cf5e0a60b028bf423a29452afbce3c61e9 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info> Date: Wed, 14 Jan 2009 13:09:50 -0600 Subject: [PATCH 1/5] Add git-tool.remote --- extra/git-tool/remote/remote.factor | 392 ++++++++++++++++++++++++++++ 1 file changed, 392 insertions(+) create mode 100644 extra/git-tool/remote/remote.factor diff --git a/extra/git-tool/remote/remote.factor b/extra/git-tool/remote/remote.factor new file mode 100644 index 0000000000..e5291a8459 --- /dev/null +++ b/extra/git-tool/remote/remote.factor @@ -0,0 +1,392 @@ + +USING: accessors calendar git-tool git-tool io.directories +io.monitors io.pathnames kernel locals math namespaces +sequences splitting system threads ui ui.gadgets +ui.gadgets.buttons ui.gadgets.labels ui.gadgets.packs ; + +USING: git-tool ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +IN: git-tool.remote + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +TUPLE: <git-remote-gadget> < pack + repository + branch + remote + remote-branch + fetch-period + push + closed + last-refresh ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: current-branch ( REPO -- branch ) + { "git" "branch" } git-process stdout>> [ "* " head? ] find nip 2 tail ; + +: list-branches ( REPO -- branches ) + { "git" "branch" } git-process stdout>> + [ empty? not ] filter + [ 2 tail ] map ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: list-remotes ( REPO -- remotes ) + { "git" "remote" } git-process stdout>> [ empty? not ] filter ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +:: list-remote-branches ( REPO REMOTE -- branches ) + [let | OUT [ REPO { "git" "remote" "show" REMOTE } git-process stdout>> ] | + + " Tracked remote branches" OUT member? + [ + OUT + " Tracked remote branches" OUT index 1 + tail first " " split + [ empty? not ] filter + ] + [ + OUT + OUT [ " New remote branches" head? ] find drop + 1 + tail first " " split + [ empty? not ] filter + ] + if ] ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +:: refresh-git-remote-gadget ( GADGET -- ) + + [let | REPO [ GADGET repository>> ] | + + GADGET clear-gadget + + GADGET + + ! Repository label + + "Repository: " REPO [ current-directory get ] with-directory append + <label> + add-gadget + + ! Branch button + + <shelf> + + "Branch: " <label> add-gadget + + REPO current-branch + [ + drop + + <pile> + REPO list-branches + + [| BRANCH | + + BRANCH + [ + drop + REPO { "git" "checkout" BRANCH } git-process popup-if-error + GADGET refresh-git-remote-gadget + ] + <bevel-button> add-gadget + + ] + each + + "Select a branch" open-window + + ] + <bevel-button> add-gadget + + add-gadget + + ! Remote button + + <shelf> + + "Remote: " <label> add-gadget + + GADGET remote>> + [ + drop + + <pile> + + REPO list-remotes + + [| REMOTE | + + REMOTE + [ + drop + GADGET REMOTE >>remote drop + GADGET "master" >>remote-branch drop + GADGET refresh-git-remote-gadget + ] + <bevel-button> add-gadget + + ] + each + + "Select a remote" open-window + + ] + <bevel-button> add-gadget + + add-gadget + + ! Remote branch button + + <shelf> + + "Remote branch: " <label> add-gadget + + GADGET remote-branch>> + [ + drop + + <pile> + + REPO GADGET remote>> list-remote-branches + + [| REMOTE-BRANCH | + + REMOTE-BRANCH + [ + drop + GADGET REMOTE-BRANCH >>remote-branch drop + GADGET refresh-git-remote-gadget + ] + <bevel-button> add-gadget + ] + + each + + "Select a remote branch" open-window + + ] + <bevel-button> add-gadget + + add-gadget + + ! Fetch button + + "Fetch" + [ + drop + [let | REMOTE [ GADGET remote>> ] | + REPO { "git" "fetch" REMOTE } git-process popup-if-error ] + + GADGET refresh-git-remote-gadget + ] + <bevel-button> add-gadget + + ! Available changes + + [let | REMOTE [ GADGET remote>> ] + REMOTE-BRANCH [ GADGET remote-branch>> ] | + + [let | ARG [ { ".." REMOTE "/" REMOTE-BRANCH } concat ] | + + [let | PROCESS [ REPO { "git" "log" ARG } git-process ] | + + PROCESS stdout>> + [ + <shelf> + + "Changes available:" <label> add-gadget + + "View" + [ + drop + PROCESS popup-process-window + ] + <bevel-button> add-gadget + + "Merge" + [ + drop + + [let | ARG [ { REMOTE "/" REMOTE-BRANCH } concat ] | + + REPO { "git" "merge" ARG } git-process popup-process-window + + ] + + GADGET refresh-git-remote-gadget + + ] + <bevel-button> add-gadget + + add-gadget + + ] + when + + ] ] ] + + + ! Pushable changes + + [let | REMOTE [ GADGET remote>> ] + REMOTE-BRANCH [ GADGET remote-branch>> ] | + + [let | ARG [ { REMOTE "/" REMOTE-BRANCH ".." } concat ] | + + [let | PROCESS [ REPO { "git" "log" ARG } git-process ] | + + PROCESS stdout>> + [ + <shelf> + + "Pushable changes: " <label> add-gadget + + "View" + [ + drop + PROCESS popup-process-window + ] + <bevel-button> add-gadget + + "Push" + [ + drop + + REPO { "git" "push" REMOTE REMOTE-BRANCH } + git-process + popup-process-window + + GADGET refresh-git-remote-gadget + + ] + <bevel-button> add-gadget + + add-gadget + + ] + when + + ] ] ] + + drop + + ] ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +:: start-fetch-thread ( GADGET -- ) + + GADGET f >>closed drop + + [ + + [ + + GADGET closed>> + [ f ] + [ + [let | REPO [ GADGET repository>> ] + REMOTE-BRANCH [ GADGET remote-branch>> ] | + + REPO { "git" "fetch" REMOTE-BRANCH } git-process drop ] + + GADGET fetch-period>> sleep + + t + ] + if + + + ] + loop + + ] + + in-thread ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +:: start-monitor-thread ( GADGET -- ) + + GADGET f >>closed drop + + [ + [ + [let | MONITOR [ GADGET repository>> t <monitor> ] | + + [ + GADGET closed>> + [ f ] + [ + + [let | PATH [ MONITOR next-change drop ] | + + ".git" PATH subseq? + [ ] + [ + micros + GADGET last-refresh>> 0 or - + 1000000 > + [ + GADGET micros >>last-refresh drop + GADGET refresh-git-remote-gadget + ] + when + ] + if ] + + t + + ] + if + ] + loop + ] + ] + with-monitors + ] + in-thread ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +M: <git-remote-gadget> pref-dim* ( gadget -- dim ) drop { 500 500 } ; + +M:: <git-remote-gadget> graft* ( GADGET -- ) + GADGET start-fetch-thread + GADGET start-monitor-thread ; + +M:: <git-remote-gadget> ungraft* ( GADGET -- ) GADGET t >>closed drop ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +:: git-remote-tool ( REPO -- ) + + <git-remote-gadget> new-gadget + + { 0 1 } >>orientation + 1 >>fill + + REPO >>repository + + "origin" >>remote + + "master" >>remote-branch + + 5 minutes >>fetch-period + + dup refresh-git-remote-gadget + + "git-remote-tool" open-window ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: factor-git-remote-tool ( -- ) "resource:" git-remote-tool ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +MAIN: factor-git-remote-tool \ No newline at end of file From 0cb58510bb49c52a983a7dd8c94f1f5dd2e70e30 Mon Sep 17 00:00:00 2001 From: Tim Allen <screwtape@froup.com> Date: Wed, 14 Jan 2009 00:05:38 +1100 Subject: [PATCH 2/5] Move Vim syntax-highlighter to a Vim subdirectory. This makes it easier to describe where the syntax-highlighting file should be installed, and allows us to easily package other Vim runtime files. This commit also adds a README that describes how to regenerate the syntax file. --- .../generate-syntax/generate-syntax.factor | 2 +- misc/vim/README | 25 +++++++++++++++++++ misc/{ => vim/syntax}/factor.vim | 0 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 misc/vim/README rename misc/{ => vim/syntax}/factor.vim (100%) diff --git a/basis/editors/vim/generate-syntax/generate-syntax.factor b/basis/editors/vim/generate-syntax/generate-syntax.factor index 74b04c346f..061e938dcf 100644 --- a/basis/editors/vim/generate-syntax/generate-syntax.factor +++ b/basis/editors/vim/generate-syntax/generate-syntax.factor @@ -4,7 +4,7 @@ IN: editors.vim.generate-syntax : generate-vim-syntax ( -- ) "misc/factor.vim.fgen" resource-path <fhtml> - "misc/factor.vim" resource-path + "misc/vim/syntax/factor.vim" resource-path template-convert ; MAIN: generate-vim-syntax diff --git a/misc/vim/README b/misc/vim/README new file mode 100644 index 0000000000..1e82708ba4 --- /dev/null +++ b/misc/vim/README @@ -0,0 +1,25 @@ +Vim support for Factor +---------------------- + +This directory contains various support files that make editing Factor code +more pleasant in Vim. The file-layout exactly matches the Vim runtime +structure, so you can install them by copying the contents of this directory +into ~/.vim/ or the equivalent path on other platforms (Open Vim and type +":help 'runtimepath'" for details). + +The current set of files is as follows: + + syntax/factor.vim + Syntax highlighting for Factor code. + +Note: The syntax-highlighting file is automatically generated to include the +names of all the vocabularies Factor knows about. To regenerate it manually, +run the following code in the listener: + + USE: editors.vim.generate-syntax + + generate-vim-syntax + +...or run it from the command-line: + + factor -run=editors.vim.generate-syntax diff --git a/misc/factor.vim b/misc/vim/syntax/factor.vim similarity index 100% rename from misc/factor.vim rename to misc/vim/syntax/factor.vim From 2e731c63f21090c508b9406015633b94138b4d6c Mon Sep 17 00:00:00 2001 From: Tim Allen <screwtape@froup.com> Date: Wed, 14 Jan 2009 00:31:22 +1100 Subject: [PATCH 3/5] Mention Vim support files in the Vim integration documentation. --- basis/editors/gvim/gvim.factor | 3 +++ basis/editors/vim/vim-docs.factor | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/basis/editors/gvim/gvim.factor b/basis/editors/gvim/gvim.factor index 8fb4d6b23d..15fd52f5ee 100644 --- a/basis/editors/gvim/gvim.factor +++ b/basis/editors/gvim/gvim.factor @@ -3,6 +3,9 @@ namespaces sequences system combinators editors.vim vocabs.loader make ; IN: editors.gvim +! This code builds on the code in editors.vim; see there for +! more information. + SINGLETON: gvim HOOK: gvim-path io-backend ( -- path ) diff --git a/basis/editors/vim/vim-docs.factor b/basis/editors/vim/vim-docs.factor index 3387dc5971..7f527bf18f 100644 --- a/basis/editors/vim/vim-docs.factor +++ b/basis/editors/vim/vim-docs.factor @@ -12,5 +12,6 @@ $nl "USE: vim" "\"c:\\\\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" } "." ; - +"On Unix, you may omit the last line if " { $snippet "\"vim\"" } " is in your " { $snippet "$PATH" } "." +$nl +"You may also wish to install Vim support files to enable syntax hilighting and other features. These are in the " { $link resource-path } " in " { $snippet "misc/vim" } "." ; From 8998f21aa6958dbe08b32b32481f0daeb57bb937 Mon Sep 17 00:00:00 2001 From: Tim Allen <screwtape@froup.com> Date: Wed, 14 Jan 2009 00:39:35 +1100 Subject: [PATCH 4/5] Add more Vim support files. --- misc/vim/README | 4 ++++ misc/vim/ftdetect/factor.vim | 1 + misc/vim/ftplugin/factor_settings.vim | 17 +++++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 misc/vim/ftdetect/factor.vim create mode 100644 misc/vim/ftplugin/factor_settings.vim diff --git a/misc/vim/README b/misc/vim/README index 1e82708ba4..bede151458 100644 --- a/misc/vim/README +++ b/misc/vim/README @@ -9,6 +9,10 @@ into ~/.vim/ or the equivalent path on other platforms (Open Vim and type The current set of files is as follows: + ftdetect/factor.vim + Teach Vim when to load Factor support files. + ftplugin/factor_settings.vim + Teach Vim to follow the Factor Coding Style guidelines. syntax/factor.vim Syntax highlighting for Factor code. diff --git a/misc/vim/ftdetect/factor.vim b/misc/vim/ftdetect/factor.vim new file mode 100644 index 0000000000..eb9c0deda6 --- /dev/null +++ b/misc/vim/ftdetect/factor.vim @@ -0,0 +1 @@ +autocmd BufRead,BufNewFile *.factor,{,.}factor*-rc set filetype=factor diff --git a/misc/vim/ftplugin/factor_settings.vim b/misc/vim/ftplugin/factor_settings.vim new file mode 100644 index 0000000000..ced9e85719 --- /dev/null +++ b/misc/vim/ftplugin/factor_settings.vim @@ -0,0 +1,17 @@ +" Code formatting settings loosely adapted from: +" http://concatenative.org/wiki/view/Factor/Coding%20Style + +" Tabs are not allowed in Factor source files; use four spaces instead. +setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4 + +" Try to limit lines to 64 characters, except for documentation, which can be +" any length. +if expand("%:t") !~ "-docs\.factor$" + setlocal textwidth=64 + + " Mark anything in column 64 or beyond as a syntax error. + match Error /\%>63v.\+/ +endif + +" Teach Vim what comments look like. +setlocal comments+=b:!,b:#! From d3cdd79795b5e2308ddfab19c27704f1d4287cf0 Mon Sep 17 00:00:00 2001 From: Slava Pestov <slava@slava-pestovs-macbook-pro.local> Date: Wed, 14 Jan 2009 18:33:15 -0600 Subject: [PATCH 5/5] Clarify with-stream docs --- basis/io/streams/duplex/duplex-docs.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/io/streams/duplex/duplex-docs.factor b/basis/io/streams/duplex/duplex-docs.factor index 48afafeec7..5bf33e9002 100644 --- a/basis/io/streams/duplex/duplex-docs.factor +++ b/basis/io/streams/duplex/duplex-docs.factor @@ -20,11 +20,11 @@ HELP: <duplex-stream> HELP: with-stream { $values { "stream" duplex-stream } { "quot" quotation } } -{ $description "Calls the quotation in a new dynamic scope, with both " { $link input-stream } " and " { $link output-stream } " rebound to " { $snippet "stream" } ". The stream is closed if the quotation returns or throws an error." } ; +{ $description "Calls the quotation in a new dynamic scope, with both " { $link input-stream } " and " { $link output-stream } " rebound to " { $snippet "stream" } ", which must be a duplex stream. The stream is closed if the quotation returns or throws an error." } ; HELP: with-stream* { $values { "stream" duplex-stream } { "quot" quotation } } -{ $description "Calls the quotation in a new dynamic scope, with both " { $link input-stream } " and " { $link output-stream } " rebound to " { $snippet "stream" } "." } +{ $description "Calls the quotation in a new dynamic scope, with both " { $link input-stream } " and " { $link output-stream } " rebound to " { $snippet "stream" } ", which must be a duplex stream." } { $notes "This word does not close the stream. Compare with " { $link with-stream } "." } ; HELP: <encoder-duplex>