# HG changeset patch # User Stefan Monnier # Date 970266278 0 # Node ID 638a006b3c47dfcd45682119d81fc580fa6c984a # Parent 57c841880df20d056e421d9a0496dbdf67a1a0ee (dired-map-over-marks): Use modern backquotes and docstring. diff -r 57c841880df2 -r 638a006b3c47 lisp/dired.el --- a/lisp/dired.el Fri Sep 29 22:21:30 2000 +0000 +++ b/lisp/dired.el Fri Sep 29 22:24:38 2000 +0000 @@ -334,66 +334,65 @@ (and (> count 0) count)))) (defmacro dired-map-over-marks (body arg &optional show-progress) -;; "Macro: Perform BODY with point somewhere on each marked line -;;and return a list of BODY's results. -;;If no marked file could be found, execute BODY on the current line. -;; If ARG is an integer, use the next ARG (or previous -ARG, if ARG<0) -;; files instead of the marked files. -;; In that case point is dragged along. This is so that commands on -;; the next ARG (instead of the marked) files can be chained easily. -;; If ARG is otherwise non-nil, use current file instead. -;;If optional third arg SHOW-PROGRESS evaluates to non-nil, -;; redisplay the dired buffer after each file is processed. -;;No guarantee is made about the position on the marked line. -;; BODY must ensure this itself if it depends on this. -;;Search starts at the beginning of the buffer, thus the car of the list -;; corresponds to the line nearest to the buffer's bottom. This -;; is also true for (positive and negative) integer values of ARG. -;;BODY should not be too long as it is expanded four times." -;; -;;Warning: BODY must not add new lines before point - this may cause an -;;endless loop. -;;This warning should not apply any longer, sk 2-Sep-1991 14:10. - (` (prog1 - (let (buffer-read-only case-fold-search found results) - (if (, arg) - (if (integerp (, arg)) - (progn;; no save-excursion, want to move point. - (dired-repeat-over-lines - (, arg) - (function (lambda () - (if (, show-progress) (sit-for 0)) - (setq results (cons (, body) results))))) - (if (< (, arg) 0) - (nreverse results) - results)) - ;; non-nil, non-integer ARG means use current file: - (list (, body))) - (let ((regexp (dired-marker-regexp)) next-position) - (save-excursion - (goto-char (point-min)) - ;; remember position of next marked file before BODY - ;; can insert lines before the just found file, - ;; confusing us by finding the same marked file again - ;; and again and... + "Eval BODY with point on each marked line. Return a list of BODY's results. +If no marked file could be found, execute BODY on the current line. + If ARG is an integer, use the next ARG (or previous -ARG, if ARG<0) + files instead of the marked files. + In that case point is dragged along. This is so that commands on + the next ARG (instead of the marked) files can be chained easily. + If ARG is otherwise non-nil, use current file instead. +If optional third arg SHOW-PROGRESS evaluates to non-nil, + redisplay the dired buffer after each file is processed. +No guarantee is made about the position on the marked line. + BODY must ensure this itself if it depends on this. +Search starts at the beginning of the buffer, thus the car of the list + corresponds to the line nearest to the buffer's bottom. This + is also true for (positive and negative) integer values of ARG. +BODY should not be too long as it is expanded four times." + ;; + ;;Warning: BODY must not add new lines before point - this may cause an + ;;endless loop. + ;;This warning should not apply any longer, sk 2-Sep-1991 14:10. + `(prog1 + (let (buffer-read-only case-fold-search found results) + (if ,arg + (if (integerp ,arg) + (progn ;; no save-excursion, want to move point. + (dired-repeat-over-lines + ,arg + (function (lambda () + (if ,show-progress (sit-for 0)) + (setq results (cons ,body results))))) + (if (< ,arg 0) + (nreverse results) + results)) + ;; non-nil, non-integer ARG means use current file: + (list ,body)) + (let ((regexp (dired-marker-regexp)) next-position) + (save-excursion + (goto-char (point-min)) + ;; remember position of next marked file before BODY + ;; can insert lines before the just found file, + ;; confusing us by finding the same marked file again + ;; and again and... + (setq next-position (and (re-search-forward regexp nil t) + (point-marker)) + found (not (null next-position))) + (while next-position + (goto-char next-position) + (if ,show-progress (sit-for 0)) + (setq results (cons ,body results)) + ;; move after last match + (goto-char next-position) + (forward-line 1) + (set-marker next-position nil) (setq next-position (and (re-search-forward regexp nil t) - (point-marker)) - found (not (null next-position))) - (while next-position - (goto-char next-position) - (if (, show-progress) (sit-for 0)) - (setq results (cons (, body) results)) - ;; move after last match - (goto-char next-position) - (forward-line 1) - (set-marker next-position nil) - (setq next-position (and (re-search-forward regexp nil t) - (point-marker))))) - (if found - results - (list (, body)))))) - ;; save-excursion loses, again - (dired-move-to-filename)))) + (point-marker))))) + (if found + results + (list ,body))))) + ;; save-excursion loses, again + (dired-move-to-filename))) (defun dired-get-marked-files (&optional localp arg) "Return the marked files' names as list of strings.