From 0a6c881174ae637a8bae9dcfed5fe496d7a71c1e Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Thu, 7 Mar 2024 15:49:07 +0300 Subject: [PATCH] org-babel: Fix smart `replace-regexp-in-string' behavior during variable assignment * lisp/ob-latex.el (org-babel-expand-body:latex): * lisp/ob-lilypond.el (org-babel-expand-body:lilypond): * lisp/ob-org.el (org-babel-expand-body:org): * lisp/ob-sql.el (org-babel-sql-expand-vars): Pass FIXEDCASE and LITERAL arguments to `replace-regexp-in-string'. This avoids changing case and special handling of \N constructs in the replacement string. --- lisp/ob-latex.el | 2 +- lisp/ob-lilypond.el | 2 +- lisp/ob-org.el | 2 +- lisp/ob-sql.el | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el index acb83228b..866ae1ba1 100644 --- a/lisp/ob-latex.el +++ b/lisp/ob-latex.el @@ -136,7 +136,7 @@ exporting the literal LaTeX source." (regexp-quote (format "%S" (car pair))) (if (stringp (cdr pair)) (cdr pair) (format "%S" (cdr pair))) - body))) + body t t))) (org-babel--get-vars params)) (let ((prologue (cdr (assq :prologue params))) (epilogue (cdr (assq :epilogue params)))) diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el index 7791fe201..35df76fc9 100644 --- a/lisp/ob-lilypond.el +++ b/lisp/ob-lilypond.el @@ -142,7 +142,7 @@ blocks.") (replace-regexp-in-string (concat "$" (regexp-quote name)) (if (stringp value) value (format "%S" value)) - body)))) + body t t)))) vars) (concat (and prologue (concat prologue "\n")) diff --git a/lisp/ob-org.el b/lisp/ob-org.el index d4570816f..6944eb47c 100644 --- a/lisp/ob-org.el +++ b/lisp/ob-org.el @@ -51,7 +51,7 @@ $VAR instances are replaced by VAR values defined in PARAMS." (setq body (replace-regexp-in-string (regexp-quote (format "$%s" (car var))) (format "%s" (cdr var)) - body nil 'literal))) + body 'fixedcase 'literal))) (let ((prologue (cdr (assq :prologue params))) (epilogue (cdr (assq :epilogue params)))) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 55c41828f..dc067a417 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -407,11 +407,11 @@ argument mechanism." val (if sqlite nil '(:fmt (lambda (el) (if (stringp el) - el - (format "%S" el)))))))) + el + (format "%S" el)))))))) data-file) (if (stringp val) val (format "%S" val)))) - body))) + body t t))) vars) body)