Subject: bug#30938: 27.0; `dired-do-create-files' etc.: do NOT always raise error if no files

From: Drew Adams <[email-masked]>
Date: Fri, 30 Mar 2018 10:12:13 -0700 (PDT)

> I might agree that it's a bug if I understand it.  But since you
> refuse to explain it, I guess I never will.

Maybe this will help (but I doubt it) -

1. Existing Dired+ command (updated to accommodate this bug by
adding INTERACTIVEP and passing that to `dired-get-marked-files'):

(defun diredp-insert-subdirs (&optional switches interactivep)
  "Insert the marked subdirectories.
Like using \\<dired-mode-map>`\\[dired-maybe-insert-subdir]' at \
each marked directory line."
  (interactive
   (list (and current-prefix-arg
              (read-string
               "Switches for listing: "
               (or dired-subdir-switches  dired-actual-switches)))
         t))
  (dolist (subdir
            (dired-get-marked-files
             nil nil
             (lambda (fl)
               (and (file-directory-p fl)
                    (not (diredp-string-match-p "/[.][.]?\\'" fl))))
             nil
             interactivep))
    (dired-maybe-insert-subdir subdir switches)))

Imaginary function that uses that command as a utility:

(defun insert-marked-subdirs-and-do-stuff ()
  (DO-STUFF)
  (diredp-insert-subdirs)
  (DO-OTHER-STUFF))

If you assume that the insertion of marked subdirs is
not a requirement for the main behavior of this function,
e.g., that it acts on any that get inserted but it doesn't
_require_ any such insertions to do its job in general,
then without some change as proposed this function can
end in error without ever trying to DO-OTHER-STUFF.

I'm arguing that similar considerations can apply to
other existing commands.

Whether each such case is actually problematic is not
so important (IMO).  The point is for individual such
commands to, a priori, treat the non-interactive case
separately.

A non-interactive use case for an arbitrary command that
calls ` dired-get-marked-files' does not necessarily
have `user-error' as the right behavior for an empty set
of marked files.  That's all I'm saying.