From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: To Drew Adams?: `dired-get-marked-files' returns error when not onfile Date: Thu, 8 Jul 2010 06:32:04 -0700 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1278595998 4671 80.91.229.12 (8 Jul 2010 13:33:18 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 8 Jul 2010 13:33:18 +0000 (UTC) Cc: 'emacs mailing list' To: Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 08 15:33:16 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OWrE3-0002Hh-NG for geh-help-gnu-emacs@m.gmane.org; Thu, 08 Jul 2010 15:33:16 +0200 Original-Received: from localhost ([127.0.0.1]:33224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OWrE2-0005n4-Vk for geh-help-gnu-emacs@m.gmane.org; Thu, 08 Jul 2010 09:33:14 -0400 Original-Received: from [140.186.70.92] (port=44713 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OWrDE-0005lk-7S for help-gnu-emacs@gnu.org; Thu, 08 Jul 2010 09:32:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OWrDC-0008Sj-Sx for help-gnu-emacs@gnu.org; Thu, 08 Jul 2010 09:32:23 -0400 Original-Received: from rcsinet10.oracle.com ([148.87.113.121]:42501) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OWrDC-0008Sd-NP for help-gnu-emacs@gnu.org; Thu, 08 Jul 2010 09:32:22 -0400 Original-Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by rcsinet10.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id o68DWIYW024114 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 8 Jul 2010 13:32:20 GMT Original-Received: from acsmt353.oracle.com (acsmt353.oracle.com [141.146.40.153]) by acsinet15.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o687ItcB022983; Thu, 8 Jul 2010 13:32:16 GMT Original-Received: from abhmt001.oracle.com by acsmt355.oracle.com with ESMTP id 389134641278595931; Thu, 08 Jul 2010 06:32:11 -0700 Original-Received: from dradamslap1 (/141.144.168.54) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 08 Jul 2010 06:32:10 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: thread-index: AcsebwONByKSEmfTRResJrFc955I1wAL3ThA X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5931 X-Source-IP: acsmt353.oracle.com [141.146.40.153] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090204.4C35D362.0086:SCFMA4539814,ss=1,fgs=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:74136 Archived-At: > > 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?