Browse Source

LaTeX export: When exporting to a buffer only, do not require a file name

Carsten Dominik 15 years ago
parent
commit
d2f219fd41
2 changed files with 32 additions and 16 deletions
  1. 7 0
      lisp/ChangeLog
  2. 25 16
      lisp/org-latex.el

+ 7 - 0
lisp/ChangeLog

@@ -1,3 +1,10 @@
+2010-02-12  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-latex.el (org-export-as-latex): Do nit require the buffer to
+	be visiting a file when only exporting to a buffer or string.
+	(org-export-latex-fix-inputenc): Only save the buffer is there is
+	a file name attached to it.
+
 2010-02-09  Dan Davison  <davison@stats.ox.ac.uk>
 
 	* org-src.el (org-edit-src-exit): Widen before exiting edit buffers

+ 25 - 16
lisp/org-latex.el

@@ -637,21 +637,29 @@ when PUB-DIR is set, use this as the publishing directory."
 		    (and (not
 			  (plist-get opt-plist :skip-before-1st-heading))
 			 (org-export-grab-title-from-buffer))
-		    (file-name-sans-extension
-		     (file-name-nondirectory buffer-file-name))))
-	 (filename (concat (file-name-as-directory
-			    (or pub-dir
-				(org-export-directory :LaTeX ext-plist)))
-			   (file-name-sans-extension
-			    (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")
-		     filename))
+		    (and buffer-file-name
+			 (file-name-sans-extension
+			  (file-name-nondirectory buffer-file-name)))
+		    "No Title"))
+	 (filename 
+	  (and (not to-buffer)
+	       (concat
+		(file-name-as-directory
+		 (or pub-dir
+		     (org-export-directory :LaTeX ext-plist)))
+		(file-name-sans-extension
+		 (or (and subtree-p
+			  (org-entry-get rbeg "EXPORT_FILE_NAME" t))
+		     (file-name-nondirectory ;sans-extension
+		      (or buffer-file-name
+			  (error "Don't know which export file to use.")))))
+		".tex")))
+	 (filename
+	  (and filename
+	       (if (equal (file-truename filename)
+			  (file-truename (or buffer-file-name "dummy.org")))
+		   (concat filename ".tex")
+		 filename)))
 	 (buffer (if to-buffer
 		     (cond
 		      ((eq to-buffer 'string) (get-buffer-create
@@ -2056,7 +2064,8 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
 	(goto-char (match-beginning 1))
 	(delete-region (match-beginning 1) (match-end 1))
 	(insert opt))
-      (save-buffer))))
+      (and buffer-file-name
+	   (save-buffer)))))
 
 ;;; List handling: