Hello,

When I attempt to run M-x org-bibtex on a .org file with non-standard bibtex types that have a tag, they fail to export if org-bibtex-tags-are-keywords is set to t. This persists even if I add the bibtex type to org-bibtex-types.  I checked, and this problem persists with a minimal init file, and a minimal org file. I have also checked, and I get the same problem with Emacs 24.3.5 from emacsforosx.  I just started using org-bibtex so I do not know how far the bug goes back.

Here is a minimal example that gets the bug.


** Critique of Practical Reason  :ex:
:PROPERTIES:
:TITLE: Critique of Practical Reason
:BOOKTITLE: Practical Philosophy
:BTYPE: bookinbook
:CUSTOM_ID: Kant:1996a
:AUTHOR: Kant, Immanuel
:PAGES: 133--276
:TRANSLATOR: Gregor, Mary J
:EDITOR: Gregor, Mary J
:YEAR:  1996
:PUBLISHER: Cambridge University Press
:ADDRESS: Cambridge UK
:END: 



I press ``M-x org-bibtex'' it returns ``Bibtex error on "Critique of Practical Reason"". This error does not occur if I change ``BTYPE" to ``book'' or if I remove the tag ``:ex:'' from the headline. As I noted above, I added ``bookinbook'' to the org-bibtex-types and added the appropriate fields there and in org-bibtex-fields.



Here is a minimal init:

(setq org-bibtex-types
  '((:article
     (:description . "An article from a journal or magazine")
     (:required :author :title :journal :year)
     (:optional :volume :number :pages :month :note :annote :url :abstract :keywords :file :uri))
    (:book
     (:description . "A book with an explicit publisher")
     (:required (:editor :author) :title :publisher :year)
     (:optional (:volume :number) :series (:address :location) :edition :month :note :annote :url :abstract :keywords :file :uri))
    (:bookinbook
     (:description . "A part of a book, which could be, and once was, its own book.")
     (:required :title (:chapter :pages) :publisher :year :booktitle)
     (:optional :crossref :author :editor :volume :translator :number :series :type :address :location :edition :note :annote :url :abstract :keywords :file :uri))
    (:booklet
     (:description . "A work that is printed and bound, but without a named publisher or sponsoring institution.")
     (:required :title)
     (:optional :author :howpublished (:address :location) :month :year :note :annote :url :abstract :keywords :file :uri))
    (:conference
     (:description . "")
     (:required :author :title :booktitle :year)
     (:optional :editor :pages :organization :publisher (:address :location) :month :note :annote :url :abstract :keywords :file :uri))
    (:inbook
     (:description . "A part of a book, which may be a chapter (or section or whatever) and/or a range of pages.")
     (:required (:author :editor) :title (:chapter :pages) :publisher :year)
     (:optional :crossref (:volume :number) :series :type (:address :location) :edition :month :note :annote :url :abstract :keywords :file :uri))
        (:incollection
     (:description . "A part of a book having its own title.")
     (:required :author :title :booktitle :publisher :year)
     (:optional :crossref :editor (:volume :number) :series :type :chapter :pages (:address :location) :edition :month :note :annote :url :abstract :keywords :file :uri))
    (:inproceedings
     (:description . "An article in a conference proceedings")
     (:required :author :title :booktitle :year)
     (:optional :crossref :editor (:volume :number) :series :pages (:address :location) :month :organization :publisher :note :annote :url :abstract :keywords :file :uri))
    (:manual
     (:description . "Technical documentation.")
     (:required :title)
     (:optional :author :organization (:address :location) :edition :month :year :note :annote :url :abstract :keywords :file :uri))
    (:mastersthesis
     (:description . "A Master’s thesis.")
     (:required :author :title :school :year)
     (:optional :type (:address :location) :month :note :annote :url :abstract :keywords :file :uri))
    (:misc
     (:description . "Use this type when nothing else fits.")
     (:required)
     (:optional :author :crossref :booktitle :date :title :howpublished :month :year :note :annote :location :url :abstract :keywords :file :uri))
    (:phdthesis
     (:description . "A PhD thesis.")
     (:required :author :title :school :year)
     (:optional :type (:address :location) :month :note :annote :url :abstract :keywords :file :uri))
    (:proceedings
     (:description . "The proceedings of a conference.")
     (:required :title :year)
     (:optional :editor (:volume :number) :series (:address :location) :month :organization :publisher :note :annote :url :abstract :keywords :file :uri))
    (:techreport
     (:description . "A report published by a school or other institution.")
     (:required :author :title :institution :year)
     (:optional :type (:address :location) :month :note :annote :url :abstract :keywords :file :uri))
    (:unpublished
     (:description . "A document having an author and title, but not formally published.")
     (:required :author :title :note)
     (:optional :month :year :annote :url :abstract :keywords :file :uri))) )

