Selaa lähdekoodia

ox-beamer: Add a helpful error message

* lisp/ox-beamer.el (org-beamer--format-block): Return an error
  message when using a special environment as a block type.  Also
  check for incomplete environment definitions.
Nicolas Goaziou 11 vuotta sitten
vanhempi
commit
d745cd1952
1 muutettua tiedostoa jossa 10 lisäystä ja 8 poistoa
  1. 10 8
      lisp/ox-beamer.el

+ 10 - 8
lisp/ox-beamer.el

@@ -539,12 +539,14 @@ used as a communication channel."
 			 ((not env) "column")
 			 ;; Use specified environment.
 			 (t env))))
-	 (env-format (unless (member environment '("column" "columns"))
-		       (assoc environment
-			      (append org-beamer-environments-special
-				      org-beamer-environments-extra
-				      org-beamer-environments-default))))
 	 (raw-title (org-element-property :raw-value headline))
+	 (env-format
+	  (cond ((member environment '("column" "columns")) nil)
+		((assoc environment
+			(append org-beamer-environments-extra
+				org-beamer-environments-default)))
+		(t (user-error "Wrong block type at a headline named \"%s\""
+			       raw-title))))
 	 (title (org-export-data (org-element-property :title headline) info))
 	 (options (let ((options (org-element-property :BEAMER_OPT headline)))
 		    (if (not options) ""
@@ -589,7 +591,7 @@ used as a communication channel."
 	       (if (equal environment "column") options "")
 	       (format "%s\\textwidth" column-width)))
      ;; Block's opening string.
-     (when env-format
+     (when (nth 2 env-format)
        (concat
 	(org-fill-template
 	 (nth 2 env-format)
@@ -617,8 +619,8 @@ used as a communication channel."
 			    (format "[%s]" raw-title))))))
 	"\n"))
      contents
-     ;; Block's closing string.
-     (when environment (concat (nth 3 env-format) "\n"))
+     ;; Block's closing string, if any.
+     (and (nth 3 env-format) (concat (nth 3 env-format) "\n"))
      (when column-width "\\end{column}\n")
      (when end-columns-p "\\end{columns}"))))