Jelajahi Sumber

Code cleanup: use a generic :for-backend parameter.

Bastien Guerry 14 tahun lalu
induk
melakukan
ed6d676026
5 mengubah file dengan 20 tambahan dan 28 penghapusan
  1. 1 1
      lisp/org-ascii.el
  2. 1 1
      lisp/org-docbook.el
  3. 12 20
      lisp/org-exp.el
  4. 3 3
      lisp/org-html.el
  5. 3 3
      lisp/org-latex.el

+ 1 - 1
lisp/org-ascii.el

@@ -294,7 +294,7 @@ publishing directory."
 	 (lines (org-split-string
 		 (org-export-preprocess-string
 		  region
-		  :for-ascii t
+		  :for-backend 'ascii
 		  :skip-before-1st-heading
 		  (plist-get opt-plist :skip-before-1st-heading)
 		  :drawers (plist-get opt-plist :drawers)

+ 1 - 1
lisp/org-docbook.el

@@ -527,7 +527,7 @@ publishing directory."
 	   (org-export-preprocess-string
 	    region
 	    :emph-multiline t
-	    :for-docbook t
+	    :for-backend 'docbook
 	    :skip-before-1st-heading
 	    (plist-get opt-plist :skip-before-1st-heading)
 	    :drawers (plist-get opt-plist :drawers)

+ 12 - 20
lisp/org-exp.el

@@ -962,7 +962,7 @@ Pressing `1' will switch between these two options."
 	  (cond (subtree-p
 		 (setq subtree-p nil)
 		 (message "Export buffer: "))
-		((not subtree-p) 
+		((not subtree-p)
 		 (setq subtree-p t)
 		 (message "Export subtree: "))))
 	(when (eq r1 ?\ )
@@ -1032,14 +1032,8 @@ to export.  It then creates a temporary buffer where it does its job.
 The result is then again returned as a string, and the exporter works
 on this string to produce the exported version."
   (interactive)
-  (let* ((htmlp (plist-get parameters :for-html))
-	 (asciip (plist-get parameters :for-ascii))
-	 (latexp (plist-get parameters :for-LaTeX))
-	 (docbookp (plist-get parameters :for-docbook))
-	 (backend (cond (htmlp 'html)
-			(latexp 'latex)
-			(asciip 'ascii)
-			(docbookp 'docbook)))
+  (let* ((docbookp (eq (plist-get parameters :for-backend) 'docbook))
+	 (backend (plist-get parameters :for-backend))
 	 (archived-trees (plist-get parameters :archived-trees))
 	 (inhibit-read-only t)
 	 (drawers org-drawers)
@@ -1198,20 +1192,20 @@ on this string to produce the exported version."
       (run-hooks 'org-export-preprocess-before-backend-specifics-hook)
 
       ;; LaTeX-specific preprocessing
-      (when latexp
+      (when (eq backend 'latex)
 	(require 'org-latex nil)
 	(org-export-latex-preprocess parameters))
 
       ;; ASCII-specific preprocessing
-      (when asciip
+      (when (eq backend 'ascii)
 	(org-export-ascii-preprocess parameters))
 
       ;; HTML-specific preprocessing
-      (when htmlp
+      (when (eq backend 'html)
 	(org-export-html-preprocess parameters))
 
       ;; DocBook-specific preprocessing
-      (when docbookp
+      (when (eq backend 'docbook)
 	(require 'org-docbook nil)
 	(org-export-docbook-preprocess parameters))
 
@@ -1220,7 +1214,7 @@ on this string to produce the exported version."
 
       ;; Remove #+TBLFM and #+TBLNAME lines
       (org-export-handle-table-metalines)
-      
+
       ;; Run the final hook
       (run-hooks 'org-export-preprocess-final-hook)
 
@@ -2209,7 +2203,7 @@ specifying a range of lines, include only those lines ."
 	     (lbeg (string-to-number (car lines)))
 	     (lend (string-to-number (cadr lines)))
 	     (beg (if (zerop lbeg) (point-min)
-		    (goto-char (point-min)) 
+		    (goto-char (point-min))
 		    (forward-line (1- lbeg))
 		    (point)))
 	     (end (if (zerop lend) (point-max)
@@ -2294,8 +2288,6 @@ in the list) and remove property and value from the list in LISTVAR."
 		   backend lang code opts indent caption))
       (replace-match trans t t))))
 
-(defvar htmlp)  ;; dynamically scoped
-(defvar latexp)  ;; dynamically scoped
 (defvar org-export-latex-verbatim-wrap) ;; defined in org-latex.el
 (defvar org-export-latex-listings) ;; defined in org-latex.el
 (defvar org-export-latex-listings-langs) ;; defined in org-latex.el
@@ -2802,8 +2794,8 @@ Does include HTML export options as well as TODO and CATEGORY stuff."
 #+AUTHOR:    %s
 #+EMAIL:     %s
 #+DATE:      %s
-#+DESCRIPTION: 
-#+KEYWORDS: 
+#+DESCRIPTION:
+#+KEYWORDS:
 #+LANGUAGE:  %s
 #+OPTIONS:   H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s -:%s f:%s *:%s <:%s
 #+OPTIONS:   TeX:%s LaTeX:%s skip:%s d:%s todo:%s pri:%s tags:%s
@@ -2812,7 +2804,7 @@ Does include HTML export options as well as TODO and CATEGORY stuff."
 #+EXPORT_EXCLUDE_TAGS: %s
 #+LINK_UP:   %s
 #+LINK_HOME: %s
-#+XSLT: 
+#+XSLT:
 #+CATEGORY:  %s
 #+SEQ_TODO:  %s
 #+TYP_TODO:  %s

+ 3 - 3
lisp/org-html.el

@@ -531,7 +531,7 @@ a file."
   "Alist of characters to be converted by `org-html-protect'."
   :type '((repeat (cons (string :tag "Character")
 			(string :tag "HTML equivalent")))))
