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

Setting buffer variable for a buffer that is being created...

Expand Messages
  • Hari
    I m trying to setup an event that will mark a buffer variable upon creation (tabnew, tabe [no filename]). The code below sets the variable for the current
    Message 1 of 3 , Nov 1, 2008
    • 0 Attachment
      I'm trying to setup an event that will mark a buffer variable upon creation (tabnew, tabe   [no filename]). The code below sets the variable for the current active buffer, not for the new one that is being created. Am I doing something that is even possible?


      autocmd BufCreate * call HandleFileNewEvent()

      function! HandleFileNewEvent()
       " Mark file as new
       " try different tricks to find the right buffer

       "  this sets the variable for the current buffer //ERROR
          let b:FileNew = 1

      " This complains that the buffer number is not found, ls later shows that the number is correct... too early? // ERROR
          call setbufvar(expand("<abuf>"), "FileNew1", 1)

      endfunction




      Thanks!
      Hari


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---

    • Hari
      This worked: call setbufvar(str2nr(expand( )), FileNew , 1) ... --~--~---------~--~----~------------~-------~--~----~ You received this message from
      Message 2 of 3 , Nov 1, 2008
      • 0 Attachment
        This worked:
            call setbufvar(str2nr(expand('<abuf>')), "FileNew", 1)

        On Sat, Nov 1, 2008 at 9:34 PM, Hari <hari.rangarajan@...> wrote:
        I'm trying to setup an event that will mark a buffer variable upon creation (tabnew, tabe   [no filename]). The code below sets the variable for the current active buffer, not for the new one that is being created. Am I doing something that is even possible?


        autocmd BufCreate * call HandleFileNewEvent()

        function! HandleFileNewEvent()
         " Mark file as new
         " try different tricks to find the right buffer

         "  this sets the variable for the current buffer //ERROR
            let b:FileNew = 1

        " This complains that the buffer number is not found, ls later shows that the number is correct... too early? // ERROR
            call setbufvar(expand("<abuf>"), "FileNew1", 1)

        endfunction




        Thanks!
        Hari



        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---

      • Tony Mechelynck
        ... The fact that the current buffer is not the buffer being created is documented under :help BufCreate . Have you tried not using expand()? call
        Message 3 of 3 , Nov 2, 2008
        • 0 Attachment
          On 02/11/08 05:34, Hari wrote:
          > I'm trying to setup an event that will mark a buffer variable upon
          > creation (tabnew, tabe [no filename]). The code below sets the variable
          > for the current active buffer, not for the new one that is being
          > created. Am I doing something that is even possible?
          >
          >
          > autocmd BufCreate * call HandleFileNewEvent()
          >
          > function! HandleFileNewEvent()
          > " Mark file as new
          > " try different tricks to find the right buffer
          >
          > " this sets the variable for the current buffer //ERROR
          > let b:FileNew = 1
          >
          > " This complains that the buffer number is not found, ls later shows
          > that the number is correct... too early? // ERROR
          > call setbufvar(expand("<abuf>"), "FileNew1", 1)
          >
          > endfunction
          >
          >
          >
          >
          > Thanks!
          > Hari

          The fact that the current buffer is not the buffer being created is
          documented under ":help BufCreate".

          Have you tried not using expand()?

          call setbufvar("<abuf>", "FileNew1", 1)


          Best regards,
          Tony.
          --
          The study of non-linear physics is like the study of non-elephant
          biology.

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        Your message has been successfully submitted and would be delivered to recipients shortly.