Clean up editors.*vim so that it runs detached with gvim and there is less

code duplication. Use mvim on mac. Remove gvim.unix vocabulary since it
doesn't do anything besides return "gvim" as the path.
db4
Doug Coleman 2011-10-29 15:10:42 -07:00
parent 8205caa5ca
commit 5594e82492
7 changed files with 36 additions and 50 deletions

View File

@ -1,24 +1,17 @@
USING: io.backend io.files kernel math math.parser USING: editors.vim io.backend kernel namespaces system
namespaces sequences system combinators vocabs.loader ;
editors.vim vocabs.loader make ;
IN: editors.gvim IN: editors.gvim
! This code builds on the code in editors.vim; see there for ! This code builds on the code in editors.vim; see there for
! more information. ! more information.
SINGLETON: gvim SINGLETON: gvim
HOOK: gvim-path io-backend ( -- path )
M: gvim vim-command ( file line -- string )
[
gvim-path ,
number>string "+" prepend , ,
] { } make ;
gvim vim-editor set-global gvim vim-editor set-global
{ HOOK: find-gvim-path io-backend ( -- path )
{ [ os unix? ] [ "editors.gvim.unix" ] } M: object find-gvim-path f ;
{ [ os windows? ] [ "editors.gvim.windows" ] }
} cond require M: gvim find-vim-path find-gvim-path "gvim" or ;
M: gvim vim-detached? t ;
os windows? [ "editors.gvim.windows" require ] when

View File

@ -1 +0,0 @@
Doug Coleman

View File

@ -1 +0,0 @@
not loaded

View File

@ -1,7 +0,0 @@
USING: kernel namespaces editors.gvim system ;
IN: editors.gvim.unix
M: unix gvim-path
\ gvim-path get-global [
"gvim"
] unless* ;

View File

@ -1,10 +1,6 @@
USING: editors.gvim io.files kernel namespaces sequences USING: editors.gvim io.directories.search.windows sequences
windows.shell32 io.directories.search.windows system system ;
io.pathnames ;
IN: editors.gvim.windows IN: editors.gvim.windows
M: windows gvim-path M: windows find-gvim-path
\ gvim-path get-global [ "vim" [ "gvim.exe" tail? ] find-in-program-files ;
"vim" [ "gvim.exe" tail? ] find-in-program-files
[ "gvim.exe" ] unless*
] unless* ;

View File

@ -1,10 +1,8 @@
USING: definitions io.launcher kernel math math.parser parser USING: editors.vim kernel namespaces ;
namespaces prettyprint editors make ;
IN: editors.macvim IN: editors.macvim
: macvim ( file line -- ) SINGLETON: macvim
drop macvim \ vim-editor set-global
[ "open" , "-a" , "MacVim", , ] { } make
run-detached drop ;
[ macvim ] edit-hook set-global M: macvim vim-path \ vim-path get-global "mvim" or ;
M: macvim vim-detached? t ;

View File

@ -1,23 +1,31 @@
USING: definitions io io.launcher kernel math math.parser USING: editors io.backend io.launcher kernel make math.parser
namespaces parser prettyprint sequences editors accessors namespaces sequences strings system vocabs.loader ;
make strings ;
IN: editors.vim IN: editors.vim
SYMBOL: vim-path
SYMBOL: vim-editor SYMBOL: vim-editor
HOOK: vim-command vim-editor ( file line -- array )
SINGLETON: vim SINGLETON: vim
\ vim vim-editor set-global
M: vim vim-command SYMBOL: vim-path
HOOK: find-vim-path vim-editor ( -- path )
HOOK: vim-detached? vim-editor ( -- detached? )
M: vim find-vim-path "vim" ;
M: vim vim-detached? f ;
: actual-vim-path ( -- path )
\ vim-path get-global [ find-vim-path ] unless* ;
: vim-command ( file line -- command )
[ [
vim-path get dup string? [ , ] [ % ] if actual-vim-path dup string? [ , ] [ % ] if
[ , ] [ number>string "+" prepend , ] bi* [ , ] [ number>string "+" prepend , ] bi*
] { } make ; ] { } make ;
: vim ( file line -- ) : vim ( file line -- )
vim-command run-process drop ; vim-command vim-detached? [ run-detached ] [ run-process ] if drop ;
"vim" vim-path set-global
[ vim ] edit-hook set-global [ vim ] edit-hook set-global
\ vim vim-editor set-global