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

Re: unlet-ing variables in buffers?

Expand Messages
  • Christian Brabandt
    Hi LCD! ... did you lock it? It worked for me with some test variable. ... I don t know. This depends on what locked it, I guess. ... Don t know. regards,
    Message 1 of 8 , Apr 11, 2013
    • 0 Attachment
      Hi LCD!

      On Do, 11 Apr 2013, LCD 47 wrote:

      > On 10 April 2013, Christian Brabandt <cblists@...> wrote:
      > > Hi LCD!
      >
      > Hi!
      >
      > > On Mi, 10 Apr 2013, LCD 47 wrote:
      > >
      > > > Variables local to (non-current) buffers can be read with
      > > > getbufvar() and written with setbufvar(). Is there a way to delete
      > > > variables from buffers? That is, is there a moral equivalent of
      > > > "unlet b:var" for non-current buffers?
      > >
      > > I think, since you only get references to variables when using
      > > getbufvar() you can simply modify the returned b: dict
      > >
      > > :call setbufvar(1, 'foobar', 2)
      > > :let var=getbufvar(1, '')
      > > :call filter(var, 'v:key != ''foobar''')
      > > :echo getbufvar(1, 'foobar')
      >
      > Hmm, interesting idea, but "var" is locked:
      >
      > E741: Value is locked: filter() argument

      did you lock it? It worked for me with some test variable.

      > Is it safe / sane to unlock it?

      I don't know. This depends on what locked it, I guess.

      > Also, I presume Vim maintains reference counts and the like for
      > garbage collection, would this kind of manipulation do the right
      > adjustments?

      Don't know.

      regards,
      Christian
      --
      Selbst eine gute Ehe ist Bußzeit.
      -- Russisches 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.
    • LCD 47
      ... I didn t, but in my test buffer 1 is hidden, and a buffer 2 is current (that s the case I care for). /lcd -- -- You received this message from the
      Message 2 of 8 , Apr 11, 2013
      • 0 Attachment
        On 11 April 2013, Christian Brabandt <cblists@...> wrote:
        > Hi LCD!
        >
        > On Do, 11 Apr 2013, LCD 47 wrote:
        >
        > > On 10 April 2013, Christian Brabandt <cblists@...> wrote:
        > > > Hi LCD!
        > >
        > > Hi!
        > >
        > > > On Mi, 10 Apr 2013, LCD 47 wrote:
        > > >
        > > > > Variables local to (non-current) buffers can be read with
        > > > > getbufvar() and written with setbufvar(). Is there a way to delete
        > > > > variables from buffers? That is, is there a moral equivalent of
        > > > > "unlet b:var" for non-current buffers?
        > > >
        > > > I think, since you only get references to variables when using
        > > > getbufvar() you can simply modify the returned b: dict
        > > >
        > > > :call setbufvar(1, 'foobar', 2)
        > > > :let var=getbufvar(1, '')
        > > > :call filter(var, 'v:key != ''foobar''')
        > > > :echo getbufvar(1, 'foobar')
        > >
        > > Hmm, interesting idea, but "var" is locked:
        > >
        > > E741: Value is locked: filter() argument
        >
        > did you lock it? It worked for me with some test variable.

        I didn't, but in my test buffer 1 is hidden, and a buffer 2 is
        current (that's the case I care for).

        /lcd

        --
        --
        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 LCD! ... That is probably the reason, the variable is locked, because the buffer is hidden. regards, Christian -- Flugzeug an Tower, Flugzeug an Tower: Wir
        Message 3 of 8 , Apr 11, 2013
        • 0 Attachment
          Hi LCD!

          On Do, 11 Apr 2013, LCD 47 wrote:

          > On 11 April 2013, Christian Brabandt <cblists@...> wrote:
          > > Hi LCD!
          > >
          > > On Do, 11 Apr 2013, LCD 47 wrote:
          > >
          > > > On 10 April 2013, Christian Brabandt <cblists@...> wrote:
          > > > > Hi LCD!
          > > >
          > > > Hi!
          > > >
          > > > > On Mi, 10 Apr 2013, LCD 47 wrote:
          > > > >
          > > > > > Variables local to (non-current) buffers can be read with
          > > > > > getbufvar() and written with setbufvar(). Is there a way to delete
          > > > > > variables from buffers? That is, is there a moral equivalent of
          > > > > > "unlet b:var" for non-current buffers?
          > > > >
          > > > > I think, since you only get references to variables when using
          > > > > getbufvar() you can simply modify the returned b: dict
          > > > >
          > > > > :call setbufvar(1, 'foobar', 2)
          > > > > :let var=getbufvar(1, '')
          > > > > :call filter(var, 'v:key != ''foobar''')
          > > > > :echo getbufvar(1, 'foobar')
          > > >
          > > > Hmm, interesting idea, but "var" is locked:
          > > >
          > > > E741: Value is locked: filter() argument
          > >
          > > did you lock it? It worked for me with some test variable.
          >
          > I didn't, but in my test buffer 1 is hidden, and a buffer 2 is
          > current (that's the case I care for).

          That is probably the reason, the variable is locked, because the buffer
          is hidden.

          regards,
          Christian
          --
          Flugzeug an Tower, Flugzeug an Tower: "Wir sind 1000 km von der Küste
          entfernt und haben keinen Tropfen Sprit mehr im Tank. Was sollen wir tun?
          Tower an Flugzeug: "Bitte sprechen sie mir nach: Vater unser, der du bist ..."

          --
          --
          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.
        • Yukihiro Nakadaira
          What vim version are you using. Perhaps older than 7.3.560? -- Yukihiro Nakadaira - yukihiro.nakadaira@gmail.com -- -- You received this message from the
          Message 4 of 8 , Apr 11, 2013
          • 0 Attachment
            What vim version are you using.
            Perhaps older than 7.3.560?

            --
            Yukihiro Nakadaira - yukihiro.nakadaira@...

            --
            --
            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.
             
             
          • LCD 47
            ... I m using 7.3.884. It doesn t matter, this is for a rather popular plugin, so if the solution depends on Vim version I ll have to think of a different
            Message 5 of 8 , Apr 12, 2013
            • 0 Attachment
              On 12 April 2013, Yukihiro Nakadaira <yukihiro.nakadaira@...> wrote:
              > What vim version are you using.
              > Perhaps older than 7.3.560?

              I'm using 7.3.884. It doesn't matter, this is for a rather popular
              plugin, so if the solution depends on Vim version I'll have to think of
              a different approach.

              /lcd

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