From ece2c8b768b76936c25635d1db5b896e29a8240a Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Fri, 15 Sep 2017 09:55:01 +0100 Subject: [PATCH] skelrc: Shiny new function to return an expanded string. --- skelrc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/skelrc b/skelrc index ef8c93b..43d6052 100644 --- a/skelrc +++ b/skelrc @@ -62,6 +62,23 @@ its chosen major-mode before calling `skel-include'." (let ((val (assq key alist))) (and val (cdr val)))) +(defun skelrc-expand-text (text) + "Return the result of expanding TEXT in the current context. + +The context is extended with any new associations formed during +the expansion." + (let* ((alist skel-alist) + (expanded (with-temp-buffer + (let ((skel-alist alist)) + (insert text) + (goto-char (point-min)) + (skelrc-dribble "before: alist = `%s'" skel-alist) + (skel-do-fill-in) + (setq alist skel-alist) + (buffer-string))))) + (setq skel-alist alist) + expanded)) + (defun skelrc-prefix-lines (prefix lines) "Return LINES, each with PREFIX prepended to the beginning. -- 2.11.0