# HG changeset patch # User Richard M. Stallman # Date 740084020 0 # Node ID 473c03886fc27d2ac9fdd10458ea551bd84d67db # Parent b9d69ed987e74a2a7e0e8bd5c49f76a9eb72722e (picture-replace-match): New function. diff -r b9d69ed987e7 -r 473c03886fc2 lisp/textmodes/picture.el --- a/lisp/textmodes/picture.el Mon Jun 14 15:35:55 1993 +0000 +++ b/lisp/textmodes/picture.el Mon Jun 14 18:53:40 1993 +0000 @@ -263,6 +263,28 @@ (forward-line -1) (insert contents)))) +;; Like replace-match, but overwrites. +(defun picture-replace-match (newtext fixedcase literal) + (let (ocolumn change pos) + (goto-char (setq pos (match-end 0))) + (setq ocolumn (current-column)) + ;; Make the replacement and undo it, to see how it changes the length. + (let ((buffer-undo-list nil) + list1) + (replace-match newtext fixedcase literal) + (setq change (- (current-column) ocolumn)) + (setq list1 buffer-undo-list) + (while list1 + (setq list1 (primitive-undo 1 list1)))) + (goto-char pos) + (if (> change 0) + (delete-region (point) + (progn + (move-to-column-force (+ change (current-column))) + (point)))) + (replace-match newtext fixedcase literal) + (if (< change 0) + (insert-char ?\ (- change))))) ;; Picture Tabs