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

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

Re: quote bashslash in a shell command


From: Aurélien Aptel
Subject: Re: quote bashslash in a shell command
Date: Mon, 7 Jul 2014 13:34:00 +0200

On Mon, Jul 7, 2014 at 8:27 AM, William Xu <william.xwl@gmail.com> wrote:
> What i'd like to have is that i try a shell command on bash, then i can
> simpy copy and paste in elisp.

I don't think it's possible. It's a good use case for raw strings
(which I've tried to get in vanilla emacs [1]) or more generally
reader macros (see Pascal's post).

But what you can do is copy and paste your shell code, select it, and
call this function:

(defun my-raw-string (start end)
  (interactive "r")
  (let ((r (prin1-to-string (buffer-substring-no-properties start end))))
    (delete-region start end)
    (insert r)))

which will turn this:

a b \ c

to this:

"a b \\ c"

1: http://definitelyaplug.b0.cx/post/raw-strings/



reply via email to

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