From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: [patch, ox] suppress title Date: Wed, 11 Feb 2015 01:38:43 +0100 Message-ID: <871tlxcmek.fsf@gmx.us> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLLKS-000178-Us for emacs-orgmode@gnu.org; Tue, 10 Feb 2015 19:38:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLLKN-0004Wp-Nh for emacs-orgmode@gnu.org; Tue, 10 Feb 2015 19:38:56 -0500 Received: from plane.gmane.org ([80.91.229.3]:44173) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLLKN-0004Wa-Cz for emacs-orgmode@gnu.org; Tue, 10 Feb 2015 19:38:51 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YLLKL-0006Td-Pj for emacs-orgmode@gnu.org; Wed, 11 Feb 2015 01:38:49 +0100 Received: from tsn109-201-154-187.dyn.nltelcom.net ([109.201.154.187]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 11 Feb 2015 01:38:49 +0100 Received: from rasmus by tsn109-201-154-187.dyn.nltelcom.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 11 Feb 2015 01:38:49 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hi, Sometime when requiring custom formatting of the header for a document, it would be nice to be able to use #+TITLE without triggering the insertion of the tile (e.g. \maketitle in latex and

title

in ox-html). For instance, one might have special org-html-preamble code. This patch adds an "#+OPTIONS: title:{nil,t}" option. Any objections? Thanks, Rasmus -- If you can mix business and politics wonderful things can happen! --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-ox-Optional-export-of-title.patch >From 94a3415fecb3976edc4fa3d4a5078a33774326ae Mon Sep 17 00:00:00 2001 From: Rasmus Date: Wed, 11 Feb 2015 00:09:39 +0100 Subject: [PATCH] ox: Optional export of title * ox.el (org-export-with-title): New variable. * ox (org-export-options-alist), ox-ascii.el (org-ascii-template--document-title), ox-beamer.el (org-beamer-template), ox-html.el (org-html-template), ox-latex.el (org-latex-template), ox-man.el (org-man-template), ox-odt.el (org-odt-template), ox-org.el (org-org-template), ox-publish.el (org-publish-project-alist), ox-texinfo.el (org-texinfo-template), ox-groff.el (org-groff--mt-head): Use new variable. * ox-koma-letter.el (org-koma-letter-use-title): Mark obsolete. * test-ox.el (test-org-export/parse-option-keyword): Add :with-title. This is useful in e.g. ox-html where title can be set via `org-html-preamble-template' or when using the {{{title}}}-macro. --- contrib/lisp/ox-groff.el | 4 +++- contrib/lisp/ox-koma-letter.el | 14 +++----------- lisp/ox-ascii.el | 4 +++- lisp/ox-beamer.el | 3 ++- lisp/ox-html.el | 7 ++++--- lisp/ox-latex.el | 3 ++- lisp/ox-man.el | 3 ++- lisp/ox-odt.el | 3 ++- lisp/ox-org.el | 3 ++- lisp/ox-publish.el | 3 ++- lisp/ox-texinfo.el | 11 ++++++----- lisp/ox.el | 10 ++++++++++ testing/lisp/test-ox.el | 4 ++-- 13 files changed, 43 insertions(+), 29 deletions(-) diff --git a/contrib/lisp/ox-groff.el b/contrib/lisp/ox-groff.el index b618395..31b4e0f 100644 --- a/contrib/lisp/ox-groff.el +++ b/contrib/lisp/ox-groff.el @@ -563,7 +563,9 @@ See `org-groff-text-markup-alist' for details." (t (format ".AF \"%s\" \n" (or org-groff-organization ""))))) ;; 2. Title - (let ((subtitle1 (plist-get attr :subtitle1)) + (let ((title (if (plist-get info :with-title) + title "")) + (subtitle1 (plist-get attr :subtitle1)) (subtitle2 (plist-get attr :subtitle2))) (cond diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index de40fe6..ed556a8 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -338,16 +338,6 @@ This option can also be set with the OPTIONS keyword, e.g.: :group 'org-export-koma-letter :type 'boolean) -(defcustom org-koma-letter-use-title t - "Non-nil means use a title in the letter if present. -This option can also be set with the OPTIONS keyword, -e.g. \"title:nil\". - -See also `org-koma-letter-prefer-subject' for the handling of -title versus subject." - :group 'org-export-koma-letter - :type 'boolean) - (defcustom org-koma-letter-default-class "default-koma-letter" "Default class for `org-koma-letter'. The value must be a member of `org-latex-classes'." @@ -383,6 +373,9 @@ was not present." (defvar org-koma-letter-special-contents nil "Holds special content temporarily.") +(make-obsolete-variable 'org-koma-letter-use-title + 'Org-export-with-title + "25.1" 'set) ;;; Define Back-End @@ -418,7 +411,6 @@ was not present." (:with-phone nil "phone" org-koma-letter-use-phone) (:with-place nil "place" org-koma-letter-use-place) (:with-subject nil "subject" org-koma-letter-subject-format) - (:with-title nil "title" org-koma-letter-use-title) (:with-title-as-subject nil "title-subject" org-koma-letter-prefer-subject) ;; Special properties non-nil when a setting happened in buffer. ;; They are used to prioritize in-buffer settings over "lco" diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el index f7bc319..c4b34cb 100644 --- a/lisp/ox-ascii.el +++ b/lisp/ox-ascii.el @@ -969,7 +969,9 @@ INFO is a plist used as a communication channel." ;; Links in the title will not be resolved later, so we make ;; sure their path is located right after them. (info (org-combine-plists info '(:ascii-links-to-notes nil))) - (title (org-export-data (plist-get info :title) info)) + (title (if (plist-get info :with-title) + (org-export-data (plist-get info :title) info) + "")) (author (and (plist-get info :with-author) (let ((auth (plist-get info :author))) (and auth (org-export-data auth info))))) diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el index f53b359..1d23746 100644 --- a/lisp/ox-beamer.el +++ b/lisp/ox-beamer.el @@ -877,7 +877,8 @@ holding export options." "\\begin{document}\n\n" ;; 10. Title command. (org-element-normalize-string - (cond ((string= "" title) nil) + (cond ((null (plist-get info :with-title)) nil) + ((string= "" title) nil) ((not (stringp org-latex-title-command)) nil) ((string-match "\\(?:[^%]\\|^\\)%s" org-latex-title-command) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 3733319..50df520 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -1848,9 +1848,10 @@ holding export options." (let ((div (assq 'content (plist-get info :html-divs)))) (format "<%s id=\"%s\">\n" (nth 1 div) (nth 2 div))) ;; Document title. - (let ((title (plist-get info :title))) - (format "

%s

\n" - (org-export-data (or title "") info))) + (when (plist-get info :with-title) + (let ((title (plist-get info :title))) + (format "

%s

\n" + (org-export-data (or title "") info)))) contents (format "\n" (nth 1 (assq 'content (plist-get info :html-divs)))) ;; Postamble. diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index d7514aa..566c870 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -1260,7 +1260,8 @@ holding export options." ;; Title command. (let ((command (plist-get info :latex-title-command))) (org-element-normalize-string - (cond ((string= "" title) nil) + (cond ((null (plist-get info :with-title)) nil) + ((string= "" title) nil) ((not (stringp command)) nil) ((string-match "\\(?:[^%]\\|^\\)%s" command) (format command title)) diff --git a/lisp/ox-man.el b/lisp/ox-man.el index 4f3991b..59d107f 100644 --- a/lisp/ox-man.el +++ b/lisp/ox-man.el @@ -311,7 +311,8 @@ This function shouldn't be used for floats. See "Return complete document string after Man conversion. CONTENTS is the transcoded contents string. INFO is a plist holding export options." - (let* ((title (org-export-data (plist-get info :title) info)) + (let* ((title (when (plist-get :with-title) + (org-export-data (plist-get info :title) info))) (attr (read (format "(%s)" (mapconcat #'identity diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index aff9edd..85bc191 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -1508,7 +1508,8 @@ original parsed data. INFO is a plist holding export options." ;; Preamble - Title, Author, Date etc. (insert - (let* ((title (org-export-data (plist-get info :title) info)) + (let* ((title (and (plist-get info :with-title) + (org-export-data (plist-get info :title) info))) (author (and (plist-get info :with-author) (let ((auth (plist-get info :author))) (and auth (org-export-data auth info))))) diff --git a/lisp/ox-org.el b/lisp/ox-org.el index 5f2d126..eb5ce11 100644 --- a/lisp/ox-org.el +++ b/lisp/ox-org.el @@ -164,7 +164,8 @@ as a communication channel." (concat "#+OPTIONS: " (org-element-property :value k))))) "\n")) - (format "#+TITLE: %s\n" (org-export-data (plist-get info :title) info)) + (and (plist-get info :with-title) + (format "#+TITLE: %s\n" (org-export-data (plist-get info :title) info))) (and (plist-get info :with-date) (let ((date (org-export-data (org-export-get-date info) info))) (and (org-string-nw-p date) diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el index 49b46b1..3cca0c9 100644 --- a/lisp/ox-publish.el +++ b/lisp/ox-publish.el @@ -175,6 +175,7 @@ included. See the back-end documentation for more information. :with-footnotes `org-export-with-footnotes' :with-inlinetasks `org-export-with-inlinetasks' :with-latex `org-export-with-latex' + :with-planning `org-export-with-planning' :with-priority `org-export-with-priority' :with-properties `org-export-with-properties' :with-smart-quotes `org-export-with-smart-quotes' @@ -186,7 +187,7 @@ included. See the back-end documentation for more information. :with-tags `org-export-with-tags' :with-tasks `org-export-with-tasks' :with-timestamps `org-export-with-timestamps' - :with-planning `org-export-with-planning' + :with-title `org-export-with-title' :with-todo-keywords `org-export-with-todo-keywords' The following properties may be used to control publishing of diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index 0e33008..68ebd19 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -568,11 +568,12 @@ holding export options." ;; Title "@finalout\n" "@titlepage\n" - (format "@title %s\n" (or (plist-get info :texinfo-printed-title) title)) - (let ((subtitle (plist-get info :subtitle))) - (and subtitle - (org-element-normalize-string - (replace-regexp-in-string "^" "@subtitle " subtitle)))) + (when (plist-get info :with-title) + (format "@title %s\n" (or (plist-get info :texinfo-printed-title) title)) + (let ((subtitle (plist-get info :subtitle))) + (and subtitle + (org-element-normalize-string + (replace-regexp-in-string "^" "@subtitle " subtitle))))) (when (plist-get info :with-author) (concat ;; Primary author. diff --git a/lisp/ox.el b/lisp/ox.el index cdfc8ed..ac4fde9 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -137,6 +137,7 @@ (:with-tags nil "tags" org-export-with-tags) (:with-tasks nil "tasks" org-export-with-tasks) (:with-timestamps nil "<" org-export-with-timestamps) + (:with-title nil "title" org-export-with-title) (:with-todo-keywords nil "todo" org-export-with-todo-keywords)) "Alist between export properties and ways to set them. @@ -743,6 +744,15 @@ e.g. \"tasks:nil\"." (repeat :tag "Specific TODO keywords" (string :tag "Keyword")))) +(defcustom org-export-with-title t + "Non-nil means print title into the exported file. +This option can also be set with the OPTIONS keyword, +e.g. \"title:nil\"." + :group 'org-export-general + :version "25.1" + :package-version '(Org . 8.3) + :type 'boolean) + (defcustom org-export-time-stamp-file t "Non-nil means insert a time stamp into the exported file. The time stamp shows when the file was created. This option can diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 79b5c69..4a74ab3 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -111,7 +111,7 @@ variable, and communication channel under `info'." (org-export--parse-option-keyword "H:1 num:t \\n:t timestamp:t arch:t author:t creator:t d:t email:t *:t e:t ::t f:t pri:t -:t ^:t toc:t |:t tags:t tasks:t <:t todo:t inline:nil - stat:t") + stat:t title:t") '(:headline-levels 1 :preserve-breaks t :section-numbers t :time-stamp-file t :with-archived-trees t :with-author t :with-creator t :with-drawers t @@ -119,7 +119,7 @@ variable, and communication channel under `info'." :with-footnotes t :with-inlinetasks nil :with-priority t :with-special-strings t :with-statistics-cookies t :with-sub-superscript t :with-toc t :with-tables t :with-tags t :with-tasks t :with-timestamps t - :with-todo-keywords t))) + :with-title t :with-todo-keywords t))) ;; Test some special values. (should (equal -- 2.3.0 --=-=-=--