Am 21.11.2012 09:05, schrieb Ingo Karkat:
On 20-Nov-12 20:14:08 +0100, Nate Soares wrote:

In that case I'd like to make a feature request for a way to handle
functions with ranges without moving the cursor. My suggestion would
be adding a [save] argument to :function which calls winsaveview()
before entering and winrestview() after exiting the function, as this
has potential applications beyond just [range] functions.

Compared to the invocation of user commands with a range:

Alright, when one defines a user command with `-range', the cursor
doesn't move:

    :com! -bar -range TestRangeCursor :echo "Range: <line1>,<line2>"
    :%TestRangeCursor

There are also several Ex-commands that don't move:
    :foldopen, :=, :z, :yank, ...

Others move although they don't operate on the range:
    :list, :print, ...

Thoughts on the proposed api?

That might be a good compromise. Even though nobody has so far come up
with a use case for the current, impractical behavior, Bram is
(rightly) very concerned about preserving behavior.

Though I have no experience with this, I guess this argument (I'd call
it [keepview]) could be implemented without many lines of code and
effort.

-- regards, ingo

PS: Please bottom-post on this list.

Somehow I don't like `keepview', it does too much.

What about a function modifier (next to `range') that just prevents
cursor movement?  No idea for a good name yet:
   dontmove
   keeppos
   stay

func! MyFunc() range stay
   echo a:firstline a:lastline
endfunc

(for the uninitiated, this is about unwanted cursor movement with
    :func! MyFunc() range
    :endfunc
    :10,20call MyFunc()
)

--
Andy

--
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

Raspunde prin e-mail lui