[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dired question
From: |
Stephen Dickey |
Subject: |
Re: dired question |
Date: |
18 Oct 2004 18:05:40 +0000 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> > I would like to run a command on files marked in a dired buffer in the
> > order in which they were marked. Is there a built in way to do this?
>
> Dired does not keep track of the order in which things were marked.
> It just keeps a bit saying "marked/not-marked".
>
> > If not, I was thinking of advising dired-mark and
> > dired-get-marked-files to do this. Does this approach seem reasonable?
>
> I'm not very familiar with dired's internals, so don't take my word for it,
> but it does seem like a reasonable way. E.g. just maintain in dired-mark
> a side list of the last N files marked (N being e.g. the number of lines in
> the current buffer) and use it in dired-get-marked-files to sort the
> marked files.
OK, thanks.
It was simpler than I thought to quickley cobble something together to
do what I want. This is what I ended up with:
(require 'dired)
(require 'cl)
(make-variable-buffer-local 'srd-mark-list)
(defadvice dired-mark (before srd-dired-mark)
(if (equal dired-marker-char ?\040)
(setq srd-mark-list
(remove (dired-get-filename) srd-mark-list))
(setq srd-mark-list
(adjoin (dired-get-filename)
srd-mark-list
:test #'equal))))
(ad-activate 'dired-mark)
(defun srd-do-shell-command (command)
(interactive "scommand: ")
(dired-do-shell-command command
nil
(reverse srd-mark-list)))
Re: dired question, Brad Collins, 2004/10/18