Browse Source

Implement EXPORT_TITLE property.

Carsten Dominik 17 years ago
parent
commit
bd8d5b51c0
4 changed files with 32 additions and 15 deletions
  1. 2 1
      doc/org.texi
  2. 10 0
      lisp/ChangeLog
  3. 15 10
      lisp/org-exp.el
  4. 5 4
      lisp/org.el

+ 2 - 1
doc/org.texi

@@ -6693,7 +6693,8 @@ turned off exporting of the text before the first headline (see below), the
 title will be the file name without extension.
 
 If you are exporting only a subtree by marking is as the region, the heading
-of the subtree will become the title of the document.
+of the subtree will become the title of the document.  If the subtree has a
+property @code{EXPORT_TITLE}, that will take precedence.
 
 @node Headings and sections, Table of contents, Document title, Markup rules
 @subheading Headings and sections

+ 10 - 0
lisp/ChangeLog

@@ -1,5 +1,15 @@
 2008-05-20  Carsten Dominik  <dominik@science.uva.nl>
 
+	* org.el (org-default-properties): Add EXPORT_FILE_NAME and
+	EXPORT_TITLE.
+
+	* org-exp.el (org-export-get-title-from-subtree)
+	(org-export-as-ascii, org-export-as-html): Make sure the original
+	region-beginning and region-end are used, even after moving
+	point.
+	(org-export-get-title-from-subtree): Also try the EXPORT_TITLE
+	property.
+
 	* org-remember.el (org-remember-last-stored-marker): New variable.
 	(org-remember-goto-last-stored): Use `org-goto-marker-or-bmk'.
 	(org-remember-handler): Also use marker to remember

+ 15 - 10
lisp/org-exp.el

@@ -1558,18 +1558,19 @@ on this string to produce the exported version."
 
 (defun org-export-get-title-from-subtree ()
   "Return subtree title and exclude it from export."
-  (let (title (m (mark)))
+  (let (title (m (mark)) (rbeg (region-beginning)) (rend (region-end)))
     (save-excursion
-      (goto-char (region-beginning))
+      (goto-char rbeg)
       (when (and (org-at-heading-p)
-		 (>= (org-end-of-subtree t t) (region-end)))
+		 (>= (org-end-of-subtree t t) rend))
 	;; This is a subtree, we take the title from the first heading
-	(goto-char (region-beginning))
+	(goto-char rbeg)
 	(looking-at org-todo-line-regexp)
 	(setq title (match-string 3))
 	(org-unmodified
 	 (add-text-properties (point) (1+ (point-at-eol))
-			      (list :org-license-to-kill t)))))
+			      (list :org-license-to-kill t)))
+	(setq title (or (org-entry-get nil "EXPORT_TITLE") title))))
     title))
 
 (defun org-solidify-link-text (s &optional alist)
@@ -1748,12 +1749,14 @@ underlined headlines.  The default is 3."
   (let* ((opt-plist (org-combine-plists (org-default-export-plist)
 					(org-infile-export-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)))))
 	 (custom-times org-display-custom-times)
 	 (org-ascii-current-indentation '(0 . 0))
 	 (level 0) line txt
@@ -2359,12 +2362,14 @@ PUB-DIR is set, use this as the publishing directory."
 	 valid thetoc have-headings first-heading-pos
 	 (odd org-odd-levels-only)
 	 (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)))))
 	 ;; The following two are dynamically scoped into other
 	 ;; routines below.
 	 (org-current-export-dir
@@ -3844,7 +3849,7 @@ END:VEVENT\n"
 			      (org-entry-get nil "LOCATION"))
 		    uid (if org-icalendar-store-UID
 			    (org-id-get-create)
-			  (or (org-id-get) (orgg-id-new))))
+			  (or (org-id-get) (org-id-new))))
 	      (if (string-match org-bracket-link-regexp hd)
 		  (setq hd (replace-match (if (match-end 3) (match-string 3 hd)
 					    (match-string 1 hd))

+ 5 - 4
lisp/org.el

@@ -2610,7 +2610,7 @@ collapsed state."
 ;; Autoload ID code
 
 (org-autoload "org-id"
- '(org-id-get-create org-id-copy org-id-get 
+ '(org-id-get-create org-id-new org-id-copy org-id-get 
    org-id-get-with-outline-path-completion 
    org-id-get-with-outline-drilling
    org-id-goto org-id-find))
@@ -9766,7 +9766,8 @@ but in some other way.")
 (defconst org-default-properties
   '("ARCHIVE" "CATEGORY" "SUMMARY" "DESCRIPTION"
     "LOCATION" "LOGGING" "COLUMNS" "VISIBILITY"
-    "TABLE_EXPORT_FORMAT" "TABLE_EXPORT_FILE")
+    "TABLE_EXPORT_FORMAT" "TABLE_EXPORT_FILE"
+    "EXPORT_FILE_NAME" "EXPORT_TITLE")
   "Some properties that are used by Org-mode for various purposes.
 Being in this list makes sure that they are offered for completion.")
 
@@ -13114,8 +13115,8 @@ With optional NODE, go directly to that node."
 	(if (or (> marker (point-max)) (< marker (point-min)))
 	    (widen))
 	(goto-char marker))
-    (if bookmark.
-	(bookmark-jump bookmark-jump)
+    (if bookmark
+	(bookmark-jump bookmark)
       (error "Cannot find location"))))
 
 (defun org-quote-csv-field (s)