all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Bug: org-export-to-buffer throws error if buffer is empty or contains empty lines only [9.0 (release_9.0-6-gf56456)]
@ 2016-11-19 12:33 Stefan-W. Hahn
  2016-11-19 22:10 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan-W. Hahn @ 2016-11-19 12:33 UTC (permalink / raw)
  To: emacs-orgmode

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.

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

* Re: Bug: org-export-to-buffer throws error if buffer is empty or contains empty lines only [9.0 (release_9.0-6-gf56456)]
  2016-11-19 12:33 Bug: org-export-to-buffer throws error if buffer is empty or contains empty lines only [9.0 (release_9.0-6-gf56456)] Stefan-W. Hahn
@ 2016-11-19 22:10 ` Nicolas Goaziou
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2016-11-19 22:10 UTC (permalink / raw)
  To: Stefan-W. Hahn; +Cc: emacs-orgmode

Hello,

"Stefan-W. Hahn" <stefan.hahn@s-hahn.de> writes:

> 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)

Fixed. Thank you.

Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2016-11-19 22:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-19 12:33 Bug: org-export-to-buffer throws error if buffer is empty or contains empty lines only [9.0 (release_9.0-6-gf56456)] Stefan-W. Hahn
2016-11-19 22:10 ` Nicolas Goaziou

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.