0

I'm having a problem while invoking emacs to eval some elisp from the windows powershell.It seems to be a problem with the usage of quotes, but I can't figure that out:

This is the command that I'm executing:

PS> emacs.exe --eval '(with-current-buffer "*scratch*" (insert "Hi"))'

Then emacs opens and I get the following message in the *Backtrace* buffer:

Debugger entered--Lisp error: (void-variable *scratch*)
(set-buffer *scratch*)
(save-current-buffer (set-buffer *scratch*) (insert Hi))
(with-current-buffer *scratch* (insert Hi))
eval((with-current-buffer *scratch* (insert Hi)))
command-line-1(("--eval" "(with-current-buffer *scratch* (insert Hi))"))
command-line()
normal-top-level()

Any help on how to run this correctly would be awesome.

Thanks

quicoju
  • 1,661
  • 11
  • 15
  • @JordonBiondo I don't see a way how can the quotes can be escaped here. Any suggestion? – quicoju May 16 '14 at 02:32
  • @quicoju It looks like [this](http://ss64.com/ps/syntax-esc.html) has all the information you could possibly need. Also, SO has a couple of [related](http://stackoverflow.com/q/19862232/1199226) [posts](http://stackoverflow.com/q/18116186/1199226) about escaping quotes in PowerShell... – itsjeyd May 16 '14 at 06:19
  • What is `*scratch*`? Why in asterisks? The error says that var is void. – Vesper May 16 '14 at 10:30
  • @Vesper That is the buffer's name, emacs should see this string as "\*scratch\*", but for some reason powershell isn't passing the double quotes to emacs. – quicoju May 16 '14 at 12:50
  • After playing a while with the quotes, I realized that I need to pass the emacs' escape character for the double quotes. So the command that finally worked for me is: PS> emacs.exe --eval '(with-current-buffer \"*scratch*\" (insert \"Hi\"))' Thanks everyone for your help. – quicoju May 16 '14 at 13:32

1 Answers1

3

After playing a while with the quotes, I realized that I need to pass the emacs' escape character for the double quotes. So the command that finally worked for me is:

PS> emacs.exe --eval '(with-current-buffer \"*scratch*\" (insert \"Hi\"))'

Thanks everyone for your help.

quicoju
  • 1,661
  • 11
  • 15