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

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

bug#48072: 28.0.50: dired-read-shell-command: handle empty input properl


From: Boruch Baum
Subject: bug#48072: 28.0.50: dired-read-shell-command: handle empty input properly [PATCH]
Date: Wed, 28 Apr 2021 08:00:11 -0400
User-agent: NeoMutt/20180716

On 2021-04-28 13:03, Michael Albinus wrote:
> Boruch Baum <boruch_baum@gmx.com> writes:
> >
> > +      (unless (executable-find command)
> > +        (user-error "Not a valid command!"))
>
> This doesn't check the remote case.

Good point. It's an area of dired I'm weak in  because I don't use it.
How about the following (with the update diredc regex):

      (unless (executable-find
                (if (string-match "^ *\\([^ ]+\\) " command)
                  (substring command (match-beginning 1) (match-end 1))
                 command)
                (file-remote-p file))
        (user-error "Not a valid command!"))

The snippet is currently in three separate points in diredc with slight
differences (defsubst called-for). For preparing the completion
candidates, the snippet is there at function
diredc--advice--shell-guess-fallback.

For the post-input check (`diredc--advice--dired-read-shell-command',
and with a tweak, also `diredc-do-async-shell-command'), how about this
for checking that the command is valid for all selected file:

      (unless (executable-find
                (if (string-match "^ *\\([^ ]+\\) " command)
                  (substring command (match-beginning 1) (match-end 1))
                 command)
                (let ((f files)
                       remote-found)
                  (while (and f (not (setq remote-found (file-remote-p (pop 
f))))))
                  remote-found))
        (user-error "Not a valid command!"))


ref: https://github.com/Boruch-Baum/emacs-diredc

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0





reply via email to

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