branch: externals/ellama
commit 9ce1ee692cf3bae68fcfd16ff59abbb3b7377631
Merge: 710433ddf3 1b78d0f617
Author: Sergey Kostyaev <[email protected]>
Commit: GitHub <[email protected]>

    Merge pull request #356 from stsquad/less-agressive-variable-substitution
    
    ellama-blueprints: be less aggressive matching template vars
---
 ellama-blueprint.el | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/ellama-blueprint.el b/ellama-blueprint.el
index 10d1c58fd2..ab77fd3853 100644
--- a/ellama-blueprint.el
+++ b/ellama-blueprint.el
@@ -58,8 +58,12 @@
   "C-c C-c" #'ellama-transient-blueprint-mode-menu
   "C-c C-k" #'ellama-kill-current-buffer)
 
+(defvar ellama-blueprint-variable-regexp
+  "{\\([[:alnum:]_-]+\\)}"
+  "Regular expression to match blueprint variables like {var_name}.")
+
 (defvar ellama-blueprint-font-lock-keywords
-  '(("{\\([^}]+\\)}" 1 'font-lock-keyword-face))
+  '((,ellama-blueprint-variable-regexp 1 'font-lock-keyword-face))
   "Highlight variables in curly braces for Ellama Blueprint Mode.")
 
 ;;;###autoload
@@ -69,7 +73,7 @@
   "Toggle Ellama Blueprint mode."
   :keymap ellama-blueprint-mode-map
   :group 'ellama
-  (setq font-lock-defaults '((("{\\([^}]+\\)}" 1 font-lock-keyword-face t))))
+  (setq font-lock-defaults '(((,ellama-blueprint-variable-regexp 1 
font-lock-keyword-face t))))
   (setq header-line-format
        (concat
         (propertize
@@ -228,7 +232,7 @@ corresponding prompt is inserted into a blueprint buffer."
   (save-excursion
     (let ((vars '()))
       (goto-char (point-min))
-      (while (re-search-forward "\{\\([^}]+\\)}" nil t)
+      (while (re-search-forward ellama-blueprint-variable-regexp nil t)
        (push (match-string 1) vars))
       (seq-uniq vars))))
 

Reply via email to