diff options
| author | Richard M. Stallman | 2005-05-15 21:33:25 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2005-05-15 21:33:25 +0000 |
| commit | 09b092ad34087702db39e663dac6354a0718bf08 (patch) | |
| tree | cdce62fbfe91837387af23e3e8facfc154f7fc7d | |
| parent | 149d2fd32c45a5c648d1c33f91736b9cc576f90f (diff) | |
| download | emacs-09b092ad34087702db39e663dac6354a0718bf08.tar.gz emacs-09b092ad34087702db39e663dac6354a0718bf08.zip | |
(dired-map-over-marks): New arg distinguish-one-marked.
(dired-get-marked-files): New arg distinguish-one-marked.
(dired-mark-pop-up): Handle FILES = (t FILE) specially.
| -rw-r--r-- | lisp/dired.el | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/lisp/dired.el b/lisp/dired.el index 8ba7ca00c1f..60a9a7d35c1 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -450,7 +450,8 @@ Return value is the number of files marked, or nil if none were marked." | |||
| 450 | "flagged" "marked")))) | 450 | "flagged" "marked")))) |
| 451 | (and (> count 0) count))) | 451 | (and (> count 0) count))) |
| 452 | 452 | ||
| 453 | (defmacro dired-map-over-marks (body arg &optional show-progress) | 453 | (defmacro dired-map-over-marks (body arg &optional show-progress |
| 454 | distinguish-one-marked) | ||
| 454 | "Eval BODY with point on each marked line. Return a list of BODY's results. | 455 | "Eval BODY with point on each marked line. Return a list of BODY's results. |
| 455 | If no marked file could be found, execute BODY on the current line. | 456 | If no marked file could be found, execute BODY on the current line. |
| 456 | If ARG is an integer, use the next ARG (or previous -ARG, if ARG<0) | 457 | If ARG is an integer, use the next ARG (or previous -ARG, if ARG<0) |
| @@ -465,7 +466,10 @@ No guarantee is made about the position on the marked line. | |||
| 465 | Search starts at the beginning of the buffer, thus the car of the list | 466 | Search starts at the beginning of the buffer, thus the car of the list |
| 466 | corresponds to the line nearest to the buffer's bottom. This | 467 | corresponds to the line nearest to the buffer's bottom. This |
| 467 | is also true for (positive and negative) integer values of ARG. | 468 | is also true for (positive and negative) integer values of ARG. |
| 468 | BODY should not be too long as it is expanded four times." | 469 | BODY should not be too long as it is expanded four times. |
| 470 | |||
| 471 | If DISTINGUISH-ONE-MARKED is non-nil, then if we find just one marked file, | ||
| 472 | return (t FILENAME) instead of (FILENAME)." | ||
| 469 | ;; | 473 | ;; |
| 470 | ;;Warning: BODY must not add new lines before point - this may cause an | 474 | ;;Warning: BODY must not add new lines before point - this may cause an |
| 471 | ;;endless loop. | 475 | ;;endless loop. |
| @@ -505,13 +509,15 @@ BODY should not be too long as it is expanded four times." | |||
| 505 | (set-marker next-position nil) | 509 | (set-marker next-position nil) |
| 506 | (setq next-position (and (re-search-forward regexp nil t) | 510 | (setq next-position (and (re-search-forward regexp nil t) |
| 507 | (point-marker))))) | 511 | (point-marker))))) |
| 512 | (if (and ,distinguish-one-marked (= (length results) 1)) | ||
| 513 | (setq results (cons t results))) | ||
| 508 | (if found | 514 | (if found |
| 509 | results | 515 | results |
| 510 | (list ,body))))) | 516 | (list ,body))))) |
| 511 | ;; save-excursion loses, again | 517 | ;; save-excursion loses, again |
| 512 | (dired-move-to-filename))) | 518 | (dired-move-to-filename))) |
| 513 | 519 | ||
| 514 | (defun dired-get-marked-files (&optional localp arg filter) | 520 | (defun dired-get-marked-files (&optional localp arg filter distinguish-one-marked) |
| 515 | "Return the marked files' names as list of strings. | 521 | "Return the marked files' names as list of strings. |
| 516 | The list is in the same order as the buffer, that is, the car is the | 522 | The list is in the same order as the buffer, that is, the car is the |
| 517 | first marked file. | 523 | first marked file. |
| @@ -522,13 +528,21 @@ Optional second argument ARG specifies files near point | |||
| 522 | If ARG is otherwise non-nil, use file. Usually ARG comes from | 528 | If ARG is otherwise non-nil, use file. Usually ARG comes from |
| 523 | the command's prefix arg. | 529 | the command's prefix arg. |
| 524 | Optional third argument FILTER, if non-nil, is a function to select | 530 | Optional third argument FILTER, if non-nil, is a function to select |
| 525 | some of the files--those for which (funcall FILTER FILENAME) is non-nil." | 531 | some of the files--those for which (funcall FILTER FILENAME) is non-nil. |
| 526 | (let ((all-of-them | 532 | |
| 527 | (save-excursion | 533 | If DISTINGUISH-ONE-MARKED is non-nil, then if we find just one marked file, |
| 528 | (dired-map-over-marks (dired-get-filename localp) arg))) | 534 | return (t FILENAME) instead of (FILENAME). |
| 529 | result) | 535 | Don't use that together with FILTER." |
| 536 | (let* ((all-of-them | ||
| 537 | (save-excursion | ||
| 538 | (dired-map-over-marks | ||
| 539 | (dired-get-filename localp) | ||
| 540 | arg nil distinguish-one-marked))) | ||
| 541 | result) | ||
| 530 | (if (not filter) | 542 | (if (not filter) |
| 531 | (nreverse all-of-them) | 543 | (if (and distinguish-one-marked (eq (car all-of-them) t)) |
| 544 | all-of-them | ||
| 545 | (nreverse all-of-them)) | ||
| 532 | (dolist (file all-of-them) | 546 | (dolist (file all-of-them) |
| 533 | (if (funcall filter file) | 547 | (if (funcall filter file) |
| 534 | (push file result))) | 548 | (push file result))) |
| @@ -2537,15 +2551,21 @@ FUNCTION should not manipulate files, just read input | |||
| 2537 | (an argument or confirmation). | 2551 | (an argument or confirmation). |
| 2538 | The window is not shown if there is just one file or | 2552 | The window is not shown if there is just one file or |
| 2539 | OP-SYMBOL is a member of the list in `dired-no-confirm'. | 2553 | OP-SYMBOL is a member of the list in `dired-no-confirm'. |
| 2540 | FILES is the list of marked files." | 2554 | FILES is the list of marked files. It can also be (t FILENAME) |
| 2555 | in the case of one marked file, to distinguish that from using | ||
| 2556 | just the current file." | ||
| 2541 | (or bufname (setq bufname " *Marked Files*")) | 2557 | (or bufname (setq bufname " *Marked Files*")) |
| 2542 | (if (or (eq dired-no-confirm t) | 2558 | (if (or (eq dired-no-confirm t) |
| 2543 | (memq op-symbol dired-no-confirm) | 2559 | (memq op-symbol dired-no-confirm) |
| 2560 | ;; If FILES defaulted to the current line's file. | ||
| 2544 | (= (length files) 1)) | 2561 | (= (length files) 1)) |
| 2545 | (apply function args) | 2562 | (apply function args) |
| 2546 | (with-current-buffer (get-buffer-create bufname) | 2563 | (with-current-buffer (get-buffer-create bufname) |
| 2547 | (erase-buffer) | 2564 | (erase-buffer) |
| 2548 | (dired-format-columns-of-files files) | 2565 | ;; Handle (t FILE) just like (FILE), here. |
| 2566 | ;; That value is used (only in some cases), to mean | ||
| 2567 | ;; just one file that was marked, rather than the current line file. | ||
| 2568 | (dired-format-columns-of-files (if (eq (car files) t) (cdr files) files)) | ||
| 2549 | (remove-text-properties (point-min) (point-max) | 2569 | (remove-text-properties (point-min) (point-max) |
| 2550 | '(mouse-face nil help-echo nil))) | 2570 | '(mouse-face nil help-echo nil))) |
| 2551 | (save-window-excursion | 2571 | (save-window-excursion |