Loading ...
Sorry, an error occurred while loading the content.

BufEnter buggy?

Expand Messages
  • Aaron Bohannon
    I have an autocmd that updates the window title in my terminal based on the current file name. BufEnter clearly seems to be the event I would want to trigger
    Message 1 of 6 , Sep 28, 2013
    • 0 Attachment
      I have an autocmd that updates the window title in my terminal based on the current file name. BufEnter clearly seems to be the event I would want to trigger it with. But I've noticed two problems:

      (a) BufEnter isn't getting triggered after closing the last window in a tab and ending up in a different tab. It *should* be getting triggered, right? I mean, it gets triggered when I close a window and end up in a different window in the same tab, so why wouldn't it get triggered when I close a tab?

      (b) When switching directories in netrw (which switches buffers), BufEnter gets triggered before the directory location is known, so expand('%') will be empty. But once I'm in the directory, I get the directory location just fine by calling expand('%'), so I'm not sure how netrw is changing the buffer location *after* the BufEnter event. It seems like there's some questionable logic going on there, but I'm not sure who's to blame.

      ...Aaron

      --
      --
      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@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Christian Brabandt
      Hi Aaron! ... Are you sure? I can t replicate it. I don t see a message when doing ... But that seems to be related to the redrawing (since the old tabpage is
      Message 2 of 6 , Sep 29, 2013
      • 0 Attachment
        Hi Aaron!

        On Sa, 28 Sep 2013, Aaron Bohannon wrote:

        > (a) BufEnter isn't getting triggered after closing the last window in
        > a tab and ending up in a different tab. It *should* be getting
        > triggered, right? I mean, it gets triggered when I close a window and
        > end up in a different window in the same tab, so why wouldn't it get
        > triggered when I close a tab?

        Are you sure? I can't replicate it. I don't see a message when doing
        :au BufEnter * :echom "BufEnter triggered!"
        But that seems to be related to the redrawing (since the old tabpage is
        closed), but the event fires, nevertheless.

        Best,
        Christian
        --
        Es gibt kaum einen Menschen, von dem man nichts lernen kann.
        -- Chinesisches Sprichwort

        --
        --
        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@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Aaron Bohannon
        Yeah, I couldn t get any definitive information from :echo/:echom either. So I did this: autocmd BufEnter * let g:foo = expand( % ) And then I d check the
        Message 3 of 6 , Sep 29, 2013
        • 0 Attachment
          Yeah, I couldn't get any definitive information from :echo/:echom either. So I did this:

          autocmd BufEnter * let g:foo = expand('%')

          And then I'd check the value of g:foo with :echo after switching/closing windows.

          On Sunday, September 29, 2013 9:06:54 AM UTC-4, Christian Brabandt wrote:
          > Hi Aaron!
          >
          >
          >
          > On Sa, 28 Sep 2013, Aaron Bohannon wrote:
          >
          >
          >
          > > (a) BufEnter isn't getting triggered after closing the last window in
          >
          > > a tab and ending up in a different tab. It *should* be getting
          >
          > > triggered, right? I mean, it gets triggered when I close a window and
          >
          > > end up in a different window in the same tab, so why wouldn't it get
          >
          > > triggered when I close a tab?
          >
          >
          >
          > Are you sure? I can't replicate it. I don't see a message when doing
          >
          > :au BufEnter * :echom "BufEnter triggered!"
          >
          > But that seems to be related to the redrawing (since the old tabpage is
          >
          > closed), but the event fires, nevertheless.
          >
          >
          >
          > Best,
          >
          > Christian
          >
          > --
          >
          > Es gibt kaum einen Menschen, von dem man nichts lernen kann.
          >
          > -- Chinesisches Sprichwort

          --
          --
          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@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Christian Brabandt
          ... Now I am confused. Does this work for you yes or no? regards, Christian -- -- You received this message from the vim_use maillist. Do not top-post! Type
          Message 4 of 6 , Sep 30, 2013
          • 0 Attachment
            On Sun, September 29, 2013 19:58, Aaron Bohannon wrote:
            > So I did this:
            >
            > autocmd BufEnter * let g:foo = expand('%')
            >
            > And then I'd check the value of g:foo with :echo after switching/closing
            > windows.

            Now I am confused. Does this work for you yes or no?

            regards,
            Christian

            --
            --
            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@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • Aaron Bohannon
            The autocmd that sets the variable does not get run when I close the last window on a tab page. It is easy to check that it _does_ get run in other
            Message 5 of 6 , Sep 30, 2013
            • 0 Attachment

              The autocmd that sets the variable does not get run when I close the last window on a tab page. It is easy to check that it _does_ get run in other circumstances.

              On Sep 30, 2013 12:06 PM, "Christian Brabandt" <cblists@...> wrote:
              On Sun, September 29, 2013 19:58, Aaron Bohannon wrote:
              > So I did this:
              >
              > autocmd BufEnter *  let g:foo = expand('%')
              >
              > And then I'd check the value of g:foo with :echo after switching/closing
              > windows.

              Now I am confused. Does this work for you yes or no?

              regards,
              Christian

              --
              --
              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 a topic in the Google Groups "vim_use" group.
              To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/rIDzIjQ04sc/unsubscribe.
              To unsubscribe from this group and all its topics, send an email to vim_use+unsubscribe@....
              For more options, visit https://groups.google.com/groups/opt_out.

              --
              --
              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@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • Vlad Irnov
              ... Which Vim version are you using? I remember such bug being reported by someone and it was subsequently fixed before version 7.4. It can be tested as
              Message 6 of 6 , Sep 30, 2013
              • 0 Attachment
                On 9/28/13, Aaron Bohannon <aaron678@...> wrote:
                > I have an autocmd that updates the window title in my terminal based on the
                > current file name. BufEnter clearly seems to be the event I would want to
                > trigger it with. But I've noticed two problems:
                >
                > (a) BufEnter isn't getting triggered after closing the last window in a tab
                > and ending up in a different tab. ...

                Which Vim version are you using? I remember such bug being reported by
                someone and it was subsequently fixed before version 7.4. It can be
                tested as follows:

                tabnew Foo
                autocmd BufEnter <buffer> let g:foo+=1
                tabmove
                tabnew
                let g:foo = 0
                wincmd c
                echo g:foo

                The output is:
                0 (wrong) in Vim 7.3.829
                1 (correct) in Vim 7.3.145, Vim 7.4.000

                Regards,
                Vlad

                --
                --
                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@....
                For more options, visit https://groups.google.com/groups/opt_out.
              Your message has been successfully submitted and would be delivered to recipients shortly.