Mercurial > emacs
comparison lisp/macros.el @ 56857:be5ab1230982
(apply-macro-to-region-lines): Make it operate on all lines that begin
in the region, rather than on all complete lines in the region.
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Tue, 31 Aug 2004 23:38:53 +0000 |
parents | 695cf19ef79e |
children | e661f2202106 3219f94257bc |
comparison
equal
deleted
inserted
replaced
56856:d407cd57475c | 56857:be5ab1230982 |
---|---|
1 ;;; macros.el --- non-primitive commands for keyboard macros | 1 ;;; macros.el --- non-primitive commands for keyboard macros |
2 | 2 |
3 ;; Copyright (C) 1985, 86, 87, 92, 94, 95 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1985, 86, 87, 92, 94, 95, 04 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Maintainer: FSF | 5 ;; Maintainer: FSF |
6 ;; Keywords: abbrev | 6 ;; Keywords: abbrev |
7 | 7 |
8 ;; This file is part of GNU Emacs. | 8 ;; This file is part of GNU Emacs. |
149 (insert "\\S-"))) | 149 (insert "\\S-"))) |
150 (setq mods (cdr mods))) | 150 (setq mods (cdr mods))) |
151 (cond ((= char ?\\) | 151 (cond ((= char ?\\) |
152 (insert "\\\\")) | 152 (insert "\\\\")) |
153 ((= char ?\") | 153 ((= char ?\") |
154 (insert "\\\"")) | 154 (insert "\\\"")) |
155 ((= char ?\;) | 155 ((= char ?\;) |
156 (insert "\\;")) | 156 (insert "\\;")) |
157 ((= char 127) | 157 ((= char 127) |
158 (insert "\\C-?")) | 158 (insert "\\C-?")) |
159 ((< char 127) | 159 ((< char 127) |
238 (set-buffer standard-output) | 238 (set-buffer standard-output) |
239 (help-mode))))))))))) | 239 (help-mode))))))))))) |
240 | 240 |
241 ;;;###autoload | 241 ;;;###autoload |
242 (defun apply-macro-to-region-lines (top bottom &optional macro) | 242 (defun apply-macro-to-region-lines (top bottom &optional macro) |
243 "For each complete line between point and mark, move to the beginning | 243 "Apply last keyboard macro to all lines in the region. |
244 of the line, and run the last keyboard macro. | 244 For each line that begins in the region, move to the beginning of |
245 the line, and run the last keyboard macro. | |
245 | 246 |
246 When called from lisp, this function takes two arguments TOP and | 247 When called from lisp, this function takes two arguments TOP and |
247 BOTTOM, describing the current region. TOP must be before BOTTOM. | 248 BOTTOM, describing the current region. TOP must be before BOTTOM. |
248 The optional third argument MACRO specifies a keyboard macro to | 249 The optional third argument MACRO specifies a keyboard macro to |
249 execute. | 250 execute. |
275 \\C-x ( | 276 \\C-x ( |
276 \\M-d { \"\\C-y\", \\C-y_data, \\C-y_function }, | 277 \\M-d { \"\\C-y\", \\C-y_data, \\C-y_function }, |
277 \\C-x ) | 278 \\C-x ) |
278 | 279 |
279 and then select the region of un-tablified names and use | 280 and then select the region of un-tablified names and use |
280 `\\[apply-macro-to-region-lines]' to build the table from the names. | 281 `\\[apply-macro-to-region-lines]' to build the table from the names." |
281 " | |
282 (interactive "r") | 282 (interactive "r") |
283 (or macro | 283 (or macro |
284 (progn | 284 (progn |
285 (if (null last-kbd-macro) | 285 (if (null last-kbd-macro) |
286 (error "No keyboard macro has been defined")) | 286 (error "No keyboard macro has been defined")) |
287 (setq macro last-kbd-macro))) | 287 (setq macro last-kbd-macro))) |
288 (save-excursion | 288 (save-excursion |
289 (let ((end-marker (progn | 289 (let ((end-marker (copy-marker bottom)) |
290 (goto-char bottom) | |
291 (beginning-of-line) | |
292 (point-marker))) | |
293 next-line-marker) | 290 next-line-marker) |
294 (goto-char top) | 291 (goto-char top) |
295 (if (not (bolp)) | 292 (if (not (bolp)) |
296 (forward-line 1)) | 293 (forward-line 1)) |
297 (setq next-line-marker (point-marker)) | 294 (setq next-line-marker (point-marker)) |