Tlist and autocmd

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Tlist and autocmd

Eddy Petrișor
Hello,

I am quite new to vim usage, but I like it very much.
Currently I have a small problem. I want Tlist to be started every
time I switch to a C or C++ file (header, too) buffer.

The problem is that if Tlist is ran multiple times, Tlist is toggled.
I have the same problem with colorscheme, as I want to use a different
color scheme when edititng C source files.

Currently I have this in my vimrc:


" if we are editing c, then use my colours
if !exists("autocommands_loaded")
   let autocommands_loaded = 1
   au Syntax * colorscheme default
   au Syntax c colorscheme eddy
   au Syntax cpp colorscheme eddy
"
   au Syntax c Tlist
.....

But this does not work as I want it (It was not clear what hooks are
available for autocmd).

--
Regards,
EddyP
=============================================
"Imagination is more important than knowledge" A.Einstein
Reply | Threaded
Open this post in threaded view
|

Re: Tlist and autocmd

iler.ml
On 4/4/06, Eddy Petrişor <[hidden email]> wrote:

> I am quite new to vim usage, but I like it very much.
> Currently I have a small problem. I want Tlist to be started every
> time I switch to a C or C++ file (header, too) buffer.
>
> The problem is that if Tlist is ran multiple times, Tlist is toggled.
> I have the same problem with colorscheme, as I want to use a different
> color scheme when edititng C source files.
>
> Currently I have this in my vimrc:
>
>
> " if we are editing c, then use my colours
> if !exists("autocommands_loaded")
>    let autocommands_loaded = 1
>    au Syntax * colorscheme default
>    au Syntax c colorscheme eddy
>    au Syntax cpp colorscheme eddy
> "
>    au Syntax c Tlist

I use either 'au FileType' for filetype-dependent things, or
' au BufRead,BufNewFile *.c ....', but not 'au Syntax'.

I don't think 'au Syntax' is triggered when you load  another file.

Yakov
Reply | Threaded
Open this post in threaded view
|

Re: Tlist and autocmd

Eddy Petrișor
On 4/4/06, Yakov Lerner <[hidden email]> wrote:

> On 4/4/06, Eddy Petrişor <[hidden email]> wrote:
> > I am quite new to vim usage, but I like it very much.
> > Currently I have a small problem. I want Tlist to be started every
> > time I switch to a C or C++ file (header, too) buffer.
> >
> > The problem is that if Tlist is ran multiple times, Tlist is toggled.
> > I have the same problem with colorscheme, as I want to use a different
> > color scheme when edititng C source files.
> >
> > Currently I have this in my vimrc:
> >
> >
> > " if we are editing c, then use my colours
> > if !exists("autocommands_loaded")
> >    let autocommands_loaded = 1
> >    au Syntax * colorscheme default
> >    au Syntax c colorscheme eddy
> >    au Syntax cpp colorscheme eddy
> > "
> >    au Syntax c Tlist
>
> I use either 'au FileType' for filetype-dependent things, or
> ' au BufRead,BufNewFile *.c ....', but not 'au Syntax'.
>
> I don't think 'au Syntax' is triggered when you load  another file.


Thanks. This kind of works, but still s not what I wanted.

Problems:
 - colorscheme does not apply per window, and if I have multiple
