[Top][All Lists]

[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 <address@hidden> writes:

> "Pascal J. Bourguignon" <address@hidden> 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
>>          (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 | sed -e s/\..//
|                 echo | sed -e s/\..//|
C-SPC C-a        [echo | sed -e s/\..//|]
M-"              "echo | sed -e s/\\..//|"
C-e C-b DEL      "echo | sed -e s/\\..//"

In any case, you should always use paredit-mode for lisp editing.

__Pascal Bourguignon__
"Le mercure monte ?  C'est le moment d'acheter !"

reply via email to

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