From: Leo Butler <Leo.Butler@umanitoba.ca>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Pedro Andres Aranda Gutierrez <paaguti@gmail.com>,
Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: [BUG] Re: The orgframe construct in the Beamer exporter as a default needs a rethink
Date: Thu, 14 Mar 2024 15:49:18 +0000 [thread overview]
Message-ID: <87ttl8izk3.fsf@t14.reltub.ca> (raw)
In-Reply-To: <87o7biwa12.fsf@localhost> (Ihor Radchenko's message of "Wed, 13 Mar 2024 13:12:25 +0000")
[-- Attachment #1: Type: text/plain, Size: 1590 bytes --]
On Wed, Mar 13 2024, Ihor Radchenko <yantar92@posteo.net> wrote:
> Pedro Andres Aranda Gutierrez <paaguti@gmail.com> writes:
>
>> I really don't have anything to object to the original patch. I support the
>> need to circumvent the "\begin-or-end{frame} inside frame" problem and
>> using orgframe is a clean way of doing so.
>> My only concern is the _default_ value for `org-beamer-frame-environment'.
>> If we set it to "frame", we only need to customise it in the file local
>> variables in files where it needs to be changed and we catch all flies in a
>> stroke:
>>
>> Situation 1: presentation has no "\begin-or-end{frame} inside frame" -> no
>> extra stuff in file local variables AND newenvironment is not generated AND
>> frames are between \begin{frame} and \end{frame}
>> Situation 2: presentation needs to circumvent "\begin-or-end{frame} inside
>> frame" -> set local variable in file AND newenvironment is generated AND
>> frame is changed where it is strictly necessary,
>
> I do not like that users would need to do manual action in situation 2.
> For situation 1, Leo's patch will ensure that all the frames are between
> \begin{frame}..\end{frame}, but newenvironment is still generated.
>
> Leo, may you improve the patch to avoid defining
> `org-beamer-frame-environment' when it is not used in all the frames?
"all the" should be "any of" in that last sentence.
--
How about the attached patch?
The previous org file exports in the same way, and exporting just the
final heading shows that no newenvironment is emitted.
Leo
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ox-beamer.el-constrain-use-of-org-beamer-frame-.patch --]
[-- Type: text/x-diff; name="0001-lisp-ox-beamer.el-constrain-use-of-org-beamer-frame-.patch", Size: 3494 bytes --]
From 22d829089fc2ca153f1541abe1d5415d311b33d3 Mon Sep 17 00:00:00 2001
From: Leo Butler <leo.butler@umanitoba.ca>
Date: Tue, 12 Mar 2024 15:11:27 -0500
Subject: [PATCH] lisp/ox-beamer.el: constrain use of
org-beamer-frame-environment
* lisp/ox-beamer.el (org-beamer--format-frame, org-beamer-template):
Only use `org-beamer-frame-environment' when a frame is marked as
fragile and the frame's contents include either \begin{frame} or
\end{frame}. When `org-beamer-frame-environment' is used and not
equal to "frame", set `org-beamer--frame-environment-used' to t. When
`org-beamer--frame-environment-used' is t, `org-beamer-template' emits
a definition of the alternative frame environment.
* lisp/ox-beamer.el (org-beamer--frame-environment-used): New
variable.
Refs: https://list.orgmode.org/orgmode/87bk7jeik8.fsf@localhost/
https://list.orgmode.org/87a5nux3zr.fsf@t14.reltub.ca/T/
---
lisp/ox-beamer.el | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el
index 4fad37b59..a79490194 100644
--- a/lisp/ox-beamer.el
+++ b/lisp/ox-beamer.el
@@ -167,6 +167,10 @@ used inside beamer slides."
\f
;;; Internal Variables
+(defvar org-beamer--frame-environment-used nil
+ "Nil unless `org-beamer-frame-environment' is used.
+See `org-beamer--frame-environment'.")
+
(defconst org-beamer-column-widths
"0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.0 :ETC"
"The column widths that should be installed as allowed property values.")
@@ -429,8 +433,21 @@ used as a communication channel."
;; among `org-beamer-verbatim-elements'.
(org-element-map headline org-beamer-verbatim-elements 'identity
info 'first-match))
- (frame (or (and fragilep org-beamer-frame-environment)
- "frame")))
+ ;; 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 set `org-beamer--frame-environment-used' to
+ ;; t.
+ (frame (let ((selection
+ (or (and fragilep
+ (or (string-search "\\begin{frame}" contents)
+ (string-search "\\end{frame}" contents))
+ org-beamer-frame-environment)
+ "frame")))
+ (unless (string= selection "frame")
+ (setq org-beamer--frame-environment-used t))
+ selection)))
(concat "\\begin{" frame "}"
;; Overlay specification, if any. When surrounded by
;; square brackets, consider it as a default
@@ -851,8 +868,9 @@ holding export options."
(org-latex--insert-compiler info)
;; Document class and packages.
(org-latex-make-preamble info)
- ;; Define the alternative frame environment.
- (unless (equal "frame" org-beamer-frame-environment)
+ ;; Define the alternative frame environment, if needed.
+ (when org-beamer--frame-environment-used
+ (setq org-beamer--frame-environment-used nil)
(format "\\newenvironment<>{%s}[1][]{\\begin{frame}#2[environment=%1$s,#1]}{\\end{frame}}\n"
org-beamer-frame-environment))
;; Insert themes.
--
2.43.0
next prev parent reply other threads:[~2024-03-14 16:36 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-01 11:33 The orgframe construct in the Beamer exporter as a default needs a rethink Pedro Andres Aranda Gutierrez
2024-03-01 16:03 ` Fraga, Eric
2024-03-01 16:17 ` Pedro Andres Aranda Gutierrez
2024-03-01 17:23 ` Pedro Andres Aranda Gutierrez
2024-03-01 23:11 ` [BUG] " Leo Butler
2024-03-02 6:24 ` Pedro Andres Aranda Gutierrez
2024-03-02 6:39 ` Pedro Andres Aranda Gutierrez
2024-03-02 8:25 ` Pedro Andres Aranda Gutierrez
2024-03-02 12:22 ` Ihor Radchenko
2024-03-02 19:03 ` Pedro Andres Aranda Gutierrez
2024-03-04 11:10 ` Ihor Radchenko
2024-03-09 8:33 ` Pedro Andres Aranda Gutierrez
2024-03-12 12:33 ` Ihor Radchenko
2024-03-12 20:32 ` Leo Butler
2024-03-13 7:16 ` Pedro Andres Aranda Gutierrez
2024-03-13 13:12 ` Ihor Radchenko
2024-03-14 15:49 ` Leo Butler [this message]
2024-03-15 14:02 ` Ihor Radchenko
2024-03-16 13:12 ` Leo Butler
2024-03-16 23:24 ` Leo Butler
2024-03-17 9:53 ` Ihor Radchenko
2024-03-17 13:18 ` Leo Butler
2024-03-17 14:36 ` Ihor Radchenko
2024-03-02 12:21 ` Ihor Radchenko
2024-03-02 12:20 ` Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ttl8izk3.fsf@t14.reltub.ca \
--to=leo.butler@umanitoba.ca \
--cc=emacs-orgmode@gnu.org \
--cc=paaguti@gmail.com \
--cc=yantar92@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).