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

region-aware macro construction

Expand Messages
  • Meino Christian Cramer
    Hi, as a first try I wrote the following macro just for some tests: define-macro rreplace-string 3 screen-update ; disable screen updatea 3
    Message 1 of 10 , Jul 2, 2005
    • 0 Attachment
      Hi,

      as a first try I wrote the following macro just for some tests:

      define-macro rreplace-string
      3 screen-update ; disable screen updatea
      3 narrow-buffer ; hide everything but the region
      beginning-of-buffer ; step to the top of the region
      replace-string ; call replace-string
      1 narrow-buffer ; after work is done, widen buffer
      0 screen-update ; enable
      !emacro


      As I thought, this would works as follows:
      First "freeze" the screen. Then do a narrow-to-region "under the
      hood", ask for a replace string, actually do the replacing, widen the
      buffer again "under the hood" and finally "melt" the screen (the
      opposite of "freezing" the screen :O)

      But MicroEmacs seems to be of another opinion of that.... :)
      (in other words, I did something wrong again...sigh :O)

      MicroEmacs did the following sequence instead:
      Narrow the buffer (one can see the narrowed screen)

      That's it.

      The file on which I tried the new macro was rw.

      From what I read in the General Help (my new friend :), this /should/
      happen, but I cannot see, what I did wrong.

      When I did an execute-buffer on the buffer, which contains the
      rreplace-string, there was no error message display. Same goes for
      actually executing the macro on the test-file.

      Sorry for asking again dumb questions...

      Happy microemacsing!
      Meino
    • Jon Green
      ... Try this Jon. ; Replace a string in the region. As this is a simple replace string then it ; is not necessary to update the screen as the replace-string is
      Message 2 of 10 , Jul 3, 2005
      • 0 Attachment
        Meino Christian Cramer wrote:
        > Hi,
        >
        > as a first try I wrote the following macro just for some tests:
        >
        > define-macro rreplace-string
        > 3 screen-update ; disable screen updatea
        > 3 narrow-buffer ; hide everything but the region
        > beginning-of-buffer ; step to the top of the region
        > replace-string ; call replace-string
        > 1 narrow-buffer ; after work is done, widen buffer
        > 0 screen-update ; enable
        > !emacro
        >

        Try this
        Jon.
      • Meino Christian Cramer
        From: Jon Green Subject: Re: [jasspa] region-aware macro construction Date: Sun, 03 Jul 2005 12:48:34 +0100 Hi Jon ! Thanks a lot! But....what
        Message 3 of 10 , Jul 3, 2005
        • 0 Attachment
          From: Jon Green <jon@...>
          Subject: Re: [jasspa] region-aware macro construction
          Date: Sun, 03 Jul 2005 12:48:34 +0100

          Hi Jon !

          Thanks a lot! But....what happens to update-screen? What was wrong
          with it?

          Have a nice weekend !
          Meino


          > Meino Christian Cramer wrote:
          > > Hi,
          > >
          > > as a first try I wrote the following macro just for some tests:
          > >
          > > define-macro rreplace-string
          > > 3 screen-update ; disable screen updatea
          > > 3 narrow-buffer ; hide everything but the region
          > > beginning-of-buffer ; step to the top of the region
          > > replace-string ; call replace-string
          > > 1 narrow-buffer ; after work is done, widen buffer
          > > 0 screen-update ; enable
          > > !emacro
          > >
          >
          > Try this
          > Jon.
          >
          >
          >
          > __________________________________________________________________________
          >
          > 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
          >
          >
          >
          >
        • Jon Green
          ... Why do you need it ? The only thing that it will do is flicker the screen. Screen update will effectivelly flush any outstanding updates to the screen, but
          Message 4 of 10 , Jul 3, 2005
          • 0 Attachment
            Meino Christian Cramer wrote:
            > From: Jon Green <jon@...>
            > Subject: Re: [jasspa] region-aware macro construction
            > Date: Sun, 03 Jul 2005 12:48:34 +0100
            >
            > Hi Jon !
            >
            > Thanks a lot! But....what happens to update-screen? What was wrong
            > with it?
            >
            > Have a nice weekend !
            > Meino
            >

            Why do you need it ? The only thing that it will do is flicker the screen. Screen update
            will effectivelly flush any outstanding updates to the screen, but in this case we are not
            interested in any intermediate results are we ? It is your macro and you can put as many
            screen-updates as you like in.

            The user does not need to see that the narrow has been applied, infact the user should not
            be aware that the chosen method of performing a replacement over a region uses the narrow
            command. 'narrow' in this instance is simply the method you have selected to perform a
            region replacement. I could implement a region replacement without using narrow, I could use
            the '-n' argument of replace-string which would then limit the replacement to a number of
            lines, my macro would calculate the number of lines in the region, move to the start of the
            region and then perform a replacement over that limited number of lines. Had you implemented
            it this way then you would not expect to update the screen so by the same token you should
            not be updating the screen just becuase you are using narrow.

            Jon.
          • Meino Christian Cramer
            From: Jon Green Subject: Re: [jasspa] region-aware macro construction Date: Sun, 03 Jul 2005 16:19:51 +0100 Hi Jon, ... Hrmrm..then I
            Message 5 of 10 , Jul 3, 2005
            • 0 Attachment
              From: Jon Green <jon@...>
              Subject: Re: [jasspa] region-aware macro construction
              Date: Sun, 03 Jul 2005 16:19:51 +0100

              Hi Jon,

              > Meino Christian Cramer wrote:
              > > From: Jon Green <jon@...>
              > > Subject: Re: [jasspa] region-aware macro construction
              > > Date: Sun, 03 Jul 2005 12:48:34 +0100
              > >
              > > Hi Jon !
              > >
              > > Thanks a lot! But....what happens to update-screen? What was wrong
              > > with it?
              > >
              > > Have a nice weekend !
              > > Meino
              > >
              >
              > Why do you need it ? The only thing that it will do is flicker the screen. Screen update
              > will effectivelly flush any outstanding updates to the screen, but in this case we are not
              > interested in any intermediate results are we ? It is your macro and you can put as many
              > screen-updates as you like in.

              Hrmrm..then I understood the help the wrong way:

              3
              No screen redraw, only window variables are up-dated. This feature is
              provided for macros which manipulate the screen view and need to know
              where the cursor is in the window without redrawing the screen (which
              may cause unwanted flickering). Note that as the screen is not redrawn
              not all variables may have the correct value, for example the frame
              store variable <some garbage from copy and paste> could be out of date.

              Intention was to hide the in and out the narrow region switching just
              to hide things from the user's eye, which are not interesting. Just
              the result was intended to be drawn therefore I did switching off the
              screen-update and on afte work was done.

              I would be interesting, why my macro does not work for working from
              my errors. No doubt there are others, may be better ways to implement
              teh macro.

              But was actually wrong with my macro?. Why does "3 screen-update"
              seems not to switch off screen updateing? Why does the macro stop to
              work just after enterint it -- just only narrowing the buffer (I saw
              no error prompt or such...)?

              I know, I am too curious. But I want to understand things I try to
              get working....

              Thank you very much for your help, Jon!

              Slightly confused,
              Meino





              > The user does not need to see that the narrow has been applied, infact the user should not
              > be aware that the chosen method of performing a replacement over a region uses the narrow
              > command. 'narrow' in this instance is simply the method you have selected to perform a
              > region replacement. I could implement a region replacement without using narrow, I could use
              > the '-n' argument of replace-string which would then limit the replacement to a number of
              > lines, my macro would calculate the number of lines in the region, move to the start of the
              > region and then perform a replacement over that limited number of lines. Had you implemented
              > it this way then you would not expect to update the screen so by the same token you should
              > not be updating the screen just becuase you are using narrow.
              >
              > Jon.
              >
              >
              >
              > __________________________________________________________________________
              >
              > 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
              >
              >
              >
              >
              >
              >
            • Jon Green
              ... macros will not update the screen unless they are forced. If you run the macro and get to the prompt and then issue a ^L then you see the pending changes
              Message 6 of 10 , Jul 3, 2005
              • 0 Attachment
                Meino Christian Cramer wrote:
                >
                >
                > Hrmrm..then I understood the help the wrong way:
                >
                > 3
                > No screen redraw, only window variables are up-dated. This feature is
                > provided for macros which manipulate the screen view and need to know
                > where the cursor is in the window without redrawing the screen (which
                > may cause unwanted flickering). Note that as the screen is not redrawn
                > not all variables may have the correct value, for example the frame
                > store variable <some garbage from copy and paste> could be out of date.
                >

                macros will not update the screen unless they are forced. If you run the macro and get to
                the prompt and then issue a ^L then you see the pending changes in the buffer. As the macros
                will not update the screen unless forced you do not need to disable the update with the 3
                screen-update. (Yes sorry, my mistake, you had 3 not just a screen update - but you still do
                not need this).

                > I would be interesting, why my macro does not work for working from
                > my errors. No doubt there are others, may be better ways to implement
                > teh macro.

                The narrow region method is fine.

                >
                > But was actually wrong with my macro?. Why does "3 screen-update"
                > seems not to switch off screen updateing? Why does the macro stop to
                > work just after enterint it -- just only narrowing the buffer (I saw
                > no error prompt or such...)?

                Because you did not use @mna. replace string requires an argument the behaviour you want is
                to prompt the user from the command line. You have not provided the argument for the replace
                string so it fails.

                Jon.
              • Meino Christian Cramer
                From: Jon Green Subject: Re: [jasspa] region-aware macro construction Date: Sun, 03 Jul 2005 17:12:11 +0100 Hi Jon, thanks a lot for your
                Message 7 of 10 , Jul 3, 2005
                • 0 Attachment
                  From: Jon Green <jon@...>
                  Subject: Re: [jasspa] region-aware macro construction
                  Date: Sun, 03 Jul 2005 17:12:11 +0100

                  Hi Jon,

                  thanks a lot for your patience !:)

                  Just to proof, whether I understood right the "command in
                  a macro"-thingy. (That sounds like "Macro in a box" :)

                  A command, which has no parameter to be passed to it will work
                  interactively the same way as in a macro.

                  A command, which needs some user interaction has to use @mna in
                  macros or "literally" givven parameters either in "<val>" or in form
                  of the contents of a variable like $<varname>.

                  Is that ok ?

                  Meino


                  > Meino Christian Cramer wrote:
                  > >
                  > >
                  > > Hrmrm..then I understood the help the wrong way:
                  > >
                  > > 3
                  > > No screen redraw, only window variables are up-dated. This feature is
                  > > provided for macros which manipulate the screen view and need to know
                  > > where the cursor is in the window without redrawing the screen (which
                  > > may cause unwanted flickering). Note that as the screen is not redrawn
                  > > not all variables may have the correct value, for example the frame
                  > > store variable <some garbage from copy and paste> could be out of date.
                  > >
                  >
                  > macros will not update the screen unless they are forced. If you run the macro and get to
                  > the prompt and then issue a ^L then you see the pending changes in the buffer. As the macros
                  > will not update the screen unless forced you do not need to disable the update with the 3
                  > screen-update. (Yes sorry, my mistake, you had 3 not just a screen update - but you still do
                  > not need this).
                  >
                  > > I would be interesting, why my macro does not work for working from
                  > > my errors. No doubt there are others, may be better ways to implement
                  > > teh macro.
                  >
                  > The narrow region method is fine.
                  >
                  > >
                  > > But was actually wrong with my macro?. Why does "3 screen-update"
                  > > seems not to switch off screen updateing? Why does the macro stop to
                  > > work just after enterint it -- just only narrowing the buffer (I saw
                  > > no error prompt or such...)?
                  >
                  > Because you did not use @mna. replace string requires an argument the behaviour you want is
                  > to prompt the user from the command line. You have not provided the argument for the replace
                  > string so it fails.
                  >
                  > Jon.
                  >
                  >
                  > __________________________________________________________________________
                  >
                  > 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
                  >
                  >
                  >
                  >
                  >
                  >
                • Thomas Hundt
                  So, a side effect of !FORCE is that whatever it runs will update the screen? (Undocumented.) -Th
                  Message 8 of 10 , Jul 3, 2005
                  • 0 Attachment
                    So, a side effect of !FORCE is that whatever it runs will update the
                    screen? (Undocumented.)

                    -Th


                    Jon Green wrote:
                    > macros will not update the screen unless they are forced.
                  • Steven Phillips
                    By forced, Jon meant by calling screen-update; using !force will not up-date the screen. Steve
                    Message 9 of 10 , Jul 3, 2005
                    • 0 Attachment
                      By forced, Jon meant by calling screen-update; using !force will not up-date
                      the screen.

                      Steve

                      > Subject: [jasspa] region-aware macro construction
                      > From: Thomas Hundt <thundt@...>
                      > Date: Sunday, July 3, 2005, 8:05:12 PM
                      > To: jasspa@yahoogroups.com
                      > So, a side effect of !FORCE is that whatever it runs will update the
                      > screen? (Undocumented.)

                      > -Th


                      > Jon Green wrote:
                      >> macros will not update the screen unless they are forced.


                      > __________________________________________________________________________

                      > 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
                    • Steven Phillips
                      That is correct. Steve
                      Message 10 of 10 , Jul 3, 2005
                      • 0 Attachment
                        That is correct.

                        Steve

                        > Subject: [jasspa] region-aware macro construction
                        > From: Meino Christian Cramer <Meino.Cramer@...>
                        > Date: Sunday, July 3, 2005, 6:40:47 PM
                        > To: jasspa@yahoogroups.com, jon@...
                        > From: Jon Green <jon@...>
                        > Subject: Re: [jasspa] region-aware macro construction
                        > Date: Sun, 03 Jul 2005 17:12:11 +0100

                        > Hi Jon,

                        > thanks a lot for your patience !:)

                        > Just to proof, whether I understood right the "command in
                        > a macro"-thingy. (That sounds like "Macro in a box" :)

                        > A command, which has no parameter to be passed to it will work
                        > interactively the same way as in a macro.

                        > A command, which needs some user interaction has to use @mna in
                        > macros or "literally" givven parameters either in "<val>" or in form
                        > of the contents of a variable like $<varname>.

                        > Is that ok ?

                        > Meino


                        >> Meino Christian Cramer wrote:
                        >> >
                        >> >
                        >> > Hrmrm..then I understood the help the wrong way:
                        >> >
                        >> > 3
                        >> > No screen redraw, only window variables are up-dated. This feature is
                        >> > provided for macros which manipulate the screen view and need to know
                        >> > where the cursor is in the window without redrawing the screen (which
                        >> > may cause unwanted flickering). Note that as the screen is not redrawn
                        >> > not all variables may have the correct value, for example the frame
                        >> > store variable <some garbage from copy and paste> could be out of date.
                        >> >
                        >>
                        >> macros will not update the screen unless they are forced. If you run the macro and get to
                        >> the prompt and then issue a ^L then you see the pending changes in the buffer. As the macros
                        >> will not update the screen unless forced you do not need to disable the update with the 3
                        >> screen-update. (Yes sorry, my mistake, you had 3 not just a screen update - but you still do
                        >> not need this).
                        >>
                        >> > I would be interesting, why my macro does not work for working from
                        >> > my errors. No doubt there are others, may be better ways to implement
                        >> > teh macro.
                        >>
                        >> The narrow region method is fine.
                        >>
                        >> >
                        >> > But was actually wrong with my macro?. Why does "3 screen-update"
                        >> > seems not to switch off screen updateing? Why does the macro stop to
                        >> > work just after enterint it -- just only narrowing the buffer (I saw
                        >> > no error prompt or such...)?
                        >>
                        >> Because you did not use @mna. replace string requires an argument the behaviour you want is
                        >> to prompt the user from the command line. You have not provided the argument for the replace
                        >> string so it fails.
                        >>
                        >> Jon.
                        >>
                        >>
                        >> __________________________________________________________________________
                        >>
                        >> 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
                      Your message has been successfully submitted and would be delivered to recipients shortly.