[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Latest commit to dired-aux; maybe add string-multi-replace?
From: |
Oleh Krehel |
Subject: |
Re: Latest commit to dired-aux; maybe add string-multi-replace? |
Date: |
Mon, 29 Aug 2016 14:04:58 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) |
Noam Postavsky <address@hidden> writes:
> On Mon, Aug 29, 2016 at 4:44 AM, Oleh Krehel <address@hidden> wrote:
>> Hi all,
>>
>> I just fixed the `dired-do-compress' command to work with files and
>> directories that have spaces in them.
>>
>> After the fix, I saw this pattern repeat:
>>
>> (dired-shell-command
>> (replace-regexp-in-string
>> "%o" (shell-quote-argument out-name)
>> (replace-regexp-in-string
>> "%i" (shell-quote-argument (file-name-nondirectory file))
>> (cadr suffix)
>> nil t)
>> nil t))
>>
>> I've seen the pattern of nested `replace-regexp-in-string' quite a few
>> times before. It doesn't look great.
>
> What about using `format-spec'? I think that would be:
>
> (dired-shell-command
> (format-spec (cadr suffix)
> `((?o . ,(shell-quote-argument out-name))
> (?i . ,(shell-quote-argument
> (file-name-nondirectory file))))))
Thanks, Noam. `format-spec' is exactly what I needed.
Oleh