cwilson@NISC.SRI.COM (Chan Wilson) (02/28/90)
This has got to be simple, I just know it. But how do you do it? I want to be able to insert a character in the first column of a given region, whether it be a tab, a >, or whatnot. How is this done? --Chan ................ Chan Wilson -- cwilson@nisc.sri.com <or> radius!cwilson@apple.com Janitor/Architect of comp.binaries.apple2 archive on wuarchive.wustl.edu I don't speak for SRI, someone else does. ................
merlyn@iwarp.intel.com (Randal Schwartz) (03/01/90)
In article <13714@fs2.NISC.SRI.COM>, cwilson@NISC (Chan Wilson) writes: | This has got to be simple, I just know it. But how do you do it? | | I want to be able to insert a character in the first column of a given | region, whether it be a tab, a >, or whatnot. How is this done? Assuming you are GNU-Emacs-ing, since you didn't say... First, define your region (set-mark-command, or whatever), then... C-x n (narrow-to-region) M-< (beginning-of-buffer) M-x replace-regexp RET ^ RET tab-or->-or-whatnot RET C-x w (widen) With the appropriate conversions to elisp, you can do it from within a function. Just another Emacs hacker, -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/
byrd@comp.vuw.ac.nz (Mike Williams) (03/01/90)
+--In article <13714@fs2.NISC.SRI.COM> cwilson@NISC.SRI.COM (Chan Wilson) writes: | I want to be able to insert a character in the first column of a given | region, whether it be a tab, a >, or whatnot. How is this done? ( This assumes that you are using GNU-emacs. ) I use the following function to insert characters in the same place on a line over an entire region. It uses the goal-column if one is set, otherwise the column in which the mark was set is used. (defun insert-on-each-line (str beg end) "Insert STR at the current column on each line of the current region. Args BEG and END specify the region if called from a program." (interactive "sString to insert: \nr") (let ((len (length str))) (save-excursion (goto-char beg) (if goal-column (move-to-column goal-column)) (while (< (point) end) (save-excursion (insert str)) (setq end (+ end len)) (line-move 1))))) (global-set-key "\ei" 'insert-on-each-line) -- /-------------------------------------------------------------\ | Mike Williams, Victoria University of Wellington, Aotearoa. | \-------------------------------------------------------------/
bard@brigid.cs.cornell.edu (Bard Bloom) (03/01/90)
My own "Insert stuff in left margin". The stuff it inserts is sticky.
-- Bard the emacs gargoyle
(defvar inleft-string "> " "Default string for inleft.")
(defun inleft (p m s)
"In the region BEG to END, inserts STRING at the beginning of each line."
(interactive
(list
(if (< (point) (mark)) (point-marker) (mark-marker))
(if (< (point) (mark)) (mark-marker) (point-marker))
(progn
(setq inleft-string (read-string "Inleft String:" inleft-string))
inleft-string)
))
(goto-char p)
(beginning-of-line 1)
(while (and (<= (point-marker) m) (not (eobp)))
(insert-before-markers s)
(next-line 1)
(beginning-of-line 1)))