tmalsburg/helm-bibtex

bibtex-map-entries

Closed this issue · 11 comments

"bibtex-map-entries" where can I find documentation on how to use this function to export av bibtex file omitting some fields?

This function is not defined in this package but in bibtex.el (I'm not the author of bibtex.el). As is typically the case in Emacs, the function itself has documentation. Try M-x apropos bibtex-map-entries.

However, you can also achieve the goal using helm bibtex. Open empty file, start helm bibtex, select all entries that you want in the output, select "Insert BibTeX entry" from the list of actions. Done.

Thanks! I will ask elsewhere. The solution you give me does not really achieve what I am aiming for: omite fields from the bibtex categories (such as "abstract"). Unless I misunderstood your solution. I want to export a bibtex file generated from a manuscript with each entry having a limited number fo fields (author, title, year, journal, for instance).

Oh, sorry, I misread. You could call bibtex-completion-candidates to obtain a list of all entries, then process them (drop fields), and create new bibtex entries using the code of bibtex-completion-make-bibtex as a template. Shouldn't be difficult.

Wait, you can drop fields by setting bibtex-completion-no-export-fields. So the helm bibtex approach works after all. :)

Thanks a lot. That with bibtex-completion-no-export-fields sounds like a solution indeed (!). Im a bit of a newbie in emacs plus I don't really know any emacs lisp. I found that variable inside bibtex-completion.el. Could I set it up in my init just using (setq bibtex-completion-no-export-fields t)? As for the bibtex-completion-candidates, I don't seem to be able to call that function with M-x bibtex-completion-candidates (I still don't understand why some functions I can call with M-x and some I can't), and whether I should call the function from within my org file that contains citations or from a bibtex file. Many questions, I know.

I have the following in my init.el to exclude the fields tags, note, pdf, and file:

(setq bibtex-completion-no-export-fields '(tags note pdf file))

As for the bibtex-completion-candidates, I don't seem to be able to call that function with M-x bibtex-completion-candidates (I still don't understand why some functions I can call with M-x and some I can't)

Yes, this stuff is confusing when you're new to Emacs. There are two types of functions: ordinary functions that you cannot call with M-x and so-called commands that you can. Commands are also called "interactive" functions. The former are meant to be used in code and the latter directly by users. Interactive functions can also be used in code but it's typically not advised since they are often not designed for that purpose.

and whether I should call the function from within my org file that contains citations or from a bibtex file.

That doesn't matter. bibtex-completion-candidates just gives you the content of your bibliography no matter from where you call it.

Hope that helps.

Thanks again very much. That was so clear! I wish I had read that somewhere long time ago :) I added (setq bibtex-completion-no-export-fields '(tags note pdf file)) to test in my init.el. I restarted Emacs, and used M-x org-ref-extract-bibtex-entries from within an org file where I have cite:References in the text, to get the entries only pertinent to the text. But kept getting the non-desirable fields. I don't know what I am doing wrong, and I don't really know how to use bibtex-completion-candidates to get a Bibtex file.

When setting bibtex-completion-no-export-fields you have to replace tags note pdf file with the fields that you'd like to ignore. Also note that org-ref-extract-bibtex-entries is a function defined in a different package. I doubt that it is affected by bibtex-completion-no-export-fields.

I don't really know how to use bibtex-completion-candidates to get a Bibtex file.

Quoting form my first reply:

Open empty file, start helm bibtex, select all entries that you want in the output, select "Insert BibTeX entry" from the list of actions. Done.

Ok, I see. I though that M-x org-ref-extract-bibtex-entries looks at bibtex-completion parameters.

Thanks. I have tested it including the fields I was interested in removing (such as abstract):

(setq bibtex-completion-no-export-fields '(tags annote abstract note pdf file))

Then I start helm bibtex. This open my whole bibliography file (library.bib).
I don't know how to select more than one entry.
When I press Enter, I get cite:Reference on the empty file.

What I was aiming at was at generating a list of bibtex entries from the manuscript that I am writing, not from all my library. And those entries I would like to exclude certain bibtex fields.

I don't know how to select more than one entry.

This is described in the helm documentation (M-SPC).

When I press Enter, I get cite:Reference on the empty file.

With Enter you get the default action. To select other actions, you have to press TAB.

Ok, I see! Now it works. Thanks for your patience.
I manage to include the selected bibtex entries in a plain text.
My questions are two:

  1. Is it possible to generate such list from the cite:ref in a buffer
  2. is it possible to sort the generated bibtex entries alphabetically.