Xref: utzoo gnu.emacs:2218 comp.emacs:7660 Path: utzoo!utgpu!watserv1!watmath!uunet!jarthur!bridge2!mdb From: mdb@ESD.3Com.COM (Mark D. Baushke) Newsgroups: gnu.emacs,comp.emacs Subject: Re: block manipulation Message-ID: Date: 1 Feb 90 22:04:57 GMT References: <1418@awdprime.UUCP> Sender: news@bridge2.ESD.3Com.COM Followup-To: gnu.emacs Organization: 3Com Corp., Mountain View, CA. Lines: 68 In-reply-to: ron@woan.austin.ibm.com's message of 1 Feb 90 17:28:23 GMT On 1 Feb 90 17:28:23 GMT, ron@woan.austin.ibm.com (Ronald S. Woan) said: ron> Is there any support in GNU EMACS for manipulating blocks of texts ron> (not regions) spanning multiple lines? Or how about a real simple one, ron> how do you get rid of a column without having to write a lisp ron> functions to go down line by line deleting a particular character ron> position? Do the rectangle manipulation functions handle what you want (see $EMACS/lisp/rect.el for more information)? clear-rectangle delete-rectangle kill-rectangle open-rectangle yank-rectangle Given the above rectangle functions and add the functions insert-box insert-suffix (lisp given below) and you have a fairly full set of functionality for manipulating rectangular regions (columns) of text. (defun insert-box (start end text) "Insert a text prefix at a column in all the lines in the region. Called from a program, takes three arguments, START, END, and TEXT. The column is taken from that of START. The rough inverse of this function is kill-rectangle." (interactive "r\nsText To Insert: ") (save-excursion (let (cc) ;; the point-marker stuff is needed to keep the edits from changing ;; where end is (goto-char end) (setq end (point-marker)) (goto-char start) (setq cc (current-column)) (while (< (point) end) ;; modified 2/2/88 ;; I should here check for tab chars (insert text) (forward-line 1) (move-to-column cc)) (move-marker end nil)))) (defun insert-suffix (start end text) "Insert a text prefix at the end in all the lines in the region. Called from a program, takes three arguments, START, END, and TEXT. The column is taken from that of START." (interactive "r\nsText To Insert: ") (save-excursion (let (cc) ;; the point-marker stuff is needed to keep the edits from changing ;; where end is (goto-char end) (setq end (point-marker)) (goto-char start) (end-of-line) (while (< (point) end);; modified 2/2/88 ;; I should here check for tab chars (insert text) (forward-line 1) (end-of-line) ) (move-marker end nil)))) Enjoy! -- Mark D. Baushke mdb@ESD.3Com.COM