I considered that, actually. However, the :call docs contradict this, stating that the cursor is moved to the first line irrespective of the range separator.
I'd prefer updating :call to honor the range separator. This is potentially backwards incompatible. I think it would be preferable for sake of consistency with the :cmdline-ranges documentation -- are there objections to this backwards incompatible change and/or suggestions for ways to work around it? On Thu, Nov 29, 2012 at 9:40 AM, Roland Eggner <[email protected]>wrote: > On 2012-11-28 Wednesday at 23:26 -0800 So8res wrote: > > On Monday, November 19, 2012 1:52:44 PM UTC-8, So8res wrote: > > > I think functions with [range] should preserve the cursor line. Assume > you have: > > > > > > function RangeTest() range > > > echo line('.') > > > endfunction > > > > > > And you put the cursor on line 2 and :%call RangeTest() > > > > > > This function will echo 1, because the cursor is moved to the > beginning of the range *before* entering the function. > > > > > > I was attempting to create a function which does a search-replace (:s) > without moving the cursor (using winsaveview() and winrestview()). It turns > out this is not possible, because the cursor is moved before winsaveview() > can be called. > > > > > > Is this the intended behavior, or is it a bug? If it's intended, is > there a way to save the winview before entering a function with [range]? > > > > Bump. Should I add tests? What's the process for adding tests? (I > couldn't find a test testing function [range] and didn't think that adding > a new test file was the right decision. > > > > Are there any objections to adding this functionality? > > > :h cmdline-ranges > > 4. Ex command-line ranges *cmdline-ranges* *[range]* *E16* > > > > Some Ex commands accept a line range in front of them. This is noted as > > [range]. It consists of one or more line specifiers, separated with ',' > or > > ';'. > > > > The basics are explained in section |10.3| of the user manual. > > > > *:,* *:;* > > When separated with ';' the cursor position will be set to that line > > before interpreting the next line specifier. This doesn't happen for > ','. > > > Why not reusing or enhancing already established commandline syntax? > If “,” and “;” are not sufficient for all desired features of range > specifications, why not just introducing a new separator between line > specifications? E.g. two adjacent commas “,,”, or a caret character “^” > would > not clash with current commandline syntax AFAICS. This would be easier to > learn > from a user POV. Implementation might require more effort, though. > > -- > Roland > -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
