[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Shifting a column left or right using key
From: |
Pascal Bourguignon |
Subject: |
Re: Shifting a column left or right using key |
Date: |
Sat, 15 Apr 2006 03:59:12 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
"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.