(setq org-bibtex-fields
  '((:address      . "Usually the address of the publisher or other type of institution.  For major publishing houses, van Leunen recommends omitting the information entirely.  For small publishers, on the other hand, you can help the reader by giving the complete address.")
    (:annote       . "An annotation.  It is not used by the standard bibliography styles, but may be used by others that produce an annotated bibliography.")
    (:author       . "The name(s) of the author(s), in the format described in the LaTeX book.  Remember, all names are separated with the and keyword, and not commas.")
    (:booktitle    . "Title of a book, part of which is being cited.  See the LaTeX book for how to type titles.  For book entries, use the title field instead.")
    (:chapter      . "A chapter (or section or whatever) number.")
    (:crossref     . "The database key of the entry being cross referenced.")
    (:edition      . "The edition of a book for example, 'Second'.  This should be an ordinal, and should have the first letter capitalized, as shown here; the standard styles convert to lower case when necessary.")
    (:editor       . "Name(s) of editor(s), typed as indicated in the LaTeX book.  If there is also an author field, then the editor field gives the editor of the book or collection in which the reference appears.")
    (:howpublished . "How something strange has been published.  The first word should be capitalized.")
    (:institution  . "The sponsoring institution of a technical report.")
    (:journal      . "A journal name.")
    (:key          . "Used for alphabetizing, cross-referencing, and creating a label when the author information is missing.  This field should not be confused with the key that appears in the \cite command and at the beginning of the database entry.")
    (:month        . "The month in which the work was published or, for an unpublished work, in which it was written.  You should use the standard three-letter abbreviation,")
    (:note         . "Any additional information that can help the reader.  The first word should be capitalized.")
    (:number       . "Any additional information that can help the reader.  The first word should be capitalized.")
    (:organization . "The organization that sponsors a conference or that publishes a manual.")
    (:pages        . "One or more page numbers or range of numbers, such as 42-111 or 7,41,73-97 or 43+ (the ‘+’ in this last example indicates pages following that don’t form simple range). BibTEX requires double dashes for page ranges (--).")
    (:publisher    . "The publisher’s name.")
    (:school       . "The name of the school where a thesis was written.")
    (:series       . "The name of a series or set of books.  When citing an entire book, the the title field gives its title and an optional series field gives the name of a series or multi-volume set in which the book is published.")
    (:title        . "The work’s title, typed as explained in the LaTeX book.")
    (:type         . "The type of a technical report for example, 'Research Note'.")
    (:volume       . "The volume of a journal or multi-volume book.")
    (:year         . "The year of publication or, for an unpublished work, the year it was written.  Generally it should consist of four numerals, such as 1984, although the standard styles can handle any year whose last four nonpunctuation characters are numerals, such as '(about 1984)'")
    (:url          . "A URL for the reference")
    (:uri          . "Another common url field")
    (:annote       . "Annotation is typically not exported")
    (:abstract     . "Abstract for annotated bibliography")
    (:keywords     . "Keywords for sorting with ebib")
    (:file         . "A local file path used by ebib to open the reference in an appropriate application")
    (:location     . "The location published")

))

(setq org-bibtex-tags-are-keywords t)
(setq org-bibtex-export-arbitrary-fields nil)
(setq org-bibtex-prefix nil)



It may also be useful to note that if I set ``org-bibtex-prefix'' to "bib" and set ``org-bibtex-export-arbitrary-fields'' to t (and of course edit the property names in my .org file appropriately), I get an error even with standard bib types. 

Below is the bug report.

Thanks so much for your help,
All the best,
Leonard

Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

     http://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org-mode mailing list.
------------------------------------------------------------------------


Emacs  : GNU Emacs 24.3.1 (x86_64-apple-darwin13.1.0, NS apple-appkit-1265.19)
 of 2014-03-15 on macintosh-2.home
Package: Org-mode version 8.2.5h (8.2.5h-82-gd91d4b-elpaplus @ /Users/leonardaveryrandall/.emacs.d/elpa/org-plus-contrib-20140324/)

current state:
==============
(setq
 org-tab-first-hook '(org-hide-block-toggle-maybe
      org-src-native-tab-command-maybe
      org-babel-hide-result-toggle-maybe
      org-babel-header-arg-expand)
 org-speed-command-hook '(org-speed-command-default-hook
  org-babel-speed-command-hook)
 org-occur-hook '(org-first-headline-recenter)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-confirm-shell-link-function 'yes-or-no-p
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-src-mode-hook '(org-src-babel-configure-edit-buffer
     org-src-mode-configure-edit-buffer)
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-babel-pre-tangle-hook '(save-buffer)
 org-mode-hook '(#[nil "\300\301\302\303\304$\207"
   [org-add-hook change-major-mode-hook org-show-block-all
    append local]
   5]
 #[nil "\300\301\302\303\304$\207"
   [org-add-hook change-major-mode-hook
    org-babel-show-result-all append local]
   5]
 org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point
  org-babel-execute-safely-maybe)
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
  org-cycle-hide-inline-tasks org-cycle-show-empty-lines
  org-optimize-window-after-visibility-change)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-bibtex-tags-are-keywords t
 )