comparison lisp/dired.el @ 44234:acb1f97fda8f

(dired-get-marked-files): New arg FILTER allows selection of some files.
author Richard M. Stallman <rms@gnu.org>
date Fri, 29 Mar 2002 14:43:14 +0000
parents e87d819f2887
children 9cab12e7e72a
comparison
equal deleted inserted replaced
44233:780f3cdf5aa8 44234:acb1f97fda8f
395 results 395 results
396 (list ,body))))) 396 (list ,body)))))
397 ;; save-excursion loses, again 397 ;; save-excursion loses, again
398 (dired-move-to-filename))) 398 (dired-move-to-filename)))
399 399
400 (defun dired-get-marked-files (&optional localp arg) 400 (defun dired-get-marked-files (&optional localp arg filter)
401 "Return the marked files' names as list of strings. 401 "Return the marked files' names as list of strings.
402 The list is in the same order as the buffer, that is, the car is the 402 The list is in the same order as the buffer, that is, the car is the
403 first marked file. 403 first marked file.
404 Values returned are normally absolute pathnames. 404 Values returned are normally absolute file names.
405 Optional arg LOCALP as in `dired-get-filename'. 405 Optional arg LOCALP as in `dired-get-filename'.
406 Optional second argument ARG forces to use other files. If ARG is an 406 Optional second argument ARG specifies files near point
407 integer, use the next ARG files. If ARG is otherwise non-nil, use 407 instead of marked files. If ARG is an integer, use the next ARG files.
408 current file. Usually ARG comes from the current prefix arg." 408 If ARG is otherwise non-nil, use file. Usually ARG comes from
409 (save-excursion 409 the command's prefix arg.
410 (nreverse (dired-map-over-marks (dired-get-filename localp) arg)))) 410 Optional third argument FILTER, if non-nil, is a function to select
411 411 some of the files--those for which (funcall FILTER FILENAME) is non-nil."
412 (let ((all-of-them
413 (save-excursion
414 (dired-map-over-marks (dired-get-filename localp) arg)))
415 result)
416 (if (not filter)
417 (nreverse all-of-them)
418 (dolist (file all-of-them)
419 (if (funcall filter file)
420 (push file result)))
421 result)))
412 422
413 ;; Function dired-ls is redefinable for VMS, ange-ftp, Prospero or 423 ;; Function dired-ls is redefinable for VMS, ange-ftp, Prospero or
414 ;; other special applications. 424 ;; other special applications.
415 425
416 ;; The dired command 426 ;; The dired command