diff options
| -rw-r--r-- | lisp/textmodes/picture.el | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lisp/textmodes/picture.el b/lisp/textmodes/picture.el index b8a1ec0c5c2..3b6a5fe232c 100644 --- a/lisp/textmodes/picture.el +++ b/lisp/textmodes/picture.el | |||
| @@ -263,6 +263,28 @@ With positive argument insert that many lines." | |||
| 263 | (forward-line -1) | 263 | (forward-line -1) |
| 264 | (insert contents)))) | 264 | (insert contents)))) |
| 265 | 265 | ||
| 266 | ;; Like replace-match, but overwrites. | ||
| 267 | (defun picture-replace-match (newtext fixedcase literal) | ||
| 268 | (let (ocolumn change pos) | ||
| 269 | (goto-char (setq pos (match-end 0))) | ||
| 270 | (setq ocolumn (current-column)) | ||
| 271 | ;; Make the replacement and undo it, to see how it changes the length. | ||
| 272 | (let ((buffer-undo-list nil) | ||
| 273 | list1) | ||
| 274 | (replace-match newtext fixedcase literal) | ||
| 275 | (setq change (- (current-column) ocolumn)) | ||
| 276 | (setq list1 buffer-undo-list) | ||
| 277 | (while list1 | ||
| 278 | (setq list1 (primitive-undo 1 list1)))) | ||
| 279 | (goto-char pos) | ||
| 280 | (if (> change 0) | ||
| 281 | (delete-region (point) | ||
| 282 | (progn | ||
| 283 | (move-to-column-force (+ change (current-column))) | ||
| 284 | (point)))) | ||
| 285 | (replace-match newtext fixedcase literal) | ||
| 286 | (if (< change 0) | ||
| 287 | (insert-char ?\ (- change))))) | ||
| 266 | 288 | ||
| 267 | ;; Picture Tabs | 289 | ;; Picture Tabs |
| 268 | 290 | ||