help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: To Drew Adams?: `dired-get-marked-files' returns error when not onfi


From: Drew Adams
Subject: RE: To Drew Adams?: `dired-get-marked-files' returns error when not onfile
Date: Thu, 8 Jul 2010 06:32:04 -0700

> > However, the particular error you are concerned about is 
> > not distinguished from any other errors this way: any error
> > condition here will return nil instead of raising an error.
> 
> The above is what concerns me most. I'd consider pointer not 
> on file is not an error, esspecialy not in non-interactive invocations.
> 
> What I am trying to do: I am going to write a function that
> invokes command on:
>  a) files marked explicitly (ie. by `m') or,
>  b) all files in directory if there are not marked files.
> 
> while acting non-interactivelly, it is hard to do it, unless I want to
> hide all the errors with `condition-case' which I think is 
> not reasoanble.

As I said, "Your code can test whether there is a file on the current line in
one of these ways...".  So your code can determine whether any files are marked
and then act accordingly.

It can also do so more directly, by calling one of the macros that is defined
for this kind of thing (e.g. `dired-map-over-marks',
`dired-map-over-marks-check').  You can also examine their code and do something
different but similar, if you cannot use them out of the box for what you want.

FWIW, see also the definition of macro `dired-map-over-marks(-check)' in Dired+
(as opposed to dired(-aux).el).  It uses the prefix arg as multiple `C-u' to let
users (i.e. commands defined using the macro) treat all files.

As the doc strings of the various commands that use the macro put it, for users:

 A prefix argument ARG specifies files to use instead of marked.
  An integer means use the next ARG files (previous -ARG, if < 0).
  `C-u': Use the current file (whether or not any are marked).
  `C-u C-u': Use all files in Dired, except directories.
  `C-u C-u C-u': Use all files and directories, except `.' and `..'.
  `C-u C-u C-u C-u': Use all files and all directories.

Or as the doc string of the macro puts it, for macro users:

 If ARG is an integer, use the next ARG files (previous -ARG, if < 0).
   In that case point is dragged along.  This is so that commands on
   the next ARG (instead of the marked) files can be easily chained.
 If ARG is a cons with element 16, 64, or 256, corresponding to
   `C-u C-u', `C-u C-u C-u', or `C-u C-u C-u C-u', then use all files
   in the Dired buffer, where:
     16 includes NO directories (including `.' and `..')
     64 includes directories EXCEPT `.' and `..'
    256 includes ALL directories (including `.' and `..')
 If ARG is otherwise non-nil, use the current file.

That's not quite what you want to do, since, based on the ARG, it treats all
files even if some are marked.  But you should be able to code just what you
need, using this or some of the code in dired(-aux).el.

> On the other hand in interactive invocation, error is helpful,
> thus maybe good enough choice would be to have optional 
> pointer-away-no-error flag?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]