update packages

This commit is contained in:
2025-06-22 17:08:08 +02:00
parent 54e5633369
commit 16a0a6db93
558 changed files with 68349 additions and 26568 deletions

View File

@@ -1,11 +1,10 @@
;;; ox-beamer.el --- Beamer Back-End for Org Export Engine -*- lexical-binding: t; -*-
;;; ox-beamer.el --- Beamer Backend for Org Export Engine -*- lexical-binding: t; -*-
;; Copyright (C) 2007-2023 Free Software Foundation, Inc.
;; Copyright (C) 2007-2025 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik AT gmail DOT com>
;; Nicolas Goaziou <n.goaziou AT gmail DOT com>
;; Maintainer: Nicolas Goaziou <mail@nicolasgoaziou.fr>
;; Keywords: org, wp, tex
;; Keywords: org, text, tex
;; This file is part of GNU Emacs.
@@ -24,7 +23,7 @@
;;; Commentary:
;;
;; This library implements both a Beamer back-end, derived from the
;; This library implements both a Beamer backend, derived from the
;; LaTeX one and a minor mode easing structure edition of the
;; document. See Org manual for more information.
@@ -116,10 +115,10 @@ open The opening template for the environment, with the following escapes
%r the raw headline text (i.e. without any processing)
%H if there is headline text, that raw text in {} braces
%U if there is headline text, that raw text in [] brackets
%l the label, obtained from `org-beamer--get-label'
close The closing string of the environment."
:group 'org-export-beamer
:version "24.4"
:package-version '(Org . "8.1")
:package-version '(Org . "9.7")
:type '(repeat
(list
(string :tag "Environment")
@@ -148,6 +147,22 @@ which is replaced with the subtitle."
:package-version '(Org . "8.3")
:type '(string :tag "Format string"))
(defcustom org-beamer-frame-environment "orgframe"
"Name of the alternative beamer frame environment.
In frames marked as fragile, this environment is used in place of
the usual frame environment.
This permits insertion of a beamer frame inside example blocks,
working around beamer limitations. See
https://list.orgmode.org/87a5nux3zr.fsf@t14.reltub.ca/T/#mc7221e93f138bdd56c916b194b9230d3a6c3de09
This option may need to be changed when \"\\end{orgframe}\" string is
used inside beamer slides."
:group 'org-export-beamer
:package-version '(Org . "9.7")
:type '(string :tag "Beamer frame")
:safe (lambda (str) (string-match-p "^[A-Za-z]+$" str)))
;;; Internal Variables
@@ -165,7 +180,7 @@ which is replaced with the subtitle."
("ignoreheading" "i")
("note" "n")
("noteNH" "N"))
"Alist of environments treated in a special way by the back-end.
"Alist of environments treated in a special way by the backend.
Keys are environment names, as strings, values are bindings used
in `org-beamer-select-environment'. Environments listed here,
along with their binding, are hard coded and cannot be modified
@@ -178,10 +193,10 @@ through `org-beamer-environments-extra' variable.")
("quotation" "q" "\\begin{quotation}%a %% %h" "\\end{quotation}")
("quote" "Q" "\\begin{quote}%a %% %h" "\\end{quote}")
("structureenv" "s" "\\begin{structureenv}%a %% %h" "\\end{structureenv}")
("theorem" "t" "\\begin{theorem}%a[%h]" "\\end{theorem}")
("definition" "d" "\\begin{definition}%a[%h]" "\\end{definition}")
("example" "e" "\\begin{example}%a[%h]" "\\end{example}")
("exampleblock" "E" "\\begin{exampleblock}%a{%h}" "\\end{exampleblock}")
("theorem" "t" "\\begin{theorem}%a[%h]%l" "\\end{theorem}")
("definition" "d" "\\begin{definition}%a[%h]%l" "\\end{definition}")
("example" "e" "\\begin{example}%a[%h]%l" "\\end{example}")
("exampleblock" "E" "\\begin{exampleblock}%a{%h}%l" "\\end{exampleblock}")
("proof" "p" "\\begin{proof}%a[%h]" "\\end{proof}")
("beamercolorbox" "o" "\\begin{beamercolorbox}%o{%h}" "\\end{beamercolorbox}"))
"Environments triggered by properties in Beamer export.
@@ -221,14 +236,14 @@ An element has an overlay specification when it starts with an
`beamer' export-snippet whose value is between angular brackets.
Return overlay specification, as a string, or nil."
(let ((first-object (car (org-element-contents element))))
(when (eq (org-element-type first-object) 'export-snippet)
(when (org-element-type-p first-object 'export-snippet)
(let ((value (org-element-property :value first-object)))
(and (string-prefix-p "<" value) (string-suffix-p ">" value)
value)))))
;;; Define Back-End
;;; Define Backend
(org-export-define-derived-backend 'beamer 'latex
:menu-entry
@@ -273,7 +288,7 @@ Return overlay specification, as a string, or nil."
;;;; Bold
(defun org-beamer-bold (bold contents _info)
"Transcode BLOCK object into Beamer code.
"Transcode BOLD object into Beamer code.
CONTENTS is the text being bold. INFO is a plist used as
a communication channel."
(format "\\alert%s{%s}"
@@ -376,7 +391,7 @@ CONTENTS holds the contents of the headline. INFO is a plist
used as a communication channel."
(let ((latex-headline
(org-export-with-backend
;; We create a temporary export back-end which behaves the
;; We create a temporary export backend which behaves the
;; same as current one, but adds "\protect" in front of the
;; output of some objects.
(org-export-create-backend
@@ -408,12 +423,27 @@ used as a communication channel."
"Format HEADLINE as a frame.
CONTENTS holds the contents of the headline. INFO is a plist
used as a communication channel."
(let ((fragilep
;; FRAGILEP is non-nil when HEADLINE contains an element
;; among `org-beamer-verbatim-elements'.
(org-element-map headline org-beamer-verbatim-elements 'identity
info 'first-match)))
(concat "\\begin{frame}"
(let* ((fragilep
;; FRAGILEP is non-nil when HEADLINE contains an element
;; among `org-beamer-verbatim-elements'.
(org-element-map headline org-beamer-verbatim-elements 'identity
info 'first-match))
;; If FRAGILEP is non-nil and CONTENTS contains an occurrence
;; of \begin{frame} or \end{frame}, then set the FRAME
;; environment to be `org-beamer-frame-environment';
;; otherwise, use "frame". If the selected environment is not
;; "frame", then add the property :beamer-define-frame to
;; INFO and set it to t.
(frame (let ((selection
(or (and fragilep
(or (string-match-p "\\\\begin{frame}" contents)
(string-match-p "\\\\end{frame}" contents))
org-beamer-frame-environment)
"frame")))
(unless (string= selection "frame")
(setq info (plist-put info :beamer-define-frame t)))
selection)))
(concat "\\begin{" frame "}"
;; Overlay specification, if any. When surrounded by
;; square brackets, consider it as a default
;; specification.
@@ -480,7 +510,7 @@ used as a communication channel."
;; output.
(if (not fragilep) contents
(replace-regexp-in-string "\\`\n*" "\\& " (or contents "")))
"\\end{frame}")))
"\\end{" frame "}")))
(defun org-beamer--format-block (headline contents info)
"Format HEADLINE as a block.
@@ -512,21 +542,33 @@ used as a communication channel."
(options (if raw-options
(org-beamer--normalize-argument raw-options 'option)
""))
;; also process actions
(raw-action (org-element-property :BEAMER_ACT headline))
(action (if raw-action
;; If BEAMER_act property has its value enclosed in square
;; brackets, it is a default overlay specification and
;; overlay specification is empty. Otherwise, it is an
;; overlay specification and the default one is nil.
(org-beamer--normalize-argument
raw-action
(if (string-match "\\`\\[.*\\]\\'" raw-action) 'defaction
'action))
""))
;; Start a "columns" environment when explicitly requested or
;; when there is no previous headline or the previous
;; headline do not have a BEAMER_column property.
(parent-env (org-element-property
:BEAMER_ENV (org-export-get-parent-headline headline)))
:BEAMER_ENV (org-element-lineage headline 'headline)))
(start-columns-p
(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.
@@ -534,11 +576,11 @@ used as a communication channel."
(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
@@ -546,10 +588,13 @@ used as a communication channel."
(if (not (equal environment "columns")) "\\begin{columns}\n"
(format "\\begin{columns}%s\n" options)))
(when column-width
(format "\\begin{column}%s{%s}\n"
(format "\\begin{column}%s%s{%s}\n"
;; One can specify placement for column only when
;; HEADLINE stands for a column on its own.
(if (equal environment "column") options "")
options
(if env-format
"" ; Inner environment is specified - pass actions later.
action)
(format "%s\\columnwidth" column-width)))
;; Block's opening string.
(when (nth 2 env-format)
@@ -557,27 +602,23 @@ used as a communication channel."
(org-fill-template
(nth 2 env-format)
(nconc
;; If BEAMER_act property has its value enclosed in square
;; brackets, it is a default overlay specification and
;; overlay specification is empty. Otherwise, it is an
;; overlay specification and the default one is nil.
(let ((action (org-element-property :BEAMER_ACT headline)))
(cond
((not action) (list (cons "a" "") (cons "A" "") (cons "R" "")))
((and (string-prefix-p "[" action)
(string-suffix-p "]" action))
(list
(cons "A" (org-beamer--normalize-argument action 'defaction))
(cons "a" "")
(cons "R" action)))
(t
(list (cons "a" (org-beamer--normalize-argument action 'action))
(cons "A" "")
(cons "R" action)))))
(cond
((not action) (list (cons "a" "") (cons "A" "") (cons "R" "")))
((and (string-prefix-p "[" action)
(string-suffix-p "]" action))
(list
(cons "A" (org-beamer--normalize-argument action 'defaction))
(cons "a" "")
(cons "R" raw-action)))
(t
(list (cons "a" action)
(cons "A" "")
(cons "R" raw-action))))
(list (cons "o" options)
(cons "O" (or raw-options ""))
(cons "h" title)
(cons "r" raw-title)
(cons "l" (format "\\label{%s}" (org-beamer--get-label headline info)))
(cons "H" (if (equal raw-title "") ""
(format "{%s}" raw-title)))
(cons "U" (if (equal raw-title "") ""
@@ -693,7 +734,7 @@ contextual information."
(lambda (item _c _i)
(let ((action
(let ((first (car (org-element-contents item))))
(and (eq (org-element-type first) 'paragraph)
(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
@@ -713,7 +754,7 @@ channel."
(let ((key (org-element-property :key keyword))
(value (org-element-property :value keyword)))
;; Handle specifically BEAMER and TOC (headlines only) keywords.
;; Otherwise, fallback to `latex' back-end.
;; Otherwise, fallback to `latex' backend.
(cond
((equal key "BEAMER") value)
((and (equal key "TOC") (string-match "\\<headlines\\>" value))
@@ -738,7 +779,7 @@ used as a communication channel."
;; Fall-back to LaTeX export. However, prefer "\hyperlink" over
;; "\hyperref" since the former handles overlay specifications.
(let* ((latex-link (org-export-with-backend 'latex link contents info))
(parent (org-export-get-parent-element link))
(parent (org-element-parent-element link))
(attr (org-export-read-attribute :attr_beamer parent))
(overlay (plist-get attr :overlay)))
(cond ((string-match "\\`\\\\hyperref\\[\\(.*?\\)\\]" latex-link)
@@ -803,10 +844,9 @@ contextual information."
(org-export-get-reference radio-target info)
text))
;;;; Template
;;
;; Template used is similar to the one used in `latex' back-end,
;; Template used is similar to the one used in `latex' backend,
;; excepted for the table of contents and Beamer themes.
(defun org-beamer-template (contents info)
@@ -816,13 +856,17 @@ holding export options."
(let ((title (org-export-data (plist-get info :title) info))
(subtitle (org-export-data (plist-get info :subtitle) info)))
(concat
;; Time-stamp.
;; Timestamp.
(and (plist-get info :time-stamp-file)
(format-time-string "%% Created %Y-%m-%d %a %H:%M\n"))
;; LaTeX compiler
(org-latex--insert-compiler info)
;; Document class and packages.
(org-latex-make-preamble info)
;; Define the alternative frame environment, if needed.
(when (plist-get info :beamer-define-frame)
(format "\\newenvironment<>{%s}[1][]{\\begin{frame}#2[environment=%1$s,#1]}{\\end{frame}}\n"
org-beamer-frame-environment))
;; Insert themes.
(let ((format-theme
(lambda (prop command)
@@ -871,7 +915,7 @@ holding export options."
(and (stringp template)
(format-spec template (org-latex--format-spec info))))
;; engrave-faces-latex preamble
(when (and (eq org-latex-src-block-backend 'engraved)
(when (and (eq (plist-get info :latex-src-block-backend) 'engraved)
(org-element-map (plist-get info :parse-tree)
'(src-block inline-src-block) #'identity
info t))
@@ -924,13 +968,12 @@ holding export options."
"Support for editing Beamer oriented Org mode files."
:lighter " Bm")
(when (fboundp 'font-lock-add-keywords)
(font-lock-add-keywords
'org-mode
'((":\\(B_[a-z]+\\|BMCOL\\):" 1 'org-beamer-tag prepend))
'prepend))
(font-lock-add-keywords
'org-mode
'((":\\(B_[a-z]+\\|BMCOL\\):" 1 'org-beamer-tag prepend))
'prepend)
(defface org-beamer-tag '((t (:box (:line-width 1 :color grey40))))
(defface org-beamer-tag '((t (:box (:line-width 1 :color "grey40"))))
"The special face for beamer tags."
:group 'org-export-beamer)
@@ -1009,7 +1052,10 @@ will be displayed when `org-export-show-temporary-export-buffer'
is non-nil."
(interactive)
(org-export-to-buffer 'beamer "*Org BEAMER Export*"
async subtreep visible-only body-only ext-plist (lambda () (LaTeX-mode))))
async subtreep visible-only body-only ext-plist
(if (fboundp 'major-mode-remap)
(major-mode-remap 'latex-mode)
#'LaTeX-mode)))
;;;###autoload
(defun org-beamer-export-to-latex