unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Oleh Krehel <ohwoeowho@gmail.com>
To: Noam Postavsky <npostavs@users.sourceforge.net>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: Latest commit to dired-aux; maybe add string-multi-replace?
Date: Mon, 29 Aug 2016 14:04:58 +0200	[thread overview]
Message-ID: <8737lnvl05.fsf@limebv.nl> (raw)
In-Reply-To: <CAM-tV-9tM2ofFZydKsP0xamykJsUPJtpZAdpJWhicsVOMvtaoQ@mail.gmail.com> (Noam Postavsky's message of "Mon, 29 Aug 2016 07:52:24 -0400")

Noam Postavsky <npostavs@users.sourceforge.net> writes:

> On Mon, Aug 29, 2016 at 4:44 AM, Oleh Krehel <oleh@oremacs.com> 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



  reply	other threads:[~2016-08-29 12:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-29  8:44 Latest commit to dired-aux; maybe add string-multi-replace? Oleh Krehel
2016-08-29 11:52 ` Noam Postavsky
2016-08-29 12:04   ` Oleh Krehel [this message]
2016-08-29 12:16 ` Tino Calancha

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=8737lnvl05.fsf@limebv.nl \
    --to=ohwoeowho@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=npostavs@users.sourceforge.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).