1

In the following skeleton definition, I like to have quote characters ", ` and ' in the generated skeleton code.

For example,

I like to have the effect of

#+NAME:a-function-test 
#+BEGIN_SRC clojure 
(facts "about `a-function'"
 ) 
#+END_SRC 

But I'm only able to do this now:

#+NAME:a-function-test 
#+BEGIN_SRC clojure 
(facts about a-function
 ) 
#+END_SRC 

Here is my current implementation.

#+BEGIN_SRC emacs-lisp :results output :exports none
  (define-skeleton tdd-clojure-skeleton
    "Define a skeleton "
    "function name: "

    "#+NAME:" str "-test" " \n"
      "#+BEGIN_SRC clojure" " \n"
      "(facts " "about " str "\n"
      " )" " \n"
      "#+END_SRC" " \n"

  )
#+END_SRC

Thanks for your help!

Andrew Swann
  • 3,436
  • 2
  • 15
  • 43
Yu Shen
  • 451
  • 4
  • 15

1 Answers1

3

You just need to escape the " with a backslash \". You can also concatenate some of the strings. Only the final newline needs to be quoted:

(define-skeleton tdd-clojure-skeleton
    "Define a skeleton "
    "function name: "

    "#+NAME:" str "-test" \n
      "#+BEGIN_SRC clojure" \n
      "(facts  \"about \'" str "\'\"" \n
      " )" \n
      "#+END_SRC \n"
  )

This run with input test gives

#+NAME:test-test
#+BEGIN_SRC clojure
(facts "about 'test'"
 )
#+END_SRC
Andrew Swann
  • 3,436
  • 2
  • 15
  • 43
  • Thanks a lot for your prompt help! I tried before to do escape, but I was fooled by smartparens forbidding me to add the quote characters properly. Afterwards, I had to avoid its interfering to add according to your suggestion. – Yu Shen Apr 22 '15 at 12:35