Skip to content

Commit

Permalink
Version 10.6.4: New release with some small changes, see :help atp-news
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Szamotulski authored and vim-scripts committed Jan 5, 2012
1 parent cae9da8 commit 44bc65e
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 118 deletions.
8 changes: 6 additions & 2 deletions autoload/atplib/compiler.vim
Expand Up @@ -50,6 +50,7 @@ function! atplib#compiler#ViewOutput(bang,...)
let g:global_options = global_options
let g:local_options = local_options
let g:viewer = viewer
let g:outfile = outfile
endif
let view_cmd = viewer." ".global_options." ".local_options." ".shellescape(outfile)." &"

Expand Down Expand Up @@ -83,14 +84,16 @@ function! atplib#compiler#ViewOutput(bang,...)
if fwd_search
let msg = "[SyncTex:] waiting for the viewer "
let i=1
while !atplib#compiler#IsRunning(viewer, outfile) && i<10
let max=20
while !atplib#compiler#IsRunning(b:atp_Viewer, outfile) && i<=max
echo msg
sleep 100m
redraw
let msg.="."
let i+=1
endwhile
if i<15
exe "sleep ".g:atp_OpenAndSyncSleepTime
if i<=max
call atplib#compiler#SyncTex("", 0)
else
echohl WarningMsg
Expand Down Expand Up @@ -237,6 +240,7 @@ function! atplib#compiler#SyncTex(bang, mouse, ...)
let sync_cmd_page = "xpdf -remote " . shellescape(b:atp_XpdfServer) . " -exec 'gotoPage(".page_nr.")'"
let sync_cmd_y = "xpdf -remote " . shellescape(b:atp_XpdfServer) . " -exec 'scrollDown(".y_coord.")'"
let sync_cmd_x = "xpdf -remote " . shellescape(b:atp_XpdfServer) . " -exec 'scrollRight(".x_coord.")'"
" let sync_cmd = "xpdf -remote " . shellescape(b:atp_XpdfServer) . " -exec 'gotoPage(".page_nr.")'"." -exec 'scrollDown(".y_coord.")'"." -exec 'scrollRight(".x_coord.")'"
" There is a bug in xpdf. We need to sleep between sending commands:
let sleep = ( g:atp_XpdfSleepTime ? 'sleep '.string(g:atp_XpdfSleepTime).'s;' : '' )
let sync_cmd = "(".sync_cmd_page.";".sleep.sync_cmd_y.")&"
Expand Down
10 changes: 6 additions & 4 deletions autoload/atplib/complete.vim
Expand Up @@ -1915,8 +1915,7 @@ function! atplib#complete#TabCompletion(expert_mode,...)
call atplib#Log("TabCompletion.log", "b:comp_method=".b:comp_method)
"{{{3 --------- inputfiles
elseif (l =~ '\\input\%([^{}]*\|\s*{[^}]*\)$'||
\ l =~ '\\include\s*{[^}]*$' ||
\ l =~ '\\includeonly\s*{[^}]*$') && !normal_mode &&
\ l =~ '\\include\s*{[^}]*$') && !normal_mode &&
\ index(g:atp_completion_active_modes, 'input files') != -1
if begin =~ 'input'
let begin=substitute(begin,'.*\%(input\|include\%(only\)\?\)\s\?','','')
Expand Down Expand Up @@ -2505,7 +2504,10 @@ function! atplib#complete#TabCompletion(expert_mode,...)
endif

