comparison lisp/rect.el @ 22369:6c4756ecd4a2

(string-rectangle-line): Delete the rectangle first. (string-rectangle): Doc fix.
author Richard M. Stallman <rms@gnu.org>
date Sat, 06 Jun 1998 17:52:43 +0000
parents 84c3c863f0bd
children b13886e06eb2
comparison
equal deleted inserted replaced
22368:c3a15ab5924f 22369:6c4756ecd4a2
225 ;; to string-rectangle-line. 225 ;; to string-rectangle-line.
226 (defvar string-rectangle-string) 226 (defvar string-rectangle-string)
227 227
228 ;;;###autoload 228 ;;;###autoload
229 (defun string-rectangle (start end string) 229 (defun string-rectangle (start end string)
230 "Insert STRING on each line of the region-rectangle, shifting text right. 230 "Replace rectangle contents with STRING on each line.
231 The left edge of the rectangle specifies the column for insertion. 231 The length of STRING need not be the same as the rectangle width.
232 This command does not delete or overwrite any existing text.
233 232
234 Called from a program, takes three args; START, END and STRING." 233 Called from a program, takes three args; START, END and STRING."
235 (interactive "r\nsString rectangle: ") 234 (interactive "r\nsString rectangle: ")
236 (let ((string-rectangle-string string)) 235 (let ((string-rectangle-string string))
237 (operate-on-rectangle 'string-rectangle-line start end t))) 236 (operate-on-rectangle 'string-rectangle-line start end t)))
238 237
239 (defun string-rectangle-line (startpos begextra endextra) 238 (defun string-rectangle-line (startpos begextra endextra)
240 (let (whitespace) 239 (let (whitespace)
241 (goto-char startpos) 240 ;; Delete the width of the rectangle.
241 (delete-region startpos (point))
242 ;; Compute horizontal width of following whitespace. 242 ;; Compute horizontal width of following whitespace.
243 (let ((ocol (current-column))) 243 (let ((ocol (current-column)))
244 (skip-chars-forward " \t") 244 (skip-chars-forward " \t")
245 (setq whitespace (- (current-column) ocol))) 245 (setq whitespace (- (current-column) ocol)))
246 ;; Delete the following whitespace. 246 ;; Delete the following whitespace.