From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: Shifting a column left or right using key Date: Sat, 15 Apr 2006 03:59:12 +0200 Organization: Informatimago Message-ID: <87wtdrk39r.fsf@thalassa.informatimago.com> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1145068834 1361 80.91.229.2 (15 Apr 2006 02:40:34 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 15 Apr 2006 02:40:34 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Apr 15 04:40:31 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FUai3-0001bD-4a for geh-help-gnu-emacs@m.gmane.org; Sat, 15 Apr 2006 04:40:27 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FUai2-00053B-M4 for geh-help-gnu-emacs@m.gmane.org; Fri, 14 Apr 2006 22:40:26 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 59 Original-X-Trace: individual.net dfijbou0fp6iXYmKhCAAlQn8qbUNBmNlgmAjHCWIFzJhxmqOM7 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:t8ogCmSd45r3AutmNloNWzOMsRM= Original-Xref: shelby.stanford.edu gnu.emacs.help:138755 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:34373 Archived-At: "Abbott, Kevin-p98710" 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 "") (function force-indent-region-left)) (global-set-key (kbd "") (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.