Wednesday, October 7, 2015

Re: How can I take control over jumps `Ctrl-O` and `Ctrl-I` in Vimscript?

On Wednesday, October 7, 2015 at 9:01:25 AM UTC+2, Christian Brabandt wrote:
> Hi Annis!
>
> On Di, 06 Okt 2015, Annis Monadjem wrote:
>
> > On Wednesday, October 7, 2015 at 12:39:30 AM UTC+2, Annis Monadjem
> > wrote:
> > > Is there any way I could use Vimscript to go through the list of
> > > jumps `Ctrl-O`, `Ctrl-I` and to pick the previous jump
> > > buffers/positions?
> > >
> > > Any suggestion is greatly appreciated.
> >
> > Hi Tony, Thanks for your comments. I'm not there still. I'm trying to
> > write a Vimscript and I just need a hint on how to approach the
> > problem.
> >
> > I'm keeping all my Vim-Help-jump-buffers 'nobuflisted', except for the
> > very last Vim-Help-buffer which is 'buflisted'. I am doing this
> > purposely to keep my listing ':ls' concise and short. Most other
> > non-Help-buffers and their jumps would be 'buflisted', except for
> > deleted ones.
> >
> > When pressing 'Ctrl-O' I'd like to jump to earlier history of
> > positions/buffers of both Vim-Help-jump-buffers as well as
> > non-Help-buffers. In particular I would like to jump to
> > Vim-Help-jump-buffers even if these are 'nobuflisted'. While jumping
> > back to each earlier buffer I would like to make the new `Ctrl-O`
> > target buffer only 'buflisted' while the previous buffer
> > 'nobuflisted'. Problem is that `Ctrl-O` does not point nor open a
> > 'nobuflisted' buffer (at least I don't know) and I'd don't want to
> > 'buflisted' all Vim-Help-jump-buffers except the loaded/visible one.
> >
> > Please, share with me what would be my best approach to vimscript this
> > problem.
>
> I don't follow. Are you saying, that C-O/C-I does not jump if that
> particular buffer has been set to nobuflisted? That doesn't not sound
> right, but a quick test does not show this behaviour.
>
> So please provide exact steps that do this and show exactly what you
> expect and what happens.
>
> Best,
> Christian
> --
> Ein Blitzableiter auf einem Kirchturm ist das denkbar stärkste
> Mißtrauensvotum gegen den lieben Gott.
> -- Karl Kraus

Hi Karl,

Thanks for your remarks. Following your kind suggestion I have prepared a description below.

A) OVERALL SUMMARY:
I would like Vim Editor to show all buffers in ':ls' as usual with exception of Vim help buffers, i.e. generated by `:help` or `Ctrl-]`. Only the current active Vim-Help-buffer should be listed, while all other Vim-Help-buffers should be always unlisted. Also the editor should allow user to jump backward and forward as usual again with exception of Vim help buffers; the Vim-help-buffer where jump is active should be listed, while all other Vim-help-buffers should be unlisted.

B) THE OBJECTIVE:
To write a Vimscript that would make Vim only show the last Vim-Help-buffer as listed and all other Vim-Help-buffers as unlisted. When typing `Ctrl-O` or `Ctrl-T` (and the opposite when typing `Ctrl-I` and `Ctrl-]` in the reverse direction) it should work as usually in Vim, except in case Vim-Help-buffer is the visible/active/current buffer then:
1) if previous-buffer-jump is also a Vim-Help-buffer, then `Ctrl-O` or `Ctrl-T` should CHANGE the current Vim-Help-buffer to 'nobuflisted' before jumping to the previous Vim-Help-buffer and once on the previous one it would CHANGE it to 'buflisted'.
2) if previous buffer jump was any other NONE-Help-buffer, then `Ctrl-O` or `Ctrl-T` should KEEP the current NONE-Help-buffer as 'buflisted' and once on the previous one it should KEEP it also 'buflisted'.

C) WORK DONE AS OF NOW:
1) "~/.vim/after/ftplugin/help.vim" contains:
set buflisted

2) "~/.vimrc" contains:
autocmd BufEnter,BufWinEnter * if &filetype=='help'
\| only
\| execute "normal! zi"
\| let w:bufnuc = bufnr("%")
\| let w:bufnua = bufnr("#")
\| if w:bufnua > 0
\| execute "buffer " . w:bufnua
\| if &filetype=='help'
\| if w:bufnua != w:bufnuc
\| set nobuflisted
\| endif
\| endif
\| execute "buffer " . w:bufnuc
\| endif
\| endif

The code as specified above keeps the Vim-help-buffers unlisted with only one copy, the current one, listed.

D) PROBLEM REMAINING:
To write another script that auto-triggers whenever I press `Ctrl-O` or `Ctrl-T` (as well as `Ctrl-I` or `Ctrl-]` for reverse direction) on Vim-help-buffers and which would then follow instructions 1) and 2) in the above Objective.

I appreciate any suggestions and assistance.

Regards,
Annis Monadjem

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: