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!

1 Answer 1

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
1
  • 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
    Commented Apr 22, 2015 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.