Hi Ihor, The attached patch does two things to ox-beamer.el
1. make sure that the preferred way of calling lambda is used: #'(lambda()...) 2. simplify label detection. Depending on beamer or ltx-talk the frame name is declared as 'name=' or 'label='. My feeling is that string-prefix-p is easier to read and more efficient than a regexp. 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 This was produced by a human (implied virtues and weaknesses acknowledged) I'd hate this being fed to any form of AS (sorry AI)...
From 5ed51456959a9191499582115a7ee2989ebe5358 Mon Sep 17 00:00:00 2001 From: "Pedro A. Aranda" <[email protected]> Date: Tue, 14 Jul 2026 16:47:55 +0200 Subject: [PATCH 14/14] ox-beamer: normalise lambda, simplify label detection Make sure that all instances of (lambda ...) are preceeded by #'. Since the label must start with 'label=' or 'name=' use string-prefix-p instead od a regexp. --- lisp/ox-beamer.el | 110 +++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 56 deletions(-) diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el index e8a8e5021..45cda3650 100644 --- a/lisp/ox-beamer.el +++ b/lisp/ox-beamer.el @@ -174,7 +174,7 @@ (defcustom org-beamer-frame-environment "orgframe" :group 'org-export-beamer :package-version '(Org . "9.7") :type '(string :tag "Beamer frame") - :safe (lambda (str) (string-match-p "^[A-Za-z]+$" str))) + :safe #'(lambda (str) (string-match-p "^[A-Za-z]+$" str))) ;;; Internal Variables @@ -238,8 +238,8 @@ (defun org-beamer--normalize-argument (argument type) (cl-case type (action (format "<%s>" (org-unbracket-string "<" ">" argument))) (defaction - (format "[<%s>]" - (org-unbracket-string "<" ">" (org-unbracket-string "[" "]" argument)))) + (format "[<%s>]" + (org-unbracket-string "<" ">" (org-unbracket-string "[" "]" argument)))) (option (format "[%s]" (org-unbracket-string "[" "]" argument))) (otherwise (error "Invalid `type' argument to `org-beamer--normalize-argument': %s" type))))) @@ -266,9 +266,9 @@ (org-export-define-derived-backend 'beamer 'latex (?b "As LaTeX file (Beamer)" org-beamer-export-to-latex) (?P "As PDF file (Beamer)" org-beamer-export-to-pdf) (?O "As PDF file and open (Beamer)" - (lambda (a s v b) - (if a (org-beamer-export-to-pdf t s v b) - (org-open-file (org-beamer-export-to-pdf nil s v b))))))) + #'(lambda (a s v b) + (if a (org-beamer-export-to-pdf t s v b) + (org-open-file (org-beamer-export-to-pdf nil s v b))))))) :options-alist '((:headline-levels nil "H" org-beamer-frame-level) (:latex-class "LATEX_CLASS" nil "beamer" t) @@ -392,10 +392,10 @@ (defun org-beamer--frame-level (headline info) (org-export-get-relative-level headline info))) ;; 3. Look for "frame" environment in sub-tree. (org-element-map headline 'headline - (lambda (hl) - (let ((env (org-element-property :BEAMER_ENV hl))) - (when (and env (member-ignore-case env '("frame" "fullframe"))) - (org-export-get-relative-level hl info)))) + #'(lambda (hl) + (let ((env (org-element-property :BEAMER_ENV hl))) + (when (and env (member-ignore-case env '("frame" "fullframe"))) + (org-export-get-relative-level hl info)))) info 'first-match) ;; 4. No "frame" environment in tree: use default value. (plist-get info :headline-levels))) @@ -413,12 +413,12 @@ (defun org-beamer--format-section (headline contents info) :parent 'latex :transcoders (let ((protected-output - (lambda (object contents info) - (let ((code (org-export-with-backend - 'beamer object contents info))) - (if (org-string-nw-p code) (concat "\\protect" code) - code))))) - (mapcar (lambda (type) (cons type protected-output)) + #'(lambda (object contents info) + (let ((code (org-export-with-backend + 'beamer object contents info))) + (if (org-string-nw-p code) (concat "\\protect" code) + code))))) + (mapcar #'(lambda (type) (cons type protected-output)) '(bold footnote-reference italic strike-through timestamp underline)))) headline @@ -505,11 +505,9 @@ (defun org-beamer--format-frame (headline contents info) ;; allowed by Beamer. (and (not (member "allowframebreaks" options)) (not (cl-some - #'(lambda (s) - (string-match-p - (concat "^" (regexp-quote label-str) "=") - s)) - options)) + #'(lambda (s) + (string-prefix-p (concat label-str "=") s)) + options)) (list (let ((label (org-beamer--get-label headline info))) ;; Labels containing colons need to be @@ -602,12 +600,12 @@ (defun org-beamer--format-block (headline contents info) (or (equal environment "columns") (and column-width (not (and parent-env - (equal (downcase parent-env) "columns"))) + (equal (downcase parent-env) "columns"))) (or (org-export-first-sibling-p headline info) (not (org-element-property - :BEAMER_COL - (org-export-get-previous-element - headline info))))))) + :BEAMER_COL + (org-export-get-previous-element + headline info))))))) ;; End the "columns" environment when explicitly requested or ;; when there is no next headline or the next headline do not ;; have a BEAMER_column property. @@ -615,11 +613,11 @@ (defun org-beamer--format-block (headline contents info) (or (equal environment "columns") (and column-width (not (and parent-env - (equal (downcase parent-env) "columns"))) + (equal (downcase parent-env) "columns"))) (or (org-export-last-sibling-p headline info) (not (org-element-property - :BEAMER_COL - (org-export-get-next-element headline info)))))))) + :BEAMER_COL + (org-export-get-next-element headline info)))))))) (concat (when start-columns-p ;; Column can accept options only when the environment is @@ -770,17 +768,17 @@ (defun org-beamer-item (item contents info) (list (cons 'item - (lambda (item _c _i) - (let ((action - (let ((first (car (org-element-contents item)))) - (and (org-element-type-p first 'paragraph) - (org-beamer--element-has-overlay-p first)))) - (output (org-latex-item item contents info))) - (if (not (and action (string-match "\\\\item" output))) output - ;; If the item starts with a paragraph and that paragraph - ;; starts with an export snippet specifying an overlay, - ;; append it to the \item command. - (replace-match (concat "\\\\item" action) nil nil output))))))) + #'(lambda (item _c _i) + (let ((action + (let ((first (car (org-element-contents item)))) + (and (org-element-type-p first 'paragraph) + (org-beamer--element-has-overlay-p first)))) + (output (org-latex-item item contents info))) + (if (not (and action (string-match "\\\\item" output))) output + ;; If the item starts with a paragraph and that paragraph + ;; starts with an export snippet specifying an overlay, + ;; append it to the \item command. + (replace-match (concat "\\\\item" action) nil nil output))))))) item contents info)) @@ -893,17 +891,17 @@ (defun org-beamer--theme-header (info) (concat theme-pre (and theme-pre "\n") (let ((format-theme - (lambda (prop command) - (let ((theme (plist-get info prop))) - (when theme - (concat command - (if (not (string-match "\\[.*\\]" theme)) - (format "{%s}\n" theme) - (format "%s{%s}\n" - (match-string 0 theme) - (org-trim - (replace-match "" nil nil theme)))))))))) - (mapconcat (lambda (args) (apply format-theme args)) + #'(lambda (prop command) + (let ((theme (plist-get info prop))) + (when theme + (concat command + (if (not (string-match "\\[.*\\]" theme)) + (format "{%s}\n" theme) + (format "%s{%s}\n" + (match-string 0 theme) + (org-trim + (replace-match "" nil nil theme)))))))))) + (mapconcat #'(lambda (args) (apply format-theme args)) '((:beamer-theme "\\usetheme") (:beamer-color-theme "\\usecolortheme") (:beamer-font-theme "\\usefonttheme") @@ -1047,7 +1045,7 @@ (defun org-beamer-property-changed (property value) (save-excursion (org-back-to-heading t) ;; Filter out Beamer-related tags and install environment tag. - (let ((tags (cl-remove-if (lambda (x) (string-match "^B_" x)) + (let ((tags (cl-remove-if #'(lambda (x) (string-match "^B_" x)) (org-get-tags nil t))) (env-tag (and (org-string-nw-p value) (concat "B_" value)))) (org-set-tags (if env-tag (cons env-tag tags) tags)) @@ -1204,8 +1202,8 @@ (defun org-beamer-select-environment () org-beamer-environments-default)) (org-current-tag-alist (append '((:startgroup)) - (mapcar (lambda (e) (cons (concat "B_" (car e)) - (string-to-char (nth 1 e)))) + (mapcar #'(lambda (e) (cons (concat "B_" (car e)) + (string-to-char (nth 1 e)))) envs) '((:endgroup)) '(("BMCOL" . ?|)))) @@ -1234,9 +1232,9 @@ (defun org-beamer-select-environment () (org-set-property "BEAMER_act" (read-string "Overlay specification: ")))) ((let* ((tags-re (concat "B_" (regexp-opt (mapcar #'car envs) t))) - (env (cl-some (lambda (tag) - (and (string-match tags-re tag) - (match-string 1 tag))) + (env (cl-some #'(lambda (tag) + (and (string-match tags-re tag) + (match-string 1 tag))) tags))) (and env (progn (org-entry-put nil "BEAMER_env" env) t)))) (t (org-entry-delete nil "BEAMER_env")))))) -- 2.43.0
