unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 30938@debbugs.gnu.org, juri@linkov.net
Subject: bug#30938: 27.0; `dired-do-create-files' etc.: do NOT always raise error if no files
Date: Fri, 30 Mar 2018 08:01:42 -0700 (PDT)	[thread overview]
Message-ID: <ea1c9d9f-2405-4377-bd42-de7f020cf9d4@default> (raw)
In-Reply-To: <<83lgeac7xs.fsf@gnu.org>>

> A lot of discussion gone under the bridge, but I asked a question in
> the very beginning that was apparently ignored:
> 
>   Please provide at least one example (preferably more than one) of a
>   real-life use case where these changes get in the way.
> 
> Without an answer to that, I cannot see why we have to do anything
> about this issue, because up front I see no problem here at all, not
> one that has been spelled out.

I answered your question, pointing to the example of calling
`dired-do-isearch' (or any of the other such commands)
non-interactively - e.g., by creating a command that uses it.

If you don't believe that a user or another library could
or would define such a command (or in any other way would
call an existing function that calls the workhorse function
`dired-get-marked-files', then too bad.

In that case your idea of real-life use of Emacs Lisp differs
from mine; you will close the bug; and we will move on.  I've
already fixed my code to work around this change (except for
`dired-do-chxxx' repercussions - see below).

---

`dired-get-marked-files' is no less a utility function than
is, say, `dired-get-filename'.  And functions, including
commands, that call it are themselves candidates for reuse
in defining other functions, including other commands.

In addition, users often look to the definitions of Emacs
commands when creating similar or derivative commands.

Imagine that a user wants a command similar to
`dired-do-search' but that does things a bit differently.
S?he might look at the def of `dired-do-isearch' for
inspiration, and thus copy its use of `dired-marked-files'.
Hard-coding a non-nil 5th arg for it is a bad model.

(Same thing for `dired-do-search' etc. and the other
commands that, for some reason (?), have not yet
undergone this change.)

---

Similarly, for `dired-do-chxxx', which is NOT a command,
and which currently hardcodes a non-nil 5th arg to
`dired-get-marked-files' just like the commands do.

To fix that aberration a bit more surgery is required,
no doubt.  We could add an optional ERROR-IF-NONE-P arg
to `dired-do-chxxx', and obtain that from an optional
INTERACTIVEP arg to `dired-do-chmod' etc.  IOW, same
kind of fix.  Or perhaps Juri has a better fix in mind.

And as for "real-life" examples, BTW, I do define
`-mouse-' versions of the `dired-do-ch*' commands.
E.g.:

(defun diredp-mouse-do-chmod (event)
  "Change the mode of this file.
This calls chmod, so symbolic modes like `g+w' are allowed."
  (interactive "e")
  (let ((mouse-pos  (event-start event)))
    (select-window (posn-window mouse-pos))
    (goto-char (posn-point mouse-pos)))
  (dired-do-chxxx "Mode" "chmod" 'chmod 1)
  (diredp-previous-line 1))

As I haven't yet bothered to fix the now-bugged
`dired-do-chxxx' locally, such "real-life" commands
of mine are still broken by this recent change (for
the moment).

You can do nothing to fix this bug, and wait to see
whether Drew is the only one who has or will ever
have code that gets bitten by it.  Or you can DTRT
and not hardcode raising an error systematically
whenever `dired-get-marked-files' would come up
with no files.





  parent reply	other threads:[~2018-03-30 15:01 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-25 16:36 bug#30938: 27.0; `dired-do-create-files' etc.: do NOT always raise error if no files Drew Adams
2018-03-25 16:45 ` Drew Adams
2018-03-28 20:27   ` Juri Linkov
2018-03-28 23:45     ` Drew Adams
2018-03-29 20:04       ` Juri Linkov
2018-03-29 20:25         ` Noam Postavsky
2018-03-30  4:01           ` Drew Adams
2018-03-30  4:01         ` Drew Adams
2018-03-30  7:57           ` Eli Zaretskii
2018-04-02 19:30           ` Juri Linkov
2022-04-21 13:20             ` Lars Ingebrigtsen
2022-04-21 15:01               ` Drew Adams
     [not found]         ` <<8111e8b0-a7fb-4de4-9371-fd69c74c46e5@default>
     [not found]           ` <<83lgeac7xs.fsf@gnu.org>
2018-03-30 15:01             ` Drew Adams [this message]
2018-03-30 15:30               ` Eli Zaretskii
     [not found]         ` <<<8111e8b0-a7fb-4de4-9371-fd69c74c46e5@default>
     [not found]           ` <<<83lgeac7xs.fsf@gnu.org>
     [not found]             ` <<ea1c9d9f-2405-4377-bd42-de7f020cf9d4@default>
     [not found]               ` <<83k1tt8ttp.fsf@gnu.org>
2018-03-30 15:43                 ` Drew Adams
2018-03-30 16:07                   ` Eli Zaretskii
     [not found]         ` <<<<8111e8b0-a7fb-4de4-9371-fd69c74c46e5@default>
     [not found]           ` <<<<83lgeac7xs.fsf@gnu.org>
     [not found]             ` <<<ea1c9d9f-2405-4377-bd42-de7f020cf9d4@default>
     [not found]               ` <<<83k1tt8ttp.fsf@gnu.org>
     [not found]                 ` <<ceb6e79f-5f03-45a5-a7a4-5fe954661d5d@default>
     [not found]                   ` <<83in9d8s4b.fsf@gnu.org>
2018-03-30 17:12                     ` Drew Adams
2018-03-31  9:07                       ` Eli Zaretskii
     [not found]         ` <<<<<8111e8b0-a7fb-4de4-9371-fd69c74c46e5@default>
     [not found]           ` <<<<<83lgeac7xs.fsf@gnu.org>
     [not found]             ` <<<<ea1c9d9f-2405-4377-bd42-de7f020cf9d4@default>
     [not found]               ` <<<<83k1tt8ttp.fsf@gnu.org>
     [not found]                 ` <<<ceb6e79f-5f03-45a5-a7a4-5fe954661d5d@default>
     [not found]                   ` <<<83in9d8s4b.fsf@gnu.org>
     [not found]                     ` <<9b80ae9e-06e3-4217-89b1-eb8a3b0c93b8@default>
     [not found]                       ` <<838ta88vfz.fsf@gnu.org>
2018-03-31 16:10                         ` Drew Adams
2018-03-31 16:50                           ` Eli Zaretskii
2018-03-25 16:50 ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=ea1c9d9f-2405-4377-bd42-de7f020cf9d4@default \
    --to=drew.adams@oracle.com \
    --cc=30938@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=juri@linkov.net \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).