Просмотр исходного кода

Properties can be used to confiugre subtree export.

Carsten Dominik 17 лет назад
Родитель
Сommit
332191cc13
6 измененных файлов с 120 добавлено и 41 удалено
  1. 21 0
      ORGWEBPAGE/Changes.org
  2. 22 10
      doc/org.texi
  3. 8 0
      lisp/ChangeLog
  4. 54 26
      lisp/org-exp.el
  5. 14 4
      lisp/org-export-latex.el
  6. 1 1
      lisp/org.el

+ 21 - 0
ORGWEBPAGE/Changes.org

@@ -15,6 +15,27 @@
 
 ** Details
 
+*** New properties for customizing subtree export.
+When exporting a subtree by selecting it before calling the
+export command, you can now use the properties =EXPORT_TITLE=,
+=EXPORT_TEXT=, and =EXPORT_OPTIONS= to overrule the global
+=#+TITLE=, =#+TEXT=, and =#+OPTIONS= settings.  You can also the
+an export file name with =EXPORT_FILE_NAME= that will overrule
+the file name derived from the buffers file name.  As far as the
+options are concerned, the global =#+OPTIONS= will still be read,
+and only the options you give in the property will be
+overwritten.  For example:
+
+#+begin_src org
+,#+OPTIONS: skip:nil
+,* Computer Tricks
+,  :PROPERTIES:
+,  :EXPORT_FILE_NAME: ct.html
+,  :EXPORT_TITLE: Steve's collected computer tricks
+,  :EXPORT_OPTIONS: h:2 toc:nil
+,  :END:
+#+end_src
+ 
 *** The default of the variable `org-tags-match-list-sublevels' is now `t'.
     The main reason for this is that it is easier to explain in
     the manual and will lead to fewer surprises.

+ 22 - 10
doc/org.texi

@@ -7028,6 +7028,11 @@ These options take effect in both the HTML and La@TeX{} export, except
 for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
 @code{nil} for the La@TeX{} export.
 
+When exporting only a single subtree by selecting it with @kbd{C-c @@} before
+calling an export command, the subtree can overrule some of the file's export
+settings with properties @code{EXPORT_FILE_NAME}, @code{EXPORT_TITLE},
+@code{EXPORT_TEXT}, and @code{EXPORT_OPTIONS}.
+
 @node The export dispatcher, ASCII export, Export options, Exporting
 @section The export dispatcher
 @cindex dispatcher, for export commands
@@ -7074,9 +7079,10 @@ file.
 Export as ASCII file.  For an org file @file{myfile.org}, the ASCII file
 will be @file{myfile.txt}.  The file will be overwritten without
 warning.  If there is an active region, only the region will be
-exported. If the selected region is a single tree, the tree head will
+exported. If the selected region is a single tree@footnote{To select the
+current subtree, use @kbd{C-c @@}.}, the tree head will
 become the document title.  If the tree head entry has or inherits an
-@code{:EXPORT_FILE_NAME:} property, that name will be used for the
+@code{EXPORT_FILE_NAME} property, that name will be used for the
 export.
 @kindex C-c C-e v a
 @item C-c C-e v a
@@ -7128,13 +7134,13 @@ language, but with additional support for tables.
 @table @kbd
 @kindex C-c C-e h
 @item C-c C-e h
-Export as HTML file @file{myfile.html}.  For an org file
-@file{myfile.org}, the ASCII file will be @file{myfile.html}.  The file
-will be overwritten without warning.  If there is an active region, only
-the region will be exported. If the selected region is a single tree,
-the tree head will become the document title.  If the tree head entry
-has or inherits an @code{:EXPORT_FILE_NAME:} property, that name will be
-used for the export.
+Export as HTML file @file{myfile.html}.  For an org file @file{myfile.org},
+the ASCII file will be @file{myfile.html}.  The file will be overwritten
+without warning.  If there is an active region, only the region will be
+exported. If the selected region is a single tree@footnote{To select the
+current subtree, use @kbd{C-c @@}.}, the tree head will become the document
+title.  If the tree head entry has or inherits an @code{EXPORT_FILE_NAME}
+property, that name will be used for the export.
 @kindex C-c C-e b
 @item C-c C-e b
 Export as HTML file and immediately open it with a browser.
