all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* dired question
@ 2004-10-17 23:20 Stephen Dickey
  2004-10-18  5:21 ` oliver
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Stephen Dickey @ 2004-10-17 23:20 UTC (permalink / raw


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?
If not, I was thinking of advising dired-mark and
dired-get-marked-files to do this.  Does this approach seem
reasonable?

-- 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: dired question
  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 22:49 ` Brad Collins
  2 siblings, 1 reply; 14+ messages in thread
From: oliver @ 2004-10-18  5:21 UTC (permalink / raw



"Stephen Dickey" <bokonon@norge.freeshell_DOT_TLD> wrote in message 
news:gvyis999bj8.fsf@norge.freeshell.org...
>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?

try dired-do-shell-command (bound to !). it is either part of dired itself 
or part of the add-on dired-x.

cheers, oli

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: dired question
  2004-10-18  5:21 ` oliver
@ 2004-10-18  5:39   ` Stephen Dickey
  0 siblings, 0 replies; 14+ messages in thread
From: Stephen Dickey @ 2004-10-18  5:39 UTC (permalink / raw


"oliver" <oliver_baumann@nospam.justemail.net> writes:


> try dired-do-shell-command (bound to !). it is either part of dired itself 
> or part of the add-on dired-x.

dired-do-shell-command processes the files in the order they appear in the
dired buffer. I want to operate on them in the order they were marked.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: dired question
  2004-10-17 23:20 dired question Stephen Dickey
  2004-10-18  5:21 ` oliver
@ 2004-10-18 14:05 ` Stefan Monnier
  2004-10-18 18:05   ` Stephen Dickey
  2004-10-18 22:49 ` Brad Collins
  2 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2004-10-18 14:05 UTC (permalink / raw


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


        Stefan

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: dired question
  2004-10-18 14:05 ` Stefan Monnier
@ 2004-10-18 18:05   ` Stephen Dickey
  2004-10-18 18:58     ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Stephen Dickey @ 2004-10-18 18:05 UTC (permalink / raw


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: dired question
  2004-10-18 18:05   ` Stephen Dickey
@ 2004-10-18 18:58     ` Stefan Monnier
  2004-10-18 21:05       ` Stephen Dickey
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2004-10-18 18:58 UTC (permalink / raw


>       (setq srd-mark-list
>             (adjoin (dired-get-filename)
>                     srd-mark-list
>                     :test #'equal))))

Aka (add-to-list 'srd-mark-list (dired-get-filename))

> (defun srd-do-shell-command (command)
>   (interactive "scommand: ")
>   (dired-do-shell-command command
>                           nil
>                           (reverse srd-mark-list)))

I suspect this will break in cases where you do:
- mark A, B, C
- C-k on B
- !

because B will not be among the marked files any more but will still be in
srd-mark-list.


        Stefan

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: dired question
  2004-10-18 18:58     ` Stefan Monnier
@ 2004-10-18 21:05       ` Stephen Dickey
  2004-10-18 21:34         ` Thien-Thi Nguyen
  0 siblings, 1 reply; 14+ messages in thread
From: Stephen Dickey @ 2004-10-18 21:05 UTC (permalink / raw


Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Aka (add-to-list 'srd-mark-list (dired-get-filename))

Thanks, that looks better and doesn't require 'cl.

> I suspect this will break in cases where you do:
> - mark A, B, C
> - C-k on B
> - !
> 
> because B will not be among the marked files any more but will still be in
> srd-mark-list.

You are correct, It is not at all a robust solution. It looks like
anything that kills lines with marks will break it. I don't see an
easy way to fix it.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: dired question
  2004-10-18 21:05       ` Stephen Dickey
@ 2004-10-18 21:34         ` Thien-Thi Nguyen
  0 siblings, 0 replies; 14+ messages in thread
From: Thien-Thi Nguyen @ 2004-10-18 21:34 UTC (permalink / raw


Stephen Dickey <bokonon@norge.freeshell_DOT_TLD> writes:

> I don't see an
> easy way to fix it.

probably the original idea was best:
instrument both marking and collecting.

put a serial number as a text property on the mark (or filename).
if that is deleted, the serial number no longer bothers you.

upon collection, sort the items by their serial numbers.

thi

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: dired question
  2004-10-17 23:20 dired question Stephen Dickey
  2004-10-18  5:21 ` oliver
  2004-10-18 14:05 ` Stefan Monnier
@ 2004-10-18 22:49 ` Brad Collins
  2 siblings, 0 replies; 14+ messages in thread
From: Brad Collins @ 2004-10-18 22:49 UTC (permalink / raw


Stephen Dickey <bokonon@norge.freeshell_DOT_TLD> 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?
> If not, I was thinking of advising dired-mark and
> dired-get-marked-files to do this.  Does this approach seem
> reasonable?

What about ! which runs the command dired-do-shell-command?

,----[! -- dired-do-shell-command]
| Run a shell command command on the marked files.
| If no files are marked or a specific numeric prefix arg is given,
| the next arg files are used.  Just C-u means the current file.
| The prompt mentions the file(s) or the marker, as appropriate.
| 
| If there is a `*' in command, surrounded by whitespace, this runs
| command just once with the entire file list substituted there.
| 
| If there is no `*', but there is a `?' in command, surrounded by
| whitespace, this runs command on each file individually with the
| file name substituted for `?'.
`----

There was no mention about the order -- but they seem to be passed in
the order they are marked.  For example, I just marked three files
in dired :

* -rw-rw-rw-   1 deerpig  root        21495 05-29 00:27 2003.11.21
* -rw-rw-rw-   1 deerpig  root         6181 05-29 00:29 2003.12.18
* -rw-rw-rw-   1 deerpig  root          987 05-29 00:28 2003.12.21

And then did a word count.

   ! wc -w

and got this result in the minibuffer.

   3665 2003.11.21
   1003 2003.12.18
    143 2003.12.21

The order is the same as they were marked. Is that what you were
looking for?  dired-do-shell-command is very handy indeed, especially
for deleting non-empty directories, changing permissions etc.

b/

-- 
Brad Collins <brad@chenla.org>, Bangkok, Thailand

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Dired question
@ 2008-05-18 21:07 harven
  2008-05-18 22:20 ` Drew Adams
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: harven @ 2008-05-18 21:07 UTC (permalink / raw
  To: help-gnu-emacs

Hi,

Is there some keybinding or command in Dired that  open in background
all marked files (that is, put them in buffers, without actually
displaying them in windows) ?


^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: Dired question
  2008-05-18 21:07 Dired question harven
@ 2008-05-18 22:20 ` Drew Adams
  2008-05-19 13:23 ` Xah Lee
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 14+ messages in thread
From: Drew Adams @ 2008-05-18 22:20 UTC (permalink / raw
  To: 'harven', help-gnu-emacs

> Is there some keybinding or command in Dired that  open in background
> all marked files (that is, put them in buffers, without actually
> displaying them in windows) ?

Load library dired-x.el, then, in Dired, mark the files, then use `F' with a
prefix arg: `C-u F'.

To find this out: Consult the Emacs manual, which mentions dired-x.el. Then in
Dired mode, do `C-h m' to get info about the mode.

Unfortunately, the doc string for `F' (via `C-h k F'), which is command
`dired-do-find-marked-files', says only this: "With optional NOSELECT just find
files but do not select them." What it neglects to mention is that the optional
argument NOSELECT corresponds to using a prefix argument (`C-u').

Put this in your init file to get dired-x.el: (require 'dired-x)
Or load it manually: `M-x load-library dired-x'.






^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Dired question
  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
  3 siblings, 0 replies; 14+ messages in thread
From: Xah Lee @ 2008-05-19 13:23 UTC (permalink / raw
  To: help-gnu-emacs

harven wrote:
«Is there some keybinding or command in Dired that open in background
all marked files (that is, put them in buffers, without actually
displaying them in windows) ?»

in addiction to what Drew Adams's reply...

I also had this question, and i think i've seen this asked at least 3
times here. So perhaps emacs developers can consider moving it into
dired.

For me, i pull the function out from dired-x and put into my .emacs,
because loading dired-x changed some behavior of dired i didn't like.
(dont remember what it was).

The function to pull are:

dired-do-find-marked-files
dired-simultaneous-find-file

  Xah
  xah@xahlee.org
∑ http://xahlee.org/

☄

"Drew Adams" <drew.ad...@oracle.com> wrote:
> Load library dired-x.el, then, in Dired, mark the files, then use `F' with a
> prefix arg: `C-u F'.
>
> To find this out: Consult the Emacs manual, which mentions dired-x.el. Then in
> Dired mode, do `C-h m' to get info about the mode.
>
> Unfortunately, the doc string for `F' (via `C-h k F'), which is command
> `dired-do-find-marked-files', says only this: "With optional NOSELECT just find
> files but do not select them." What it neglects to mention is that the optional
> argument NOSELECT corresponds to using a prefix argument (`C-u').
>
> Put this in your init file to get dired-x.el: (require 'dired-x)
> Or load it manually: `M-x load-library dired-x'.




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Dired question
  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
  3 siblings, 0 replies; 14+ messages in thread
From: Joel J. Adamson @ 2008-05-19 14:05 UTC (permalink / raw
  To: harven; +Cc: help-gnu-emacs

harven <harven@free.fr> writes:

> Hi,
>
> Is there some keybinding or command in Dired that  open in background
> all marked files (that is, put them in buffers, without actually
> displaying them in windows) ?

"C-u F":
,----*Help*
| F runs the command dired-do-find-marked-files, which is an interactive
| compiled Lisp function in `dired-x.el'.
| 
| It is bound to F, <menu-bar> <operate> <find-files>.
| 
| (dired-do-find-marked-files &optional NOSELECT)
| 
| Find all marked files displaying all of them simultaneously.
| With optional NOSELECT just find files but do not select them.
| 
| The current window is split across all files marked, as evenly as possible.
| Remaining lines go to bottom-most window.  The number of files that can be
| displayed this way is restricted by the height of the current window and
| `window-min-height'.
| 
| To keep dired buffer displayed, type C-x 2 first.
| To display just marked files, type C-x 1 first.
`----
Joel


-- 
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109
Public key: http://pgp.mit.edu
http://www.unc.edu/~adamsonj

Ineffective security measure:

The information transmitted in this electronic communication is intended only
for the person or entity to whom it is addressed and may contain confidential
and/or privileged material. Any review, retransmission, dissemination or other
use of or taking of any action in reliance upon this information by persons or
entities other than the intended recipient is prohibited. If you received this
information in error, please contact the Compliance HelpLine at 800-856-1983 and
properly dispose of this information.







^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Dired question
  2008-05-18 21:07 Dired question harven
                   ` (2 preceding siblings ...)
  2008-05-19 14:05 ` Joel J. Adamson
@ 2008-05-19 19:11 ` harven
  3 siblings, 0 replies; 14+ messages in thread
From: harven @ 2008-05-19 19:11 UTC (permalink / raw
  To: help-gnu-emacs

Thanks for your answers. It definitively solves my problem.


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2008-05-19 19:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
  -- strict thread matches above, loose matches on Subject: below --
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
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

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.