all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Drew Adams <drew.adams@oracle.com>
Cc: 30285@debbugs.gnu.org, Tino Calancha <tino.calancha@gmail.com>,
	jidanni@jidanni.org
Subject: bug#30285: dired-do-chmod vs. top line of dired
Date: Sun, 04 Feb 2018 00:23:38 +0200	[thread overview]
Message-ID: <87mv0pk7m5.fsf@mail.linkov.net> (raw)
In-Reply-To: <c390a515-69ed-4054-a0ac-c052d1dfdd5e@default> (Drew Adams's message of "Thu, 1 Feb 2018 14:23:00 -0800 (PST)")

[-- Attachment #1: Type: text/plain, Size: 428 bytes --]

> 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: dired-get-marked-files-user-error.patch --]
[-- Type: text/x-diff, Size: 6386 bytes --]

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.

  reply	other threads:[~2018-02-03 22:23 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-29 12:32 bug#30285: dired-do-chmod vs. top line of dired 積丹尼 Dan Jacobson
2018-01-29 15:14 ` Tino Calancha
2018-01-29 16:05   ` Eli Zaretskii
2018-01-29 23:21     ` Tino Calancha
2018-01-29 23:42       ` Drew Adams
2018-01-30  3:53         ` Tino Calancha
2018-01-30  4:43           ` Drew Adams
2018-01-30 15:15             ` Drew Adams
2018-01-31  9:49               ` Tino Calancha
2018-01-31 19:04                 ` Drew Adams
2018-01-31 21:35         ` Juri Linkov
2018-01-31 23:20           ` Drew Adams
2018-02-01  8:16           ` Tino Calancha
2018-02-01  9:17             ` Tino Calancha
2018-02-01 16:10             ` Drew Adams
2018-02-04 23:12               ` Tino Calancha
2018-02-05 16:45                 ` Drew Adams
2018-02-01 20:07             ` Juri Linkov
2018-02-01 20:50               ` Drew Adams
2018-02-01 21:35                 ` Juri Linkov
2018-02-01 22:23                   ` Drew Adams
2018-02-03 22:23                     ` Juri Linkov [this message]
2018-02-04 10:02                       ` martin rudalics
2018-02-04 21:44                         ` Juri Linkov
2018-02-06 21:32                         ` Juri Linkov
2018-02-04 23:08                   ` Tino Calancha
2018-02-05 21:01                     ` Juri Linkov
2018-02-05 21:52                       ` Drew Adams
2018-01-29 15:24 ` 積丹尼 Dan Jacobson
2018-01-29 23:14   ` Tino Calancha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mv0pk7m5.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=30285@debbugs.gnu.org \
    --cc=drew.adams@oracle.com \
    --cc=jidanni@jidanni.org \
    --cc=tino.calancha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.