Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cite autocomplete fails #27

Closed
neilernst opened this issue Apr 2, 2012 · 6 comments
Closed

Cite autocomplete fails #27

neilernst opened this issue Apr 2, 2012 · 6 comments

Comments

@neilernst
Copy link

If I write 'cite_' and hit Ctrl-Space, I get autocomplete for all words with "c" in the document. This document has two bib files if that might be a cause. The other file I tried with only one bib file is fine.

u'/Users/nernst/Dropbox/research/papers/techdebt12/techdebt.tex']
Welcome to thread Thread-3
7
Finished normally
0
Parsing log file
!TEX root =  /Users/nernst/Dropbox/research/papers/techdebt12/techdebt.tex
Jump to:  0 0
True
None
_etic

\bibliography{abbr-long,techdebt}
Files:
[u'abbr-long', u'techdebt']
/Users/nernst/Dropbox/research/papers/techdebt12/abbr-long.bib
/Users/nernst/Dropbox/research/papers/techdebt12/abbr-long.bib has 20 lines
Traceback (most recent call last):
  File "./sublime_plugin.py", line 236, in on_query_completions
  File "./latex_cite_completions.py", line 151, in on_query_completions
AttributeError: 'NoneType' object has no attribute 'group'
_etic

@inkytonik
Copy link

I have the same problem. I tracked it down to @comment entries in my .bib file. These entries are inserted by BibDesk to keep track of reference groups. The lines that cause the problem for me are:

@comment{BibDesk Smart Groups{

The completion code looks for lines that start with @ and then expects to be able to match them with this regexp:

    kp = re.compile(r'@[^\{]+\{(.+),')

which requires a comma at the end of the line. For the comment lines, this crashes producing the error that you are seeing (or at least I get the same message).

I work-around the problem by adding a ? after the comma in the regular expression. This allows completion to work, with a side-effect that the comment prefix is also offered up as a completion.

A proper fix would be to have a more complex check that lines beginning with @ are actually bib entries, not something else such as a comment.

@msiniscalchi
Copy link
Contributor

Oh goodness... and I thought I had tamed bib files :-( I can't promise a quick fix but I'll take a look. I am thinking about parsing the file differently for other reasons anyway...

@neilernst
Copy link
Author

After seeing #50, I wanted to add that my two bib files do not have @comment, but the longer one has a 2 line header

Automatically generated by Mendeley 1.3.1
Any changes to this file will be lost if it is regenerated by Mendeley.

and the 'abbr' file is a series of @string entries (these convert 'variables' in bib files to longer strings, e.g. ACM = "Associ. Computing Machinery"

@msiniscalchi
Copy link
Contributor

Closing for now, as this may be solved with new parsing code (please be patient)

@margru
Copy link

margru commented Mar 20, 2013

I suggest the following fast fix (at least, it is working for me):
line 369 of latex_cite_completions.py
keywords = [kp.search(line).group(1).decode('ascii','ignore') for line in bib if line[0] == '@']
should be changed to
keywords = [kp.search(line).group(1).decode('ascii','ignore') for line in bib if line[0] == '@' and kp.search(line)]

@ghost
Copy link

ghost commented Jun 11, 2013

Thanks, that solved my problems with Bibdesk generated bib files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants