Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Version 1.21

- FIX: A 2]] jump inside a region (unless last line) jumped like a 1]] jump. The search for next region must not decrease the iteration counter when _not_ searching _across_ the region.
- FIX: Must not do (characterwise) end position adaptation for linewise text object that does not exclude boundaries.
- Switched example from email fortunes to Pascal begin..end blocks, as they are conceptually easier.
  • Loading branch information...
commit 38df8662926c2f8c16b22293262c4448d7c3625e 1 parent fa898eb
Ingo Karkat authored committed
View
30 autoload/CountJump/Region.vim
@@ -8,6 +8,11 @@
" Maintainer: Ingo Karkat <ingo@karkat.de>
"
" REVISION DATE REMARKS
+" 1.21.004 03-Aug-2010 FIX: A 2]] jump inside a region (unless last
+" line) jumped like a 1]] jump. The search for
+" next region must not decrease the iteration
+" counter when _not_ searching _across_ the
+" region.
" 1.20.003 30-Jul-2010 FIX: Removed setting of cursor position.
" FIX: CountJump#Region#Jump() with mode "O"
" didn't add original position to jump list.
@@ -168,19 +173,26 @@ function! CountJump#Region#SearchForNextRegion( count, pattern, step, isAcrossRe
" Check whether we're currently on the border of a region.
let l:isInRegion = (s:SearchInLineMatching(l:line, a:pattern, 1) != 0)
let l:isNextInRegion = (s:SearchInLineMatching((l:line + a:step), a:pattern, 1) != 0)
+"****D echomsg '**** in region:' (l:isInRegion ? 'current' : '') (l:isNextInRegion ? 'next' : '')
if l:isInRegion
if l:isNextInRegion
" We're inside a region; search for the current region's end.
let [l:line, l:col] = s:SearchForLastLineContinuouslyMatching(l:line, a:pattern, 1, a:step)
- if l:c == 1 && a:isAcrossRegion
- " We're done already!
- let l:isDone = 1
+ if a:isAcrossRegion
+ if l:c == 1
+ " We're done already!
+ let l:isDone = 1
+ else
+ " We've moved to the border, resume the search for following
+ " regions...
+ let l:c = max([l:c - 1, 1])
+ " ...from the next line so that we move out of the current
+ " region.
+ let l:line += a:step
+ endif
else
- " We've moved to the border, resume the search for following
- " regions...
- let l:c = max([l:c - 1, 1])
- " ...from the next line so that we move out of the current
- " region.
+ " We're on the border, start the search from the next line so
+ " that we move out of the current region.
let l:line += a:step
endif
else
@@ -190,6 +202,7 @@ function! CountJump#Region#SearchForNextRegion( count, pattern, step, isAcrossRe
endif
endif
+"****D echomsg '**** starting iteration on line' l:line
while ! l:isDone
" Search for the next region's start.
let [l:line, l:col] = s:SearchForLastLineContinuouslyMatching(l:line, a:pattern, 0, a:step)
@@ -199,6 +212,7 @@ function! CountJump#Region#SearchForNextRegion( count, pattern, step, isAcrossRe
let l:line += a:step
" If this is the last region to be found, we're almost done.
+"****D echomsg '**** iteration' l:c 'on line' l:line
let l:c -= 1
if l:c == 0
if a:isAcrossRegion
View
13 autoload/CountJump/TextObject.vim
@@ -9,6 +9,9 @@
" Maintainer: Ingo Karkat <ingo@karkat.de>
"
" REVISION DATE REMARKS
+" 1.21.008 03-Aug-2010 FIX: Must not do (characterwise) end position
+" adaptation for linewise text object that does
+" not exclude boundaries.
" 1.20.007 02-Aug-2010 The adjustment movements after the jumps to the
" text object boundaries now do not cause beeps if
" that movement cannot be done (e.g. a 'j' at the
@@ -134,6 +137,7 @@ function! CountJump#TextObject#TextObjectWithJumpFunctions( mode, isInner, isExc
set whichwrap+=h,l
try
let l:beginPosition = call(a:JumpToBegin, [1, a:isInner])
+"****D echomsg '**** begin' string(l:beginPosition) 'cursor:' string(getpos('.'))
if l:beginPosition != [0, 0]
if a:isExcludeBoundaries
if l:isLinewise
@@ -144,7 +148,9 @@ function! CountJump#TextObject#TextObjectWithJumpFunctions( mode, isInner, isExc
endif
let l:beginPosition = getpos('.')
+"****D echomsg '**** end search from' string(l:beginPosition)
let l:endPosition = call(a:JumpToEnd, [l:count, a:isInner])
+"****D echomsg '**** end ' string(l:endPosition) 'cursor:' string(getpos('.'))
if l:endPosition == [0, 0] ||
\ l:endPosition[0] < l:cursorLine ||
\ (! l:isLinewise && l:endPosition[0] == l:cursorLine && l:endPosition[1] < l:cursorCol)
@@ -167,8 +173,10 @@ function! CountJump#TextObject#TextObjectWithJumpFunctions( mode, isInner, isExc
else
let l:isSelected = 1
- if l:isLinewise && a:isExcludeBoundaries
- silent! normal! k
+ if l:isLinewise
+ if a:isExcludeBoundaries
+ silent! normal! k
+ endif
else
if ! l:isExclusive && a:isExcludeBoundaries
silent! normal! h
@@ -184,6 +192,7 @@ function! CountJump#TextObject#TextObjectWithJumpFunctions( mode, isInner, isExc
call setpos('.', l:beginPosition)
execute 'normal!' a:selectionMode
call setpos('.', l:endPosition)
+"****D echomsg '**** text object from' string(l:beginPosition) 'to' string(l:endPosition)
endif
endif
View
56 doc/CountJump.txt
@@ -34,6 +34,8 @@ This plugin contains some support for movement and text objects consisting of
text regions that can be defined by continuous lines that match a particular
pattern, e.g. comment blocks that all start with /^\s*#/.
+SEE ALSO *
+
RELATED WORKS *
- motpat.vim (vimscript #3030) offers similar functions to setup motion
mappings, but no text objects (yet).
@@ -109,38 +111,31 @@ CountJump#Motion#MakeBracketMotionWithJumpFunctions(). >
EXAMPLE *CountJump-example*
Let's illustrate the usage by developing custom motions and text objects for
-an email fortune file, which contains blocks of text delimited by lines
-containing a "-- " marker.
-
-
-We want to move around fortunes, and override the default section movements
-for it:
-]] Go to [count] next start of a fortune.
-][ Go to [count] next end of a fortune.
-[[ Go to [count] previous start of a fortune.
-[] Go to [count] previous end of a fortune.
+Pascal begin..end blocks.
+
+We want to move around blocks, and override the default section movements for
+it:
+]] Go to [count] next start of a block.
+][ Go to [count] next end of a block.
+[[ Go to [count] previous start of a block.
+[] Go to [count] previous end of a block.
>
- call CountJump#Motion#MakeBracketMotion('<buffer>', '', '', '^-- \?\n\zs', '^.*\n-- \?$', 0)
+ call CountJump#Motion#MakeBracketMotion('<buffer>', '', '', '\c^begin\n\zs', '\c^.*\nend', 0)
The begin pattern positions the cursor on the beginning of the line following
-the fortune separator '^-- \?', the end pattern on the beginning of the line
-preceding a separator.
+the "begin" keyword, the end pattern on the beginning of the line
+preceding the "end" keyword.
-We want to select a fortune, either including or excluding the preceding
-separator line:
-if "inner fortune" text object, select [count] fortunes,
- excluding the fortune separator.
-af "a fortune" text object, select [count] fortunes, including
- the preceding fortune separator.
+We want to select a block, either including or excluding the lines with the
+begin..end keywords:
+ib "inner block" text object, select [count] contents of
+ a block.
+ab "a block" text object, select [count] blocks.
>
- call CountJump#TextObject#MakeWithCountSearch('<buffer>', 'f', 'i', 'V', '^-- \?$', '^-- \?$\|\%$')
- call CountJump#TextObject#MakeWithCountSearch('<buffer>', 'f', 'a', 'V', '^-- \?$', '\ze.\n-- \?$\|\%$')
-The fortune text objects are linewise, and end either with a final separator
-or the end of the file.
+ call CountJump#TextObject#MakeWithCountSearch('<buffer>', 'b', 'ai', 'V', '\c^begin\n', '\c^end.*$')
-
-If there is a filetype detection for fortune files, we can simply put the
-above calls in a ~/.vim/ftplugin/fortunes_movement.vim script and are done.
+If there is a filetype detection for Pascal files, we can simply put the
+above calls in a ~/.vim/ftplugin/pascal_movement.vim script and are done.
==============================================================================
INSTALLATION *CountJump-installation*
@@ -185,6 +180,15 @@ IDEAS *CountJump-ideas*
==============================================================================
HISTORY *CountJump-history*
+1.21 03-Aug-2010
+- FIX: A 2]] jump inside a region (unless last line) jumped like a 1]] jump.
+ The search for next region must not decrease the iteration counter when
+ _not_ searching _across_ the region.
+- FIX: Must not do (characterwise) end position adaptation for linewise text
+ object that does not exclude boundaries.
+- Switched example from email fortunes to Pascal begin..end blocks, as they
+ are conceptually easier.
+
1.20 02-Aug-2010
- ENH: In CountJump#Motion#MakeBracketMotion(), a:keyAfterBracket and
a:inverseKeyAfterBracket can now be empty, the resulting mappings are then
Please sign in to comment.
Something went wrong with that request. Please try again.