From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Stefan-W. Hahn" Subject: Bug: org-export-to-buffer throws error if buffer is empty or contains empty lines only [9.0 (release_9.0-6-gf56456)] Date: Sat, 19 Nov 2016 13:33:16 +0100 Message-ID: <20161119123316.GG9272@seven> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c84ph-0004L1-8x for emacs-orgmode@gnu.org; Sat, 19 Nov 2016 07:33:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c84pe-0001sM-5C for emacs-orgmode@gnu.org; Sat, 19 Nov 2016 07:33:25 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:54217) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c84pd-0001r4-Pz for emacs-orgmode@gnu.org; Sat, 19 Nov 2016 07:33:22 -0500 Received: from seven.home ([92.202.56.236]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.183]) with ESMTPSA (Nemesis) id 0M0sl5-1d34Og3rXL-00v9kJ for ; Sat, 19 Nov 2016 13:33:18 +0100 Received: from seven.home (localhost [127.0.0.1]) by seven.home (8.15.2/8.15.2/Debian-3) with ESMTPS id uAJCXGBQ025869 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 19 Nov 2016 13:33:16 +0100 Received: (from hs@localhost) by seven.home (8.15.2/8.15.2/Submit) id uAJCXGf9025853 for emacs-orgmode@gnu.org; Sat, 19 Nov 2016 13:33:16 +0100 Content-Disposition: inline List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Hello, when exporting buffers containing nothing or just empty lines, like: #+BEGIN_SRC emacs-lisp (with-temp-buffer (org-mode) (insert "") (org-export-to-buffer 'html "*Formatted Copy*" nil nil t t)) #+END_SRC then org-export-to-buffer throws an error: #+BEGIN_QUOTE Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil) org-export-to-buffer(html "*Formatted Copy*" nil nil t t) (progn (org-mode) (insert "") (org-export-to-buffer (quote html) "*Formatted Copy*" nil nil t t)) (unwind-protect (progn (org-mode) (insert "") (org-export-to-buffer (quote html) "*Formatted Copy*" nil nil t t)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (org-mode) (insert "") (org-export-to-buffer (quote html) "*Formatted Copy*" nil nil t t)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))) (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (org-mode) (insert "") (org-export-to-buffer (quote html) "*Formatted Copy*" nil nil t t)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) eval((let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (org-mode) (insert "") (org-export-to-buffer (quote html) "*Formatted Copy*" nil nil t t)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) nil) elisp--eval-last-sexp(nil) eval-last-sexp(nil) funcall-interactively(eval-last-sexp nil) call-interactively(eval-last-sexp nil nil) command-execute(eval-last-sexp) #+END_QUOTE Reason for this is located here: #+BEGIN_SRC emacs-lisp (defun org-export-to-buffer (backend buffer &optional async subtreep visible-only body-only ext-plist post-process) .. (let ((output (org-export-as backend subtreep visible-only body-only ext-plist)) (buffer (get-buffer-create buffer)) (encoding buffer-file-coding-system)) (when (and (org-string-nw-p output) (org-export--copy-to-kill-ring-p)) (org-kill-new output)) (with-current-buffer buffer (erase-buffer) (setq buffer-file-coding-system encoding) --> (insert output) (goto-char (point-min)) (and (functionp post-process) (funcall post-process))) (when org-export-show-temporary-export-buffer (switch-to-buffer-other-window buffer)) buffer))) #+END_SRC In the explained case the output is nil. This gives the error. With kind regards, Stefan Emacs : GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2016-10-23 Package: Org mode version 9.0 (release_9.0-6-gf56456 @ /home/hs/.emacs.d/git/org-mode/lisp/) -- Stefan-W. Hahn It is easy to make things. It is hard to make things simple.