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.
 title will be the file name without extension.
 
 
 If you are exporting only a subtree by marking is as the region, the heading
 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
 @node Headings and sections, Table of contents, Document title, Markup rules
 @subheading Headings and sections
 @subheading Headings and sections

+ 10 - 0
lisp/ChangeLog

@@ -1,5 +1,15 @@
 2008-05-20  Carsten Dominik  <dominik@science.uva.nl>
 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.el (org-remember-last-stored-marker): New variable.
 	(org-remember-goto-last-stored): Use `org-goto-marker-or-bmk'.
 	(org-remember-goto-last-stored): Use `org-goto-marker-or-bmk'.
 	(org-remember-handler): Also use marker to remember
 	(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 ()
 (defun org-export-get-title-from-subtree ()
   "Return subtree title and exclude it from export."
   "Return subtree title and exclude it from export."
-  (let (title (m (mark)))
+  (let (title (m (mark)) (rbeg (region-beginning)) (rend (region-end)))
     (save-excursion
     (save-excursion
-      (goto-char (region-beginning))
+      (goto-char rbeg)
       (when (and (org-at-heading-p)
       (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
 	;; 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)
 	(looking-at org-todo-line-regexp)
 	(setq title (match-string 3))
 	(setq title (match-string 3))
 	(org-unmodified
 	(org-unmodified
 	 (add-text-properties (point) (1+ (point-at-eol))
 	 (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))
     title))
 
 
 (defun org-solidify-link-text (s &optional alist)
 (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)
   (let* ((opt-plist (org-combine-plists (org-default-export-plist)
 					(org-infile-export-plist)))
 					(org-infile-export-plist)))
 	 (region-p (org-region-active-p))
 	 (region-p (org-region-active-p))
+	 (rbeg (and region-p (region-beginning)))
+	 (rend (and region-p (region-end)))
 	 (subtree-p
 	 (subtree-p
 	  (when region-p
 	  (when region-p
 	    (save-excursion
 	    (save-excursion
-	      (goto-char (region-beginning))
+	      (goto-char rbeg)
 	      (and (org-at-heading-p)
 	      (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)
 	 (custom-times org-display-custom-times)
 	 (org-ascii-current-indentation '(0 . 0))
 	 (org-ascii-current-indentation '(0 . 0))
 	 (level 0) line txt
 	 (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
 	 valid thetoc have-headings first-heading-pos
 	 (odd org-odd-levels-only)
 	 (odd org-odd-levels-only)
 	 (region-p (org-region-active-p))
 	 (region-p (org-region-active-p))
+	 (rbeg (and region-p (region-beginning)))
+	 (rend (and region-p (region-end)))
 	 (subtree-p
 	 (subtree-p
 	  (when region-p
 	  (when region-p
 	    (save-excursion
 	    (save-excursion
-	      (goto-char (region-beginning))
+	      (goto-char rbeg)
 	      (and (org-at-heading-p)
 	      (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
 	 ;; The following two are dynamically scoped into other
 	 ;; routines below.
 	 ;; routines below.
 	 (org-current-export-dir
 	 (org-current-export-dir
@@ -3844,7 +3849,7 @@ END:VEVENT\n"
 			      (org-entry-get nil "LOCATION"))
 			      (org-entry-get nil "LOCATION"))
 		    uid (if org-icalendar-store-UID
 		    uid (if org-icalendar-store-UID
 			    (org-id-get-create)
 			    (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)
 	      (if (string-match org-bracket-link-regexp hd)
 		  (setq hd (replace-match (if (match-end 3) (match-string 3 hd)
 		  (setq hd (replace-match (if (match-end 3) (match-string 3 hd)
 					    (match-string 1 hd))
 					    (match-string 1 hd))

+ 5 - 4
lisp/org.el

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