From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hugh Daschbach Subject: [PATCH] Fix XEmacs "wrong type error" in org-export-as-pdf Date: Sat, 20 Dec 2008 17:36:39 -0800 Message-ID: <871vw2til4.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LEDdR-0000iq-TR for emacs-orgmode@gnu.org; Sat, 20 Dec 2008 21:01:37 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LEDdP-0000iX-Dj for emacs-orgmode@gnu.org; Sat, 20 Dec 2008 21:01:36 -0500 Received: from [199.232.76.173] (port=40566 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LEDdP-0000iU-8F for emacs-orgmode@gnu.org; Sat, 20 Dec 2008 21:01:35 -0500 Received: from adsl-209-233-135-26.dsl.lsan03.pacbell.net ([209.233.135.26]:37732 helo=hdasch) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LEDdO-0008Ey-91 for emacs-orgmode@gnu.org; Sat, 20 Dec 2008 21:01:34 -0500 Received: from hugh by hdasch with local (Exim 4.69) (envelope-from ) id 1LEDFH-0003KT-Fx for emacs-orgmode@gnu.org; Sat, 20 Dec 2008 17:36:39 -0800 From: Hugh Daschbach List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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) #("\\(.\\|^\\)\\(&\\)") mapc-internal(# ("^\\([^\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(# ("^\\([^\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