emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Fix XEmacs "wrong type error" in org-export-as-pdf
@ 2008-12-21  1:36 Hugh Daschbach, Hugh Daschbach
  2008-12-21 11:49 ` Carsten Dominik
  0 siblings, 1 reply; 2+ messages in thread
From: Hugh Daschbach, Hugh Daschbach @ 2008-12-21  1:36 UTC (permalink / raw)
  To: emacs-orgmode

XEmacs throws a wrong-type-argument exception from org-export-as-pdf
if org file contains '&'.  See sample document, traceback, and patch
below.

This may well not be the best fix.  And it's not clear why this issue
doesn't exist in Emacs.  But there are several regular expressions in
org-export-latex-special-chars that call
org-export-latex-treat-backslash-char with a nil value for
string-after.  The regular expression that matched "MB&A" is
"\\(.\\|^\\)\\(&\\)".  So there is no (match-string 3).

Here's a document that generates the exception:

--8<---------------cut here---------------start------------->8---
* Header

MB&A

* Footer
--8<---------------cut here---------------end--------------->8---

Here's the traceback:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("^[ \n	]" nil)
  (not (string-match "^[ \n	]" string-after))
  (and (not (string-match "^[ \n	]" string-after)) (not (string-match "[ 	]\\'\\|^" string-before)))
  (cond ((member ... org-html-entities) (concat string-before "$\\" ... "$")) ((and ... ...) (org-export-latex-protect-string ...)) ((not ...) (org-export-latex-protect-string ...)) ((and ... ...) (org-export-latex-protect-string ...)) (t (org-export-latex-protect-string ...)))
  org-export-latex-treat-backslash-char("B" nil)
  #<compiled-function (c) "...(304)" [sub-superscript match-data match-data match-data match-data c re-search-forward nil t get-text-property 2 org-protected match-string ("\\$" "$") "\\$" replace-match 1 "$" 3 ("&" "%" "#") "\\" "..." org-export-latex-protect-string "\\ldots{}" "~" 0 face org-link "\\~" "\\~{}" ("{" "}") match-data (...) org-inside-LaTeX-fragment-p (...) (...) org-export-latex-treat-backslash-char "" ("_" "^") (...) org-export-latex-treat-sub-super-char] 7>("\\(.\\|^\\)\\(&\\)")
  mapc-internal(#<compiled-function (c) "...(304)" [sub-superscript match-data match-data match-data match-data c re-search-forward nil t get-text-property 2 org-protected match-string ("\\$" "$") "\\$" replace-match 1 "$" 3 ("&" "%" "#") "\\" "..." org-export-latex-protect-string "\\ldots{}" "~" 0 face org-link "\\~" "\\~{}" ("{" "}") match-data (...) org-inside-LaTeX-fragment-p (...) (...) org-export-latex-treat-backslash-char "" ("_" "^") (...) org-export-latex-treat-sub-super-char] 7> ("^\\([^\n$]*?\\|^\\)\\(\\\\?\\$\\)\\([^\n$]*\\)$" "\\([a-za-z0-9]+\\|[ 	\n]\\|\\b\\|\\\\\\)\\(_\\|\\^\\)\\([a-za-z0-9]+\\|[ 	\n]\\|[:punct:]\\|{[a-za-z0-9]+}\\|([a-za-z0-9]+)\\)" "\\(.\\|^\\)\\(\\\\\\)\\([ 	\n]\\|[a-zA-Z&#%{}\"]+\\)" "\\(.\\|^\\)\\(&\\)" "\\(.\\|^\\)\\(#\\)" "\\(.\\|^\\)\\(%\\)" "\\(.\\|
 ^\\)\\({\\)" "\\(.\\|^\\)\\(}\\)" "\\(.\\|^\\)\\(~\\)" "\\(.\\|^\\)\\(\\.\\.\\.\\)"))
  mapc(#<compiled-function (c) "...(304)" [sub-superscript match-data match-data match-data match-data c re-search-forward nil t get-text-property 2 org-protected match-string ("\\$" "$") "\\$" replace-match 1 "$" 3 ("&" "%" "#") "\\" "..." org-export-latex-protect-string "\\ldots{}" "~" 0 face org-link "\\~" "\\~{}" ("{" "}") match-data (...) org-inside-LaTeX-fragment-p (...) (...) org-export-latex-treat-backslash-char "" ("_" "^") (...) org-export-latex-treat-sub-super-char] 7> ("^\\([^\n$]*?\\|^\\)\\(\\\\?\\$\\)\\([^\n$]*\\)$" "\\([a-za-z0-9]+\\|[ 	\n]\\|\\b\\|\\\\\\)\\(_\\|\\^\\)\\([a-za-z0-9]+\\|[ 	\n]\\|[:punct:]\\|{[a-za-z0-9]+}\\|([a-za-z0-9]+)\\)" "\\(.\\|^\\)\\(\\\\\\)\\([ 	\n]\\|[a-zA-Z&#%{}\"]+\\)" "\\(.\\|^\\)\\(&\\)" "\\(.\\|^\\)\\(#\\)" "\\(.\\|^\\)\\(%\\)" "\\(.\\|^\\)\\({\
 \)" "\\(.\\|^\\)\\(}\\)" "\\(.\\|^\\)\\(~\\)" "\\(.\\|^\\)\\(\\.\\.\\.\\)"))
  org-export-latex-special-chars(t)
  org-export-latex-content("\nMB&A\n\n")
  org-export-latex-first-lines(nil)
  org-export-as-latex(nil nil nil nil nil nil)
  org-export-as-pdf(nil)
  call-interactively(org-export-as-pdf)
  command-execute(org-export-as-pdf t)
  execute-extended-command(nil)
  call-interactively(execute-extended-command)
---
 lisp/org-export-latex.el |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lisp/org-export-latex.el b/lisp/org-export-latex.el
index fa6a0e4..60795fb 100644
--- a/lisp/org-export-latex.el
+++ b/lisp/org-export-latex.el
@@ -976,6 +976,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
 	 (concat string-before "$\\"
 		 (or (cdar (member (list string-after) org-html-entities))
 		     string-after) "$"))
+	((null string-after) (concat string-before "\\"))
 	((and (not (string-match "^[ \n\t]" string-after))
 	      (not (string-match "[ \t]\\'\\|^" string-before)))
 	 ;; backslash is inside a word
-- 
1.5.6.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix XEmacs "wrong type error" in org-export-as-pdf
  2008-12-21  1:36 [PATCH] Fix XEmacs "wrong type error" in org-export-as-pdf Hugh Daschbach, Hugh Daschbach
@ 2008-12-21 11:49 ` Carsten Dominik
  0 siblings, 0 replies; 2+ messages in thread
