- (cl-flet
- ((do-it! () (aa2u-phase-1) (aa2u-phase-2) (aa2u-phase-3)))
- (if (use-region-p)
- (let ((beg (region-beginning))
- (end (region-end)))
- (save-restriction
- (widen)
- (narrow-to-region beg end)
- (do-it!)))
- (do-it!)))))
+ (save-restriction
+ (widen)
+ (narrow-to-region beg end)
+ (aa2u-phase-1)
+ (aa2u-phase-2)
+ (aa2u-phase-3))))
+
+;;;###autoload
+(defun aa2u-rectangle (start end)
+ "Like `aa2u' on the region-rectangle.
+When called from a program the rectangle's corners
+are START (top left) and END (bottom right)."
+ (interactive "r")
+ (let* ((was (delete-extract-rectangle start end))
+ (now (with-temp-buffer
+ (insert-rectangle was)
+ (aa2u (point) (mark))
+ (extract-rectangle (point-min) (point-max)))))
+ (goto-char (min start end))
+ (insert-rectangle now)))
+
+;;;###autoload
+(defun aa2u-mark-as-text (start end &optional unmark)
+ "Set property `aa2u-text' of the text from START to END.
+This prevents `aa2u' from misinterpreting \"|\", \"-\" and \"+\"
+in that region as lines and intersections to be replaced.
+Prefix arg means to remove property `aa2u-text', instead."
+ (interactive "r\nP")
+ (funcall (if unmark
+ 'remove-text-properties
+ 'add-text-properties)
+ start end
+ '(aa2u-text t)))
+
+;;;###autoload
+(defun aa2u-mark-rectangle-as-text (start end &optional unmark)
+ "Like `aa2u-mark-as-text' on the region-rectangle.
+When called from a program the rectangle's corners
+are START (top left) and END (bottom right)."
+ (interactive "r\nP")
+ (apply-on-rectangle
+ (lambda (scol ecol unmark)
+ (let ((p (point)))
+ (aa2u-mark-as-text (+ p scol) (+ p ecol) unmark)))
+ start end
+ unmark))