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

mark, point, and active regions

Expand Messages
  • Schofield, Bryan (GE Trans)
    To the best that I can tell, once the first mark is set in a buffer, a mark will always remain. Many macros operate on a region, that magical area in the
    Message 1 of 10 , May 25, 2005
      To the best that I can tell, once the first mark is set in a buffer, a mark will always remain. Many macros operate on a region, that magical area in the buffer between the mark and the point. But since once the first mark is set, the buffer always has mark, then it always has a region. This where things get a little wierd for me. Let's say I have a buffer with some lines of text. I place the cursor at the beginning of line 1 and call "set-mark" (C-space). I then move the cursor down a few lines and I see the region highlighted from the beginning of the first line to the cursors current position. I decide I didn't mean to hit C-space, so I issue "abort-command" (C-g). The highlighted region disappears. Now I issue "kill-region" (C-w) and magically, the lines that had been previously highlight, but are not currently, disappear.

      MicroEmacs is doing something as a user I don't expect. To me, there is no region. I "cancelled" it and editor *appeared* to comply by removing the highlight from the "selected" lines of text. But "kill-region" is operating under a different understanding. This problem can get a lot worse. Let's assume I'm working a big file, I select something at the top of the file, then C-g because I didn't really want to select the text. I page down a few times and try to put the cursor at the beginning of the line. I fat-finger C-e and hit C-w too. My previously selected text poofs aways, my cursor goes to the beginning of the line and I'm none-the-wiser. I save my file my exit, happy with my masterpiece, only find out next week it's missing a chunk at the beginning.

      Is there a way I can find out if a region *really* exists, that is one is visibly highlighted, from inside a macro?

      -- bryan
    • Thomas Hundt
      Hey that s not a bad idea. Write a macro that first verifies that the region is currently highlighted, and does the kill only if it is. (Please be clear that
      Message 2 of 10 , May 25, 2005
        Hey that's not a bad idea. Write a macro that first verifies that the
        region is currently highlighted, and does the kill only if it is.

        (Please be clear that the *region* always exists one the mark was set,
        it's the *highlighting* that comes and goes. If you want to eliminate
        the region per se, I think you'll have to unset the mark.)

        Suggest you enable the backup functionality, in the meantime :-)

        Check out the manpage for $show-region.

        I think the while region highlighting thing was done to make life easier
        for people who use a mouse. I'm very glad to have it. The original
        design of Emacs (and hence Jasspa) is sometimes at odds to what we
        expect from modern software (i.e., gui-based stuff) so things like this
        sometimes still have kinks to work out. Many of these get worked out on
        Gnu Emacs first, since that has probably 100x the number of users (and
        10x the developers?) as does Jasspa, so it's sometimes helpful to look
        and see how they've solved something over there.

        -Th


        Schofield, Bryan (GE Trans) wrote:

        > To the best that I can tell, once the first mark is set in a buffer,
        > a mark will always remain. Many macros operate on a region, that
        > magical area in the buffer between the mark and the point. But since
        > once the first mark is set, the buffer always has mark, then it
        > always has a region. This where things get a little wierd for me.
        > Let's say I have a buffer with some lines of text. I place the cursor
        > at the beginning of line 1 and call "set-mark" (C-space). I then move
        > the cursor down a few lines and I see the region highlighted from the
        > beginning of the first line to the cursors current position. I decide
        > I didn't mean to hit C-space, so I issue "abort-command" (C-g). The
        > highlighted region disappears. Now I issue "kill-region" (C-w) and
        > magically, the lines that had been previously highlight, but are not
        > currently, disappear.

        > MicroEmacs is doing something as a user I don't expect. To me, there
        > is no region. I "cancelled" it and editor *appeared* to comply by
        > removing the highlight from the "selected" lines of text. But
        > "kill-region" is operating under a different understanding. This
        > problem can get a lot worse. Let's assume I'm working a big file, I
        > select something at the top of the file, then C-g because I didn't
        > really want to select the text. I page down a few times and try to
        > put the cursor at the beginning of the line. I fat-finger C-e and hit
        > C-w too. My previously selected text poofs aways, my cursor goes to
        > the beginning of the line and I'm none-the-wiser. I save my file my
        > exit, happy with my masterpiece, only find out next week it's missing
        > a chunk at the beginning.

        > Is there a way I can find out if a region *really* exists, that is
        > one is visibly highlighted, from inside a macro?
      • Jon Green
        ... I cannot say I have ever done this accidental deletion bit - conversely I do not use the mouse and do not rely on the hilighting to tell me where point and
        Message 3 of 10 , May 26, 2005
          Schofield, Bryan (GE Trans) wrote:
          > To the best that I can tell, once the first mark is set in a buffer,
          > a mark will always remain. Many macros operate on a region, that
          > magical area in the buffer between the mark and the point. But since
          > once the first mark is set, the buffer always has mark, then it
          > always has a region. This where things get a little wierd for me.
          > Let's say I have a buffer with some lines of text. I place the cursor
          > at the beginning of line 1 and call "set-mark" (C-space). I then move
          > the cursor down a few lines and I see the region highlighted from the
          > beginning of the first line to the cursors current position. I decide
          > I didn't mean to hit C-space, so I issue "abort-command" (C-g). The
          > highlighted region disappears. Now I issue "kill-region" (C-w) and
          > magically, the lines that had been previously highlight, but are not
          > currently, disappear.
          >
          > MicroEmacs is doing something as a user I don't expect. To me, there
          > is no region. I "cancelled" it and editor *appeared* to comply by
          > removing the highlight from the "selected" lines of text. But
          > "kill-region" is operating under a different understanding. This
          > problem can get a lot worse. Let's assume I'm working a big file, I
          > select something at the top of the file, then C-g because I didn't
          > really want to select the text. I page down a few times and try to
          > put the cursor at the beginning of the line. I fat-finger C-e and hit
          > C-w too. My previously selected text poofs aways, my cursor goes to
          > the beginning of the line and I'm none-the-wiser. I save my file my
          > exit, happy with my masterpiece, only find out next week it's missing
          > a chunk at the beginning.
          >

          I cannot say I have ever done this accidental deletion bit - conversely
          I do not use the mouse and do not rely on the hilighting to tell me
          where point and mark are - but fair point. Could easily wrap C-w with a
          region check first which I think would resolve your problem.

          I cannot look at this at the moment as I'm upgrading my computer system
          to a nice shiny new one, but will do so when everything is moved to the
          new machine and set up.

          > Is there a way I can find out if a region *really* exists, that is
          > one is visibly highlighted, from inside a macro?
          >
          > -- bryan

          For regions see osdmisc.emf, specifically search-get-region-text and
          hilight-region-text. Note the regions are very volatile (i.e. it is easy
          to loose them) unlike the 'mark'.

          Jon.
        • Schofield, Bryan (GE Trans)
          For comparison purposes, Emacs kill-region is aware when the mark is active , as are all of it s region-based functions. Doing the same thing as described
          Message 4 of 10 , May 26, 2005
            For comparison purposes, Emacs' kill-region is aware when the mark is "active", as are all of it's region-based functions. Doing the same thing as described below, you get a nice "The mark is not active now" message instead of blowing away some piece of data, in some place you might not expect. Perhaps it's this "active mark" concept that is missing in ME.

            For the record, I'm using ME on the console. In fact, my X environment consists of a single Xterm, running screen. I could unplug my mouse and not miss it. Also, the scenario below is created merely to illustrate the potential problem. I found this writing a "delete-char" macro the behaves like Emacs, that is, delete the character under the point and the characters in the region if it exists. For XEmacs users, I think that they call it "Pending Delete" mode.

            Anyway, the point is, functions that operate on the region will do so, invariably, between the mark and the point. I know that sounds OK, but really its not. If I'm not actively telling the editor where the region is, then it shouldn't assume the region is between the last place I told it and where my cursor is now.

            Regards
            -- bryan

            > -----Original Message-----
            > From: jasspa@yahoogroups.com
            > [mailto:jasspa@yahoogroups.com]On Behalf Of
            > Jon Green
            > Sent: Thursday, May 26, 2005 5:19 AM
            > To: jasspa@yahoogroups.com
            > Subject: Re: [jasspa] mark, point, and active regions
            >
            >
            > Schofield, Bryan (GE Trans) wrote:
            > > To the best that I can tell, once the first mark is set in a buffer,
            > > a mark will always remain. Many macros operate on a region, that
            > > magical area in the buffer between the mark and the point. But since
            > > once the first mark is set, the buffer always has mark, then it
            > > always has a region. This where things get a little wierd for me.
            > > Let's say I have a buffer with some lines of text. I place
            > the cursor
            > > at the beginning of line 1 and call "set-mark" (C-space). I
            > then move
            > > the cursor down a few lines and I see the region
            > highlighted from the
            > > beginning of the first line to the cursors current
            > position. I decide
            > > I didn't mean to hit C-space, so I issue "abort-command" (C-g). The
            > > highlighted region disappears. Now I issue "kill-region" (C-w) and
            > > magically, the lines that had been previously highlight, but are not
            > > currently, disappear.
            > >
            > > MicroEmacs is doing something as a user I don't expect. To me, there
            > > is no region. I "cancelled" it and editor *appeared* to comply by
            > > removing the highlight from the "selected" lines of text. But
            > > "kill-region" is operating under a different understanding. This
            > > problem can get a lot worse. Let's assume I'm working a big file, I
            > > select something at the top of the file, then C-g because I didn't
            > > really want to select the text. I page down a few times and try to
            > > put the cursor at the beginning of the line. I fat-finger
            > C-e and hit
            > > C-w too. My previously selected text poofs aways, my cursor goes to
            > > the beginning of the line and I'm none-the-wiser. I save my file my
            > > exit, happy with my masterpiece, only find out next week
            > it's missing
            > > a chunk at the beginning.
            > >
            >
            > I cannot say I have ever done this accidental deletion bit -
            > conversely
            > I do not use the mouse and do not rely on the hilighting to tell me
            > where point and mark are - but fair point. Could easily wrap
            > C-w with a
            > region check first which I think would resolve your problem.
            >
            > I cannot look at this at the moment as I'm upgrading my
            > computer system
            > to a nice shiny new one, but will do so when everything is
            > moved to the
            > new machine and set up.
            >
            > > Is there a way I can find out if a region *really* exists, that is
            > > one is visibly highlighted, from inside a macro?
            > >
            > > -- bryan
            >
            > For regions see osdmisc.emf, specifically search-get-region-text and
            > hilight-region-text. Note the regions are very volatile (i.e.
            > it is easy
            > to loose them) unlike the 'mark'.
            >
            > 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
            How does the mark become inactive in Emacs? -Th
            Message 5 of 10 , May 26, 2005
              How does the mark become "inactive" in Emacs?

              -Th


              Schofield, Bryan (GE Trans) wrote:
              > For comparison purposes, Emacs' kill-region is aware when the mark is "active", as are all of it's region-based functions. Doing the same thing as described below, you get a nice "The mark is not active now" message instead of blowing away some piece of data, in some place you might not expect. Perhaps it's this "active mark" concept that is missing in ME.
            • Schofield, Bryan (GE Trans)
              From the user s perspective, if a region isn t visibly highlighted on the screen/console, there is no mark, thus no region. For example: C-space (set the mark)
              Message 6 of 10 , May 26, 2005
                From the user's perspective, if a region isn't visibly highlighted on the screen/console, there is no mark, thus no region. For example:

                C-space (set the mark)
                move cursor (region highlighted between mark and point)
                C-g (abort, region highlight removed, mark inactive)
                At this point any region-based function, like, kill-region, comment-region, etc., do not work.

                -- bryan

                > -----Original Message-----
                > From: jasspa@yahoogroups.com
                > [mailto:jasspa@yahoogroups.com]On Behalf Of
                > Thomas Hundt
                > Sent: Thursday, May 26, 2005 11:11 AM
                > To: jasspa@yahoogroups.com
                > Subject: Re: [jasspa] mark, point, and active regions
                >
                >
                > How does the mark become "inactive" in Emacs?
                >
                > -Th
                >
                >
                > Schofield, Bryan (GE Trans) wrote:
                > > For comparison purposes, Emacs' kill-region is aware when
                > the mark is "active", as are all of it's region-based
                > functions. Doing the same thing as described below, you get a
                > nice "The mark is not active now" message instead of blowing
                > away some piece of data, in some place you might not expect.
                > Perhaps it's this "active mark" concept that is missing in ME.
                >
                >
                > ______________________________________________________________
                > ____________
                >
                > 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
                Could you write a macro my-abort-command that first unsets the mark, then executes abort-command, and bind that to ^G? -Th
                Message 7 of 10 , May 26, 2005
                  Could you write a macro "my-abort-command" that first unsets the mark,
                  then executes abort-command, and bind that to ^G?

                  -Th



                  > C-space (set the mark)
                  > move cursor (region highlighted between mark and point)
                  > C-g (abort, region highlight removed, mark inactive)

                  > At this point any region-based function, like, kill-region,
                  > comment-region, etc., do not work.
                • Schofield, Bryan (GE Trans)
                  I wrote the following macros that address the problem and satisfy me, I brought it up because I consider it bad behavior and to highlight a difference with
                  Message 8 of 10 , May 26, 2005
                    I wrote the following macros that address the problem and satisfy me, I brought it up because I consider it bad behavior and to highlight a difference with Emacs.





                    0 define-macro abort-if-region-not-active
                    0 show-region
                    !if ¬ &equ 0x05 &band $result 0x05
                    ml-write "[Region is not active]"
                    !abort
                    !endif
                    !emacro

                    define-macro kill-region-safe
                    abort-if-region-not-active
                    !if @?
                    @# kill-region
                    !else
                    kill-region
                    !endif
                    !emacro

                    define-macro forward-delete-char-and-region
                    !force -1 kill-region-safe
                    !if @?
                    @# forward-delete-char
                    !else
                    forward-delete-char
                    !endif
                    !emacro

                    define-macro backward-delete-char-and-region
                    !force -1 kill-region-safe
                    !if @?
                    @# backward-delete-char
                    !else
                    backward-delete-char
                    !endif
                    !emacro

                    > -----Original Message-----
                    > From: jasspa@yahoogroups.com
                    > [mailto:jasspa@yahoogroups.com]On Behalf Of
                    > Thomas Hundt
                    > Sent: Thursday, May 26, 2005 11:44 AM
                    > To: jasspa@yahoogroups.com
                    > Subject: Re: [jasspa] mark, point, and active regions
                    >
                    >
                    > Could you write a macro "my-abort-command" that first unsets
                    > the mark,
                    > then executes abort-command, and bind that to ^G?
                    >
                    > -Th
                    >
                    >
                    >
                    > > C-space (set the mark)
                    > > move cursor (region highlighted between mark and point)
                    > > C-g (abort, region highlight removed, mark inactive)
                    >
                    > > At this point any region-based function, like, kill-region,
                    > > comment-region, etc., do not work.
                    >
                    >
                    > ______________________________________________________________
                    > ____________
                    >
                    > 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
                    Bryan, What version (or mode) of Emacs are you using? I m using GNU Emacs 21.3.1, basic setup, in the *scratch* buffer and doing the below works are it does in
                    Message 9 of 10 , May 29, 2005
                      Bryan,

                      What version (or mode) of Emacs are you using? I'm using GNU Emacs 21.3.1,
                      basic setup, in the *scratch* buffer and doing the below works are it does
                      in ME, i.e. the C-g does not remove the mark - why am I seeing a different
                      behavior to you?

                      In all the time I have used Big Emacs (some years ago now) I have never seen
                      the behavior you describe, C-g only resets the undo cycle (as it does in ME).
                      I personally rely on the current behavior...

                      Steve

                      > Subject: [jasspa] mark, point, and active regions
                      > From: Schofield, Bryan (GE Trans) <Bryan.Schofield@...>
                      > Date: Thursday, May 26, 2005, 4:39:34 PM
                      > To: <jasspa@yahoogroups.com>
                      > From the user's perspective, if a region isn't visibly highlighted on the
                      > screen/console, there is no mark, thus no region. For example:

                      > C-space (set the mark)
                      > move cursor (region highlighted between mark and point)
                      > C-g (abort, region highlight removed, mark inactive)
                      > At this point any region-based function, like, kill-region, comment-region, etc., do not work.

                      > -- bryan

                      >> -----Original Message-----
                      >> From: jasspa@yahoogroups.com
                      >> [mailto:jasspa@yahoogroups.com]On Behalf Of
                      >> Thomas Hundt
                      >> Sent: Thursday, May 26, 2005 11:11 AM
                      >> To: jasspa@yahoogroups.com
                      >> Subject: Re: [jasspa] mark, point, and active regions
                      >>
                      >>
                      >> How does the mark become "inactive" in Emacs?
                      >>
                      >> -Th
                      >>
                      >>
                      >> Schofield, Bryan (GE Trans) wrote:
                      >> > For comparison purposes, Emacs' kill-region is aware when
                      >> the mark is "active", as are all of it's region-based
                      >> functions. Doing the same thing as described below, you get a
                      >> nice "The mark is not active now" message instead of blowing
                      >> away some piece of data, in some place you might not expect.
                      >> Perhaps it's this "active mark" concept that is missing in ME.
                      >>
                      >>
                      >> ______________________________________________________________
                      >> ____________
                      >>
                      >> 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
                    • Schofield, Bryan (GE Trans)
                      21.2.1 ... after some investigating, it seems I have emacs delete-selection-mode turned on. So I suppose what I should I do is write a delete-selection-mode
                      Message 10 of 10 , May 31, 2005
                        21.2.1 ... after some investigating, it seems I have emacs' "delete-selection-mode" turned on. So I suppose what I should I do is write a delete-selection-mode for ME :-) One of my earlier posts had about 2/3 of it anyway.

                        > -----Original Message-----
                        > From: jasspa@yahoogroups.com
                        > [mailto:jasspa@yahoogroups.com]On Behalf Of
                        > Steven Phillips
                        > Sent: Sunday, May 29, 2005 8:31 AM
                        > To: Schofield, Bryan (GE Trans)
                        > Subject: Re[2]: [jasspa] mark, point, and active regions
                        >
                        >
                        > Bryan,
                        >
                        > What version (or mode) of Emacs are you using? I'm using GNU
                        > Emacs 21.3.1,
                        > basic setup, in the *scratch* buffer and doing the below
                        > works are it does
                        > in ME, i.e. the C-g does not remove the mark - why am I
                        > seeing a different
                        > behavior to you?
                        >
                        > In all the time I have used Big Emacs (some years ago now) I
                        > have never seen
                        > the behavior you describe, C-g only resets the undo cycle (as
                        > it does in ME).
                        > I personally rely on the current behavior...
                        >
                        > Steve
                        >
                        > > Subject: [jasspa] mark, point, and active regions
                        > > From: Schofield, Bryan (GE Trans) <Bryan.Schofield@...>
                        > > Date: Thursday, May 26, 2005, 4:39:34 PM
                        > > To: <jasspa@yahoogroups.com>
                        > > From the user's perspective, if a region isn't visibly
                        > highlighted on the
                        > > screen/console, there is no mark, thus no region. For example:
                        >
                        > > C-space (set the mark)
                        > > move cursor (region highlighted between mark and point)
                        > > C-g (abort, region highlight removed, mark inactive)
                        > > At this point any region-based function, like, kill-region,
                        > comment-region, etc., do not work.
                        >
                        > > -- bryan
                        >
                        > >> -----Original Message-----
                        > >> From: jasspa@yahoogroups.com
                        > >> [mailto:jasspa@yahoogroups.com]On Behalf Of
                        > >> Thomas Hundt
                        > >> Sent: Thursday, May 26, 2005 11:11 AM
                        > >> To: jasspa@yahoogroups.com
                        > >> Subject: Re: [jasspa] mark, point, and active regions
                        > >>
                        > >>
                        > >> How does the mark become "inactive" in Emacs?
                        > >>
                        > >> -Th
                        > >>
                        > >>
                        > >> Schofield, Bryan (GE Trans) wrote:
                        > >> > For comparison purposes, Emacs' kill-region is aware when
                        > >> the mark is "active", as are all of it's region-based
                        > >> functions. Doing the same thing as described below, you get a
                        > >> nice "The mark is not active now" message instead of blowing
                        > >> away some piece of data, in some place you might not expect.
                        > >> Perhaps it's this "active mark" concept that is missing in ME.
                        > >>
                        > >>
                        > >> ______________________________________________________________
                        > >> ____________
                        > >>
                        > >> 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
                        >
                        >
                        >
                        >
                        >
                        >
                        >
                        >
                        >
                        > ______________________________________________________________
                        > ____________
                        >
                        > 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.