From: Carsten Dominik @ 2008-12-21 11:49 UTC (permalink / raw)
  To: Hugh Daschbach; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 5114 bytes --]

Fixed, thanks.

- Carsten

On Dec 21, 2008, at 2:36 AM, Hugh Daschbach wrote:

> XEmacs throws a wrong-type-argument exception from org-export-as-pdf
> if org file contains '&'.  See sample document, traceback, and patch
> below.
>
> This may well not be the best fix.  And it's not clear why this issue
> doesn't exist in Emacs.  But there are several regular expressions in
> org-export-latex-special-chars that call
> org-export-latex-treat-backslash-char with a nil value for
> string-after.  The regular expression that matched "MB&A" is
> "\\(.\\|^\\)\\(&\\)".  So there is no (match-string 3).
>
> Here's a document that generates the exception:
>
> --8<---------------cut here---------------start------------->8---
> * Header
>
> MB&A
>
> * Footer
> --8<---------------cut here---------------end--------------->8---
>
> Here's the traceback:
>
> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>  string-match("^[ \n	]" nil)
>  (not (string-match "^[ \n	]" string-after))
>  (and (not (string-match "^[ \n	]" string-after)) (not (string-match  
> "[ 	]\\'\\|^" string-before)))
>  (cond ((member ... org-html-entities) (concat string-before "$\ 
> \" ... "$")) ((and ... ...) (org-export-latex-protect-string ...))  
> ((not ...) (org-export-latex-protect-string ...)) ((and ... ...)  
> (org-export-latex-protect-string ...)) (t (org-export-latex-protect- 
> string ...)))
>  org-export-latex-treat-backslash-char("B" nil)
>  #<compiled-function (c) "...(304)" [sub-superscript match-data  
> match-data match-data match-data c re-search-forward nil t get-text- 
> property 2 org-protected match-string ("\\$" "$") "\\$" replace- 
> match 1 "$" 3 ("&" "%" "#") "\\" "..." org-export-latex-protect- 
> string "\\ldots{}" "~" 0 face org-link "\\~" "\\~{}" ("{" "}") match- 
> data (...) org-inside-LaTeX-fragment-p (...) (...) org-export-latex- 
> treat-backslash-char "" ("_" "^") (...) org-export-latex-treat-sub- 
> super-char] 7>("\\(.\\|^\\)\\(&\\)")
>  mapc-internal(#<compiled-function (c) "...(304)" [sub-superscript  
> match-data match-data match-data match-data c re-search-forward nil  
> t get-text-property 2 org-protected match-string ("\\$" "$") "\\$"  
> replace-match 1 "$" 3 ("&" "%" "#") "\\" "..." org-export-latex- 
> protect-string "\\ldots{}" "~" 0 face org-link "\\~" "\\~{}" ("{"  
> "}") match-data (...) org-inside-LaTeX-fragment-p (...) (...) org- 
> export-latex-treat-backslash-char "" ("_" "^") (...) org-export- 
> latex-treat-sub-super-char] 7> ("^\\([^\n$]*?\\|^\\)\\(\\\\?\\$\\)\\ 
> ([^\n$]*\\)$" "\\([a-za-z0-9]+\\|[ 	\n]\\|\\b\\|\\\\\\)\\(_\\|\\^\\)\ 
> \([a-za-z0-9]+\\|[ 	\n]\\|[:punct:]\\|{[a-za-z0-9]+}\\|([a-za-z0-9]+) 
> \\)" "\\(.\\|^\\)\\(\\\\\\)\\([ 	\n]\\|[a-zA-Z&#%{}\"]+\\)" "\\(.\\|^ 
> \\)\\(&\\)" "\\(.\\|^\\)\\(#\\)" "\\(.\\|^\\)\\(%\\)" "\\(.\\|^\\)\\ 
> ({\\)" "\\(.\\|^\\)\\(}\\)" "\\(.\\|^\\)\\(~\\)" "\\(.\\|^\\)\\(\\.\ 
> \.\\.\\)"))
>  mapc(#<compiled-function (c) "...(304)" [sub-superscript match-data  
> match-data match-data match-data c re-search-forward nil t get-text- 
> property 2 org-protected match-string ("\\$" "$") "\\$" replace- 
> match 1 "$" 3 ("&" "%" "#") "\\" "..." org-export-latex-protect- 
> string "\\ldots{}" "~" 0 face org-link "\\~" "\\~{}" ("{" "}") match- 
> data (...) org-inside-LaTeX-fragment-p (...) (...) org-export-latex- 
> treat-backslash-char "" ("_" "^") (...) org-export-latex-treat-sub- 
> super-char] 7> ("^\\([^\n$]*?\\|^\\)\\(\\\\?\\$\\)\\([^\n$]*\\)$" "\\ 
> ([a-za-z0-9]+\\|[ 	\n]\\|\\b\\|\\\\\\)\\(_\\|\\^\\)\\([a-za-z0-9]+\\| 
> [ 	\n]\\|[:punct:]\\|{[a-za-z0-9]+}\\|([a-za-z0-9]+)\\)" "\\(.\\|^\\) 
> \\(\\\\\\)\\([ 	\n]\\|[a-zA-Z&#%{}\"]+\\)" "\\(.\\|^\\)\\(&\\)" "\\(. 
> \\|^\\)\\(#\\)" "\\(.\\|^\\)\\(%\\)" "\\(.\\|^\\)\\({\\)" "\\(.\\|^\ 
> \)\\(}\\)" "\\(.\\|^\\)\\(~\\)" "\\(.\\|^\\)\\(\\.\\.\\.\\)"))
>  org-export-latex-special-chars(t)
>  org-export-latex-content("\nMB&A\n\n")
>  org-export-latex-first-lines(nil)
>  org-export-as-latex(nil nil nil nil nil nil)
>  org-export-as-pdf(nil)
>  call-interactively(org-export-as-pdf)
>  command-execute(org-export-as-pdf t)
>  execute-extended-command(nil)
>  call-interactively(execute-extended-command)
> ---
> lisp/org-export-latex.el |    1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/lisp/org-export-latex.el b/lisp/org-export-latex.el
> index fa6a0e4..60795fb 100644
> --- a/lisp/org-export-latex.el
> +++ b/lisp/org-export-latex.el
> @@ -976,6 +976,7 @@ The conversion is made depending of STRING- 
> BEFORE and STRING-AFTER."
> 	 (concat string-before "$\\"
> 		 (or (cdar (member (list string-after) org-html-entities))
> 		     string-after) "$"))
> +	((null string-after) (concat string-before "\\"))
> 	((and (not (string-match "^[ \n\t]" string-after))
> 	      (not (string-match "[ \t]\\'\\|^" string-before)))
> 	 ;; backslash is inside a word
> -- 
> 1.5.6.3
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[-- Attachment #1.2: Type: text/html, Size: 6754 bytes --]

[-- Attachment #2: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-12-21 11:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-21  1:36 [PATCH] Fix XEmacs "wrong type error" in org-export-as-pdf Hugh Daschbach, Hugh Daschbach
2008-12-21 11:49 ` Carsten Dominik

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).