windows, the colorscheme does not apply per window, but per whole
(using :bn works as expected, but ^ww doesn't). Is this possible?
Bram?
 - Tlist still toggles on and off if I switch from one C file to another C file

Is there a onTlist command (with that functionality) ?

--
Regards,
EddyP
=============================================
"Imagination is more important than knowledge" A.Einstein
Reply | Threaded
Open this post in threaded view
|

Re: Tlist and autocmd

Eddy Petrișor
On 4/5/06, Eddy Petrişor <[hidden email]> wrote:

> On 4/4/06, Yakov Lerner <[hidden email]> wrote:
> > On 4/4/06, Eddy Petrişor <[hidden email]> wrote:
> > > " if we are editing c, then use my colours
> > > if !exists("autocommands_loaded")
> > >    let autocommands_loaded = 1
> > >    au Syntax * colorscheme default
> > >    au Syntax c colorscheme eddy
> > >    au Syntax cpp colorscheme eddy
> > > "
> > >    au Syntax c Tlist

Changed that into TlistOpen and patched the taglist.vim file as below


--- taglist.vim.orig    Mon Aug 16 07:31:46 2004
+++ taglist.vim Wed Apr  5 16:19:17 2006
@@ -1660,6 +1660,20 @@
     let s:Tlist_Skip_Refresh = prev_Tlist_Skip_Refresh
 endfunction

+" Tlist_UserOpen_Window()
+" Open or close a taglist window
+function! s:Tlist_UserOpen_Window()
+    let curline = line('.')
+
+    " If taglist window is open then close it.
+    let winnum = bufwinnr(g:TagList_title)
+    if winnum != -1
+        return
+    endif
+
+    call s:Tlist_Toggle_Window()
+endfunction
+
 " Tlist_Extract_Tagtype
 " Extract the tag type from the tag text
 function! s:Tlist_Extract_Tagtype(tag_txt)
@@ -2778,6 +2792,7 @@

 " Define the user commands to manage the taglist window
 command! -nargs=0 Tlist call s:Tlist_Toggle_Window()
+command! -nargs=0 TlistOpen call s:Tlist_UserOpen_Window()
 command! -nargs=0 TlistClose call s:Tlist_Close_Window()
 command! -nargs=0 TlistUpdate call s:Tlist_Update_Tags()
 command! -nargs=0 TlistSync call s:Tlist_Highlight_Tag(


>  - Tlist still toggles on and off if I switch from one C file to another C file

This is fixed now. Does the author of Tlist read this ML?

> Is there a onTlist command (with that functionality) ?

Now it is and is called TlistOpen :-)

I know this is a hack, but it works in the way I need it to work.

> Problems:
>  - colorscheme does not apply per window, and if I have multiple
> windows, the colorscheme does not apply per window, but per whole
> (using :bn works as expected, but ^ww doesn't). Is this possible?
> Bram?

Still having this issue

--
Regards,
EddyP
=============================================
"Imagination is more important than knowledge" A.Einstein
Reply | Threaded
Open this post in threaded view
|

Re: Tlist and autocmd

Yegappan Lakshmanan
Hello,

On 4/5/06, Eddy Petrişor <[hidden email]> wrote:

>
> Changed that into TlistOpen and patched the taglist.vim file as below
>
>
> --- taglist.vim.orig    Mon Aug 16 07:31:46 2004
> +++ taglist.vim Wed Apr  5 16:19:17 2006
> @@ -1660,6 +1660,20 @@
>      let s:Tlist_Skip_Refresh = prev_Tlist_Skip_Refresh
>  endfunction
>
> +" Tlist_UserOpen_Window()
> +" Open or close a taglist window
> +function! s:Tlist_UserOpen_Window()
> +    let curline = line('.')
> +
> +    " If taglist window is open then close it.
> +    let winnum = bufwinnr(g:TagList_title)
> +    if winnum != -1
> +        return
> +    endif
> +
> +    call s:Tlist_Toggle_Window()
> +endfunction
> +
>  " Tlist_Extract_Tagtype
>  " Extract the tag type from the tag text
>  function! s:Tlist_Extract_Tagtype(tag_txt)
> @@ -2778,6 +2792,7 @@
>
>  " Define the user commands to manage the taglist window
>  command! -nargs=0 Tlist call s:Tlist_Toggle_Window()
> +command! -nargs=0 TlistOpen call s:Tlist_UserOpen_Window()
>  command! -nargs=0 TlistClose call s:Tlist_Close_Window()
>  command! -nargs=0 TlistUpdate call s:Tlist_Update_Tags()
>  command! -nargs=0 TlistSync call s:Tlist_Highlight_Tag(
>
>
> >  - Tlist still toggles on and off if I switch from one C file to another C file
>
> This is fixed now. Does the author of Tlist read this ML?
>

The "TlistOpen" command is already supported by the taglist
plugin in the latest version (4.0b3). You can use the following
taglist commands:

TlistOpen - Open the taglist window
TlistClose - Close the taglist window
TlistToggle - Open/Close (Toggle) the taglist window

- Yegappan

>
> > Is there a onTlist command (with that functionality) ?
>
> Now it is and is called TlistOpen :-)
>
> I know this is a hack, but it works in the way I need it to work.
>
Reply | Threaded
Open this post in threaded view
|

Re: Tlist and autocmd

Eddy Petrișor
On 4/5/06, Yegappan Lakshmanan <[hidden email]> wrote:
> Hello,

Hello Yegappan,

> The "TlistOpen" command is already supported by the taglist
> plugin in the latest version (4.0b3). You can use the following
> taglist commands:
>
> TlistOpen - Open the taglist window
> TlistClose - Close the taglist window
> TlistToggle - Open/Close (Toggle) the taglist window

Any stable release soon?

--
Regards,
EddyP
=============================================
"Imagination is more important than knowledge" A.Einstein
Reply | Threaded
Open this post in threaded view
|

Re: Tlist and autocmd

Yegappan Lakshmanan
Hello,

On 4/6/06, Eddy Petrişor <[hidden email]> wrote:
>
> > The "TlistOpen" command is already supported by the taglist
> > plugin in the latest version (4.0b3). You can use the following
> > taglist commands:
> >
> > TlistOpen - Open the taglist window
> > TlistClose - Close the taglist window
> > TlistToggle - Open/Close (Toggle) the taglist window
>

I have uploaded another beta version of the taglist plugin (4.0b4).
You can get it from:

http://vim.sourceforge.net/scripts/script.php?script_id=273

In this version, a new 'Tlist_GainFocus_On_ToggleOpen' option
setting is supported. When this variable is set, when opening the
taglist window using the ':TlistToggle' command the cursor will
be moved to the taglist window.

>
> Any stable release soon?
>

If there are no problems, then I will release the 4.0 version of the
taglist plugin in a few weeks.

- Yegappan