From a1878ea81846954d560d2a78aafac2caa8cff7ac Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 29 Oct 2011 15:27:08 -0700 Subject: [PATCH] Look for mvim on mac and use 'open -a MacVim' if it's not in the path. Since 'open -a macvim' doesn't support command line options, add a generic for opening to a line or not. --- basis/editors/macvim/macvim.factor | 9 +++++++-- basis/editors/vim/vim.factor | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/basis/editors/macvim/macvim.factor b/basis/editors/macvim/macvim.factor index f67bf141a7..46f346828e 100644 --- a/basis/editors/macvim/macvim.factor +++ b/basis/editors/macvim/macvim.factor @@ -1,8 +1,13 @@ -USING: editors.vim kernel namespaces ; +USING: editors.vim environment fry io.files io.pathnames kernel +namespaces sequences splitting ; IN: editors.macvim SINGLETON: macvim macvim \ vim-editor set-global -M: macvim vim-path \ vim-path get-global "mvim" or ; +: find-binary-path ( string -- path/f ) + [ "PATH" os-env ":" split ] dip '[ _ append-path exists? ] find nip ; + +M: macvim find-vim-path "mvim" find-binary-path { "open" "-a" "MacVim" } or ; M: macvim vim-detached? t ; +M: macvim vim-open-line? f ; diff --git a/basis/editors/vim/vim.factor b/basis/editors/vim/vim.factor index 33e596e1ad..855e2ad158 100644 --- a/basis/editors/vim/vim.factor +++ b/basis/editors/vim/vim.factor @@ -11,7 +11,9 @@ SYMBOL: vim-path HOOK: find-vim-path vim-editor ( -- path ) HOOK: vim-detached? vim-editor ( -- detached? ) +HOOK: vim-open-line? vim-editor ( -- ? ) +M: object vim-open-line? t ; M: vim find-vim-path "vim" ; M: vim vim-detached? f ; @@ -22,7 +24,7 @@ M: vim vim-detached? f ; : vim-command ( file line -- command ) [ actual-vim-path dup string? [ , ] [ % ] if - [ , ] [ number>string "+" prepend , ] bi* + [ , ] [ vim-open-line? [ number>string "+" prepend , ] [ drop ] if ] bi* ] { } make ; : vim ( file line -- )