On 11/12/13 14:38, Bram Moolenaar wrote:

Christian Brabandt wrote:

On Mo, 09 Dez 2013, Bram Moolenaar wrote:

Christian Brabandt wrote:

Bram,
I use an uppercase mark to access a blowfish encrypted file. I therefore
:bwipe that buffer when I'm done with this file. Unfortunately, I can't
use the uppercase mark again, to reload that file, Vim throws E92 error.

Attached patch fixes it and includes a test.

Seems useful.  However, why not only :bdelete the buffer?  What remains
behind that :bwipe does get rid of?

I didn't want to leave behind any way to see what buffers where loaded.

Ehm, but your patch keeps the mark, so you leave that behind.
That more or less indicates you were editing that file.

What if someone relies on :bwipe clearing the mark?  E.g., when it's a
temp file with a weird name that you don't want to accidentally jump
back to?

Is this really a problem, that someone wipes a buffer and relies on the
fact, that going back to that mark errors out? One should rather use
:delmark or use setpos() function in that case.

No, when one edits text in a temp file, you just :bwipe it to avoid
going back to that file in any way.  That works because the file name
was only stored in the buffer and it's gone.  You don't have to think
about where else the name would be stored or what marks point into that
file.

So, instead of your patch, you could create a command ":WipeBufKeepMark"
that uses setpos().  Except that setpos() requires a buffer number...
Hmm.  Perhaps we should add a way to have setpos() accept a file name?
Then you can solve it in Vimscript.


Save the filename in a VARIABLE_IN_CAPITALS and remember it in the viminfo (with the ! flag set in the 'viminfo', but not at the end if the r flag is also set). The line number (if it may be other than the latest linenumber for that file) can be remembered the same way in another, related, variable. Instead of setpos() you would then use something like

        if exists('FILENAME_A') && FILENAME_A != ""
                        \ && filereadable('FILENAME_A')
                if !exists ('LINENUMBER_A')
                        let LINENUMBER_A = 0
                endif
                exe 'e +' . LINENUMBER_A FILENAME_A
        endif

which can, of course, be assigned to a function.

Best regards,
Tony.
--
If at first you don't succeed, you must be a programmer.

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

--- You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Raspunde prin e-mail lui