Sunday, November 4, 2012

Re: sourcing functions in file with has gui_running from .vimrc

On 04/11/12 11:06, Marcin Szamotulski wrote:
> On 23:40 Sat 03 Nov , Chris Lott wrote:
>> Currently running:
>>
>> VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Sep 1 2012 18:08:47)
>> MacOS X (unix) version
>> Included patches: 1-646
>> Compiled by Bjorn Winckler <bjorn.winckler@gmail.com>
>>
>> I have these lines in my .vimrc
>>
>> if has("gui_macvim")
>> source ~/.vim/vimrc/mygfuncs.vim
>> endif
>>
>> In the mygfuncs file are some functions that set the `guitablabel` and
>> `guitabtooltip` based on two custom functions. The file is being
>> sourced (because the functions are defined), but the lines that set
>> those variables using those functions aren't working:
>>
>> set guitabtooltip=%{GuiTabToolTip()}
>> set guitablabel=%{GuiTabLabel()}
>>
>> At this point, the variables are set properly, because if I
>>
>> :set guitabtooltip
>>
>> Vim responds with
>>
>> guitabtooltip=%{GuiTabToolTip()}
>>
>> But it isn't actually being applied.
>>
>> **But** if I then `:so ~/.vimrc`, the tab label and tooltips *are* applied.
>>
>> What is going on here?
>>
>> c
>> --
>> Chris Lott <chris@chrislott.org>
>>
>> --
>> 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
>
> The way to set an option from a value returned by a function is:
>
> let &guitabltooltip=GuiTabToolTip()
>
> if you want to set local value (like setlocal does) you could use:
>
> let &l:guitabtooltip=GuiTabToolTip()
>
> You can read about it in ":help :let-&". You can also use the short
> name of an option. &guitabtooltip is just a VimL variable. There is
> also &g:guitabtooltip which will work like using the :setglobal command.
>
> Best,
> Marcin
>
No, :set guitablabel=%{GuiTabLabel()} is actually the example given
under :help 'guitablabel' so that the function is calculated every time
Vim tries to display the GUI tabs. Using :let &guitablabel =
GuiTabLabel() would calculate the function just once, when setting the
option.

For GUI tabs to be displayed, you need the e flag in 'guioptions'. Also,
the value of 'showtabline' is relevant:
0 Never
1 (default) Only if there are two or more tab pages
2 Always

If 'showtabline' is nonzero and 'guioptions' does not contain e you'll
get text-style tabs as defined by the 'tabline' option, even in GUI mode.

If these options are set correctly and you still don't see the tabs,
then another possibility is that Vim would set 'guitablabel' and
'guitabtooltip' to some default (or empty) value at GUI startup. To
counteract this, you can set them at the GUIEnter autocommand event:

if has('gui') && has('autocmd') && has('windows')
au GUIEnter * set gtl=%{GuiTabLabel()} gtt=%{GuiTabTooltip()}
endif


Best regards,
Tony.
--
Mother told me to be good, but she's been wrong before.

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

No comments: