Re: [jasspa] "graphical" string-rectangle ?
- From: Thomas Hundt <thundt@...>
Subject: Re: [jasspa] "graphical" string-rectangle ?
Date: Tue, 31 May 2005 13:54:04 -0700
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! :)
> > 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
> 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.
> 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
> or visit http://groups.yahoo.com/group/jasspa and
> modify your account settings manually.
> Yahoo! Groups Links
- Below is a version of string-rectangle with suggested changes, if no one
objects this will be in the next release.
; 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.
set-variable #l0 $window-line
set-variable #l3 $window-col
set-variable #l2 $window-line
; Compute the top line.
!if &gre #l0 #l2
set-variable #l1 #l2
set-variable #l2 #l0
set-variable #l1 #l0
; Get the string to insert
!force set-variable #l6 @1
!if ¬ $status
set-variable #l6 @ml "String"
; Fill all of the lines in the region from the first column.
set-variable $window-line #l1
; Move to the column
!while &les $window-col #l3
!if ¬ &seq @wc "\n"
insert-string " "
; Insert the string
!if ¬ &les $window-line #l2
; done the last line, return
set-variable $window-line #l0
set-variable $window-col &add #l3 &len #l6