1

I was wondering if anyone knows what's the function in bibtex that allows you to check if a field exist in an entry?

What I am trying to achieve is use the bibtex-clean-entry but as it is, it throws an error when checking @artcile entries without journal field.

1.What I wanna do is go through every entry

2.check if the journal field is existent

3.if not then make one and assign a placeholder

4.finally populate all the entries by assigning a value to the placeholder

At the moment I dunno how to do 2. and 3.

Basically I have the following: (bibtex-map-entries (lambda key start end) (bibtex-make-field t))) Which will try to make a bibtex field, but the problem is that it requires to pass in an key=>value, argument (which I don't know how) for the name of the field and its value as well.

Also the above code is not doing any checking whether the field already exist?

Any help to modifying it to do what I want will be highly appreciated it!

1 Answer 1

2

To check if a field exists, one approach is:

(defun bibtex-field-exists-p (field)
  (save-excursion
    (bibtex-beginning-of-entry)
    (let ((entry (bibtex-parse-entry)))
      (assoc field entry))))

If the field is missing, you could do something like:

(unless (bibtex-field-exists-p "journal")
    (bibtex-make-field '("journal" nil "missing" nil)))
2
  • Thank your for clarifying things, I hate this stack exchange approach where I can't up vote an answer due to the fact that I don't have enough points.
    – Kirk Walla
    Oct 25, 2018 at 12:50
  • sorry to bother again. I've tried the above suggestions but I keep getting an error about void variable. [code] Debugger entered--Lisp error: (void-variable %) bibtex-field-exists-p("journal") [code] Any ideas on what might be causing this. Google shows examples of something not being first defined or assigned a value
    – Kirk Walla
    Nov 22, 2018 at 0:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.