Permalink
Browse files

Fix history behavior

  • Loading branch information...
1 parent 9d9b8a5 commit 915e591cd858e26075aa988377ae584d8241eb5d @Shougo committed Feb 14, 2014
Showing with 32 additions and 12 deletions.
  1. +6 −3 autoload/unite/sources/vimshell_history.vim
  2. +9 −7 autoload/vimshell/history.vim
  3. +10 −2 autoload/vimshell/parser.vim
  4. +7 −0 doc/vimshell.txt
@@ -1,7 +1,7 @@
"=============================================================================
" FILE: vimshell_history.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
-" Last Modified: 13 Jul 2013.
+" Last Modified: 14 Feb 2014.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
@@ -44,6 +44,7 @@ function! s:source.hooks.on_init(args, context) "{{{
call unite#sources#vimshell_history#_change_histories(
\ vimshell#history#read())
let a:context.source__cur_keyword_pos = vimshell#get_prompt_length()
+ let a:context.source__history_path = vimshell#history#get_history_path()
endfunction"}}}
function! s:source.hooks.on_syntax(args, context) "{{{
let save_current_syntax = get(b:, 'current_syntax', '')
@@ -60,8 +61,10 @@ function! s:source.hooks.on_syntax(args, context) "{{{
endfunction"}}}
function! s:source.hooks.on_close(args, context) "{{{
let a:context.source__cur_keyword_pos = vimshell#get_prompt_length()
- if vimshell#history#read() != s:current_histories
- call vimshell#history#write(s:current_histories)
+ if vimshell#history#read(a:context.source__history_path)
+ \ !=# s:current_histories
+ call vimshell#history#write(s:current_histories,
+ \ a:context.source__history_path)
endif
endfunction"}}}
function! s:source.hooks.on_post_filter(args, context) "{{{
@@ -1,7 +1,7 @@
"=============================================================================
" FILE: history.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
-" Last Modified: 24 Nov 2013.
+" Last Modified: 14 Feb 2014.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
@@ -45,7 +45,7 @@ function! vimshell#history#append(command) "{{{
let no_history_commands = g:vimshell_interactive_no_save_history_commands
endif
- if program != '' && has_key(no_history_commands, program)
+ if program == '' || program =~ '^!' || has_key(no_history_commands, program)
" No history command.
return
endif
@@ -61,25 +61,27 @@ function! vimshell#history#append(command) "{{{
call vimshell#history#write(histories)
endfunction"}}}
-function! vimshell#history#read() "{{{
+function! vimshell#history#read(...) "{{{
if vimshell#util#is_sudo()
return []
endif
- let history_path = s:get_history_path()
+ let history_path = get(a:000, 0, vimshell#history#get_history_path())
return filereadable(history_path) ?
\ readfile(history_path) : []
endfunction"}}}
-function! vimshell#history#write(list) "{{{
+function! vimshell#history#write(list, ...) "{{{
if vimshell#util#is_sudo()
return []
endif
+ let history_path = get(a:000, 0, vimshell#history#get_history_path())
+
" Save history file.
- call writefile(a:list, s:get_history_path())
+ call writefile(a:list, history_path)
endfunction"}}}
-function! s:get_history_path() "{{{
+function! vimshell#history#get_history_path() "{{{
if &filetype ==# 'vimshell' && empty(b:vimshell.continuation)
let history_path = vimshell#get_data_directory() . '/command-history'
if !filereadable(history_path)
@@ -1,7 +1,7 @@
"=============================================================================
" FILE: parser.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
-" Last Modified: 11 Jan 2014.
+" Last Modified: 14 Feb 2014.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
@@ -96,8 +96,16 @@ function! vimshell#parser#execute_command(commands, context) "{{{
" Execute execute commands.
let commands[0].args = args
return vimshell#helpers#execute_internal_command(program, commands, context)
+ elseif program =~ '^!'
+ " Convert to internal "h" command.
+ if program == '!!'
+ let args = []
+ else
+ let args = [program[1:]] + args
+ endif
+ return vimshell#helpers#execute_internal_command('h', args, context)
elseif a:commands[-1].args[-1] =~ '&$'
- " Convert to internal bg command.
+ " Convert to internal "bg" command.
let commands[-1].args[-1] = commands[-1].args[-1][:-2]
if commands[-1].args[-1] == ''
" Delete empty arg.
View
@@ -1116,6 +1116,13 @@ h [{pattern}] *vimshell-internal-h*
you omit {pattern}, execute last command.
Note: This command does not add history.
+ Note: "![{pattern}]" or "!!" equals to "h" command"
+>
+ vimshell% ! # Execute previous command.
+ vimshell% !2 # Execute history number 2 command.
+ vimshell% !! # Execute previous command.
+ vimshell% !ls # Execute "ls" matched command.
+<
histdel {history-number} *vimshell-internal-histdel*
Deletes {history-number} history. You can check history number
using |vimshell-internal-history| command.

0 comments on commit 915e591

Please sign in to comment.