aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman <[email protected]>1993-06-14 18:53:40 +0000
committerRichard M. Stallman <[email protected]>1993-06-14 18:53:40 +0000
commit5c927015eeba89a83299536e7b2ffcf294fdbc6c (patch)
tree260dd33472c879f4a7e172fa6b33f7769de06ca4 /lisp
parent9199fa7f7f182aeb77ea48a43483753ca5bad32e (diff)
(picture-replace-match): New function.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/textmodes/picture.el22
1 files changed, 22 insertions, 0 deletions
diff --git a/lisp/textmodes/picture.el b/lisp/textmodes/picture.el
index b8a1ec0c5c..3b6a5fe232 100644
--- a/lisp/textmodes/picture.el
+++ b/lisp/textmodes/picture.el
@@ -263,6 +263,28 @@ With positive argument insert that many lines."
(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