-  
+
 (defgroup org-export-htmlize nil
   "Options for processing examples with htmlize.el."
   :tag "Org Export Htmlize"
@@ -1145,7 +1145,7 @@ PUB-DIR is set, use this as the publishing directory."
 	   (org-export-preprocess-string
 	    region
 	    :emph-multiline t
-	    :for-html t
+	    :for-backend 'html
 	    :skip-before-1st-heading
 	    (plist-get opt-plist :skip-before-1st-heading)
 	    :drawers (plist-get opt-plist :drawers)
@@ -2229,7 +2229,7 @@ that uses these same face definitions."
 (defun org-html-protect (s)
   "Convert characters to HTML equivalent.
 Possible conversions are set in `org-export-html-protect-char-alist'."
-  (let ((start 0) 
+  (let ((start 0)
 	(cl org-export-html-protect-char-alist) c)
     (while (setq c (pop cl))
       (while (string-match (car c) s start)

+ 3 - 3
lisp/org-latex.el

@@ -801,7 +801,7 @@ when PUB-DIR is set, use this as the publishing directory."
 	       (org-export-preprocess-string
 		text
 		:emph-multiline t
-		:for-LaTeX t
+		:for-backend 'latex
 		:comments nil
 		:tags (plist-get opt-plist :tags)
 		:priority (plist-get opt-plist :priority)
@@ -818,7 +818,7 @@ when PUB-DIR is set, use this as the publishing directory."
 	  (org-export-preprocess-string
 	   region
 	   :emph-multiline t
-	   :for-LaTeX t
+	   :for-backend 'latex
 	   :comments nil
 	   :tags (plist-get opt-plist :tags)
 	   :priority (plist-get opt-plist :priority)
@@ -1346,7 +1346,7 @@ If END is non-nil, it is the end of the region."
 	  (org-export-latex-content
 	   (org-export-preprocess-string
 	    (buffer-substring pt end)
-	    :for-LaTeX t
+	    :for-backend 'latex
 	    :emph-multiline t
 	    :add-text nil
 	    :comments nil