- (if cua--rectangle
- (cua--rectangle-corner 0))))))
-
-;; Typed text that replaced the highlighted region.
-(defvar cua--repeat-replace-text nil)
-
-(defun cua-repeat-replace-region (arg)
- "Repeat replacing text of highlighted region with typed text.
-Searches for the next stretch of text identical to the region last
-replaced by typing text over it and replaces it with the same stretch
-of text."
- (interactive "P")
- (when cua--last-deleted-region-pos
- (with-current-buffer (car cua--last-deleted-region-pos)
- (save-restriction
- (widen)
- ;; Find the text that replaced the region via the undo list.
- (let ((ul buffer-undo-list)
- (elt (cdr cua--last-deleted-region-pos))
- u s e)
- (when elt
- (while (consp ul)
- (setq u (car ul) ul (cdr ul))
- (cond
- ((eq u elt) ;; got it
- (setq ul nil))
- ((and (consp u) (integerp (car u)) (integerp (cdr u)))
- (if (and s (= (cdr u) s))
- (setq s (car u))
- (setq s (car u) e (cdr u)))))))
- (cond ((and s e (<= s e) (= s (mark t)))
- (setq cua--repeat-replace-text (cua--filter-buffer-noprops s e)))
- ((and (null s) (eq u elt)) ;; nothing inserted
- (setq cua--repeat-replace-text
- ""))
- (t
- (message "Cannot locate replacement text"))))))
- (setq cua--last-deleted-region-pos nil))
- (if (and cua--last-deleted-region-text
- cua--repeat-replace-text
- (search-forward cua--last-deleted-region-text nil t nil))
- (replace-match cua--repeat-replace-text arg t)))