[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: w3m-goto-url: Wrong type argument: char-or-string-p, nil on mailto

In [emacs-w3m : No.11796] Katsumi Yamaoka wrote:
>> Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil)
>>   insert(nil)
>>   (while body (insert (pop body)) (unless (bolp) (insert "\n")))

> I see.  That's due to exactly an emacs-w3m bug.  I'm going to
> fix it tomorrow.

Fixed in CVS; a patch is below.  Thanks for reporting this.
Derivatively, I realized that the *Backtrace* buffer doesn't
appear with Emacs having built on Cygwin in this case (that's
why I missed this bug :<).
--- w3m.el~	2012-04-12 09:45:33.000000000 +0000
+++ w3m.el	2012-04-13 04:40:37.554429500 +0000
@@ -8837,7 +8837,7 @@
 (defun w3m-goto-mailto-url (url &optional post-data)
   (let ((before (nreverse (buffer-list)))
 	comp info body buffers buffer function)
-    (setq url (w3m-decode-entities-string url))
+    (setq url (w3m-decode-entities-string (w3m-url-decode-string url)))
       (if (and (symbolp w3m-mailto-url-function)
 	       (fboundp w3m-mailto-url-function))
@@ -8858,7 +8858,7 @@
 	      (setq info (rfc2368-parse-mailto-url url)
 		    body (assoc "Body" info)
 		    info (delq body info)
-		    body (list (cdr body)))
+		    body (delq nil (list (cdr body))))
 	      (when post-data
 		(setq body (nconc body (list (if (consp post-data)
 						 (car post-data)
@@ -8887,13 +8887,18 @@
 	    (setq buffers nil)))))
     (when function
       (let (special-display-buffer-names
-	    special-display-regexps
-	    same-window-buffer-names
-	    same-window-regexps)
+	    special-display-regexps same-window-buffer-names
+	    same-window-regexps mod)
 	(funcall function buffer)
-	(while body
-	  (insert (pop body))
-	  (unless (bolp) (insert "\n")))))))
+	(when body
+	  (setq mod (buffer-modified-p))
+	  (search-forward (concat "\n" (regexp-quote mail-header-separator)
+				  "\n") nil 'move)
+	  (unless (bolp) (insert "\n"))
+	  (while body
+	    (insert (pop body))
+	    (unless (bolp) (insert "\n")))
+	  (set-buffer-modified-p mod))))))
 (defun w3m-convert-ftp-url-for-emacsen (url)
   (or (and (string-match "^ftp://?\\([^/@]+@\\)?\\([^/]+\\)\\(?:/~/\\)?" url)