Skip to content

Instantly share code, notes, and snippets.

@nicferrier
Created June 4, 2013 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicferrier/5710057 to your computer and use it in GitHub Desktop.
Save nicferrier/5710057 to your computer and use it in GitHub Desktop.
(defun nic-dyn-lookup (symbol)
(format "%S" (symbol-value (intern symbol))))
(defun nic-lex-lookup (symbol environment)
(let ((value (assq (intern symbol) (cadr environment))))
(when (consp value) (format "%S" (cdr value)))))
(defmacro s-lex-format (template)
(if lexical-binding
`(let ((lex-env (lambda nil nil)))
(s-format ,template 'nic-lex-lookup lex-env))
;; else it's normal binding
`(s-format ,template 'nic-dyn-lookup)))
(let ((v 10))
(s-lex-format "${v}"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment