992 |
(defun cua-do-rectangle-padding () |
(defun cua-do-rectangle-padding () |
993 |
(interactive) |
(interactive) |
994 |
(if buffer-read-only |
(if buffer-read-only |
995 |
(message "Cannot do padding in read-only buffer.") |
(message "Cannot do padding in read-only buffer") |
996 |
(cua--rectangle-operation nil nil t t t) |
(cua--rectangle-operation nil nil t t t) |
997 |
(cua--rectangle-set-corners)) |
(cua--rectangle-set-corners)) |
998 |
(cua--keep-active)) |
(cua--keep-active)) |
1098 |
'(lambda (l r) |
'(lambda (l r) |
1099 |
(cua--rectangle-right (max l (+ l (length string) -1))))))) |
(cua--rectangle-right (max l (+ l (length string) -1))))))) |
1100 |
|
|
1101 |
(defun cua-fill-char-rectangle (ch) |
(defun cua-fill-char-rectangle (character) |
1102 |
"Replace CUA rectangle contents with CHARACTER." |
"Replace CUA rectangle contents with CHARACTER." |
1103 |
(interactive "cFill rectangle with character: ") |
(interactive "cFill rectangle with character: ") |
1104 |
(cua--rectangle-operation 'clear nil t 1 nil |
(cua--rectangle-operation 'clear nil t 1 nil |
1105 |
'(lambda (s e l r) |
'(lambda (s e l r) |
1106 |
(delete-region s e) |
(delete-region s e) |
1107 |
(move-to-column l t) |
(move-to-column l t) |
1108 |
(insert-char ch (- r l))))) |
(insert-char character (- r l))))) |
1109 |
|
|
1110 |
(defun cua-replace-in-rectangle (regexp newtext) |
(defun cua-replace-in-rectangle (regexp newtext) |
1111 |
"Replace REGEXP with NEWTEXT in each line of CUA rectangle." |
"Replace REGEXP with NEWTEXT in each line of CUA rectangle." |
1137 |
(t nil))))) |
(t nil))))) |
1138 |
|
|
1139 |
(defvar cua--rectangle-seq-format "%d" |
(defvar cua--rectangle-seq-format "%d" |
1140 |
"Last format used by cua-sequence-rectangle.") |
"Last format used by `cua-sequence-rectangle'.") |
1141 |
|
|
1142 |
(defun cua-sequence-rectangle (first incr fmt) |
(defun cua-sequence-rectangle (first incr format) |
1143 |
"Resequence each line of CUA rectangle starting from FIRST. |
"Resequence each line of CUA rectangle starting from FIRST. |
1144 |
The numbers are formatted according to the FORMAT string." |
The numbers are formatted according to the FORMAT string." |
1145 |
(interactive |
(interactive |
1150 |
(string-to-number |
(string-to-number |
1151 |
(read-string "Increment: (1) " nil nil "1")) |
(read-string "Increment: (1) " nil nil "1")) |
1152 |
(read-string (concat "Format: (" cua--rectangle-seq-format ") ")))) |
(read-string (concat "Format: (" cua--rectangle-seq-format ") ")))) |
1153 |
(if (= (length fmt) 0) |
(if (= (length format) 0) |
1154 |
(setq fmt cua--rectangle-seq-format) |
(setq format cua--rectangle-seq-format) |
1155 |
(setq cua--rectangle-seq-format fmt)) |
(setq cua--rectangle-seq-format format)) |
1156 |
(cua--rectangle-operation 'clear nil t 1 nil |
(cua--rectangle-operation 'clear nil t 1 nil |
1157 |
'(lambda (s e l r) |
'(lambda (s e l r) |
1158 |
(delete-region s e) |
(delete-region s e) |
1159 |
(insert (format fmt first)) |
(insert (format format first)) |
1160 |
(setq first (+ first incr))))) |
(setq first (+ first incr))))) |
1161 |
|
|
1162 |
(defmacro cua--convert-rectangle-as (command tabify) |
(defmacro cua--convert-rectangle-as (command tabify) |