if exists("g:atp_".package."_command_values") &&
\ ( atplib#search#SearchPackage(package) || test || atplib#search#DocumentClass(b:atp_MainFile) == package )
\ (
\ atplib#search#SearchPackage(package) || test ||
\ atplib#search#DocumentClass(b:atp_MainFile) == package || package == "common"
\ )
for key in keys({"g:atp_".package."_command_values"})
" uncomment this to debug in which package file there is a mistake.
if command =~ key
Expand Down Expand Up @@ -2539,7 +2541,7 @@ function! atplib#complete#TabCompletion(expert_mode,...)
" {{{3 ------------ LABELS /are done later only the completions variable /
elseif completion_method == 'labels'
let completion_list = []
" {{{3 ------------ TEX INPUTFILES
" {{{3 ------------ INPUTFILES
elseif completion_method == 'inputfiles'
let completion_list=[]
call extend(completion_list, atplib#search#KpsewhichGlobPath('tex', b:atp_OutDir . ',' . g:atp_texinputs, '*.tex', ':t:r', '^\%(\/home\|\.\|.*users\)', '\%(^\\usr\|texlive\|miktex\|kpsewhich\|generic\)'))
Expand Down
52 changes: 29 additions & 23 deletions autoload/atplib/motion.vim
Expand Up @@ -1487,36 +1487,42 @@ endfunction
" Note: the 's' search flag is passed by the associated commands.
" This can be extended:
" (1) skip empty lines between comments
function! atplib#motion#SkipComment(flag, mode, ...)
function! atplib#motion#SkipComment(flag, mode, count, ...)
let flag = ( a:flag =~ 'b' ? 'b' : '' )
let nr = ( a:flag =~ 'b' ? -1 : 1 )
call search('^\zs\s*%', flag)
call cursor(line("."), ( nr == -1 ? 1 : len(getline(line(".")))))

let line = getline(line("."))
" find previous line
let pline_nr=min([line("$"), max([1,line(".")+nr])])
let pline = getline(pline_nr)
for c in range(1, a:count)
let test = search('^\zs\s*%', flag)
if !test
return
endif
call cursor(line("."), ( nr == -1 ? 1 : len(getline(line(".")))))

while pline =~ '^\s*%'
call cursor(line(".")+nr, ( nr == -1 ? 1 : len(getline(line(".")+nr))))
let line = getline(line("."))
" find previous line
let pline_nr=min([line("$"), max([1,line(".")+nr])])
let pline = getline(pline_nr)
endwhile
if a:mode == 'n' && ( !g:atp_VimCompatible || g:atp_VimCompatible =~? '\<no\>' )
if a:flag =~# 'b'
call cursor(line(".")-1,1)
else
call cursor(line(".")+1,1)

while pline =~ '^\s*%' && line(".") != line("$") && line(".") != 1
call cursor(line(".")+nr, ( nr == -1 ? 1 : len(getline(line(".")+nr))))
let pline_nr=min([line("$"), max([1,line(".")+nr])])
let pline = getline(pline_nr)
endwhile
if a:mode == 'n' && ( !g:atp_VimCompatible || g:atp_VimCompatible =~? '\<no\>' )
if a:flag =~# 'b'
call cursor(line(".")-1,1)
else
call cursor(line(".")+1,1)
endif
endif
endif
if a:mode == 'v'
let end_pos = [ line("."), col(".") ]
" Go where visual mode started
exe "normal `" . ( nr == 1 ? '<' : '>' )
exe "normal " . visualmode()
call cursor(end_pos)
endif
if a:mode == 'v'
let end_pos = [ line("."), col(".") ]
" Go where visual mode started
exe "normal `" . ( nr == 1 ? '<' : '>' )
exe "normal " . visualmode()
call cursor(end_pos)
endif
endfor
endfunction

" Syntax motion
Expand Down
71 changes: 25 additions & 46 deletions autoload/atplib/various.vim
Expand Up @@ -2,49 +2,11 @@
" Descriptiion: These are various editting tools used in ATP.
" Note: This file is a part of Automatic Tex Plugin for Vim.
" Language: tex
" Last Change: Mon Dec 05, 2011 at 20:31:38 +0000
" Last Change: Mon Dec 26, 2011 at 12:01:47 +0000

let s:sourced = exists("s:sourced") ? 1 : 0

" Replace function (like :normal! r)
function! atplib#various#Replace() "{{{
" It will not work with <:> since with the default settings "normal %" is not
" working with <:>, possibly because g:atp_bracket_dict doesn't contain this
" pair.
let char = nr2char(getchar())
let f_char = getline(line("."))[col(".")-1]
if f_char =~ '^[(){}\[\]]$'
if f_char =~ '^[({\[]$'
let bracket_dict = { '{' : '}',
\ '(' : ')',
\ '[' : ']',}
else
let bracket_dict = { '}' : '{',
\ ')' : '(',
\ ']' : '[',}
endif
let c_bracket = get(bracket_dict,char, "")
if c_bracket == ""
exe "normal! r".char
return
endif
let [b_line, b_col] = [line("."), col(".")]
exe "normal! %"
let [e_line, e_col] = [line("."), col(".")]
if b_line == e_line && b_col == e_col
exe "normal! r".char
return
endif
call cursor(b_line, b_col)
exe "normal! r".char
call cursor(e_line, e_col)
exe "normal! r".c_bracket
call cursor(b_line, b_col)
return
else
exe "normal! r".char
endif
endfunction
"}}}

" This is the wrap selection function.
Expand Down Expand Up @@ -388,7 +350,8 @@ function! atplib#various#TexAlign(bang)
let save_pos = getpos(".")
let synstack = map(synstack(line("."), col(".")), 'synIDattr( v:val, "name")')

let balign=searchpair('\\begin\s*{\s*array\s*}', '', '\\end\s*{\s*array\s*}', 'bnW')
let barray=searchpair('\\begin\s*{\s*array\s*}', '', '\\end\s*{\s*array\s*}', 'bnW', '',max([1,line('.')-500]))
let bsmallmatrix=searchpair('\\begin\s*{\s*smallmatrix\s*}', '', '\\end\s*{\s*smallmatrix\s*}', 'bnW', '',max([1,line('.')-500]))
" let [bmatrix, bmatrix_col]=searchpairpos('\\matrix\s*\%(\[[^]]*\]\s*\)\=\zs{', '', '}', 'bnW', '', max([1, (line(".")-g:atp_completion_limits[2])]))
let [bmatrix, bmatrix_col]=searchpos('^\%([^%]\|\\%\)*\\matrix\s*\%(\[[^]]*\]\s*\)\=\zs{', 'bW', max([1, (line(".")-g:atp_completion_limits[2])]))
if bmatrix != 0
Expand All @@ -403,13 +366,20 @@ function! atplib#various#TexAlign(bang)
let AlignCtr = 'l+'
let AlignSep = '&\|\\pgfmatrixnextcell'
let env = "matrix"
elseif balign
elseif barray
let bpat = '\\begin\s*{\s*array\s*}'
let bline = balign+1
let bline = barray+1
let epat = '\\end\s*{\s*array\s*}'
let AlignCtr = 'l+'
let AlignSep = '&'
let env = "array"
elseif bsmallmatrix
let bpat = '\\begin\s*{\s*smallmatrix\s*}'
let bline = bsmallmatrix+1
let epat = '\\end\s*{\s*smallmatrix\s*}'
let AlignCtr = 'l+'
let AlignSep = '&'
let env = "smallmatrix"
elseif count(synstack, 'texMathZoneA') || count(synstack, 'texMathZoneAS')
let bpat = '\\begin\s*{\s*align\*\=\s*}'
let epat = '\\end\s*{\s*align\*\=\s*}'
Expand Down Expand Up @@ -950,8 +920,8 @@ function! atplib#various#OpenLog()
nnoremap <silent> <buffer> [c :call atplib#various#Search('\CLaTeX Warning: Citation', 'bW')<CR>
nnoremap <silent> <buffer> ]r :call atplib#various#Search('\CLaTeX Warning: Reference', 'W')<CR>
nnoremap <silent> <buffer> [r :call atplib#various#Search('\CLaTeX Warning: Reference', 'bW')<CR>
nnoremap <silent> <buffer> ]e :call atplib#various#Search('^[^!].*\n\zs!', 'W')<CR>
nnoremap <silent> <buffer> [e :call atplib#various#Search('^[^!].*\n\zs!', 'bW')<CR>
nnoremap <silent> <buffer> ]e :call atplib#various#Search('^!', 'W')<CR>
nnoremap <silent> <buffer> [e :call atplib#various#Search('^!', 'bW')<CR>
nnoremap <silent> <buffer> ]f :call atplib#various#Search('\CFont \%(Info\\|Warning\)', 'W')<CR>
nnoremap <silent> <buffer> [f :call atplib#various#Search('\CFont \%(Info\\|Warning\)', 'bW')<CR>
nnoremap <silent> <buffer> ]p :call atplib#various#Search('\CPackage', 'W')<CR>
Expand Down Expand Up @@ -1674,8 +1644,16 @@ function! atplib#various#Dictionary(word)
let cmd=g:atp_Python." ".shellescape(URLquery_path)." ".shellescape(url)." ".shellescape(wget_file)
call system(cmd)
let loclist = getloclist(0)
exe 'lvimgrep /\CMathematical English Usage - a Dictionary/j '.fnameescape(wget_file)
let entry=readfile(wget_file)[getloclist(0)[0]['lnum']+1]
exe 'silent! lvimgrep /\CMathematical English Usage - a Dictionary/j '.fnameescape(wget_file)
let entry=get(readfile(wget_file),get(get(getloclist(0),0,{}),'lnum',-1)+1, -1)
if entry == -1
call delete(wget_file)
redraw
echohl WarningMsg
echomsg "[ATP:] internet connection seems to be broken."
echohl Normal
return
endif
call setloclist(0, loclist)
let entry = substitute(entry, '<p>', "\n", 'g')
let entry = substitute(entry, '<h4>\zs\([0-9]\+\)\ze</h4>', "\n\\1", 'g')
Expand Down Expand Up @@ -1718,6 +1696,7 @@ function! atplib#various#Dictionary(word)
endif
let i+=1
endfor
call delete(wget_file)
endfunction

function! atplib#various#Complete_Dictionary(ArgLead, CmdLine, CursorPos)
Expand Down
60 changes: 43 additions & 17 deletions doc/automatic-tex-plugin.txt
@@ -1,6 +1,6 @@
*automatic-tex-plugin.txt* LaTeX filetype plugin Last change: 11 December 2011
*automatic-tex-plugin.txt* LaTeX filetype plugin Last change: 28 December 2011

An Introduction to AUTOMATIC (La)TeX PLUGIN (ver. 10.6.3)
An Introduction to AUTOMATIC (La)TeX PLUGIN (ver. 10.6.4)
by Marcin Szamotulski
mszamot [AT] gmail [DOT] com
-----------------------------------------------------------------------------
Expand Down Expand Up @@ -163,6 +163,23 @@ for all the defined functions :help atp*()CTRL-d, mappings: :help atp-mapCTRL-d

================================================================================
NEWS *atp-news*
>
======================
Changes in version 10.6.4
<
ATP normal r map is working better, that is |.| works well with |atp-r| map.

|g:atp_OpenAndSyncSleepTime| = "500m" -- sleep time between the time when
ATP finds the viewer working and syncing (forward searching) for the command
|atp-:View|! (with bang) (this is time left for the viewer to open the file).

Plus some new package files for completion: showidx, makeidx, syntonly and
a better completion for the \includeonly{} command (which removes items from
completion menu which are already included).

Count added to |atp-]%| and |atp-[%|.

|atp-:TexAlign| works with smallmatrix environment.
>
======================
Changes in version 10.6.3
Expand Down Expand Up @@ -1146,6 +1163,10 @@ map <LocalLeader>v,map <F3>, imap <F3>
With bang (and <F3> maps) opens viewer at the cursor position in vim
(forward search). This will only work for viewers that support forward
searching (xpdf, xdvi, okular, skim).
*g:atp_OpenAndSyncSleepTime*
let |g:atp_OpenAndSyncSleepTime|="500m"
Give 500 milliseconds for the viewer to read the file, before
|atp-:View|! command will do a forward search.

:SyncTex[!] *atp-:SyncTex* *atp-\f*
map <LocalLeader>f, map <S-LeftMouse>
Expand Down Expand Up @@ -1341,11 +1362,12 @@ map <F1>, imap <F1>
map =d
This is an interface to http://www.impan.pl/Dictionary/. Type a [word]
and you will get quotes from mathematical articles or books written by
native speakers of English. The command has a completion for words.
native speakers of English. The command has a completion for words
List of words is hard coded in ATP (it is too slow to get it), since the
dictionary evolves it might contain new entries.
dictionary evolves it might contain new entries (note: if this is the
case, please inform me).

The map takes the |<word>| under the cursor as an argument.
The map takes the |<cword>| under the cursor as an argument.

:Delete[!] *atp-:Delete*
map <F6>d
Expand Down Expand Up @@ -1799,12 +1821,16 @@ nmap -p

*atp-:SkipCommentForward*
*atp-]star* *atp-]%* *atp-gc*
:SkipCommentForward
nmap ]* ]% gc
Go to end of current/next comment group.
:[count]SkipCommentForward
nmap [count]]* [count]]% [count]gc
Go to end of current/next comment group. Do this [count] times. The
default [count] is 1.

