Mercurial > emacs
comparison lisp/dired.el @ 3737:8a0b09b3a24c
(dired-repeat-over-lines): Going fwd, skip new lines
that FUNCTION inserts after the current line.
Going backwd, no need for dired-move-to-filename each time.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 15 Jun 1993 07:59:07 +0000 |
parents | 47680ad33068 |
children | 242b72c42f33 |
comparison
equal
deleted
inserted
replaced
3736:dea4ce3d7a4d | 3737:8a0b09b3a24c |
---|---|
1540 | 1540 |
1541 ;; Commands to mark or flag file(s) at or near current line. | 1541 ;; Commands to mark or flag file(s) at or near current line. |
1542 | 1542 |
1543 (defun dired-repeat-over-lines (arg function) | 1543 (defun dired-repeat-over-lines (arg function) |
1544 ;; This version skips non-file lines. | 1544 ;; This version skips non-file lines. |
1545 (beginning-of-line) | 1545 (let ((pos (make-marker))) |
1546 (while (and (> arg 0) (not (eobp))) | |
1547 (setq arg (1- arg)) | |
1548 (beginning-of-line) | 1546 (beginning-of-line) |
1549 (while (and (not (eobp)) (dired-between-files)) (forward-line 1)) | 1547 (while (and (> arg 0) (not (eobp))) |
1550 (save-excursion (funcall function)) | 1548 (setq arg (1- arg)) |
1551 (forward-line 1)) | 1549 (beginning-of-line) |
1552 (while (and (< arg 0) (not (bobp))) | 1550 (while (and (not (eobp)) (dired-between-files)) (forward-line 1)) |
1553 (setq arg (1+ arg)) | 1551 (save-excursion |
1554 (forward-line -1) | 1552 (forward-line 1) |
1555 (while (and (not (bobp)) (dired-between-files)) (forward-line -1)) | 1553 (move-marker pos (1+ (point)))) |
1556 (beginning-of-line) | 1554 (save-excursion (funcall function)) |
1557 (save-excursion (funcall function)) | 1555 ;; Advance to the next line--actually, to the line that *was* next. |
1558 (dired-move-to-filename)) | 1556 ;; (If FUNCTION inserted some new lines in between, skip them.) |
1559 (dired-move-to-filename)) | 1557 (goto-char pos)) |
1558 (while (and (< arg 0) (not (bobp))) | |
1559 (setq arg (1+ arg)) | |
1560 (forward-line -1) | |
1561 (while (and (not (bobp)) (dired-between-files)) (forward-line -1)) | |
1562 (beginning-of-line) | |
1563 (save-excursion (funcall function))) | |
1564 (move-marker pos nil) | |
1565 (dired-move-to-filename))) | |
1560 | 1566 |
1561 (defun dired-between-files () | 1567 (defun dired-between-files () |
1562 ;; Point must be at beginning of line | 1568 ;; Point must be at beginning of line |
1563 ;; Should be equivalent to (save-excursion (not (dired-move-to-filename))) | 1569 ;; Should be equivalent to (save-excursion (not (dired-move-to-filename))) |
1564 ;; but is about 1.5..2.0 times as fast. (Actually that's not worth it) | 1570 ;; but is about 1.5..2.0 times as fast. (Actually that's not worth it) |