2.2 The Mark and The Region

  • 2.2.1 The Mark Stack
  • 2.2.2 Using The Mouse
  • Each buffer has a distinguished position known as the mark. The mark initially points to the beginning of the buffer. The area between the mark and the point is known as the region. Many Hemlock commands which manipulate large pieces of text use the text in the region. To use these commands, one must first use some command to mark the region. [annotate]

    Although the mark is always pointing somewhere (initially to the beginning of the buffer), region commands insist that the region be made active before it can be used. This prevents accidental use of a region command from mysteriously mangling large amounts of text. [annotate]

    Active Regions Enabled  (initial value t) [Variable]
              

    When this variable is true, region commands beep unless the region is active. This may be set to nil for more traditional Emacs region semantics. [annotate]

    [annotate]

    Once a marking command makes the region active, it remains active until: [annotate]

    Motion commands have the effect of redefining the region, since they move the point and leave the region active. [annotate]

    Commands that insert a large chunk of text into the buffer usually set an ephemerally active region around the inserted text. An ephemerally active region is always deactivated by the next command, regardless of the kind of command. The ephemerally active region allows an immediately following region command to manipulate the inserted text, but doesn't persist annoyingly. This is also very useful with active region highlighting, since it visibly marks the inserted text. [annotate]

    Highlight Active Region  (initial value t) [Variable]
    Active Region Highlighting Font  (initial value nil) [Variable]
              

    When Highlight Active Region is true, Hemlock displays the text in the region in a different font whenever the region is active. This provides a visible indication of what text will be manipulated by a region command. Active region highlighting is only supported under X windows. [annotate]

    Active Region Highlighting Font is the name of the font to use for active region highlighting. If unspecified, Hemlock uses an underline font. [annotate]

    [annotate]

    Set/Pop Mark  (bound to C-@) [Command]
              

    This command moves the mark to the point (saving the old mark on the mark stack) and activates the region. After using this command to mark one end of the region, use motion commands to move to the other end, then do the region command. This is the traditional Emacs marking command; when running under a windowing system with mouse support, it is usually easier to use the mouse with the Point to Here and Generic Pointer Up. [annotate]

    For historical reasons, the prefix argument causes this command to do things that are distinct commands in Hemlock. A prefix argument of four does Pop and Goto Mark, and a prefix argument of 16 does Pop Mark. [annotate]

    [annotate]

    Mark Whole Buffer  (bound to C-x h) [Command]
    Mark to Beginning of Buffer  (bound to C-<) [Command]
    Mark to End of Buffer  (bound to C->) [Command]
              

    Mark Whole Buffer sets the region around the whole buffer, with the point at the beginning and the mark at the end. If a prefix argument is supplied, then the mark is put at the beginning and the point at the end. The mark is pushed on the mark stack beforehand, so popping the stack twice will restore it. [annotate]

    Mark to Beginning of Buffer sets the current region from point to the beginning of the buffer. [annotate]

    Mark to End of Buffer sets the current region from the end of the buffer to point. [annotate]

    [annotate]

    Activate Region  (bound to C-x C-Space, C-x C-@) [Command]
              

    This command makes the region active, using whatever the current position of the mark happens to be. This is useful primarily when the region is accidentally deactivated. [annotate]

    [annotate]

    2.2.1 The Mark Stack

    As was hinted at earlier, each buffer has a mark stack, providing a history of positions in that buffer. The current mark is the mark on the top of the stack; earlier values are recovered by popping the stack. Since commands that move a long distance save the old position on the mark stack, the mark stack commands are useful for jumping to interesting places in a buffer without having to do a search. [annotate]

    Pop Mark  (bound to C-M-Space) [Command]
    Pop and Goto Mark  (bound to M-@, M-Space) [Command]
              

    Pop Mark pops the mark stack, restoring the current mark to the next most recent value. Pop and Goto Mark also pops the mark stack, but instead of discarding the current mark, it moves the point to that position. Both commands deactivate the region. [annotate]

    [annotate]

    Exchange Point and Mark  (bound to C-x C-x) [Command]
              

    This command interchanges the position of the point and the mark, thus moving to where the mark was, and leaving the mark where the point was. This command can be used to switch between two positions in a buffer, since repeating it undoes its effect. The old mark isn't pushed on the mark stack, since it is saved in the point. [annotate]

    [annotate]

    2.2.2 Using The Mouse

    It can be convenient to use the mouse to point to positions in text, especially when moving large distances. Hemlock defines several commands for using the mouse. These commands can only be used when running under X windows [annotate]

    Here to Top of Window  (bound to Rightdown) [Command]
    Top Line to Here  (bound to Leftdown) [Command]
              

    Here to Top of Window scrolls the window so as to move the line which is under the mouse cursor to the top of the window. This has the effect of moving forward in the buffer by the distance from the top of the window to the mouse cursor. Top Line to Here is the inverse operation, it scrolls backward, moving current the top line underneath the mouse. [annotate]

    If the mouse is near the left edge of a window, then these commands do smooth scrolling. Here To Top of Window repeatedly scrolls the window up by one line until the mouse button is released. Similarly, Top Line to Here smoothly scrolls down. [annotate]

    [annotate]

    Point to Here  (bound to Middledown, S-Leftdown) [Command]
              

    This command moves the point to the position of the mouse, changing to a different window if necessary. [annotate]

    When used in a window's modeline, this moves the point of the window's buffer to the position within the file that is the same percentage, start to end, as the horizontal position of the mouse within the modeline. This also makes this window current if necessary. [annotate]

    This command supplies a function Generic Pointer Up invokes if it runs without any intervening generic pointer up predecessors executing. If the position of the pointer is different than the current point when the user invokes Generic Pointer Up, then this function pushes a buffer mark at point and moves point to the pointer's position. This allows the user to mark off a region with the mouse. [annotate]

    [annotate]

    Generic Pointer Up  (bound to Middleup, S-Leftup) [Command]
              

    Other commands determine this command's action by supplying functions that this command invokes. The following built-in commands supply the following generic up actions: [annotate]

    Point to Here
    When the position of the pointer is different than the current point, the action pushes a buffer mark at point and moves point to the pointer's position. [annotate]
    Bufed Goto and Quit
    The action is a no-op. [annotate]

    [annotate]

    Insert Kill Buffer  (bound to S-Rightdown) [Command]
              

    This command is a combination of Point to Here and Un-Kill. It moves the point to the mouse location and inserts the most recently killed text. [annotate]

    [annotate]