[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: quote bashslash in a shell command
From: |
Pascal J. Bourguignon |
Subject: |
Re: quote bashslash in a shell command |
Date: |
Mon, 07 Jul 2014 17:27:24 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
William Xu <william.xwl@gmail.com> writes:
> "Pascal J. Bourguignon" <pjb@informatimago.com> writes:
>
>> What you'd want to do, is to define a DSL, a domain specific language,
>> to build shell command strings. So you could write something as:
>>
>> (pipe (echo foo.bar)
>> (sed -e s/\..//))
>
> That sounds a overkill.
>
> What i'd like to have is that i try a shell command on bash, then i can
> simpy copy and paste in elisp.
If you use the paredit minor mode in emacs lisp mode buffers, then M-"
paredit-doublequote will double the backquotes.
Unfortunately, since | is an escape character in lisp, if you paste a
shell pipe with an odd number of | in elisp, select it and M-", it will
signal an Unbalanced parentheses error and not do the work.
Instead you can add a | at the end to make an even number of them,
select the shell expression and type M-".
C-y echo foo.bar | sed -e s/\..//
| echo foo.bar | sed -e s/\..//|
C-SPC C-a [echo foo.bar | sed -e s/\..//|]
M-" "echo foo.bar | sed -e s/\\..//|"
C-e C-b DEL "echo foo.bar | sed -e s/\\..//"
In any case, you should always use paredit-mode for lisp editing.
--
__Pascal Bourguignon__
http://www.informatimago.com/
"Le mercure monte ? C'est le moment d'acheter !"