29
29
" warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
30
30
" PURPOSE.
31
31
" See the GNU General Public License version 2 for more details.
32
- " Revision: $Id: bash-support.vim,v 1.115 2012/05/31 10:52:34 mehner Exp $
32
+ " Revision: $Id: bash-support.vim,v 1.118 2012/12/01 11:03:54 mehner Exp $
33
33
"
34
34
" ------------------------------------------------------------------------------
35
35
"
99
99
end
100
100
"
101
101
let s: BASH_BASH = $SHELL
102
- let s: BASH_Man = ' man'
102
+ let s: BASH_Man = ' /usr/bin/ man'
103
103
let s: BASH_OutputGvim = ' vim'
104
104
" ==============================================================================
105
105
endif
@@ -268,7 +268,7 @@ function! BASH_InitMenu ()
268
268
" -------------------------------------------------------------------------------
269
269
exe " menu " .s: BASH_Root .' &Comments.end-of-&line\ comment<Tab>\\cl :call BASH_EndOfLineComment()<CR>'
270
270
exe " imenu " .s: BASH_Root .' &Comments.end-of-&line\ comment<Tab>\\cl <Esc>:call BASH_EndOfLineComment()<CR>'
271
- exe " vmenu <silent> " .s: BASH_Root .' &Comments.end-of-&line\ comment<Tab>\\cl <Esc>:call BASH_MultiLineEndComments()<CR>A'
271
+ exe " vmenu <silent> " .s: BASH_Root .' &Comments.end-of-&line\ comment<Tab>\\cl <Esc>:call BASH_MultiLineEndComments()<CR>A'
272
272
273
273
exe " menu <silent> " .s: BASH_Root .' &Comments.ad&just\ end-of-line\ com\.<Tab>\\cj :call BASH_AdjustLineEndComm()<CR>'
274
274
exe " imenu <silent> " .s: BASH_Root .' &Comments.ad&just\ end-of-line\ com\.<Tab>\\cj <Esc>:call BASH_AdjustLineEndComm()<CR>'
@@ -896,10 +896,10 @@ function! BASH_InitMenu ()
896
896
" ( the one in the current buffer ; other versions may exist elsewhere ! )
897
897
"
898
898
899
- exe " menu <silent> " .s: BASH_Root .' &Run.save\ +\ &run\ script<Tab>\\rr\ \r <C-F9> :call BASH_Run("n")<CR>'
900
- exe " imenu <silent> " .s: BASH_Root .' &Run.save\ +\ &run\ script<Tab>\\rr\ \r <C-F9> <C-C>:call BASH_Run("n")<CR>'
899
+ exe " menu <silent> " .s: BASH_Root .' &Run.save\ +\ &run\ script<Tab>\\rr\ \ <C-F9> :call BASH_Run("n")<CR>'
900
+ exe " imenu <silent> " .s: BASH_Root .' &Run.save\ +\ &run\ script<Tab>\\rr\ \ <C-F9> <C-C>:call BASH_Run("n")<CR>'
901
901
if ! s: MSWIN
902
- exe " vmenu <silent> " .s: BASH_Root .' &Run.save\ +\ &run\ script<Tab>\\rr\ \r <C-F9> <C-C>:call BASH_Run("v")<CR>'
902
+ exe " vmenu <silent> " .s: BASH_Root .' &Run.save\ +\ &run\ script<Tab>\\rr\ \ <C-F9> <C-C>:call BASH_Run("v")<CR>'
903
903
endif
904
904
"
905
905
" set execution right only for the user ( may be user root ! )
@@ -916,8 +916,8 @@ function! BASH_InitMenu ()
916
916
exe " imenu <silent> " .s: BASH_Root .' &Run.syntax\ check\ o&ptions<Tab>\\rco <C-C>:call BASH_SyntaxCheckOptionsLocal()<CR>'
917
917
"
918
918
if ! s: MSWIN
919
- exe " menu <silent> " .s: BASH_Root .' &Run.start\ &debugger<Tab>\\rd\ \ \ \ <F9> :call BASH_Debugger()<CR>'
920
- exe " imenu <silent> " .s: BASH_Root .' &Run.start\ &debugger<Tab>\\rd\ \ \ \ <F9> <C-C>:call BASH_Debugger()<CR>'
919
+ exe " menu <silent> " .s: BASH_Root .' &Run.start\ &debugger<Tab>\\rd\ \ <F9> :call BASH_Debugger()<CR>'
920
+ exe " imenu <silent> " .s: BASH_Root .' &Run.start\ &debugger<Tab>\\rd\ \ <F9> <C-C>:call BASH_Debugger()<CR>'
921
921
exe " menu <silent> " .s: BASH_Root .' &Run.make\ script\ &executable<Tab>\\re :call BASH_MakeScriptExecutable()<CR>'
922
922
exe " imenu <silent> " .s: BASH_Root .' &Run.make\ script\ &executable<Tab>\\re <C-C>:call BASH_MakeScriptExecutable()<CR>'
923
923
endif
@@ -971,14 +971,14 @@ function! BASH_InitMenu ()
971
971
" ----- menu help {{{2
972
972
" ===============================================================================================
973
973
"
974
- exe " menu <silent> " .s: BASH_Root .' &Help.&Bash\ manual<Tab>\\hb :call BASH_help("b ")<CR>'
975
- exe " imenu <silent> " .s: BASH_Root .' &Help.&Bash\ manual<Tab>\\hb <C-C>:call BASH_help("b ")<CR>'
974
+ exe " menu <silent> " .s: BASH_Root .' &Help.&Bash\ manual<Tab>\\hb :call BASH_help("bash ")<CR>'
975
+ exe " imenu <silent> " .s: BASH_Root .' &Help.&Bash\ manual<Tab>\\hb <C-C>:call BASH_help("bash ")<CR>'
976
976
"
977
- exe " menu <silent> " .s: BASH_Root .' &Help.&help\ (Bash\ builtins)<Tab>\\hh :call BASH_help("h ")<CR>'
978
- exe " imenu <silent> " .s: BASH_Root .' &Help.&help\ (Bash\ builtins)<Tab>\\hh <C-C>:call BASH_help("h ")<CR>'
977
+ exe " menu <silent> " .s: BASH_Root .' &Help.&help\ (Bash\ builtins)<Tab>\\hh :call BASH_help("help ")<CR>'
978
+ exe " imenu <silent> " .s: BASH_Root .' &Help.&help\ (Bash\ builtins)<Tab>\\hh <C-C>:call BASH_help("help ")<CR>'
979
979
"
980
- exe " menu <silent> " .s: BASH_Root .' &Help.&manual\ (utilities)<Tab>\\hm :call BASH_help("m ")<CR>'
981
- exe " imenu <silent> " .s: BASH_Root .' &Help.&manual\ (utilities)<Tab>\\hm <C-C>:call BASH_help("m ")<CR>'
980
+ exe " menu <silent> " .s: BASH_Root .' &Help.&manual\ (utilities)<Tab>\\hm :call BASH_help("man ")<CR>'
981
+ exe " imenu <silent> " .s: BASH_Root .' &Help.&manual\ (utilities)<Tab>\\hm <C-C>:call BASH_help("man ")<CR>'
982
982
"
983
983
exe " menu <silent> " .s: BASH_Root .' &Help.bash-&support<Tab>\\hbs :call BASH_HelpBASHsupport()<CR>'
984
984
exe " imenu <silent> " .s: BASH_Root .' &Help.bash-&support<Tab>\\hbs <C-C>:call BASH_HelpBASHsupport()<CR>'
@@ -1883,7 +1883,7 @@ endfunction " ---------- end of function Bash_SubstituteTag ----------
1883
1883
" Comments : vim modeline {{{1
1884
1884
" ------------------------------------------------------------------------------
1885
1885
function ! BASH_CommentVimModeline ()
1886
- put = ' # vim: set tabstop=' .&tabstop .' shiftwidth=' .&shiftwidth .' : '
1886
+ put = ' # vim: filetype=sh : tabstop=' .&tabstop .' : shiftwidth=' .&shiftwidth .' : '
1887
1887
endfunction " ---------- end of function BASH_CommentVimModeline ----------
1888
1888
"
1889
1889
" ------------------------------------------------------------------------------
@@ -1968,15 +1968,15 @@ function! BASH_help( type )
1968
1968
let cuc = getline (" ." )[col (" ." ) - 1 ] " character under the cursor
1969
1969
let item = expand (" <cword>" ) " word under the cursor
1970
1970
if empty (item) || match ( item, cuc ) == -1
1971
- if a: type == ' m '
1971
+ if a: type == ' man '
1972
1972
let item= BASH_Input (' [tab compl. on] name of command line utility : ' , ' ' , ' shellcmd' )
1973
1973
endif
1974
- if a: type == ' h '
1974
+ if a: type == ' help '
1975
1975
let item= BASH_Input (' [tab compl. on] name of bash builtin : ' , ' ' , ' customlist,BASH_BuiltinComplete' )
1976
1976
endif
1977
1977
endif
1978
1978
1979
- if empty (item) && a: type != ' b '
1979
+ if empty (item) && a: type != ' bash '
1980
1980
return
1981
1981
endif
1982
1982
" ------------------------------------------------------------------------------
@@ -1998,22 +1998,23 @@ function! BASH_help( type )
1998
1998
setlocal buftype = nofile
1999
1999
setlocal noswapfile
2000
2000
setlocal bufhidden = delete
2001
- setlocal filetype = sh " allows repeated use of <S-F1>
2002
2001
setlocal syntax = OFF
2003
2002
endif
2004
2003
setlocal modifiable
2004
+ setlocal filetype = man
2005
2005
"
2006
2006
" -------------------------------------------------------------------------------
2007
2007
" read Bash help
2008
2008
" -------------------------------------------------------------------------------
2009
- if a: type == ' h'
2010
- silent exe " :%!help " .item
2009
+ if a: type == ' help'
2010
+ setlocal wrap
2011
+ silent exe " :%!help -m " .item
2011
2012
endif
2012
2013
"
2013
2014
" -------------------------------------------------------------------------------
2014
2015
" open a manual (utilities)
2015
2016
" -------------------------------------------------------------------------------
2016
- if a: type == ' m '
2017
+ if a: type == ' man '
2017
2018
"
2018
2019
" Is there more than one manual ?
2019
2020
"
@@ -2060,7 +2061,6 @@ function! BASH_help( type )
2060
2061
endif
2061
2062
endif
2062
2063
2063
- set filetype = man
2064
2064
silent exe " :%!" .s: BASH_Man .' ' .catalog.' ' .item
2065
2065
2066
2066
if s: MSWIN
@@ -2072,18 +2072,12 @@ function! BASH_help( type )
2072
2072
" -------------------------------------------------------------------------------
2073
2073
" open the bash manual
2074
2074
" -------------------------------------------------------------------------------
2075
- if a: type == ' b '
2076
- silent exe " :%!man 1 bash"
2075
+ if a: type == ' bash '
2076
+ silent exe " :%!" . s: BASH_Man . ' 1 bash'
2077
2077
2078
2078
if s: MSWIN
2079
2079
call s: bash_RemoveSpecialCharacters ()
2080
2080
endif
2081
-
2082
- if ! empty (item)
2083
- " assign to the search pattern register "" :
2084
- let @/ = item
2085
- echo " use n/N to search for '" .item." '"
2086
- endif
2087
2081
endif
2088
2082
2089
2083
setlocal nomodifiable
@@ -2341,7 +2335,8 @@ endfunction " ---------- end of function BASH_BashCmdLineArguments ---------
2341
2335
let s: BASH_OutputBufferName = " Bash-Output"
2342
2336
let s: BASH_OutputBufferNumber = -1
2343
2337
"
2344
- function ! BASH_Run ( mode )
2338
+ function ! BASH_Run ( mode ) range
2339
+
2345
2340
silent exe ' :cclose'
2346
2341
"
2347
2342
let l: arguments = exists (" b:BASH_ScriptCmdLineArgs" ) ? " " .b: BASH_ScriptCmdLineArgs : " "
@@ -2351,7 +2346,12 @@ function! BASH_Run ( mode )
2351
2346
"
2352
2347
silent exe " :update"
2353
2348
"
2354
- if a: mode== " v"
2349
+ if a: firstline != a: lastline
2350
+ let tmpfile = tempname ()
2351
+ silent exe ' :' .a: firstline .' ,' .a: lastline .' write ' .tmpfile
2352
+ endif
2353
+ "
2354
+ if a: mode== " v"
2355
2355
let tmpfile = tempname ()
2356
2356
silent exe " :'<,'>write " .tmpfile
2357
2357
endif
@@ -2366,8 +2366,7 @@ function! BASH_Run ( mode )
2366
2366
"
2367
2367
" ----- visual mode ----------
2368
2368
"
2369
- if a: mode== " v"
2370
- echomsg " :!" .s: BASH_BASH .l: bashCmdLineArgs ." < " .tmpfile." -s " .l: arguments
2369
+ if ( a: mode== " v" ) || ( a: firstline != a: lastline )
2371
2370
exe " :!" .s: BASH_BASH .l: bashCmdLineArgs ." < " .tmpfile." -s " .l: arguments
2372
2371
call delete (tmpfile)
2373
2372
return
@@ -2442,7 +2441,7 @@ function! BASH_Run ( mode )
2442
2441
endif
2443
2442
endif
2444
2443
"
2445
- if a: mode== " v"
2444
+ if ( a: mode== " v" ) || ( a: firstline != a: lastline )
2446
2445
silent exe " :%!" .s: BASH_BASH .l: bashCmdLineArgs ." < " .tmpfile." -s " .l: arguments
2447
2446
endif
2448
2447
setlocal nomodifiable
@@ -2469,11 +2468,15 @@ function! BASH_Run ( mode )
2469
2468
exe ' :!' .s: BASH_BASH .l: bashCmdLineArgs .' "' .l: fullname .' " ' .l: arguments
2470
2469
else
2471
2470
if a: mode== ' n'
2472
- silent exe ' !xterm -title ' .l: fullnameesc .' ' .s: BASH_XtermDefaults
2473
- \ .' -e ' .s: BASH_Wrapper .' ' .l: bashCmdLineArgs .l: fullnameesc .l: arguments .' &'
2474
- endif
2475
- "
2476
- if a: mode== " v"
2471
+ if a: firstline != a: lastline
2472
+ let titlestring = l: fullnameesc .' \ lines\ \ ' .a: firstline .' \ -\ ' .a: lastline
2473
+ silent exe ' :!xterm -title ' .titlestring .' ' .s: BASH_XtermDefaults
2474
+ \ .' -e ' .s: BASH_Wrapper .' ' .l: bashCmdLineArgs .tmpfile.l: arguments .' &'
2475
+ else
2476
+ silent exe ' !xterm -title ' .l: fullnameesc .' ' .s: BASH_XtermDefaults
2477
+ \ .' -e ' .s: BASH_Wrapper .' ' .l: bashCmdLineArgs .l: fullnameesc .l: arguments .' &'
2478
+ endif
2479
+ elseif a: mode== " v"
2477
2480
let titlestring = l: fullnameesc .' \ lines\ \ ' .line (" '<" ).' \ -\ ' .line (" '>" )
2478
2481
silent exe ' :!xterm -title ' .titlestring .' ' .s: BASH_XtermDefaults
2479
2482
\ .' -e ' .s: BASH_Wrapper .' ' .l: bashCmdLineArgs .tmpfile.l: arguments .' &'
0 commit comments