emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH]: make ox-beamer obey global export title/author settings
@ 2025-02-03 15:43 Pedro A. Aranda
  2025-02-03 15:59 ` [PATCH]: make ox-latex " Pedro A. Aranda
  0 siblings, 1 reply; 2+ messages in thread
From: Pedro A. Aranda @ 2025-02-03 15:43 UTC (permalink / raw)
  To: Org Mode List; +Cc: Ihor Radchenko

[-- 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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-03 16:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-03 15:43 [PATCH]: make ox-beamer obey global export title/author settings Pedro A. Aranda
2025-02-03 15:59 ` [PATCH]: make ox-latex " Pedro A. Aranda

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).