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#30285: dired-do-chmod vs. top line of dired Date: Mon, 29 Jan 2018 20:43:06 -0800 (PST) Message-ID: <1dd0ec16-7f13-4753-beef-0daeaf84ed8d@default> References: <87mv0wg80c.fsf@jidanni.org> <87efm8snnr.fsf@gmail.com> <83efm8irac.fsf@gnu.org> <87d11sl08v.fsf@gmail.com> 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 1517287352 12193 195.159.176.226 (30 Jan 2018 04:42:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Jan 2018 04:42:32 +0000 (UTC) Cc: 30285@debbugs.gnu.org, jidanni@jidanni.org To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jan 30 05:42:28 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 1egNkH-0001qG-PJ for geb-bug-gnu-emacs@m.gmane.org; Tue, 30 Jan 2018 05:42:09 +0100 Original-Received: from localhost ([::1]:37700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1egNmI-0003e7-HK for geb-bug-gnu-emacs@m.gmane.org; Mon, 29 Jan 2018 23:44:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59570) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1egNmB-0003ds-3X for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2018 23:44:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1egNm6-0000eN-5V for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2018 23:44:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40546) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1egNm6-0000eB-1V for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2018 23:44:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1egNm5-0002gh-OX for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2018 23:44:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 30 Jan 2018 04:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30285 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30285-submit@debbugs.gnu.org id=B30285.151728740210270 (code B ref 30285); Tue, 30 Jan 2018 04:44:01 +0000 Original-Received: (at 30285) by debbugs.gnu.org; 30 Jan 2018 04:43:22 +0000 Original-Received: from localhost ([127.0.0.1]:48443 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egNlS-0002fa-IU for submit@debbugs.gnu.org; Mon, 29 Jan 2018 23:43:22 -0500 Original-Received: from aserp2120.oracle.com ([141.146.126.78]:44352) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egNlQ-0002fM-UN for 30285@debbugs.gnu.org; Mon, 29 Jan 2018 23:43:21 -0500 Original-Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w0U4gGiw042789; Tue, 30 Jan 2018 04:43:12 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=XAWKUr9haEJGjz4KoiryjnNBVV6d6fYoe2Y6ACPVsGY=; b=PBIS7e+d3tTzAUN/L6cFJShKsSgbn+gdqQerDA6oENacNCO0q4i+xvhOYYnLLFP6aYxD 6JexY2gmoQrFPV1kXm5tHe46dKtCRAQAJGKWhx8FZPIx1W813zRSqQhlMKnzL5ogHJGP mE73XfiLPuhbG2fiYOYqK7vOL4o53XjD0F8CpENHGVnEFs8FKCFzqupmS3KPYtUjh8yt OnLWRrcNkNBufHnF00YU2AKHRDPAhGl8C2wRrAOo5+vOm4c/ovfJhh3wRaifc10G4COf 3AEWQAzZJEmrN/d36DRC5STTHyyXTYaXPlHH5d+X8kPHb5CGaxDWVBK0iXVP3yVryYVQ Ug== Original-Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2ftfm5ga51-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Jan 2018 04:43:12 +0000 Original-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w0U4hB2X025506 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 30 Jan 2018 04:43:12 GMT Original-Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w0U4h8qe032022; Tue, 30 Jan 2018 04:43:08 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4639.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8789 signatures=668655 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-1801300060 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:142681 Archived-At: > > The `dired-do-*' commands already DTRT wrt the marked-files-or-file- > > at-point. > > No, they don't. They annoying users asking a useless prompt, like: >=20 > Change mode of * [0 files] to: > ;; Just to notify the user after his input: > No file on this line I see that only for the reported places (this bug). Dunno if that's what you meant. Otherwise I don't see that at all. With point on a file or dir line (even on `.' or `..') and no files marked I get this prompt, where THE-FILE-OR-DIR is the name of the file or directory: Change mode of `THE-FILE-OR-DIR' to:=20 IOW, except for the bug case it works fine, and there is no function `dired-marked-files-or-file-at-point-p'. Likewise, for other `dired-do-*' commands. The marked-files-or-file-at-point behavior is done by `dired-get-marked-files'. That's exactly what it does. (defun dired-do-chmod (&optional arg) "..." (interactive "P") (let* ((files (dired-get-marked-files t arg)) ; <=3D=3D=3D=3D=3D=3D ...)) All that's needed is to test for FILES =3D nil. > This bug report is just about the unnecessary prompt in the top line. OK. We agree that the bug is only about the top line (or top two lines, if details are not hidden). Well, not really. It's really about point on any line where there is no file or dir. That includes: 1. The empty line at the end of the buffer. 2. The empty line before each inserted subdir listing. 3. The first two lines of the main dir and of each inserted subdir - that is, the highlighted line with the full (sub)dir name and the "total..." information line that follows it. The right thing to do is to test first for whether point is on a file or dir line. There are several ways to do that. One is shown above: (dired-get-marked-files t arg), and that's already used by commands such as `dired-do-chmod'. We just need to test its return value. Another is to use (dired-move-to-filename). One of the main uses of that simple function is to test whether or not point is on a file or dir line. A third way, more costly, is to use `dired-get-filename', Some of these ways give you a choice of whether to raise an error or just return nil when point is not on a file or dir line, i.e., when we are in one of the cases where we don't want to try to act on the indicated file(s), because there are none. For `dired-do-chmod' and similar, I'd say just test the return value of `dired-get-marked-files' which is already called at the beginning of the function. If, in some other `dired-do-*' command that function is not called at the beginning anyway, just use `dired-move-to-filename':=20 (defun dired-do-whatever (&optional arg) "..." (interactive (progn (dired-move-to-filename 'RAISE-ERROR) (list current-prefix-arg)))) ...)