Apparently it was caused by the following custom function for org-export-before-parsing-hook that I had to remove the subtree with "beameronly" tag:

(defun as/delete-ignored-heading (backend)
    (unless (equal backend 'beamer)

      ; remove subtree with beameronly tag
      (org-map-entries
       (lambda ()
         (progn
           (org-narrow-to-subtree)
           (org-cut-subtree)
           )
         )
       "+beameronly" 'tree)
      )
)

(setq org-export-before-parsing-hook '(as/delete-ignored-heading))


What I did wrong to cause this error? It worked for sum subtrees but not for others.




From: joon.ro@outlook.com
To: emacs-orgmode@gnu.org
Date: Sun, 26 Apr 2015 14:35:53 -0500
Subject: [O] export fails with "byte-code: Before first headline at position ..."

Hi,

When I try to export my org files I'm getting this error. For example:

byte-code: Before first headline at position 1 in buffer Blog.org<2>

I could not find any way to fix this - any help will be very appreciated.

Thank you,
Joon