From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#30938: 27.0; `dired-do-create-files' etc.: do NOT always raise error if no files Date: Wed, 28 Mar 2018 16:45:50 -0700 (PDT) Message-ID: <70149736-0c90-4059-91d0-155144bf4abd@default> References: <7ea429b5-b12e-4639-9d77-11db71504d9c@default> <87605g7xpj.fsf@mail.linkov.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1522280654 8403 195.159.176.226 (28 Mar 2018 23:44:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 28 Mar 2018 23:44:14 +0000 (UTC) Cc: 30938@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Mar 29 01:44:10 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f1Kjf-000220-Jn for geb-bug-gnu-emacs@m.gmane.org; Thu, 29 Mar 2018 01:44:07 +0200 Original-Received: from localhost ([::1]:52623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1Kli-00044l-T8 for geb-bug-gnu-emacs@m.gmane.org; Wed, 28 Mar 2018 19:46:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46197) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1Klb-00043U-MI for bug-gnu-emacs@gnu.org; Wed, 28 Mar 2018 19:46:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f1KlW-00074b-PL for bug-gnu-emacs@gnu.org; Wed, 28 Mar 2018 19:46:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:49864) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f1KlW-00073s-Kq for bug-gnu-emacs@gnu.org; Wed, 28 Mar 2018 19:46:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1f1KlW-0005CA-82 for bug-gnu-emacs@gnu.org; Wed, 28 Mar 2018 19:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 28 Mar 2018 23:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30938 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30938-submit@debbugs.gnu.org id=B30938.152228076019961 (code B ref 30938); Wed, 28 Mar 2018 23:46:02 +0000 Original-Received: (at 30938) by debbugs.gnu.org; 28 Mar 2018 23:46:00 +0000 Original-Received: from localhost ([127.0.0.1]:57761 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f1KlU-0005Bt-F1 for submit@debbugs.gnu.org; Wed, 28 Mar 2018 19:46:00 -0400 Original-Received: from aserp2130.oracle.com ([141.146.126.79]:47672) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f1KlT-0005Be-Ip for 30938@debbugs.gnu.org; Wed, 28 Mar 2018 19:45:59 -0400 Original-Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2SNTXct080518; Wed, 28 Mar 2018 23:45:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=kCcq8Xeqlmhpuik6jwc+M/slihwasqtZlnzQevTw1j4=; b=Z4uvn2dQVSjFcNvOlaWCUlMcinp/3HG0OXGq7o7TJrzyx52Qz3LhYBPQLf1d1DsabENX pQUkL4L0YsNaq0+ZIWdhsFsQ7fhBv/M34HxKBCGNKJuuAkOhOhwElCt3ZCPTAdVaNDKU Pabhmz2rNYMSVca+gldT7HoPCh8b9PyafKoc7vX5uuS4T9KSobVbM1w7HaSqs+RusZbc vu12Z3zxSiOjP2q2xEQCJrb+r1ySVy1Orqjzf59qOh7ee8nszfy8zy9ZSJ91z7qZMujC NLVHIZ2hgJdiJesWNeYOV/372yQM2otZC8zuDFjMrPtI3bLqdQOkqi8PGOF7ujB8eZc6 eg== Original-Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2h0ms6818b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Mar 2018 23:45:53 +0000 Original-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w2SNjqOm011314 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Mar 2018 23:45:52 GMT Original-Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w2SNjpss023177; Wed, 28 Mar 2018 23:45:51 GMT In-Reply-To: <87605g7xpj.fsf@mail.linkov.net> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4666.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8846 signatures=668695 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803280233 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:144676 Archived-At: > > For example, `dired-do-isearch' could be called non-interactively > > in a context where it should do nothing (or something else should > > be done) if there are no marked files. Something like this is > > better: > > > > (defun dired-do-isearch (&optional interactivep) > > "Search for a string through all marked files using Isearch. > > When invoked interactively, raise an error if no files are marked." > > (interactive "p") > > (multi-isearch-files > > (dired-get-marked-files > > nil nil 'dired-nondirectory-p nil interactivep))) >=20 > Is there a better way than doing the same by adding such a formal arg > to all 12 affected commands? Are you asking whether adding an optional INTERACTIVEP arg to commands that call `dired-get-marked-files', and passing that as the 5th arg, is better than having them systematically raise a `user-error' (i.e., even in the non-interactive case) when `dired-get-marked-files' finds no marked files? If so, yes; that was the point I was making in that mail. There is not necessarily any user error - or any error at all - when no files are marked (e.g., when the function is called on a non-file-line part of the buffer). That's what I've done in my code (dired+.el), for example: ;; Updated for Emacs 27-pretest-2 change in dired-get-marked-files signatur= e. ;; dired-get-marked-files: Added optional arg ERROR-IF-NONE-P. ;; diredp-list-marked, diredp-insert-subdirs, dired-do-(i)search(-regexp), ;; dired-do-query-replace-regexp, dired-do-find-marked-files, ;; diredp-describe-marked-autofiles: ;; Added optional arg INTERACTIVEP. ;; Pass non-nil ERROR-IF-NONE-P to dired-get-marked-files when INTERACTI= VEP. ;; (See Emacs bug #30938.) Emacs has already updated those 13 commands (there's one also in dired-x.el) to add the 5th arg to their calls to `dired-get-marked-files'. The only further change needed is to pass that arg as non-nil only when the command is called interactively. It is only in the interactive case that we can know (assume) that such an error should be raised. [Dunno whether any of the 15 _other_ commands that call `dired-get-marked-files' need similar treatment, i.e., those where NO 5th arg is passed yet (in dired.el, image-dired.el, epa-dired.el, thumbs.el, and message.el).]