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

Re: [jasspa] 3 questions - Indent/Outdent region.

Expand Messages
  • Tony Bedford
    I think that would be very useful, indenting and outdenting on blocks is something I do a LOT and I m sure others do too. By the way I have just being reading
    Message 1 of 19 , Oct 1, 2004
    • 0 Attachment
      I think that would be very useful, indenting and outdenting on blocks is
      something I do a LOT and I'm sure others do too.

      By the way I have just being reading info pages in ME, very nice :)

      Many thanks,
      Tony

      >From: Jon Green <jon@...>
      >Reply-To: jasspa@yahoogroups.com
      >To: jasspa@yahoogroups.com
      >Subject: Re: [jasspa] 3 questions - Indent/Outdent region.
      >Date: Thu, 30 Sep 2004 22:01:09 +0100
      >
      >Tony Bedford wrote:
      > > These are cool.
      > >
      > > But, (I know I'm being a pain now) the only slight problem is, if you
      >want
      > > to outdent by
      > > several tabs you have to reselect the region again.
      > >
      > > I think I will need to come up with some sort of macro that will
      > > outdent/indent by the specified number of stops. And basically use a
      > > keyboard macro to apply it on a line by line basis.
      > >
      > > Cheers all,
      > > Tony
      >
      >With a little bit of tweeking then we can make a version with
      >a sticky region that remains active. It is a little wierd
      >as nothing else operates like this but may be more
      >appropriate. So you can continue to change the indent until
      >the region is removed.
      >
      >Jon.
      >;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      >; Macro to decrease 'n' lines by a tab stop. If a region is hilighted then
      >; the whole region is shoved back by a tab stop. The there is no region, or
      >a
      >; numeric argument is specified then 'n' lines are indented by a tab stop.
      >define-macro shove-back
      > ; Test the region first before we destroy the region by executing
      > ; some macro commands
      > 0 show-region
      > !if &equ &band $result 5 5
      > !if ¬ &band $result 2
      > 3 show-region
      > !endif
      > ; Save the position for later.
      > set-position "\x82"
      > ; Determine if there is a hilight region in effect.
      > -2 show-region
      > set-variable #l0 $window-line
      > set-variable #l2 $window-col
      > 2 show-region
      > set-variable #l1 $window-line
      > set-variable #l3 $window-col
      > !if &les #l0 #l1
      > ; If we are in the firat column then back up a line as the
      > ; user will have selected the previous lines not this one.
      > !if &equ #l3 0
      > set-variable #l1 &sub #l1 1
      > !endif
      > !else
      > !if &equ #l2 0
      > set-variable #l0 &sub #l0 1
      > !endif
      > ; Swap #l0<=>#l1, #l2<=>#l3
      > set-variable #l4 #l0
      > set-variable #l0 #l1
      > set-variable #l1 #l4
      > !endif
      > set-variable #l7 1
      > !else
      > ; No region assume a single line.
      > set-position "\x82"
      > set-variable #l0 $window-line
      > set-variable #l1 #l0
      > set-variable #l7 0
      > !endif
      > ; If there is a numeric argument then we loose the region and use the
      > ; numeric argument as the number of lines to process.
      > !if @?
      > goto-position "\x82"
      > set-variable #l0 $window-line
      > !if ¬ &gre @# 0
      > ; -ve argument then abort.
      > !return
      > !endif
      > set-variable #l1 &add #l0 &sub @# 1
      > !endif
      > ; 3000 ml-write &spr "start line = %d end line = %d" #l0 #l1 We are
      > ; processing lines #l0 to #l1 inclusive, move back by a tab stop on
      >all
      > ; given lines.
      > !if ¬ &equ #l0 $window-line
      > goto-line #l0
      > !endif
      > ; If region mark the starting point.
      > !if #l7
      > set-mark
      > !endif
      > !repeat
      > beginning-of-line
      > set-variable #l5 $tabsize
      > !while &gre &pdec #l5 1 0
      > !if &ise @wc " "
      > forward-delete-char
      > !else
      > ; Any tab is consumed and we stop, any other character and
      >we
      > ; stop.
      > !if &ise @wc "\t"
      > forward-delete-char
      > !endif
      > set-variable #l5 0
      > !endif
      > !done
      > !force forward-line
      > ; Check for end of buffer.
      > !if ¬ $status
      > ; End of buffer - re-enable the region.
      > !if #l7
      > exchange-point-and-mark
      > -3 show-region
      > exchange-point-and-mark
      > 3 show-region
      > 1 show-region
      > !endif
      > !return
      > !endif
      > !until &gre $window-line #l1
      > ; Reenable the region.
      > !if #l7
      > exchange-point-and-mark
      > -3 show-region
      > exchange-point-and-mark
      > 3 show-region
      > 1 show-region
      > !endif
      >!emacro
      >global-bind-key shove-back "C-x left"
      >
      >;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      >; Macro to increase 'n' lines by a tab stop. If a region is hilighted then
      >; the whole region is indented back by a tab stop. The there is no region,
      >or
      >; a numeric argument is specified then 'n' lines are indented by a tab
      >stop.
      >define-macro shove-over
      > ; Test the region first before we destroy the region by executing
      > ; some macro commands
      > 0 show-region
      > !if &equ &band $result 5 5
      > !if ¬ &band $result 2
      > 3 show-region
      > !endif
      > ; Save the position for later.
      > set-position "\x82"
      > ; Determine if there is a hilight region in effect.
      > -2 show-region
      > set-variable #l0 $window-line
      > set-variable #l2 $window-col
      > 2 show-region
      > set-variable #l1 $window-line
      > set-variable #l3 $window-col
      > !if &les #l0 #l1
      > ; If we are in the firat column then back up a line as the
      > ; user will have selected the previous lines not this one.
      > !if &equ #l3 0
      > set-variable #l1 &sub #l1 1
      > !endif
      > !elif &gre #l0 #l1
      > !if &equ #l2 0
      > set-variable #l0 &sub #l0 1
      > !endif
      > ; Swap #l0<=>#l1, #l2<=>#l3
      > set-variable #l4 #l0
      > set-variable #l0 #l1
      > set-variable #l1 #l4
      > !endif
      > set-variable #l7 1
      > !else
      > ; No region assume a single line.
      > set-position "\x82"
      > set-variable #l0 $window-line
      > set-variable #l1 #l0
      > set-variable #l7 0
      > !endif
      > ; If there is a numeric argument then we loose the region and use the
      > ; numeric argument as the number of lines to process.
      > !if @?
      > goto-position "\x82"
      > set-variable #l0 $window-line
      > !if ¬ &gre @# 0
      > ; -ve argument then abort.
      > !return
      > !endif
      > set-variable #l1 &add #l0 &sub @# 1
      > !endif
      > ; processing lines #l0 to #l1 inclusive, move back by a tab stop on
      >all
      > ; given lines.
      > !if ¬ &equ #l0 $window-line
      > goto-line #l0
      > !endif
      > ; If region mark the starting point.
      > !if #l7
      > set-mark
      > !endif
      > !repeat
      > ; Go forward first to make sure we are not at end of buffer.
      > !force forward-line
      > ; Check for end of buffer.
      > !if ¬ $status
      > beginning-of-line
      > !if #l7
      > exchange-point-and-mark
      > -3 show-region
      > exchange-point-and-mark
      > 3 show-region
      > 1 show-region
      > !endif
      > !return
      > !endif
      > backward-line
      > beginning-of-line
      > $tabsize insert-string " "
      > forward-line
      > !until &gre $window-line #l1
      > beginning-of-line
      > ; Reenable the region.
      > !if #l7
      > exchange-point-and-mark
      > -3 show-region
      > exchange-point-and-mark
      > 3 show-region
      > 1 show-region
      > !endif
      >!emacro
      >global-bind-key shove-over "C-x right"

      _________________________________________________________________
      It's fast, it's easy and it's free. Get MSN Messenger today!
      http://www.msn.co.uk/messenger
    • Thomas Hundt
      Personally I wish there were a good outline mode that would do all this for me... but then you re getting into is it a word processor or an editor and
      Message 2 of 19 , Oct 1, 2004
      • 0 Attachment
        Personally I wish there were a good outline mode that would do all this
        for me... but then you're getting into "is it a word processor or an
        editor" and potentially a whole lot of work. And different people have
        different ideas about how plain-text word processing/formatting should
        be done.

        BTW, for some reason often I seem to end up using the rectangle
        functions to tweak indentation on large blocks of text. You know about
        those, right? Kill-rectangle etc.

        -Th


        Tony Bedford wrote:
        > I think that would be very useful, indenting and outdenting on blocks is
        > something I do a LOT and I'm sure others do too.


        --
        Thomas Hundt
      • Tony Bedford
        ... This sounds like what I wanted...basically common programming related editing tasks would be reindenting the body of a for loop, if block or while loop. In
        Message 3 of 19 , Oct 4, 2004
        • 0 Attachment
          >BTW, for some reason often I seem to end up using the rectangle
          >functions to tweak indentation on large blocks of text. You know about
          >those, right? Kill-rectangle etc.


          This sounds like what I wanted...basically common programming related
          editing tasks would be reindenting the body of a for loop, if block or while
          loop. In XSLT and XML there are similar tasks that require this - even in
          plain text.

          Are you saying one way is to kill a rectangle and then yank it back in at
          the right location? I hadnp;t thought of doing it like that, also it's a
          little harder to get it right like that too.

          OK I'll try some more experimentation today.

          Cheers,
          Tony




          >From: Thomas Hundt <thundt@...>
          >Reply-To: jasspa@yahoogroups.com
          >To: jasspa@yahoogroups.com
          >Subject: Re: [jasspa] 3 questions - Indent/Outdent region.
          >Date: Fri, 01 Oct 2004 10:07:56 -0700
          >
          >Personally I wish there were a good outline mode that would do all this
          >for me... but then you're getting into "is it a word processor or an
          >editor" and potentially a whole lot of work. And different people have
          >different ideas about how plain-text word processing/formatting should
          >be done.
          >
          >BTW, for some reason often I seem to end up using the rectangle
          >functions to tweak indentation on large blocks of text. You know about
          >those, right? Kill-rectangle etc.
          >
          >-Th
          >
          >
          >Tony Bedford wrote:
          > > I think that would be very useful, indenting and outdenting on blocks is
          > > something I do a LOT and I'm sure others do too.
          >
          >
          >--
          >Thomas Hundt

          _________________________________________________________________
          It's fast, it's easy and it's free. Get MSN Messenger today!
          http://www.msn.co.uk/messenger
        Your message has been successfully submitted and would be delivered to recipients shortly.