Created
June 4, 2013 22:11
-
-
Save nicferrier/5710057 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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