🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.emacs
Article #9640

Re: insert char. in first column.

#9640
From: Mike Williams
Date: Thu, 01 Mar 1990 02:13
30 lines
1776 bytes
+--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. |
      \-------------------------------------------------------------/
Technical Details
Message-ID: <BYRD.90Mar1131302@barretts.comp.vuw.ac.nz>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!munnari.oz.au!kaukau.comp.vuw.ac.nz!byrd
References: <13714@fs2.NISC.SRI.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!munnari.oz.au!kaukau.comp.vuw.ac.nz!byrd
From: byrd@comp.vuw.ac.nz (Mike Williams)
Newsgroups: comp.emacs
Subject: Re: insert char. in first column.
Message-ID: <BYRD.90Mar1131302@barretts.comp.vuw.ac.nz>
Date: 1 Mar 90 02:13:02 GMT
References: <13714@fs2.NISC.SRI.COM>
Sender: news@kaukau.comp.vuw.ac.nz (News Admin)
Organization: Dept. of Computer Science, Victoria Uni. of Wellington, NZ.
Lines: 30
In-Reply-To: cwilson@NISC.SRI.COM's message of 28 Feb 90 14:26:20 GMT