unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Pascal Bourguignon <pjb@informatimago.com>
Subject: Re: Shifting a column left or right using key
Date: Sat, 15 Apr 2006 03:59:12 +0200	[thread overview]
Message-ID: <87wtdrk39r.fsf@thalassa.informatimago.com> (raw)
In-Reply-To: mailman.423.1145058292.9609.help-gnu-emacs@gnu.org

"Abbott, Kevin-p98710" <Kevin.Abbott@gdc4s.com> writes:
> Years ago I used IBM PERSONAL EDITOR  (PE) to edit text files.
>  One nice option that PE had was that one could mark a rectangle in front of a
> column of text or data and use the ctrl --> or ctrl <-- to shift the column/
> text left or right.  Actually, the function deleted the whitespace or added
> whitespace to the left of the column.  Once the text or column reached the
> marked rectangle area the text/data would be deleted a column of characters at
> a time.
>
> Does anyone have a ELISP function that does this?

Just write it!  It's funny, really!

(defun force-indent-region-left (start end)
  (interactive "r")
  (setf mark-even-if-inactive t)
  (let* ((start (progn (goto-char start)
                       (beginning-of-line)
                       (point)))
         (end   (progn (goto-char end)
                       (forward-line)
                       (beginning-of-line)
                       (point)))
         (lnum  (count-lines start end)))
    (goto-char start)
    (dotimes (i (1- lnum))
      (beginning-of-line)
      (unless (looking-at "$")
        (delete-char 1))
      (forward-line))
    (set-mark start)))

(defun indent-region-right (start end)
  (interactive "r")
  (setf mark-even-if-inactive t)
  (let* ((start (progn (goto-char start)b
                       (beginning-of-line)
                       (point)))
         (end   (progn (goto-char end)
                       (forward-line)
                       (beginning-of-line)
                       (point)))
         (lnum  (count-lines start end)))
    (indent-rigidly start end 1)
    (goto-char start)
    (forward-line (1- lnum))
    (set-mark start)))

(global-set-key (kbd "<f7>") (function force-indent-region-left))
(global-set-key (kbd "<f8>") (function indent-region-right))

Then you can use F7 and F8 to do what you want.  The region
disappears, but you can still press F7/F8 to indent.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Kitty like plastic.
Confuses for litter box.
Don't leave tarp around.

       reply	other threads:[~2006-04-15  1:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.423.1145058292.9609.help-gnu-emacs@gnu.org>
2006-04-15  1:59 ` Pascal Bourguignon [this message]
     [not found] <mailman.447.1145124370.9609.help-gnu-emacs@gnu.org>
2006-04-15 22:10 ` Shifting a column left or right using key B. T. Raven
2006-04-15 23:04   ` Drew Adams
2006-04-14 23:08 Abbott, Kevin-p98710
2006-04-15  8:45 ` Peter Dyballa
     [not found] ` <mailman.435.1145090737.9609.help-gnu-emacs@gnu.org>
2006-04-15 16:53   ` B. T. Raven
2006-04-15 17:59     ` Peter Dyballa
2006-04-15 18:05     ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wtdrk39r.fsf@thalassa.informatimago.com \
    --to=pjb@informatimago.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).