@@ -7365,7 +7371,13 @@ Org mode contains a La@TeX{} exporter written by Bastien Guerry.
 @table @kbd
 @kindex C-c C-e l
 @item C-c C-e l
-Export as La@TeX{} file @file{myfile.tex}.
+Export as La@TeX{} file @file{myfile.tex}.  For an org file
+@file{myfile.org}, the ASCII file will be @file{myfile.tex}.  The file will
+be overwritten without warning.  If there is an active region, only the
+region will be exported. If the selected region is a single tree@footnote{To
+select the current subtree, use @kbd{C-c @@}.}, the tree head will become the
+document title.  If the tree head entry has or inherits an
+@code{EXPORT_FILE_NAME} property, that name will be used for the export.
 @kindex C-c C-e L
 @item C-c C-e L
 Export to a temporary buffer, do not create a file.

+ 8 - 0
lisp/ChangeLog

@@ -1,3 +1,11 @@
+2008-05-21  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-export-latex.el (org-export-as-latex): Make sure region
+	bounds are correct.  Parse subtree properties relating to export.
+
+	* org-exp.el (org-export-add-options-to-plist): New function.
+	(org-infile-export-plist): Use `org-export-add-options-to-plist'.
+
 2008-05-20  Carsten Dominik  <dominik@science.uva.nl>
 
 	* org.el (org-default-properties): Add EXPORT_FILE_NAME and

+ 54 - 26
lisp/org-exp.el

@@ -782,34 +782,56 @@ modified) list.")
 			    (substring ext-setup-or-nil start)))))))
 	(setq p (plist-put p :text text))
 	(when options
-	  (let ((op '(("H"     . :headline-levels)
-		      ("num"   . :section-numbers)
-		      ("toc"   . :table-of-contents)
-		      ("\\n"   . :preserve-breaks)
-		      ("@"     . :expand-quoted-html)
-		      (":"     . :fixed-width)
-		      ("|"     . :tables)
-		      ("^"     . :sub-superscript)
-		      ("-"     . :special-strings)
-		      ("f"     . :footnotes)
-		      ("d"     . :drawers)
-		      ("tags"  . :tags)
-		      ("*"     . :emphasize)
-		      ("TeX"   . :TeX-macros)
-		      ("LaTeX" . :LaTeX-fragments)
-		      ("skip"  . :skip-before-1st-heading)
-		      ("author" . :author-info)
-		      ("timestamp" . :time-stamp-file)))
-		o)
-	    (while (setq o (pop op))
-	      (if (string-match (concat (regexp-quote (car o))
-					":\\([^ \t\n\r;,.]*\\)")
-				options)
-		  (setq p (plist-put p (cdr o)
-				     (car (read-from-string
-					   (match-string 1 options)))))))))
+	  (setq p (org-export-add-options-to-plist p options)))
 	p))))
 
+(defun org-export-add-options-to-plist (p options)
+  "Parse an OPTONS line and set values in the property list P."
+  (let (o)
+    (when options
+      (let ((op '(("H"     . :headline-levels)
+		  ("num"   . :section-numbers)
+		  ("toc"   . :table-of-contents)
+		  ("\\n"   . :preserve-breaks)
+		  ("@"     . :expand-quoted-html)
+		  (":"     . :fixed-width)
+		  ("|"     . :tables)
+		  ("^"     . :sub-superscript)
+		  ("-"     . :special-strings)
+		  ("f"     . :footnotes)
+		  ("d"     . :drawers)
+		  ("tags"  . :tags)
+		  ("*"     . :emphasize)
+		  ("TeX"   . :TeX-macros)
+		  ("LaTeX" . :LaTeX-fragments)
+		  ("skip"  . :skip-before-1st-heading)
+		  ("author" . :author-info)
+		  ("timestamp" . :time-stamp-file)))
+	    o)
+	(while (setq o (pop op))
+	  (if (string-match (concat (regexp-quote (car o))
+				    ":\\([^ \t\n\r;,.]*\\)")
+			    options)
+	      (setq p (plist-put p (cdr o)
+				 (car (read-from-string
+				       (match-string 1 options))))))))))
+  p)
+  
+(defun org-export-add-subtree-options (p pos)
+  "Add options in subtree at position POS to property list P."
+  (save-excursion
+    (goto-char pos)
+    (when (org-at-heading-p)
+      (let (a)
+	;; This is actually read in `org-export-get-title-from-subtree'
+	;; (when (setq a (org-entry-get pos "EXPORT_TITLE"))
+	;;   (setq p (plist-put p :title a)))
+	(when (setq a (org-entry-get pos "EXPORT_TEXT"))
+	  (setq p (plist-put p :text a)))
+	(when (setq a (org-entry-get pos "EXPORT_OPTIONS"))
+	  (setq p (org-export-add-options-to-plist p a)))))
+    p))
+
 (defun org-export-directory (type plist)
   (let* ((val (plist-get plist :publishing-directory))
 	 (dir (if (listp val)
@@ -1757,6 +1779,9 @@ underlined headlines.  The default is 3."
 	      (goto-char rbeg)
 	      (and (org-at-heading-p)
 		   (>= (org-end-of-subtree t t) rend)))))
+	 (opt-plist (if subtree-p 
+			(org-export-add-subtree-options opt-plist rbeg)
+		      opt-plist))
 	 (custom-times org-display-custom-times)
 	 (org-ascii-current-indentation '(0 . 0))
 	 (level 0) line txt
@@ -2370,6 +2395,9 @@ PUB-DIR is set, use this as the publishing directory."
 	      (goto-char rbeg)
 	      (and (org-at-heading-p)
 		   (>= (org-end-of-subtree t t) rend)))))
