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

customizing the UnsavedChanges event ?

Expand Messages
  • Yakov Lerner
    Is there an autoevent for a decision what to do with unsaved changes when leaving the unsaved modified buffer ? For example, customizing such event would allow
    Message 1 of 3 , Sep 5, 2003
    • 0 Attachment
      Is there an autoevent for a decision what to do with
      unsaved changes when leaving the unsaved modified buffer ?

      For example, customizing such event would allow me to
      specify:
      - for *.abc buffers - autowrite
      - for *.xyz buffers - ask
      - for *.pqr buffers - autowrite if leaving via commands x,y,z
      but ask if leaving via commands a,b,c
      - for *.klm buffers - autowrite with versiosning

      Does it exist, such autoevent ?

      Yakov Lerner
    • Keith Roberts
      ... e.g. au BufLeave *.abc :if &modified :w :endif Or, even better, define a function whose argument determines the actions above, then: au BufLeave
      Message 2 of 3 , Sep 5, 2003
      • 0 Attachment
        >-----Original Message-----
        >From: Yakov Lerner [mailto:qlerner@...]
        >Sent: Friday, September 05, 2003 12:19 AM
        >To: vim-dev@...
        >Subject: customizing the UnsavedChanges event ?
        >
        >Is there an autoevent for a decision what to do with
        >unsaved changes when leaving the unsaved modified buffer ?
        >
        >For example, customizing such event would allow me to
        >specify:
        > - for *.abc buffers - autowrite
        > - for *.xyz buffers - ask
        > - for *.pqr buffers - autowrite if leaving via commands x,y,z
        > but ask if leaving via commands a,b,c
        > - for *.klm buffers - autowrite with versiosning
        >
        >Does it exist, such autoevent ?
        >
        >Yakov Lerner
        >

        :h BufLeave

        e.g.
        au BufLeave *.abc :if &modified<cr>:w<cr>:endif<cr>


        Or, even better, define a function whose argument determines the actions
        above, then:
        au BufLeave *.abc Write_when_leave(write.arg)
        au BufLeave *.xyz Write_when_leave(query.arg)
        au BufLeave *.pqr Write_when_leave(xyz_abc.arg)

        You get the idea.
      • Bram Moolenaar
        ... No. You could use exception handling when it happens in a script. I ll add a note about adding an event for this, I can see it is useful. -- I m sure that
        Message 3 of 3 , Sep 5, 2003
        • 0 Attachment
          Yakov Lerner wrote:

          > Is there an autoevent for a decision what to do with
          > unsaved changes when leaving the unsaved modified buffer ?
          >
          > For example, customizing such event would allow me to
          > specify:
          > - for *.abc buffers - autowrite
          > - for *.xyz buffers - ask
          > - for *.pqr buffers - autowrite if leaving via commands x,y,z
          > but ask if leaving via commands a,b,c
          > - for *.klm buffers - autowrite with versiosning
          >
          > Does it exist, such autoevent ?

          No. You could use exception handling when it happens in a script.

          I'll add a note about adding an event for this, I can see it is useful.

          --
          I'm sure that I asked CBuilder to do a "full" install. Looks like I got
          a "fool" install, instead. Charles E Campbell, Jr, PhD


          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
          \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
          \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///
        Your message has been successfully submitted and would be delivered to recipients shortly.