unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Aurélien Aptel" <aurelien.aptel+emacs@gmail.com>
To: William Xu <william.xwl@gmail.com>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: quote bashslash in a shell command
Date: Mon, 7 Jul 2014 13:34:00 +0200	[thread overview]
Message-ID: <CA+5B0FP2xYtJcph0ifUhfjSR4wuvCYCFYJ4A39PQ=dq1VZJHNg@mail.gmail.com> (raw)
In-Reply-To: <87vbr9znsl.fsf@gmail.com>

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	other threads:[~2014-07-07 11:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.4940.1404662528.1147.help-gnu-emacs@gnu.org>
2014-07-06 16:22 ` quote bashslash in a shell command Pascal J. Bourguignon
2014-07-07  6:27   ` William Xu
2014-07-07 11:34     ` Aurélien Aptel [this message]
2014-07-07 15:27     ` Pascal J. Bourguignon
2014-07-08  3:59       ` William Xu
2014-07-08  5:04         ` Pascal J. Bourguignon
     [not found]   ` <mailman.4987.1404714478.1147.help-gnu-emacs@gnu.org>
2014-07-08  7:49     ` jduthen
2014-07-06 16:01 William Xu

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='CA+5B0FP2xYtJcph0ifUhfjSR4wuvCYCFYJ4A39PQ=dq1VZJHNg@mail.gmail.com' \
    --to=aurelien.aptel+emacs@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=william.xwl@gmail.com \
    /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.
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).