[comp.emacs] block manipulation

ron@woan.austin.ibm.com (Ronald S. Woan/2113674) (02/02/90)

Is there any support in GNU EMACS for manipulating blocks of texts
(not regions) spanning multiple lines? Or how about a real simple one,
how do you get rid of a column without having to write a lisp
functions to go down line by line deleting a particular character
position?

						Ron

+-----All Views Expressed Are My Own And Are Not Necessarily Shared By------+
+------------------------------My Employer----------------------------------+
+ Ronald S. Woan  (IBM VNET)WOAN AT AUSTIN, (AUSTIN)ron@woan.austin.ibm.com +
+ outside of IBM       @cs.utexas.edu:ibmaus!auschs!woan.austin.ibm.com!ron +
+ last resort                                        woan@peyote.cactus.org +

mdb@ESD.3Com.COM (Mark D. Baushke) (02/02/90)

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

nhess@dvlseq.oracle.com (Nate Hess) (02/02/90)

In article <1418@awdprime.UUCP>, ron@woan (Ronald S. Woan/2113674) writes:
>Is there any support in GNU EMACS for manipulating blocks of texts
>(not regions) spanning multiple lines?

Yes, there is.

Try doing  `C-h a rectangle RET'  for the relevant functions.

--woodstock
-- 
	   "What I like is when you're looking and thinking and looking
	   and thinking...and suddenly you wake up."   - Hobbes

nhess@dvlseq.oracle.com or ...!uunet!oracle!nhess or (415) 598-3046