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

RE: [jasspa] "graphical" string-rectangle ?

Expand Messages
  • Phillips, Steven
    Meino, The short answer to this is no. The wanted behavior can be split into 2 items: 1) rectangle hilighting - ME does not support rectangular region
    Message 1 of 7 , May 31, 2005
    • 0 Attachment
      Meino,

      The short answer to this is no.

      The wanted behavior can be split into 2 items:

      1) rectangle hilighting - ME does not support rectangular region
      high-lighting and as supporting it would impacted the general rendering
      performance I'm very reluctant to add it. The main reason why ME does
      not support it is because ME would strictly only need this in one
      instance, just after a call to yank-rectangle. When the user sets a
      mark, ME has no indication of the user's intent (normal region or
      rectangle) so must hilight the normal region which breaks your wanted
      behavior.

      2) Dynamic string-rectangle - this would be tricky to implement well
      (how do you stop this 'insertion mode'? C-g is often used during text
      editing - aborting the insertion mode would be a pain, undo would become
      interesting...). There are just too many different ways of editing in ME
      to make such a macro safe and non-restrictive.

      I think the current interface is the best starting point, perhaps minor
      changes to this could resolve your main issues? For example:

      Only the start line, end line and start column are required (there is no
      need of an end column); currently the start column is the cursor column
      if the cursor is before the mark or the mark column otherwise. It may be
      better if the cursor's column was always used.

      Change the string-rectangle command so a region does not need to be
      active, as per commands like sort-lines; this makes more sense if the
      first suggestion is implemented.

      After a call to string-rectangle the state ME is left in does not allow
      string-rectangle to be simply called again, so trying to pad a column of
      text in a large number of lines to line up to another line (i.e.
      inserting a number of spaces etc) becomes a real pain. If you could
      simply call string-rectangle again and again and each time text was
      added after the last calls text, this would greatly help. This is
      trivial and logical if the other 2 suggested changes are implemented.

      Steve

      > -----Original Message-----
      > From: jasspa@yahoogroups.com [mailto:jasspa@yahoogroups.com] On Behalf
      Of
      > Meino Christian Cramer
      > Sent: Tuesday, May 24, 2005 4:43 PM
      > To: jasspa@yahoogroups.com
      > Subject: [jasspa] "graphical" string-rectangle ?
      >
      > Hi,
      >
      > is there any macro or hack or ??? to achieve the following behaviour
      > in MicroEmacs:
      >
      > Current state (as far as I know ;)
      > If one wants to insert a rectangle of text with string-rectangle s/he
      > has to mark a point in the text, move downwards right, while the
      > marked region isn't identical to the area, which is valid
      > for string-rectangle.
      >
      > Then s/he has to submit the command string-rectangle, and to give the
      > text to be inserted on the "command-line" of the minibuffer
      > non-interactivly.
      >
      > After <RETURN>, the text will be inserted. If it is at the incorrect
      > playe: Go back to START.
      >
      > Wnated behaviour:
      > After marking the start point of the rectangle, moving the cursor
      > will mark a rectangle instead of a region. Typing text will insert it
      > simultaneously and interactively.
      >
      > Any chance ?
      >
      > Happy microemacsing!
      > 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
      >
      >
      >
      >
    • Thomas Hundt
      I agree, this interactive functionality sounds like more trouble than it s worth. Perhaps one could write a macro that loops and waits for keys. I didn t even
      Message 2 of 7 , May 31, 2005
      • 0 Attachment
        I agree, this interactive functionality sounds like more trouble than
        it's worth. Perhaps one could write a macro that loops and waits for keys.

        I didn't even know string-rectangle existed. I always do search and
        replace of "^" with whatever it is I want to prepend.

        On the other hand, now that I've seen string-rectangle, it seems weird
        that the mark gets unset after running it. I can see wanting to run it
        again to insert "one more space" or something. It also only seems to
        work if the region is highlighted. (Then again, I'm still on 04/03/01.)

        Here is a macro that lets one run it over and over:

        ;------------------------------------------------------------
        ; my-string-rectangle: doesn't unset mark after running
        ;------------------------------------------------------------
        define-macro my-string-rectangle
        exchange-point-and-mark ; put me at mark
        set-position "\x80"
        exchange-point-and-mark ; back to point
        copy-region ; redisplays highlight, needed for string-rectangle
        string-rectangle
        set-position "\x81"
        goto-position "\x80"
        set-mark ; set the real mark
        goto-position "\x81"
        !return
        !emacro


        -Th


        > 2) Dynamic string-rectangle - this would be tricky to implement well

        > After a call to string-rectangle the state ME is left in does not allow
        > string-rectangle to be simply called again,

        > If you could
        > simply call string-rectangle again and again and each time text was
        > added after the last calls text, this would greatly help.

        >>Meino Christian Cramer
        >>
        >>Hi,
        >>
        >> is there any macro or hack or ??? to achieve the following behaviour
        >> in MicroEmacs:
        >>
        >> Current state (as far as I know ;)
        >> If one wants to insert a rectangle of text with string-rectangle s/he
        >> has to mark a point in the text, move downwards right, while the
        >> marked region isn't identical to the area, which is valid
        >> for string-rectangle.
        >>
        >> Then s/he has to submit the command string-rectangle, and to give the
        >> text to be inserted on the "command-line" of the minibuffer
        >> non-interactivly.
        >>
        >> After <RETURN>, the text will be inserted. If it is at the incorrect
        >> playe: Go back to START.
        >>
        >> Wnated behaviour:
        >> After marking the start point of the rectangle, moving the cursor
        >> will mark a rectangle instead of a region. Typing text will insert it
        >> simultaneously and interactively.
        >>
        >> Any chance ?
        >>
        >> Happy microemacsing!
        >> Meino
        >>
        >>
        >>
      • Meino Christian Cramer
        From: Phillips, Steven Subject: RE: [jasspa] graphical string-rectangle ? Date: Tue, 31 May 2005 04:28:56 -0400 Steve, ... Could be
        Message 3 of 7 , May 31, 2005
        • 0 Attachment
          From: "Phillips, Steven" <sphillips@...>
          Subject: RE: [jasspa] "graphical" string-rectangle ?
          Date: Tue, 31 May 2005 04:28:56 -0400

          Steve,

          > Meino,
          >
          > The short answer to this is no.
          >
          > The wanted behavior can be split into 2 items:
          >
          > 1) rectangle hilighting - ME does not support rectangular region
          > high-lighting and as supporting it would impacted the general rendering
          > performance I'm very reluctant to add it. The main reason why ME does
          > not support it is because ME would strictly only need this in one
          > instance, just after a call to yank-rectangle. When the user sets a
          > mark, ME has no indication of the user's intent (normal region or
          > rectangle) so must hilight the normal region which breaks your wanted
          > behavior.

          Could be solved with "mark-region" and "mark-rectangle".

          > 2) Dynamic string-rectangle - this would be tricky to implement well
          > (how do you stop this 'insertion mode'? C-g is often used during text
          > editing - aborting the insertion mode would be a pain, undo would become
          > interesting...). There are just too many different ways of editing in ME
          > to make such a macro safe and non-restrictive.

          The end of the insertion can be marked by pressing <RETURN> as you
          already do with string-rectangle.


          > I think the current interface is the best starting point, perhaps minor
          > changes to this could resolve your main issues? For example:
          >
          > Only the start line, end line and start column are required (there is no
          > need of an end column); currently the start column is the cursor column
          > if the cursor is before the mark or the mark column otherwise. It may be
          > better if the cursor's column was always used.
          >
          > Change the string-rectangle command so a region does not need to be
          > active, as per commands like sort-lines; this makes more sense if the
          > first suggestion is implemented.
          >
          > After a call to string-rectangle the state ME is left in does not allow
          > string-rectangle to be simply called again, so trying to pad a column of
          > text in a large number of lines to line up to another line (i.e.
          > inserting a number of spaces etc) becomes a real pain. If you could
          > simply call string-rectangle again and again and each time text was
          > added after the last calls text, this would greatly help. This is
          > trivial and logical if the other 2 suggested changes are implemented.

          The main issue I have with a non-interactive string-rectangle is,
          that I am tired to count things before I type them in...

          Suppose you want to indent something -- a rectangle of course --
          until it lines up with soething else above or below that rectangle.

          With the current implemeentation you first have to count the spaces
          needed (dont miscount! Otherwise: Go back to START), start
          string-rectangle, enter that amount of space, hit <RETURN> (fingers
          crossed) and VOILA!....ooops...to wo space to much...UNDO...and...

          All lines of a text in ME are entered interactively...only
          rectangles are not.

          I wish, there would be a better way..

          Meino



          > Steve
          >
          > > -----Original Message-----
          > > From: jasspa@yahoogroups.com [mailto:jasspa@yahoogroups.com] On Behalf
          > Of
          > > Meino Christian Cramer
          > > Sent: Tuesday, May 24, 2005 4:43 PM
          > > To: jasspa@yahoogroups.com
          > > Subject: [jasspa] "graphical" string-rectangle ?
          > >
          > > Hi,
          > >
          > > is there any macro or hack or ??? to achieve the following behaviour
          > > in MicroEmacs:
          > >
          > > Current state (as far as I know ;)
          > > If one wants to insert a rectangle of text with string-rectangle s/he
          > > has to mark a point in the text, move downwards right, while the
          > > marked region isn't identical to the area, which is valid
          > > for string-rectangle.
          > >
          > > Then s/he has to submit the command string-rectangle, and to give the
          > > text to be inserted on the "command-line" of the minibuffer
          > > non-interactivly.
          > >
          > > After <RETURN>, the text will be inserted. If it is at the incorrect
          > > playe: Go back to START.
          > >
          > > Wnated behaviour:
          > > After marking the start point of the rectangle, moving the cursor
          > > will mark a rectangle instead of a region. Typing text will insert it
          > > simultaneously and interactively.
          > >
          > > Any chance ?
          > >
          > > Happy microemacsing!
          > > 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
          >
          >
          >
          >
          >
          >
        • Thomas Hundt
          ... Well in the time-tested tradition of let the machine do the repetitive work why don t you just write a macro that does something like: ; macro indent
          Message 4 of 7 , May 31, 2005
          • 0 Attachment
            > Suppose you want to indent something -- a rectangle of course --
            > until it lines up with soething else above or below that rectangle.
            >
            > With the current implemeentation you first have to count the spaces
            > needed (dont miscount! Otherwise: Go back to START), start
            > string-rectangle, enter that amount of space, hit <RETURN> (fingers
            > crossed) and VOILA!....ooops...to wo space to much...UNDO...and...

            Well in the time-tested tradition of "let the machine do the repetitive
            work" why don't you just write a macro that does something like:

            ; macro "indent the region the same number of blanks as line above"
            save line number of current location
            exchange-point-and-mark ; now at beginning of to-be-indented area
            backward-line
            count number of spaces from ^ ; how many blanks to insert
            forward-line ; now on the first line to be indented
            subtract current_line_number from saved_line_number
            for this many lines, prepend the counted number of spaces

            Of course, this isn't the way I do such a thing myself. What I do is go
            to the line that has the spaces at the beginning, mark the BOL, cursor
            to the end of the spaces, copy the region (i.e., just the spaces) and
            then do query-replace-string of ^ with those spaces (inserted in the
            minibuffer using yank) and just keep hitting spacebar and replacing (and
            thus indenting) until I'm at the end of the area I want to indent.
            Simple, and nearly foolproof. And no counting!

            I also have a small macro that indents the current line 4 spaces and
            moves to the next line (I call it "shove-over"). I use this a lot.

            -Th
          • Meino Christian Cramer
            From: Thomas Hundt Subject: Re: [jasspa] graphical string-rectangle ? Date: Tue, 31 May 2005 13:54:04 -0700 Hi Thomas, Thank you for your
            Message 5 of 7 , Jun 1 10:55 AM
            • 0 Attachment
              From: Thomas Hundt <thundt@...>
              Subject: Re: [jasspa] "graphical" string-rectangle ?
              Date: Tue, 31 May 2005 13:54:04 -0700

              Hi Thomas,

              Thank you for your help and hints ! :)

              More general: A interactive string-srectangle would solve a dozen of
              "problems" for which each a different solution may already exist.

              If the indentation "problem" would be my only concern, I wouldn't
              ask for such a "big" solution...


              NO CRITISM! :)


              Keep microemacsing!
              Meino



              > > Suppose you want to indent something -- a rectangle of course --
              > > until it lines up with soething else above or below that rectangle.
              > >
              > > With the current implemeentation you first have to count the spaces
              > > needed (dont miscount! Otherwise: Go back to START), start
              > > string-rectangle, enter that amount of space, hit <RETURN> (fingers
              > > crossed) and VOILA!....ooops...to wo space to much...UNDO...and...
              >
              > Well in the time-tested tradition of "let the machine do the repetitive
              > work" why don't you just write a macro that does something like:
              >
              > ; macro "indent the region the same number of blanks as line above"
              > save line number of current location
              > exchange-point-and-mark ; now at beginning of to-be-indented area
              > backward-line
              > count number of spaces from ^ ; how many blanks to insert
              > forward-line ; now on the first line to be indented
              > subtract current_line_number from saved_line_number
              > for this many lines, prepend the counted number of spaces
              >
              > Of course, this isn't the way I do such a thing myself. What I do is go
              > to the line that has the spaces at the beginning, mark the BOL, cursor
              > to the end of the spaces, copy the region (i.e., just the spaces) and
              > then do query-replace-string of ^ with those spaces (inserted in the
              > minibuffer using yank) and just keep hitting spacebar and replacing (and
              > thus indenting) until I'm at the end of the area I want to indent.
              > Simple, and nearly foolproof. And no counting!
              >
              > I also have a small macro that indents the current line 4 spaces and
              > moves to the next line (I call it "shove-over"). I use this a lot.
              >
              > -Th
              >
              >
              > __________________________________________________________________________
              >
              > 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
              Below is a version of string-rectangle with suggested changes, if no one objects this will be in the next release. Steve ... ; string-rectangle; The user is
              Message 6 of 7 , Jun 5 3:32 PM
              • 0 Attachment
                Below is a version of string-rectangle with suggested changes, if no one
                objects this will be in the next release.

                Steve

                -----------------------------
                ; string-rectangle; The user is prompted for a string which is inserted at
                ; the same horizontal position on all lines spanned by the current region.
                define-macro string-rectangle
                set-variable #l0 $window-line
                set-variable #l3 $window-col
                exchange-point-and-mark
                set-variable #l2 $window-line
                exchange-point-and-mark
                ; Compute the top line.
                !if &gre #l0 #l2
                set-variable #l1 #l2
                set-variable #l2 #l0
                !else
                set-variable #l1 #l0
                !endif
                ; Get the string to insert
                !force set-variable #l6 @1
                !if ¬ $status
                set-variable #l6 @ml "String"
                !endif
                ; Fill all of the lines in the region from the first column.
                set-variable $window-line #l1
                !repeat
                ; Move to the column
                beginning-of-line
                !while &les $window-col #l3
                !if ¬ &seq @wc "\n"
                forward-char
                !else
                insert-string " "
                !endif
                !done
                ; Insert the string
                insert-string #l6
                !if ¬ &les $window-line #l2
                ; done the last line, return
                set-variable $window-line #l0
                set-variable $window-col &add #l3 &len #l6
                !return
                !endif
                forward-line
                !until 0
                !emacro
                -----------------------------
              Your message has been successfully submitted and would be delivered to recipients shortly.