Hi Org-mode main states emacs 28.2 as a requirement. emacs 28.1 added string-replace and I think we should take advantage of it...
best, /pa -- Fragen sind nicht da, um beantwortet zu werden, Fragen sind da um gestellt zu werden Georg Kreisler "Sagen's Paradeiser" (ORF: Als Radiohören gefährlich war) => write BE! Year 2 of the New Koprocracy
From 04caf74fd777abcba965f619268cbd002169acd5 Mon Sep 17 00:00:00 2001 From: "Pedro A. Aranda" <[email protected]> Date: Sun, 21 Jun 2026 08:13:28 +0200 Subject: [PATCH] Use string-replace for easier reading Emacs 28.1 introduced string-replace. From a readability point of view, it is better when the search or replacement strings contain 'special characters' that need to be escaped (i.e. dot, backslash, etc.) * lisp/ox-latex.el (org-latex-generate-engraved-preamble, org-latex--text-markup, org-latex--inline-image, org-latex-plain-text): Convert regexps to strings when possible in order to use (string-replace). --- lisp/ox-latex.el | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 8e2f72209..8bf39eaef 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -1411,7 +1411,7 @@ (defun org-latex-generate-engraved-preamble (info) (replace-regexp-in-string "[^A-Za-z]" "" (symbol-name theme)) (replace-regexp-in-string "newcommand" "renewcommand" - (replace-regexp-in-string + (string-replace "#" "##" (funcall gen-theme-spec theme))))) engraved-themes @@ -1905,7 +1905,7 @@ (defun org-latex--text-markup (text markup info) (let ((separator (org-latex--find-verb-separator text))) (concat "\\verb" separator - (replace-regexp-in-string "\n" " " text) + (string-replace "\n" " " text) separator))) (protectedtexttt (org-latex--protect-texttt text)) ;; Else use format string. @@ -3055,10 +3055,7 @@ (defun org-latex--inline-image (link info) "\\includesvg" image-code nil t)) - (setq image-code (replace-regexp-in-string "\\.svg}" - "}" - image-code - nil t)))) + (setq image-code (string-replace "\\.svg}" "}" image-code)))) ;; Return proper string, depending on FLOAT. (pcase float ((and (pred stringp) env-string) @@ -3281,7 +3278,7 @@ (defun org-latex-plain-text (text info) (setq output (org-export-activate-smart-quotes output :latex info text))) ;; Convert special strings. (when specialp - (setq output (replace-regexp-in-string "\\.\\.\\." "\\\\ldots{}" output))) + (setq output (string-replace "..." "\\ldots{}" output))) ;; Handle break preservation if required. (when (plist-get info :preserve-breaks) (setq output (replace-regexp-in-string -- 2.43.0
