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

Execution of macro right before save of file

Expand Messages
  • Meino Christian Cramer
    Hi, For my daily work it is neccessary, that I will not save files with lines matching ^[ ]+$ I thought of binding clean to a hook but can t find an
    Message 1 of 7 , Nov 1, 2005
    • 0 Attachment
      Hi,

      For my daily work it is neccessary, that I will not save files with
      lines matching ^[ ]+$

      I thought of binding 'clean' to a hook but can't find an appropiate
      hook for that. Additionally I connot decide whether I understood the
      concept of hooks and how to use them for sure.... :)

      Is there a way to achieve the execution of 'clean' right before
      saveing the buffer ?

      Thank you very much for any help in advance!
      Meino
    • Steven Phillips
      There is no built in mechanism at present although I can see a need of one. With the current release the best (and only) solution I can think of is to rebind
      Message 2 of 7 , Nov 1, 2005
      • 0 Attachment
        There is no built in mechanism at present although I can see a need of one.
        With the current release the best (and only) solution I can think of is to
        rebind the keys you use to save the buffer to a macro which first cleans the
        buffer, e.g.:

        define-macro my-save-buffer
        clean
        @# save-buffer @mna
        !emacro
        global-bind-key my-save-buffer "C-x C-s"

        (Note I have not tested this macro!)

        Steve

        > Subject: [jasspa] Execution of macro right before save of file
        > From: Meino Christian Cramer <Meino.Cramer@...>
        > Date: Tuesday, November 1, 2005, 6:35:02 PM
        > To: jasspa@yahoogroups.com
        > Hi,

        > For my daily work it is neccessary, that I will not save files with
        > lines matching ^[ ]+$

        > I thought of binding 'clean' to a hook but can't find an appropiate
        > hook for that. Additionally I connot decide whether I understood the
        > concept of hooks and how to use them for sure.... :)

        > Is there a way to achieve the execution of 'clean' right before
        > saveing the buffer ?

        > Thank you very much for any help in advance!
        > Meino





        > __________________________________________________________________________

        > This is an unmoderated list. JASSPA is not responsible for the content of
        > any material posted to this list.

        > To unsubscribe, send a mail message to

        > mailto:jasspa-unsubscribe@yahoogroups.com

        > or visit http://groups.yahoo.com/group/jasspa and
        > modify your account settings manually.


        >
        > Yahoo! Groups Links



        >
      • Meino Christian Cramer
        From: Steven Phillips Subject: Re: [jasspa] Execution of macro right before save of file Date: Tue, 1 Nov 2005 23:01:00 +0000 Hi Steve !
        Message 3 of 7 , Nov 1, 2005
        • 0 Attachment
          From: Steven Phillips <bill@...>
          Subject: Re: [jasspa] Execution of macro right before save of file
          Date: Tue, 1 Nov 2005 23:01:00 +0000

          Hi Steve !

          Thanks a for the macro! :O)
          Sometimes the solution for a problem is too simple and too
          straight-forward as it can be found by me... :O)))))))))

          Beside of that I would welcome the implementation of
          I-will-now-leave-fhook. An additional idea would be the possibility
          to stop the process of saveing (and leaving) if the macro to be
          executed returns an error code. A message could be displayed than.

          This would ensure that certain files have to be saved in a certain
          format. This would make life in companies sometimes more easier ;)

          Thanks a lot for your help!
          Have a nice day!
          Meino


          > There is no built in mechanism at present although I can see a need of one.
          > With the current release the best (and only) solution I can think of is to
          > rebind the keys you use to save the buffer to a macro which first cleans the
          > buffer, e.g.:
          >
          > define-macro my-save-buffer
          > clean
          > @# save-buffer @mna
          > !emacro
          > global-bind-key my-save-buffer "C-x C-s"
          >
          > (Note I have not tested this macro!)
          >
          > Steve
          >
          > > Subject: [jasspa] Execution of macro right before save of file
          > > From: Meino Christian Cramer <Meino.Cramer@...>
          > > Date: Tuesday, November 1, 2005, 6:35:02 PM
          > > To: jasspa@yahoogroups.com
          > > Hi,
          >
          > > For my daily work it is neccessary, that I will not save files with
          > > lines matching ^[ ]+$
          >
          > > I thought of binding 'clean' to a hook but can't find an appropiate
          > > hook for that. Additionally I connot decide whether I understood the
          > > concept of hooks and how to use them for sure.... :)
          >
          > > Is there a way to achieve the execution of 'clean' right before
          > > saveing the buffer ?
          >
          > > Thank you very much for any help in advance!
          > > Meino
          >
          >
          >
          >
          >
          > > __________________________________________________________________________
          >
          > > This is an unmoderated list. JASSPA is not responsible for the content of
          > > any material posted to this list.
          >
          > > To unsubscribe, send a mail message to
          >
          > > mailto:jasspa-unsubscribe@yahoogroups.com
          >
          > > or visit http://groups.yahoo.com/group/jasspa and
          > > modify your account settings manually.
          >
          >
          > >
          > > Yahoo! Groups Links
          >
          >
          >
          > >
          >
          >
          >
          >
          >
          > __________________________________________________________________________
          >
          > This is an unmoderated list. JASSPA is not responsible for the content of
          > any material posted to this list.
          >
          > To unsubscribe, send a mail message to
          >
          > mailto:jasspa-unsubscribe@yahoogroups.com
          >
          > or visit http://groups.yahoo.com/group/jasspa and
          > modify your account settings manually.
          >
          >
          >
          > Yahoo! Groups Links
          >
          >
          >
          >
          >
          >
        • Meino Christian Cramer
          From: Steven Phillips Subject: Re: [jasspa] Execution of macro right before save of file Date: Tue, 1 Nov 2005 23:01:00 +0000 Hi Steve, the
          Message 4 of 7 , Nov 2, 2005
          • 0 Attachment
            From: Steven Phillips <bill@...>
            Subject: Re: [jasspa] Execution of macro right before save of file
            Date: Tue, 1 Nov 2005 23:01:00 +0000

            Hi Steve,

            the macro "kills" me -- ooops...not me of course...it kills ME ;)

            I got "Error executing <macrofile>, line <line#>."

            Pressing RETURN then (which normally loads the offending file)
            displays in the minibuffer "No such command "<binary garbage>", where
            <binary garbarge> is some non-ascii- characters.

            I will try to fix this by myself...I just want to post this as an
            information only.

            Keep microemacsing!
            Meino


            > There is no built in mechanism at present although I can see a need of one.
            > With the current release the best (and only) solution I can think of is to
            > rebind the keys you use to save the buffer to a macro which first cleans the
            > buffer, e.g.:
            >
            > define-macro my-save-buffer
            > clean
            > @# save-buffer @mna
            > !emacro
            > global-bind-key my-save-buffer "C-x C-s"
            >
            > (Note I have not tested this macro!)
            >
            > Steve
            >
            > > Subject: [jasspa] Execution of macro right before save of file
            > > From: Meino Christian Cramer <Meino.Cramer@...>
            > > Date: Tuesday, November 1, 2005, 6:35:02 PM
            > > To: jasspa@yahoogroups.com
            > > Hi,
            >
            > > For my daily work it is neccessary, that I will not save files with
            > > lines matching ^[ ]+$
            >
            > > I thought of binding 'clean' to a hook but can't find an appropiate
            > > hook for that. Additionally I connot decide whether I understood the
            > > concept of hooks and how to use them for sure.... :)
            >
            > > Is there a way to achieve the execution of 'clean' right before
            > > saveing the buffer ?
            >
            > > Thank you very much for any help in advance!
            > > Meino
            >
            >
            >
            >
            >
            > > __________________________________________________________________________
            >
            > > This is an unmoderated list. JASSPA is not responsible for the content of
            > > any material posted to this list.
            >
            > > To unsubscribe, send a mail message to
            >
            > > mailto:jasspa-unsubscribe@yahoogroups.com
            >
            > > or visit http://groups.yahoo.com/group/jasspa and
            > > modify your account settings manually.
            >
            >
            > >
            > > Yahoo! Groups Links
            >
            >
            >
            > >
            >
            >
            >
            >
            >
            > __________________________________________________________________________
            >
            > This is an unmoderated list. JASSPA is not responsible for the content of
            > any material posted to this list.
            >
            > To unsubscribe, send a mail message to
            >
            > mailto:jasspa-unsubscribe@yahoogroups.com
            >
            > or visit http://groups.yahoo.com/group/jasspa and
            > modify your account settings manually.
            >
            >
            >
            > Yahoo! Groups Links
            >
            >
            >
            >
            >
            >
          • Meino Christian Cramer
            From: Steven Phillips Subject: Re: [jasspa] Execution of macro right before save of file Date: Tue, 1 Nov 2005 23:01:00 +0000 Hi, FIXED! It
            Message 5 of 7 , Nov 2, 2005
            • 0 Attachment
              From: Steven Phillips <bill@...>
              Subject: Re: [jasspa] Execution of macro right before save of file
              Date: Tue, 1 Nov 2005 23:01:00 +0000

              Hi,

              FIXED!
              It was some non-visible "something" between my macro definition...

              Sorry for the wrong alert.

              Keep microemacsing!
              Meino


              > There is no built in mechanism at present although I can see a need of one.
              > With the current release the best (and only) solution I can think of is to
              > rebind the keys you use to save the buffer to a macro which first cleans the
              > buffer, e.g.:
              >
              > define-macro my-save-buffer
              > clean
              > @# save-buffer @mna
              > !emacro
              > global-bind-key my-save-buffer "C-x C-s"
              >
              > (Note I have not tested this macro!)
              >
              > Steve
              >
              > > Subject: [jasspa] Execution of macro right before save of file
              > > From: Meino Christian Cramer <Meino.Cramer@...>
              > > Date: Tuesday, November 1, 2005, 6:35:02 PM
              > > To: jasspa@yahoogroups.com
              > > Hi,
              >
              > > For my daily work it is neccessary, that I will not save files with
              > > lines matching ^[ ]+$
              >
              > > I thought of binding 'clean' to a hook but can't find an appropiate
              > > hook for that. Additionally I connot decide whether I understood the
              > > concept of hooks and how to use them for sure.... :)
              >
              > > Is there a way to achieve the execution of 'clean' right before
              > > saveing the buffer ?
              >
              > > Thank you very much for any help in advance!
              > > Meino
              >
              >
              >
              >
              >
              > > __________________________________________________________________________
              >
              > > This is an unmoderated list. JASSPA is not responsible for the content of
              > > any material posted to this list.
              >
              > > To unsubscribe, send a mail message to
              >
              > > mailto:jasspa-unsubscribe@yahoogroups.com
              >
              > > or visit http://groups.yahoo.com/group/jasspa and
              > > modify your account settings manually.
              >
              >
              > >
              > > Yahoo! Groups Links
              >
              >
              >
              > >
              >
              >
              >
              >
              >
              > __________________________________________________________________________
              >
              > This is an unmoderated list. JASSPA is not responsible for the content of
              > any material posted to this list.
              >
              > To unsubscribe, send a mail message to
              >
              > mailto:jasspa-unsubscribe@yahoogroups.com
              >
              > or visit http://groups.yahoo.com/group/jasspa and
              > modify your account settings manually.
              >
              >
              >
              > Yahoo! Groups Links
              >
              >
              >
              >
              >
              >
            • Meino Christian Cramer
              From: Steven Phillips Subject: Re: [jasspa] Execution of macro right before save of file Date: Tue, 1 Nov 2005 23:01:00 +0000 Hi Steve, I
              Message 6 of 7 , Nov 6, 2005
              • 0 Attachment
                From: Steven Phillips <bill@...>
                Subject: Re: [jasspa] Execution of macro right before save of file
                Date: Tue, 1 Nov 2005 23:01:00 +0000

                Hi Steve,

                I have "tuned" your macro and wrote a similiar piece of code
                to be executed when pressing "C-x C-c" -- unfortunately I got "problems" ;)

                These are my current definitions

                define-macro my-save-buffer
                !force clean
                @# save-buffer @mna
                !emacro
                global-bind-key my-save-buffer "C-x C-s"

                define-macro my-save-buffers-exit-emacs
                !force clean
                @# save-buffers-exit-emacs @mna
                !emacro
                global-bind-key my-save-buffers-exit-emacs "C-x C-c"


                1.) When loading a file, which has blanks before $, I get asked "save
                buffer?" even when nothing was changed myself. It would
                be nice, if this question could be skipped when the "clean"
                command was the only one, which changes the buffer...
                2.) When loading binary files by accident or intentionally, the macro
                should *not* clean anything...

                I would be very happy for any hint to achieve this...

                Happy MicroEmacsing!
                Meino


                > There is no built in mechanism at present although I can see a need of one.
                > With the current release the best (and only) solution I can think of is to
                > rebind the keys you use to save the buffer to a macro which first cleans the
                > buffer, e.g.:
                >
                > define-macro my-save-buffer
                > clean
                > @# save-buffer @mna
                > !emacro
                > global-bind-key my-save-buffer "C-x C-s"
                >
                > (Note I have not tested this macro!)
                >
                > Steve
                >
              • Steven Phillips
                You noeed to only do the clean if the buffer is edited, i.e. check that the edit mode is enabled, i.e. try something like: define-macro my-save-buffer !if
                Message 7 of 7 , Nov 7, 2005
                • 0 Attachment
                  You noeed to only do the clean if the buffer is edited, i.e. check that the
                  edit mode is enabled, i.e. try something like:

                  define-macro my-save-buffer
                  !if &bmod "edit"
                  !force clean
                  !endif
                  @# save-buffer @mna
                  !emacro

                  Similarly you should check whether "binary" (or "rbin") mode is NOT set.

                  WRT. string-rectangle, is it possible you did not have a multiple lined region
                  defined?

                  Steve

                  > Subject: [jasspa] Execution of macro right before save of file
                  > From: Meino Christian Cramer <Meino.Cramer@...>
                  > Date: Monday, November 7, 2005, 4:38:38 AM
                  > To: jasspa@yahoogroups.com, bill@...
                  > From: Steven Phillips <bill@...>
                  > Subject: Re: [jasspa] Execution of macro right before save of file
                  > Date: Tue, 1 Nov 2005 23:01:00 +0000

                  > Hi Steve,

                  > I have "tuned" your macro and wrote a similiar piece of code
                  > to be executed when pressing "C-x C-c" -- unfortunately I got "problems" ;)

                  > These are my current definitions

                  > define-macro my-save-buffer
                  > !force clean
                  > @# save-buffer @mna
                  > !emacro
                  > global-bind-key my-save-buffer "C-x C-s"
                  >
                  > define-macro my-save-buffers-exit-emacs
                  > !force clean
                  > @# save-buffers-exit-emacs @mna
                  > !emacro
                  > global-bind-key my-save-buffers-exit-emacs "C-x C-c"


                  > 1.) When loading a file, which has blanks before $, I get asked "save
                  > buffer?" even when nothing was changed myself. It would
                  > be nice, if this question could be skipped when the "clean"
                  > command was the only one, which changes the buffer...
                  > 2.) When loading binary files by accident or intentionally, the macro
                  > should *not* clean anything...

                  > I would be very happy for any hint to achieve this...

                  > Happy MicroEmacsing!
                  > Meino


                  >> There is no built in mechanism at present although I can see a need of one.
                  >> With the current release the best (and only) solution I can think of is to
                  >> rebind the keys you use to save the buffer to a macro which first cleans the
                  >> buffer, e.g.:
                  >>
                  >> define-macro my-save-buffer
                  >> clean
                  >> @# save-buffer @mna
                  >> !emacro
                  >> global-bind-key my-save-buffer "C-x C-s"
                  >>
                  >> (Note I have not tested this macro!)
                  >>
                  >> Steve
                  >>



                  > __________________________________________________________________________

                  > This is an unmoderated list. JASSPA is not responsible for the content of
                  > any material posted to this list.

                  > To unsubscribe, send a mail message to

                  > mailto:jasspa-unsubscribe@yahoogroups.com

                  > or visit http://groups.yahoo.com/group/jasspa and
                  > modify your account settings manually.


                  >
                  > Yahoo! Groups Links



                  >
                Your message has been successfully submitted and would be delivered to recipients shortly.