Note: if |g:atp_VimCompatible|=1 (the default) it goes one line below
the last commented line, if it is 0 it goes to the end of the comment.

Note: This commands wraps around the begining/end of the file. The
'wrapscan' option applies.
*atp-:SkipCommentBackward*
*atp-[star* *atp-[%* *atp-gC*
:SkipCommentBackward
Expand Down Expand Up @@ -4655,15 +4681,15 @@ nmaps: g>, g<, 2g>, ..., 6g>
A normal map to m`vipg>`` (or m`vip2g>``).

*atp-r*
nmap r
If |g:atp_VimCompatible| is 0 then the normal command |r| will be over written
with an ATP function with the following feature: if you do |atp-r|
over one of the brackets: (:), {:}, [:] then r(, r{, r[ (and r), r},
r]) will change both: the opening and the closing bracket. Otherwise,
i.e. over any other character, or |atp-r| over a bracket with
replacing character other than opening bracket at opening position or
closing bracket at closing position, |atp-r| will work the same as |r|.
nmap r{char}
Over any charackter which is not a bracket: (:), [:], {:} it acts as
|r| command. Over a bracket which has a closing bracket and if {char}
is another bracket it replaces both opening and closing bracket. When
replacing brackets it will not remember the changing bracket for the
|.| command, so you cannot use |.| to change more brackets, but if
|atp-r| was used for changing text (non-brackets, or not-closed/opened
brackets) then the action can be repeated with |.|.


================================================================================
REQUIREMENTS *atp-requirements*
Expand Down

0 comments on commit 44bc65e

Please sign in to comment.