bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Drew Adams
Subject: bug#30938: 27.0; `dired-do-create-files' etc.: do NOT always raise error if no files
Date: Wed, 28 Mar 2018 16:45:50 -0700 (PDT)

> > For example, `dired-do-isearch' could be called non-interactively
> > in a context where it should do nothing (or something else should
> > be done) if there are no marked files.  Something like this is
> > better:
> >
> > (defun dired-do-isearch (&optional interactivep)
> >   "Search for a string through all marked files using Isearch.
> > When invoked interactively, raise an error if no files are marked."
> >   (interactive "p")
> >   (multi-isearch-files
> >    (dired-get-marked-files
> >      nil nil 'dired-nondirectory-p nil interactivep)))
> 
> Is there a better way than doing the same by adding such a formal arg
> to all 12 affected commands?

Are you asking whether adding an optional INTERACTIVEP arg to
commands that call `dired-get-marked-files', and passing that
as the 5th arg, is better than having them systematically raise
a `user-error' (i.e., even in the non-interactive case) when
`dired-get-marked-files' finds no marked files?

If so, yes; that was the point I was making in that mail.

There is not necessarily any user error - or any error at
all - when no files are marked (e.g., when the function
is called on a non-file-line part of the buffer).

That's what I've done in my code (dired+.el), for example:

;; Updated for Emacs 27-pretest-2 change in dired-get-marked-files signature.
;;  dired-get-marked-files: Added optional arg ERROR-IF-NONE-P.
;;  diredp-list-marked, diredp-insert-subdirs, dired-do-(i)search(-regexp),
;;  dired-do-query-replace-regexp, dired-do-find-marked-files,
;;  diredp-describe-marked-autofiles:
;;    Added optional arg INTERACTIVEP.
;;    Pass non-nil ERROR-IF-NONE-P to dired-get-marked-files when INTERACTIVEP.
;;    (See Emacs bug #30938.)

Emacs has already updated those 13 commands (there's one
also in dired-x.el) to add the 5th arg to their calls to
`dired-get-marked-files'.  The only further change needed
is to pass that arg as non-nil only when the command is
called interactively.  It is only in the interactive case
that we can know (assume) that such an error should be
raised.

[Dunno whether any of the 15 _other_ commands that call
`dired-get-marked-files' need similar treatment, i.e.,
those where NO 5th arg is passed yet (in dired.el,
image-dired.el, epa-dired.el, thumbs.el, and message.el).]






reply via email to

[Prev in Thread] Current Thread [Next in Thread]