unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: <mafeusek@gmail.com>
Cc: 'emacs mailing list' <help-gnu-emacs@gnu.org>
Subject: RE: To Drew Adams?: `dired-get-marked-files' returns error when not onfile
Date: Thu, 8 Jul 2010 06:32:04 -0700	[thread overview]
Message-ID: <C9D798AFDA3F417E9CF91A02592CDFEF@us.oracle.com> (raw)
In-Reply-To: <umt47hl6fn6l.fsf@gmail.com>

> > 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	other threads:[~2010-07-08 13:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-06 20:46 To Drew Adams?: `dired-get-marked-files' returns error when not on file mafeusek
2010-07-06 20:58 ` Deniz Dogan
2010-07-06 21:10 ` To Drew Adams?: `dired-get-marked-files' returns error when not onfile Drew Adams
2010-07-07 16:39   ` To Drew Adams?: `dired-get-marked-files' returns error when notonfile Drew Adams
2010-07-08  7:27   ` To Drew Adams?: `dired-get-marked-files' returns error when not onfile mafeusek
2010-07-08 13:32     ` Drew Adams [this message]

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=C9D798AFDA3F417E9CF91A02592CDFEF@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=mafeusek@gmail.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).