M-x parsebib-find-next-item does not show up
Closed this issue · 11 comments
- Versions
emacs: 24.3.1 - .emacs
; bare bones
(require 'package)
(package-initialize)
(require 'parsebib)
;(load "parsebib.el")
;(load "/home/chaitanya/.emacs.d/elpa/parsebib-20150205.1305/parsebib.el")
C-h f parse-bib-next-item shows help about the function.
But, M-x parsebib-find-next-item does not show up. Says, No match.
Tried (load "parsebib.el") and also (load "absolute-path-to-parsebib.el"); both give same result as above.
When loading .el file do not byte compile to .elc files; although, I am not sure if this should be the case.
Since, parsebib is not working for me, I can't use helm-bibtex and therefore org-ref.
Might be related to tmalsburg/helm-bibtex#25
M-x parsebib-find-next-item
isn't supposed to turn anything up, because parsebib-find-next-item
isn't a command: it cannot be executed with M-x
.
I suspect you have the same problem as reported in tmalsburg/helm-bibtex#25, though. Have you tried restarting Emacs and reinstalling parsebib
?
Yep. I think they are related too.
I restarted emacs a zillion times. Also, I reinstalled parsebib a couple of times. Same result.
Can you tell me how I can test if parsebib is working the way it is supposed to work?
Weird...
You can test what parsebib
does by opening a .bib
file in Emacs and then do M-: (parsebib-find-next-item)
. That should return the name of the first item after point
, e.g.,
#("incollection" 0 12 (fontified t face font-lock-function-name-face))
This is the representation of a fontified string, the important part is the string at the beginning (here "incollection"
).
Then, without moving the cursor, do M-: (parsebib-read-entry “incollection”)
. That should return the fields of the entry as an alist.
If the first item is a @preamble
or @string
, use parsebib-read-preamble
or parsebib-read-string
instead, both of which take no arguments.
If that doesn’t return anything, could you post a few of your BibTeX entries in a gist or in this thread, so I can take a look at them? Thanks.
Both parsebib-find-next-item and parsebib-read-entry work in the bibtex
file that I used. But, obviously I only checked a couple of entries at the
top of the file.
I am not sure errors, if there are any, further down in the file would
cause errors in helm-bibtex.
Doing M-x helm-bibtex > pattern: /search term/ leads to fall back behavior.
Basically, it just shows 'Loading bibliography' and then if I just type the
search term and press enter, it just takes me to the end of the bib file
(which I think is the fallback behavior for helm-bibtex).
On Thu, Feb 19, 2015 at 11:07 PM, Joost Kremers notifications@github.com
wrote:
Weird...
You can test what parsebib does by opening a .bib file in Emacs and then
do M-: (parsebib-find-next-item). That should return the name of the
first item after point, e.g.,#("incollection" 0 12 (fontified t face font-lock-function-name-face))
This is the representation of a fontified string, the important part is
the string at the beginning (here "incollection").Then, without moving the cursor, do M-: (parsebib-read-entry
“incollection”). That should return the fields of the entry as an alist.If the first item is a @Preamble or @string, use parsebib-read-preamble
or parsebib-read-string instead, both of which take no arguments.If that doesn’t return anything, could you post a few of your BibTeX
entries in a gist or in this thread, so I can take a look at them? Thanks.—
Reply to this email directly or view it on GitHub
#3 (comment).
42
Try this:
-
Open your
.bib
file -
Go to the
*scratch*
buffer -
Copy & paste the following code (replace
"Bibliography.bib"
with the name of your.bib
file):(with-current-buffer "Bibliography.bib" (let ((entries (helm-bibtex-parse-bibliography))) (assoc "=key=" (car (last entries)))))
-
Put the cursor right after the last parenthesis and type
C-x C-e
The key of the last entry read should appear in the minibuffer.
This is what I get. The bib file is created by JabRef. JabRef opens the file just fine. I will also check if the file can be processed by a python bibtex module and post a link to the whole file shortly.
Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil)
#[(it) "�@\227�AB\207" [--cl-var--] 2](("Url" . "{http://link.aps.org/doi/10.1103/PhysRevB.81.121413}"))
mapcar(#[(it) "�@\227�AB\207" [--cl-var--] 2] (("Url" . "{http://link.aps.org/doi/10.1103/PhysRevB.81.121413}") ("Timestamp" . "{2013.07.23}") ("Publisher" . "{American Physical Society}") ("Owner" . "{chaitanya}") ("Numpages" . "{4}") ("Keywords" . "{Ru(0001), RuO2, CO oxidation}") ("Issue" . "{12}") ("File" . "{Sljivancanin10.pdf:Sljivancanin10.pdf:PDF}") ("Doi" . "{10.1103/PhysRevB.81.121413}") ("Volume" . "{81}") ("Pages" . "{121413}") ("Month" . "{Mar}") ("Year" . "{2010}") ("Journal" . "{Physical Review B}") ("Author" . "{\\v{S}ljivan\\v{c}anin, \\v{Z}eljko and Hammer, Bj\\o{}rk}") ("Title" . "{{CO} oxidation on fully oxygen covered {R}u(0001): {R}ole of step edges}") ("=type=" . #("Article" 0 7 (fontified t face font-lock-function-name-face))) ("=key=" . "Sljivancanin10")))
helm-bibtex-parse-bibliography()
(let ((entries (helm-bibtex-parse-bibliography))) (assoc "=key=" (car (last entries))))
(save-current-buffer (set-buffer "mynewrefs.bib") (let ((entries (helm-bibtex-parse-bibliography))) (assoc "=key=" (car (last entries)))))
(with-current-buffer "mynewrefs.bib" (let ((entries (helm-bibtex-parse-bibliography))) (assoc "=key=" (car (last entries)))))
eval((with-current-buffer "mynewrefs.bib" (let ((entries (helm-bibtex-parse-bibliography))) (assoc "=key=" (car (last entries))))) nil)
eval-last-sexp-1(nil)
eval-last-sexp(nil)
ad-Orig-call-interactively(eval-last-sexp nil nil)
call-interactively(eval-last-sexp nil nil)
I can parse the file without any problem with pybtex.
Here is the link to the full file if you want to have a look.
https://drive.google.com/file/d/0BzoeB0s5X2tYcjhiSzdQR2d4d3M/view?usp=sharing
I downloaded your file and tried to read it. On my machine, parsebib
has no problems with it. I'm using Emacs 24.4, though, so perhaps it's a problem with Emacs 24.3. I'm trying to set up a virtual machine with Emacs 24.3 so I can test that version. Will let you know ASAP.
Ok, I installed the VM and did some experimenting. The problem is not with parsebib
nor with helm-bibtex
. For some reason, the interaction of cl-loop
and --map
triggers a bug in (I think) cl-loop
that has apparently been fixed in Emacs 24.4. It's possible to work around it, but that has to be done in helm-bibtex
. I'll report the issue to the helm-bibtex
maintainer, but for now, to get things working again, you can replace the function helm-bibtex-parse-bibliograpy
with the following modified version:
(defun helm-bibtex-parse-bibliography ()
"Parse the BibTeX entries listed in the current buffer and
return a list of entry keys in the order in which the entries
appeared in the BibTeX files."
(goto-char (point-min))
(cl-loop
for entry-type = (parsebib-find-next-item)
while entry-type
unless (member-ignore-case entry-type '("preamble" "string" "comment"))
collect (-map (lambda (it)
(cons (downcase (car it)) (cdr it)))
(parsebib-read-entry entry-type))))
You can put this function in your ~/emacs.d/init.el
after (require 'helm-bibtex)
, or you can replace the function in helm-bibtex.el
and recompile the file.
The latest version of helm-bibtex
contains a fix for this issue. Do report back if you still have problems.
Works now. Thank you! @joostkremers @tmalsburg