From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#30285: dired-do-chmod vs. top line of dired Date: Tue, 30 Jan 2018 00:14:00 +0900 Message-ID: <87efm8snnr.fsf@gmail.com> References: <87mv0wg80c.fsf@jidanni.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1517238815 25108 195.159.176.226 (29 Jan 2018 15:13:35 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 29 Jan 2018 15:13:35 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 30285@debbugs.gnu.org To: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jan 29 16:13:31 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 1egB7a-0005dI-FY for geb-bug-gnu-emacs@m.gmane.org; Mon, 29 Jan 2018 16:13:22 +0100 Original-Received: from localhost ([::1]:44143 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1egB9Z-0000Xu-Po for geb-bug-gnu-emacs@m.gmane.org; Mon, 29 Jan 2018 10:15:25 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1egB9K-0000Pq-DF for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2018 10:15:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1egB9C-0001x2-Di for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2018 10:15:10 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40126) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1egB9C-0001wv-9a for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2018 10:15:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1egB9B-0005Q4-WB for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2018 10:15:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 29 Jan 2018 15:15: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.151723885720766 (code B ref 30285); Mon, 29 Jan 2018 15:15:01 +0000 Original-Received: (at 30285) by debbugs.gnu.org; 29 Jan 2018 15:14:17 +0000 Original-Received: from localhost ([127.0.0.1]:48023 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egB8S-0005Os-KN for submit@debbugs.gnu.org; Mon, 29 Jan 2018 10:14:16 -0500 Original-Received: from mail-pg0-f51.google.com ([74.125.83.51]:43550) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egB8Q-0005OX-Kz for 30285@debbugs.gnu.org; Mon, 29 Jan 2018 10:14:15 -0500 Original-Received: by mail-pg0-f51.google.com with SMTP id n17so4681233pgf.10 for <30285@debbugs.gnu.org>; Mon, 29 Jan 2018 07:14:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=esNEVPt5xpJ8y9BIUp0unTxbXG3Hk4K3s1HdbNTYzHQ=; b=jN9uJDu66U1JCAlDqTe9mWRp/1gFdqHwsfMcSc9uZiueD9YtQh1XCf2yfwq5Cq27sk SLpAeQXU11zRAj03JLcHDht5yB7rhyvmxHMW2wcLJ5liOl4NnDIouISDhFPUBQ1XuPa0 bujQHsDlqcWhy/czxVWFvWd/3eCEmvg2+QFPIU1CDe/4k3rkZfRBRw/rj7sS9/LVlrZZ +kxrU9x2WxgKtCFAAKGy0SyNDy7BRDJZ1droAsJDCe7Mi5df9yQM5NB7i0zDLoSAA1q6 rAPQiaB6LK+iP6R4/QHogFmWi5Xaw/eDJKBRHgJPOBZGKnHJUr1iq/msE9XJ5QZVoXRo GZFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=esNEVPt5xpJ8y9BIUp0unTxbXG3Hk4K3s1HdbNTYzHQ=; b=NxRrXQA4xTBlY+K7oFAvNz5Xu6NX3lkhud+iLcK8uiksZEO7kn6aKIU9dr9afynVSu mPTO/SReuCWKbX8K+fpOwnNYPLi0AHpP7zrHpCuRgXDQqtQnET/OkWckEsESYreNE8L7 L6Hsyev4Bh4bX6nXe2hcs9Pb1UqGbG5C9f8brUEqesa+PS5VoBbhXldNodhUXt5rCafx NI6vbmPKTU8R+/1n8U0k8qW4uSGtsoUafiyn47gv9AEe6phOXb3Vvsg6WQuDZ6F/U7dP /j8zjaNdzex05ca1LpyBMgT8//RDRYSGdpc3zdvG1uji4r9/Z1LIsClKgDjl1g8WSYuF oFLw== X-Gm-Message-State: AKwxyteS6Faa4zrPLpIRVffzHPdMsSdHDRiXMRcuD1AxiFOdQ47F/c/T BZLq/woUHAv/TqRduF9XrgeDwg== X-Google-Smtp-Source: AH8x227ZpEmuWrl278ZxkQ4QL1SgfryZObIvlm6RlKopwVg+wNHMXtvCEXicDlgpDhi7FjsuS9pjHg== X-Received: by 10.98.232.14 with SMTP id c14mr27648214pfi.215.1517238848750; Mon, 29 Jan 2018 07:14:08 -0800 (PST) Original-Received: from calancha-pc (146.219.128.101.dy.bbexcite.jp. [101.128.219.146]) by smtp.gmail.com with ESMTPSA id j4sm35361724pfe.53.2018.01.29.07.14.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 29 Jan 2018 07:14:07 -0800 (PST) In-Reply-To: <87mv0wg80c.fsf@jidanni.org> ("=?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson"'s message of "Mon, 29 Jan 2018 20:32:51 +0800") 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:142651 Archived-At: =E7=A9=8D=E4=B8=B9=E5=B0=BC Dan Jacobson writes: Thank you for your report. > M runs the command dired-do-chmod. > If used on the very top line of dired > (the directory name,) it says: > "Change mode of * [0 files] to: " > which doesn't make a lot of sense. Agreed. > emacs-version "25.2.2" > > Same problem if used on the second line, (total...). > > (Why doesn't it just complain "can't operate on" like it does for the > third line, ".".) Following patch just do nothing in these cases. That's OK for me. Do you prefer to inform the user in this case that there is no file to change the mode? --8<-----------------------------cut here---------------start------------->= 8--- commit 9b10f6ef6fbb3e6c50ffb04b97fc5b0b86d3e559 Author: tino calancha Date: Tue Jan 30 00:02:00 2018 +0900 dired-do-chmod: Avoid unecessary prompt =20=20=20=20 * lisp/dired-aux.el (dired-do-chmod): Offer to change mode just if there are any marked files or there is a file at point (Bug#30285). diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 55b68a372e..3868efe0c1 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -361,40 +361,42 @@ dired-do-chmod Type M-n to pull the file attributes of the file at point into the minibuffer." (interactive "P") - (let* ((files (dired-get-marked-files t arg)) - ;; The source of default file attributes is the file at point. - (default-file (dired-get-filename t t)) - (modestr (when default-file - (nth 8 (file-attributes default-file)))) - (default - (and (stringp modestr) - (string-match "^.\\(...\\)\\(...\\)\\(...\\)$" modestr) - (replace-regexp-in-string - "-" "" - (format "u=3D%s,g=3D%s,o=3D%s" - (match-string 1 modestr) - (match-string 2 modestr) - (match-string 3 modestr))))) - (modes (dired-mark-read-string - "Change mode of %s to: " - nil 'chmod arg files default)) - num-modes) - (cond ((or (equal modes "") - ;; Use `eq' instead of `equal' - ;; to detect empty input (bug#12399). - (eq modes default)) - ;; We used to treat empty input as DEFAULT, but that is not - ;; such a good idea (Bug#9361). - (error "No file mode specified")) - ((string-match-p "^[0-7]+" modes) - (setq num-modes (string-to-number modes 8)))) - - (dolist (file files) - (set-file-modes - file - (if num-modes num-modes - (file-modes-symbolic-to-number modes (file-modes file))))) - (dired-do-redisplay arg))) + (when (or (cdr (dired-get-marked-files nil nil nil 'distinguish-1-marked= )) + (dired-get-filename t t)) + (let* ((files (dired-get-marked-files t arg)) + ;; The source of default file attributes is the file at point. + (default-file (dired-get-filename t t)) + (modestr (when default-file + (nth 8 (file-attributes default-file)))) + (default + (and (stringp modestr) + (string-match "^.\\(...\\)\\(...\\)\\(...\\)$" modestr) + (replace-regexp-in-string + "-" "" + (format "u=3D%s,g=3D%s,o=3D%s" + (match-string 1 modestr) + (match-string 2 modestr) + (match-string 3 modestr))))) + (modes (dired-mark-read-string + "Change mode of %s to: " + nil 'chmod arg files default)) + num-modes) + (cond ((or (equal modes "") + ;; Use `eq' instead of `equal' + ;; to detect empty input (bug#12399). + (eq modes default)) + ;; We used to treat empty input as DEFAULT, but that is not + ;; such a good idea (Bug#9361). + (error "No file mode specified")) + ((string-match-p "^[0-7]+" modes) + (setq num-modes (string-to-number modes 8)))) + + (dolist (file files) + (set-file-modes + file + (if num-modes num-modes + (file-modes-symbolic-to-number modes (file-modes file))))) + (dired-do-redisplay arg)))) =20 ;;;###autoload (defun dired-do-chgrp (&optional arg) --8<-----------------------------cut here---------------end--------------->= 8--- In GNU Emacs 27.0.50 (build 7, x86_64-pc-linux-gnu, GTK+ Version 3.22.11) Repository revision: ea8c0e1b9eaa6651919fb4e039e3fcb5a1fa73db