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

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

Expand Messages
  • Tony Bedford
    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
    Message 1 of 19 , Sep 30, 2004
      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

      >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 00:18:04 +0100
      >
      >Tony Bedford wrote:
      > > 3 questions guys:
      > >
      >
      > <SNIP>
      >
      > >
      > > 3) Last, but not least, how do I indent or outdent blocks of text, I
      >really
      > > miss this feature?!
      > >
      >
      >Attached is my latest offering for the 'shove-over' and
      >'shove-back' macros to perform the indent and outdent.
      >These are a little more sophisticated than the original
      >circa 2002 macros as they handle both numeric arguments
      >and selected regions with the same command. Hopefully
      >I have not messed up, it is the first time that I've
      >really tried to combine both hilighted regions and
      >argument commands in a single macro. The region
      >selection is a little hairy, but otherwise
      >the macro is reasonably straight forward.
      >
      >They are bundled up with the other utilty
      >contribution macros so will get shipped
      >in future as an example.
      >
      >Regards
      >Jon.
      >; -!- emf -!-
      >; This is part of the JASSPA MicroEmacs macro files
      >; Copyright (C) 1999-2004 JASSPA (www.jasspa.com)
      >; See the file me.emf for copying and conditions.
      >;
      >; Created: Thu Mar 25 21:49:50 2004
      >; Synopsis: Useful extensions to user.emf file
      >; Add to your file ~/.jasspa/$LOGNAME.emf
      >; Authors: Jon Green
      >;
      >
      >;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      >;; ; Set up CVS to be compressed.
      >;; set-variable %cvs-com "cvs -z9 "
      >
      >;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      >; spotless; Perform a clean and remove any multi-blank lines.
      >define-macro spotless
      > -1 clean
      >!emacro
      >
      >;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      >; comment-adjust; Used for comments in electric-c mode (and the other
      >; electic modes. Moves to the comment fill position, saves having to mess
      >; around with comments at the end of the line.
      >0 define-macro comment-adjust
      > ; delete all spaces up until the next character
      > !while &sin @wc " \t"
      > forward-delete-char
      > !done
      > ; Fill the line to the current $c-margin. We use this as
      > ; this is the only variable that tells us where the margin
      > ; should be.
      > !if &gre $window-acol 0
      > backward-char
      > !if &sin @wc " \t"
      > forward-delete-char
      > !jump -4
      > !else
      > forward-char
      > !endif
      > !endif
      > ; Now fill to the $c-margin
      > &sub $c-margin $window-acol insert-string " "
      >!emacro
      >global-bind-key comment-adjust "esc tab"
      >global-bind-key comment-adjust "C-insert"
      >; Comment margin to adjust to.
      >set-variable $c-margin 40
      >
      >;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      >; insert-date; Insert the current date into the text.
      >define-macro insert-date
      > ascii-time
      > ; ascii-time returns a formatted string in #l9
      > insert-string #l9
      >!emacro
      >
      >;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      >; Macro to delete the whitespace, or if on a word all of the word until the
      >; next word is reached.
      >0 define-macro super-delete
      > set-variable #l0 0
      > !while ¬ &sin @wc " \t\n"
      > forward-char
      > set-variable #l0 &add #l0 1
      > !done
      > !repeat
      > !force forward-char
      > !if $status
      > set-variable #l0 &add #l0 1
      > !endif
      > !until &or &seq @wc "" ¬ &sin @wc " \t\n"
      > #l0 backward-delete-char
      > !return
      >!emacro
      >global-bind-key super-delete "C-delete"
      >
      >;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      >; Macro to backspace the whitespace, or if on a word all of the word until
      >the
      >; previous word is reached.
      >0 define-macro super-backspace
      > set-variable #l0 -1
      > set-variable #l1 0
      > !repeat
      > !force backward-char
      > !if $status
      > set-variable #l0 &add #l0 1
      > !if &sin @wc " \t\n"
      > set-variable #l1 1
      > !endif
      > !else
      > set-variable #l1 1
      > !endif
      > !until #l1
      > !repeat
      > !force backward-char
      > !if $status
      > set-variable #l0 &add #l0 1
      > !else
      > &add #l0 1 forward-delete-char
      > !return
      > !endif
      > !until ¬ &sin @wc " \t\n"
      > forward-char
      > #l0 forward-delete-char
      > !return
      >!emacro
      >global-bind-key super-backspace "C-backspace"
      >
      >;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      >; Command to move to the previous buffer.
      >define-macro previous-buffer
      > &neg @# next-buffer
      >!emacro
      >
      >;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      >; Macro to increase 'n' lines by a tab stop. If a region is hilighted then
      >; the whole region is shoved back by a tab stop. If 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
      > !force -3 show-region
      > !force 3 show-region
      > !force -1 show-region
      > !else
      > ; No region assume a single line.
      > set-position "\x82"
      > set-variable #l0 $window-line
      > set-variable #l1 #l0
      > !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 &les @# 0
      > ; -ve argument then abort.
      > !abort
      > !elif &gre @# 1
      > set-variable #l1 &add #l0 &sub @# 1
      > !endif
      > !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
      > !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
      > goto-position "\x82"
      > !return
      > !endif
      > !until &gre $window-line #l1
      >!emacro
      >global-bind-key shove-back "C-x left"
      >
      >;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      >; Macro to decrease 'n' lines by a tab stop. If a region is hilighted then
      >; the whole region is indented back by a tab stop. If 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
      > !force -3 show-region
      > !force 3 show-region
      > !force -1 show-region
      > !else
      > ; No region assume a single line.
      > set-position "\x82"
      > set-variable #l0 $window-line
      > set-variable #l1 #l0
      > !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 &les @# 0
      > ; -ve argument then abort.
      > !abort
      > !elif &gre @# 1
      > set-variable #l1 &add #l0 &sub @# 1
      > !endif
      > !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
      > !repeat
      > ; Go forward first to make sure we are not at end of buffer.
      > !force forward-line
      > ; Check for end of buffer.
      > !if ¬ $status
      > goto-position "\x82"
      > !return
      > !endif
      > backward-line
      > beginning-of-line
      > $tabsize insert-string " "
      > beginning-of-line
      > forward-line
      > !until &gre $window-line #l1
      >!emacro
      >global-bind-key shove-over "C-x right"
      >
      >;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      >;; ; If you loose the C-k kill-line key then you are miss-typing and
      >unbinding.
      >;; ; Remove the global-unbind-key binding so this cannot happen.
      >;; !force global-unbind-key "esc C-k"
      >
      >;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      >;; ; If you can never remember the undo key then bind to a function key.
      >;; global-bind-key undo "f12"

      _________________________________________________________________
      Use MSN Messenger to send music and pics to your friends
      http://www.msn.co.uk/messenger
    • Thomas Hundt
      I would write it as: if no ^U (C-u) value given, indent the current tab width (i.e., one tab stop); if ^U value given, indent it that much. The ^U value is in
      Message 2 of 19 , Sep 30, 2004
        I would write it as: if no ^U (C-u) value given, indent the current tab
        width (i.e., one tab stop); if ^U value given, indent it that much.

        The ^U value is in variable @#. You will see it used in loops, like
        this, to perform a function over @# number of lines:

        define-macro quote-line
        !while &gre &pdec @# 1 0 ; C-u prefix support
        beginning-of-line
        insert-string "|"
        forward-line
        !done
        !emacro ; quote-line
        global-bind-key quote-line "C-x q"

        Good luck

        -Th



        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
        >
        >
        >>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 00:18:04 +0100
        >>
        >>Tony Bedford wrote:
        >>
        >>>3 questions guys:
        >>>
        >>
        >> <SNIP>
        >>
        >>>3) Last, but not least, how do I indent or outdent blocks of text, I
        >>
        >>really
        >>
        >>>miss this feature?!
        >>>
        >>
        >>Attached is my latest offering for the 'shove-over' and
        >>'shove-back' macros to perform the indent and outdent.
        >>These are a little more sophisticated than the original
        >>circa 2002 macros as they handle both numeric arguments
        >>and selected regions with the same command. Hopefully
        >>I have not messed up, it is the first time that I've
        >>really tried to combine both hilighted regions and
        >>argument commands in a single macro. The region
        >>selection is a little hairy, but otherwise
        >>the macro is reasonably straight forward.
        >>
        >>They are bundled up with the other utilty
        >>contribution macros so will get shipped
        >>in future as an example.
        >>
        >>Regards
        >>Jon.
        >>; -!- emf -!-
        >>; This is part of the JASSPA MicroEmacs macro files
        >>; Copyright (C) 1999-2004 JASSPA (www.jasspa.com)
        >>; See the file me.emf for copying and conditions.
        >>;
        >>; Created: Thu Mar 25 21:49:50 2004
        >>; Synopsis: Useful extensions to user.emf file
        >>; Add to your file ~/.jasspa/$LOGNAME.emf
        >>; Authors: Jon Green
        >>;
        >>
        >>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        >>;; ; Set up CVS to be compressed.
        >>;; set-variable %cvs-com "cvs -z9 "
        >>
        >>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        >>; spotless; Perform a clean and remove any multi-blank lines.
        >>define-macro spotless
        >> -1 clean
        >>!emacro
        >>
        >>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        >>; comment-adjust; Used for comments in electric-c mode (and the other
        >>; electic modes. Moves to the comment fill position, saves having to mess
        >>; around with comments at the end of the line.
        >>0 define-macro comment-adjust
        >> ; delete all spaces up until the next character
        >> !while &sin @wc " \t"
        >> forward-delete-char
        >> !done
        >> ; Fill the line to the current $c-margin. We use this as
        >> ; this is the only variable that tells us where the margin
        >> ; should be.
        >> !if &gre $window-acol 0
        >> backward-char
        >> !if &sin @wc " \t"
        >> forward-delete-char
        >> !jump -4
        >> !else
        >> forward-char
        >> !endif
        >> !endif
        >> ; Now fill to the $c-margin
        >> &sub $c-margin $window-acol insert-string " "
        >>!emacro
        >>global-bind-key comment-adjust "esc tab"
        >>global-bind-key comment-adjust "C-insert"
        >>; Comment margin to adjust to.
        >>set-variable $c-margin 40
        >>
        >>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        >>; insert-date; Insert the current date into the text.
        >>define-macro insert-date
        >> ascii-time
        >> ; ascii-time returns a formatted string in #l9
        >> insert-string #l9
        >>!emacro
        >>
        >>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        >>; Macro to delete the whitespace, or if on a word all of the word until the
        >>; next word is reached.
        >>0 define-macro super-delete
        >> set-variable #l0 0
        >> !while ¬ &sin @wc " \t\n"
        >> forward-char
        >> set-variable #l0 &add #l0 1
        >> !done
        >> !repeat
        >> !force forward-char
        >> !if $status
        >> set-variable #l0 &add #l0 1
        >> !endif
        >> !until &or &seq @wc "" ¬ &sin @wc " \t\n"
        >> #l0 backward-delete-char
        >> !return
        >>!emacro
        >>global-bind-key super-delete "C-delete"
        >>
        >>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        >>; Macro to backspace the whitespace, or if on a word all of the word until
        >>the
        >>; previous word is reached.
        >>0 define-macro super-backspace
        >> set-variable #l0 -1
        >> set-variable #l1 0
        >> !repeat
        >> !force backward-char
        >> !if $status
        >> set-variable #l0 &add #l0 1
        >> !if &sin @wc " \t\n"
        >> set-variable #l1 1
        >> !endif
        >> !else
        >> set-variable #l1 1
        >> !endif
        >> !until #l1
        >> !repeat
        >> !force backward-char
        >> !if $status
        >> set-variable #l0 &add #l0 1
        >> !else
        >> &add #l0 1 forward-delete-char
        >> !return
        >> !endif
        >> !until ¬ &sin @wc " \t\n"
        >> forward-char
        >> #l0 forward-delete-char
        >> !return
        >>!emacro
        >>global-bind-key super-backspace "C-backspace"
        >>
        >>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        >>; Command to move to the previous buffer.
        >>define-macro previous-buffer
        >> &neg @# next-buffer
        >>!emacro
        >>
        >>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        >>; Macro to increase 'n' lines by a tab stop. If a region is hilighted then
        >>; the whole region is shoved back by a tab stop. If 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
        >> !force -3 show-region
        >> !force 3 show-region
        >> !force -1 show-region
        >> !else
        >> ; No region assume a single line.
        >> set-position "\x82"
        >> set-variable #l0 $window-line
        >> set-variable #l1 #l0
        >> !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 &les @# 0
        >> ; -ve argument then abort.
        >> !abort
        >> !elif &gre @# 1
        >> set-variable #l1 &add #l0 &sub @# 1
        >> !endif
        >> !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
        >> !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
        >> goto-position "\x82"
        >> !return
        >> !endif
        >> !until &gre $window-line #l1
        >>!emacro
        >>global-bind-key shove-back "C-x left"
        >>
        >>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        >>; Macro to decrease 'n' lines by a tab stop. If a region is hilighted then
        >>; the whole region is indented back by a tab stop. If 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
        >> !force -3 show-region
        >> !force 3 show-region
        >> !force -1 show-region
        >> !else
        >> ; No region assume a single line.
        >> set-position "\x82"
        >> set-variable #l0 $window-line
        >> set-variable #l1 #l0
        >> !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 &les @# 0
        >> ; -ve argument then abort.
        >> !abort
        >> !elif &gre @# 1
        >> set-variable #l1 &add #l0 &sub @# 1
        >> !endif
        >> !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
        >> !repeat
        >> ; Go forward first to make sure we are not at end of buffer.
        >> !force forward-line
        >> ; Check for end of buffer.
        >> !if ¬ $status
        >> goto-position "\x82"
        >> !return
        >> !endif
        >> backward-line
        >> beginning-of-line
        >> $tabsize insert-string " "
        >> beginning-of-line
        >> forward-line
        >> !until &gre $window-line #l1
        >>!emacro
        >>global-bind-key shove-over "C-x right"
        >>
        >>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        >>;; ; If you loose the C-k kill-line key then you are miss-typing and
        >>unbinding.
        >>;; ; Remove the global-unbind-key binding so this cannot happen.
        >>;; !force global-unbind-key "esc C-k"
        >>
        >>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        >>;; ; If you can never remember the undo key then bind to a function key.
        >>;; global-bind-key undo "f12"
        >
        --
        Thomas Hundt
      • Jon Green
        ... 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
        Message 3 of 19 , Sep 30, 2004
          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.
        • 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 4 of 19 , Oct 1, 2004
            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 5 of 19 , Oct 1, 2004
              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 6 of 19 , Oct 4, 2004
                >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.