From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#30285: dired-do-chmod vs. top line of dired Date: Sun, 04 Feb 2018 00:23:38 +0200 Organization: LINKOV.NET Message-ID: <87mv0pk7m5.fsf@mail.linkov.net> References: <87mv0wg80c.fsf@jidanni.org> <87efm8snnr.fsf@gmail.com> <83efm8irac.fsf@gnu.org> <87d11sl08v.fsf@gmail.com> <87fu6lwxxu.fsf@mail.linkov.net> <87k1vwcwy1.fsf@mail.linkov.net> <5620cf82-9402-4895-bdd1-fdf5401c8172@default> <871si475qh.fsf@mail.linkov.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1517698461 19805 195.159.176.226 (3 Feb 2018 22:54:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 3 Feb 2018 22:54:21 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: 30285@debbugs.gnu.org, Tino Calancha , jidanni@jidanni.org To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 03 23:54:16 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 1ei6hE-0004Uu-Hp for geb-bug-gnu-emacs@m.gmane.org; Sat, 03 Feb 2018 23:54:08 +0100 Original-Received: from localhost ([::1]:57744 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ei6jC-0004hz-J0 for geb-bug-gnu-emacs@m.gmane.org; Sat, 03 Feb 2018 17:56:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ei6j6-0004hU-3b for bug-gnu-emacs@gnu.org; Sat, 03 Feb 2018 17:56:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ei6j4-0002lH-Oe for bug-gnu-emacs@gnu.org; Sat, 03 Feb 2018 17:56:04 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48183) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ei6j4-0002kz-II for bug-gnu-emacs@gnu.org; Sat, 03 Feb 2018 17:56:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ei6j4-0005Tr-7N for bug-gnu-emacs@gnu.org; Sat, 03 Feb 2018 17:56:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 03 Feb 2018 22:56:02 +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.151769856021059 (code B ref 30285); Sat, 03 Feb 2018 22:56:02 +0000 Original-Received: (at 30285) by debbugs.gnu.org; 3 Feb 2018 22:56:00 +0000 Original-Received: from localhost ([127.0.0.1]:56080 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ei6j1-0005Tb-S4 for submit@debbugs.gnu.org; Sat, 03 Feb 2018 17:56:00 -0500 Original-Received: from sub3.mail.dreamhost.com ([69.163.253.7]:57029 helo=homiemail-a20.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ei6iz-0005TS-Hx for 30285@debbugs.gnu.org; Sat, 03 Feb 2018 17:55:58 -0500 Original-Received: from homiemail-a20.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a20.g.dreamhost.com (Postfix) with ESMTP id 9C9FE7EC063; Sat, 3 Feb 2018 14:55:56 -0800 (PST) Original-Received: from localhost.linkov.net (m91-129-107-8.cust.tele2.ee [91.129.107.8]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by homiemail-a20.g.dreamhost.com (Postfix) with ESMTPSA id B43E87EC060; Sat, 3 Feb 2018 14:55:54 -0800 (PST) In-Reply-To: (Drew Adams's message of "Thu, 1 Feb 2018 14:23:00 -0800 (PST)") 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:142869 Archived-At: --=-=-= Content-Type: text/plain > This might be better: "No files specified" > Or this: "No files chosen" > [...] > The return value of `dired-get-marked-files' needs to be tested as > soon as it's available. When it is nil we must not call > `dired-read-shell-command' or do anything else - just raise a > `user-error'. > > This is a general change that needs to be looked for and made > wherever appropriate. Agreed. Simplicity is the hallmark of Emacs. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=dired-get-marked-files-user-error.patch diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 55b68a3..f5caa2a 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -301,7 +301,8 @@ dired-do-chxxx ;; PROGRAM is the program used to change the attribute. ;; OP-SYMBOL is the type of operation (for use in `dired-mark-pop-up'). ;; ARG describes which files to use, as in `dired-get-marked-files'. - (let* ((files (dired-get-marked-files t arg)) + (let* ((files (or (dired-get-marked-files t arg) + (user-error "No files specified"))) ;; The source of default file attributes is the file at point. (default-file (dired-get-filename t t)) (default (when default-file @@ -361,7 +362,8 @@ 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)) + (let* ((files (or (dired-get-marked-files t arg) + (user-error "No files specified"))) ;; The source of default file attributes is the file at point. (default-file (dired-get-filename t t)) (modestr (when default-file @@ -476,7 +478,8 @@ dired-do-print `lpr-switches' as default." (interactive "P") (require 'lpr) - (let* ((file-list (dired-get-marked-files t arg)) + (let* ((file-list (or (dired-get-marked-files t arg) + (user-error "No files specified"))) (lpr-switches (if (and (stringp printer-name) (string< "" printer-name)) @@ -666,7 +669,8 @@ dired-do-async-shell-command The output appears in the buffer `*Async Shell Command*'." (interactive - (let ((files (dired-get-marked-files t current-prefix-arg))) + (let ((files (or (dired-get-marked-files t current-prefix-arg) + (user-error "No files specified")))) (list ;; Want to give feedback whether this file or marked files are used: (dired-read-shell-command "& on %s: " current-prefix-arg files) @@ -727,7 +731,8 @@ dired-do-shell-command ;;Functions dired-run-shell-command and dired-shell-stuff-it do the ;;actual work and can be redefined for customization. (interactive - (let ((files (dired-get-marked-files t current-prefix-arg))) + (let ((files (or (dired-get-marked-files t current-prefix-arg) + (user-error "No files specified")))) (list ;; Want to give feedback whether this file or marked files are used: (dired-read-shell-command "! on %s: " current-prefix-arg files) @@ -1030,7 +1035,8 @@ dired-do-compress-to Choose the archiving command based on the archive file-name extension and `dired-compress-files-alist'." (interactive) - (let* ((in-files (dired-get-marked-files)) + (let* ((in-files (or (dired-get-marked-files) + (user-error "No files specified"))) (out-file (expand-file-name (read-file-name "Compress to: "))) (rule (cl-find-if (lambda (x) @@ -1153,7 +1159,8 @@ dired-mark-confirm ;; Pass t for DISTINGUISH-ONE-MARKED so that a single file which ;; is marked pops up a window. That will help the user see ;; it isn't the current line file. - (let ((files (dired-get-marked-files t arg nil t)) + (let ((files (or (dired-get-marked-files t arg nil t) + (user-error "No files specified"))) (string (if (eq op-symbol 'compress) "Compress or uncompress" (capitalize (symbol-name op-symbol))))) (dired-mark-pop-up nil op-symbol files #'y-or-n-p @@ -1845,7 +1852,8 @@ dired-do-create-files The rest of into-dir are optional arguments. For any other return value, TARGET is treated as a directory." (or op1 (setq op1 operation)) - (let* ((fn-list (dired-get-marked-files nil arg)) + (let* ((fn-list (or (dired-get-marked-files nil arg) + (user-error "No files specified"))) (rfn-list (mapcar #'dired-make-relative fn-list)) (dired-one-file ; fluid variable inside dired-create-files (and (consp fn-list) (null (cdr fn-list)) (car fn-list))) @@ -2799,14 +2807,16 @@ dired-do-isearch "Search for a string through all marked files using Isearch." (interactive) (multi-isearch-files - (dired-get-marked-files nil nil 'dired-nondirectory-p))) + (or (dired-get-marked-files nil nil 'dired-nondirectory-p) + (user-error "No files specified")))) ;;;###autoload (defun dired-do-isearch-regexp () "Search for a regexp through all marked files using Isearch." (interactive) (multi-isearch-files-regexp - (dired-get-marked-files nil nil 'dired-nondirectory-p))) + (or (dired-get-marked-files nil nil 'dired-nondirectory-p) + (user-error "No files specified")))) ;;;###autoload (defun dired-do-search (regexp) @@ -2827,7 +2837,8 @@ dired-do-query-replace-regexp (query-replace-read-args "Query replace regexp in marked files" t t))) (list (nth 0 common) (nth 1 common) (nth 2 common)))) - (dolist (file (dired-get-marked-files nil nil 'dired-nondirectory-p)) + (dolist (file (or (dired-get-marked-files nil nil 'dired-nondirectory-p) + (user-error "No files specified"))) (let ((buffer (get-file-buffer file))) (if (and buffer (with-current-buffer buffer buffer-read-only)) @@ -2851,7 +2862,8 @@ dired-do-find-regexp (require 'grep) (defvar grep-find-ignored-files) (defvar grep-find-ignored-directories) - (let* ((files (dired-get-marked-files)) + (let* ((files (or (dired-get-marked-files) + (user-error "No files specified"))) (ignores (nconc (mapcar (lambda (s) (concat s "/")) grep-find-ignored-directories) diff --git a/lisp/dired-x.el b/lisp/dired-x.el index a90f1f4..1beeafe 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -1335,7 +1335,9 @@ dired-do-find-marked-files To keep Dired buffer displayed, type \\[split-window-below] first. To display just marked files, type \\[delete-other-windows] first." (interactive "P") - (dired-simultaneous-find-file (dired-get-marked-files) noselect)) + (dired-simultaneous-find-file (or (dired-get-marked-files) + (user-error "No files specified")) + noselect)) (defun dired-simultaneous-find-file (file-list noselect) "Visit all files in FILE-LIST and display them simultaneously. --=-=-=--