all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Dickey <bokonon@norge.freeshell_DOT_TLD>
Subject: Re: dired question
Date: 18 Oct 2004 18:05:40 +0000	[thread overview]
Message-ID: <gvy3c0b3nrf.fsf@otaku.freeshell.org> (raw)
In-Reply-To: jwvsm8cjfe2.fsf-monnier+gnu.emacs.help@gnu.org

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)))

  reply	other threads:[~2004-10-18 18:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-17 23:20 dired question Stephen Dickey
2004-10-18  5:21 ` oliver
2004-10-18  5:39   ` Stephen Dickey
2004-10-18 14:05 ` Stefan Monnier
2004-10-18 18:05   ` Stephen Dickey [this message]
2004-10-18 18:58     ` Stefan Monnier
2004-10-18 21:05       ` Stephen Dickey
2004-10-18 21:34         ` Thien-Thi Nguyen
2004-10-18 22:49 ` Brad Collins
  -- strict thread matches above, loose matches on Subject: below --
2008-05-18 21:07 Dired question harven
2008-05-18 22:20 ` Drew Adams
2008-05-19 13:23 ` Xah Lee
2008-05-19 14:05 ` Joel J. Adamson
2008-05-19 19:11 ` harven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=gvy3c0b3nrf.fsf@otaku.freeshell.org \
    --to=bokonon@norge.freeshell_dot_tld \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.