+	 (opt-plist (if subtree-p 
+			(org-export-add-subtree-options opt-plist rbeg)
+		      opt-plist))
 	 ;; The following two are dynamically scoped into other
 	 ;; routines below.
 	 (org-current-export-dir

+ 14 - 4
lisp/org-export-latex.el

@@ -361,12 +361,19 @@ when PUB-DIR is set, use this as the publishing directory."
   (let* ((wcf (current-window-configuration))
 	 (opt-plist org-export-latex-options-plist)
 	 (region-p (org-region-active-p))
+	 (rbeg (and region-p (region-beginning)))
+	 (rend (and region-p (region-end)))
 	 (subtree-p
 	  (when region-p
 	    (save-excursion
-	      (goto-char (region-beginning))
+	      (goto-char rbeg)
 	      (and (org-at-heading-p)
-		   (>= (org-end-of-subtree t t) (region-end))))))
+		   (>= (org-end-of-subtree t t) rend)))))
+	 (opt-plist (if subtree-p 
+			(org-export-add-subtree-options opt-plist rbeg)
+		      opt-plist))
+	 ;; Make sure the variable contains the updated values.
+	 (org-export-latex-options-plist opt-plist)
 	 (title (or (and subtree-p (org-export-get-title-from-subtree))
 		    (plist-get opt-plist :title)
 		    (and (not
@@ -378,8 +385,11 @@ when PUB-DIR is set, use this as the publishing directory."
 			    (or pub-dir
 				(org-export-directory :LaTeX ext-plist)))
 			   (file-name-sans-extension
-			    (file-name-nondirectory ;sans-extension
-			     buffer-file-name)) ".tex"))
+			    (or (and subtree-p
+				     (org-entry-get rbeg "EXPORT_FILE_NAME" t))
+				(file-name-nondirectory ;sans-extension
+				 buffer-file-name)))
+			   ".tex"))
 	 (filename (if (equal (file-truename filename)
 			      (file-truename buffer-file-name))
 		       (concat filename ".tex")

+ 1 - 1
lisp/org.el

@@ -12680,7 +12680,7 @@ context.  See the individual commands for more information."
 
 (defun org-ctrl-c-star ()
   "Compute table, or change heading status of lines.
-Calls `org-table-recalculate' or `org-toggle-region-headlines',
+Calls `org-table-recalculate' or `org-toggle-region-headings',
 depending on context.  This will also turn a plain list item or a normal
 line into a subheading."
   (interactive)