From: "Pedro A. Aranda" <paaguti@gmail.com>
To: Org Mode List <emacs-orgmode@gnu.org>
Cc: Ihor Radchenko <yantar92@posteo.net>
Subject: [PATCH]: make ox-beamer obey global export title/author settings
Date: Mon, 3 Feb 2025 16:43:08 +0100 [thread overview]
Message-ID: <80e9da5a-4058-4327-8c0b-8d7e9c82d6ac@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 171 bytes --]
Hi,
Attached is the patch for ox-beamer.el for the bug reported in
https://list.orgmode.org/87a5bbwwcz.fsf@antr.me/
Unified patch for ox-latex.el following.
Best, /PA
[-- Attachment #2: 0001-Honour-export-with-in-ox-beamer.patch --]
[-- Type: text/x-patch, Size: 6158 bytes --]
From 2bc2a27b31dc51b66f597f19a076330c35ad7022 Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda" <paaguti@gmail.com>
Date: Mon, 3 Feb 2025 12:47:38 +0100
Subject: [PATCH] Honour export-with in ox-beamer
ox-beamer: Honour `org-export-with-title' and `org-export-with-author'
* lisp/ox-beamer.el (org-beamer--frame-level): Add checks to suppress title or
author when `org-export-with-title' or `org-export-with-author' are `nil'.
* testing/lisp/test-ox-beamer.el (test-ox-beamer-with-author): Test fix when
`org-export-with-author' is `nil'.
(test-ox-beamer-with-author): Test fix when `org-export-with-author' is `nil'.
* etc/ORG-NEWS: Announce bug fix
Reported by: Antero Mejr <mail@antr.me>
Link: https://list.orgmode.org/87a5bbwwcz.fsf@antr.me/
---
etc/ORG-NEWS | 5 ++++
lisp/ox-beamer.el | 35 +++++++++++++++-----------
testing/lisp/test-ox-beamer.el | 45 ++++++++++++++++++++++++++++++++++
3 files changed, 71 insertions(+), 14 deletions(-)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index cb2c16da8..7fc85ae79 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -527,6 +527,11 @@ were tangled into a file named =NAME.bibtex=. Now, they are tangled
into a file named =FILE.bib=, using the standard extension =.bib=,
matching the rest of the ecosystem, including BibTeX and LaTeX.
+*** Fixed beamer export control via ~org-export-with-title~ and ~org-export-with-author~
+
+Globat settings controlled by ~org-export-with-title~ and
+~org-export-with-author~ are now honoured when exporting to Beamer.
+
* Version 9.7
** Important announcements and breaking changes
diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el
index e862da99d..56ef91f3d 100644
--- a/lisp/ox-beamer.el
+++ b/lisp/ox-beamer.el
@@ -900,30 +900,37 @@ holding export options."
(let ((sec-num (plist-get info :section-numbers)))
(when (integerp sec-num)
(format "\\setcounter{secnumdepth}{%d}\n" sec-num)))
- ;; Author.
- (let ((author (and (plist-get info :with-author)
- (let ((auth (plist-get info :author)))
- (and auth (org-export-data auth info)))))
- (email (and (plist-get info :with-email)
- (org-export-data (plist-get info :email) info))))
- (cond ((and author email (not (string= "" email)))
- (format "\\author{%s\\thanks{%s}}\n" author email))
- ((or author email) (format "\\author{%s}\n" (or author email)))))
+ (when (plist-get info :with-author)
+ ;; Author.
+ (let ((author (and (plist-get info :with-author)
+ (let ((auth (plist-get info :author)))
+ (and auth (org-export-data auth info)))))
+ (email (and (plist-get info :with-email)
+ (org-export-data (plist-get info :email) info))))
+ (cond ((and author email (not (string= "" email)))
+ (format "\\author{%s\\thanks{%s}}\n" author email))
+ ((or author email) (format "\\author{%s}\n" (or author email))))))
;; Date.
(let ((date (and (plist-get info :with-date) (org-export-get-date info))))
(format "\\date{%s}\n" (org-export-data date info)))
;; Title
- (format "\\title{%s}\n" title)
- (when (org-string-nw-p subtitle)
- (concat (format (plist-get info :beamer-subtitle-format) subtitle) "\n"))
+ (when (and (plist-get info :with-title) title)
+ (format "\\title{%s}\n" title)
+ ;; Subtitle only makes sense if title is generated
+ (when (org-string-nw-p subtitle)
+ (concat (format (plist-get info :beamer-subtitle-format) subtitle) "\n")))
;; Beamer-header
(let ((beamer-header (plist-get info :beamer-header)))
(when beamer-header
(format "%s\n" (plist-get info :beamer-header))))
;; 9. Hyperref options.
(let ((template (plist-get info :latex-hyperref-template)))
- (and (stringp template)
- (format-spec template (org-latex--format-spec info))))
+ (when (stringp template)
+ (unless (plist-get info :with-author) ;; produce empty pdfauthor
+ (setq template (replace-regexp-in-string "%a" "" template)))
+ (unless (plist-get info :with-title) ;; produce empty pdftitle
+ (setq template (replace-regexp-in-string "%t" "" template)))
+ (format-spec template (org-latex--format-spec info))))
;; engrave-faces-latex preamble
(when (and (eq (plist-get info :latex-src-block-backend) 'engraved)
(org-element-map (plist-get info :parse-tree)
diff --git a/testing/lisp/test-ox-beamer.el b/testing/lisp/test-ox-beamer.el
index f5743409f..5fcfa4a52 100644
--- a/testing/lisp/test-ox-beamer.el
+++ b/testing/lisp/test-ox-beamer.el
@@ -106,5 +106,50 @@ Here is a second example:
(should (search-forward (concat "\\end{frame}") nil t))
(should (search-forward (concat "\\end{" org-beamer-frame-environment "}"))))))
+(ert-deftest test-ox-beamer-with-author()
+ "Test that setting `org-export-with-author' to `nil' suppressed the author
+from the generated LaTeX"
+ (let ((org-export-with-author nil))
+ (org-test-with-exported-text
+ 'beamer
+ "#+STARTUP: beamer
+#+TITLE: Title
+#+SUBTITLE: SubTitle
+#+AUTHOR: Yo
+#+LATEX_CLASS: beamer
+#+LATEX_CLASS_OPTIONS: [presentation]
+#+BEAMER_THEME: Boadilla
+#+OPTIONS: H:2 toc:t num:t
+
+* Hola
+** Hola 1
+- Hola2"
+ (goto-char (point-min))
+ (should-not (search-forward "\\author{Yo}" nil t))
+ (goto-char (point-min))
+ (should (search-forward " pdfauthor={}," nil t)))))
+
+(ert-deftest test-ox-beamer-with-title()
+ "Test that setting `org-export-with-title' to `nil' suppressed the author
+from the generated LaTeX"
+ (let ((org-export-with-title nil))
+ (org-test-with-exported-text
+ 'beamer
+ "#+STARTUP: beamer
+#+TITLE: Title
+#+SUBTITLE: SubTitle
+#+AUTHOR: Yo
+#+LATEX_CLASS: beamer
+#+LATEX_CLASS_OPTIONS: [presentation]
+#+BEAMER_THEME: Boadilla
+#+OPTIONS: H:2 toc:t num:t
+
+* Hola
+** Hola 1
+- Hola2"
+ (goto-char (point-min))
+ (should-not (search-forward "\\title{Title}" nil t))
+ (goto-char (point-min))
+ (should (search-forward " pdftitle={}," nil t)))))
(provide 'test-ox-beamer)
;;; test-ox-beamer.el ends here
--
2.34.1
next reply other threads:[~2025-02-03 15:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-03 15:43 Pedro A. Aranda [this message]
2025-02-03 15:59 ` [PATCH]: make ox-latex obey global export title/author settings Pedro A. Aranda
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=80e9da5a-4058-4327-8c0b-8d7e9c82d6ac@gmail.com \
--to=paaguti@gmail.com \
--cc=emacs-orgmode@gnu.org \
--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).