Jump to content

Autocomplete words from a textfile?


Recommended Posts

Hi all,

 

Does this exist already: An Alfred workflow that will simply autocomplete a typed word from a textfile list of special words?

 

If not, does anyone have an idea of how to achieve this? I'm most comfortable in Python so I could probably start making this myself if somebody gave me some pointers.

 

 

The use case is auto-completion of references stored in a .bib file when I write academic articles in Typora using pandoc-crossref for references, however I have to remember all references in my head since there is no autocompletion from linked .bib file.

(I have asked for this before, however I was probably being too specific in my request, so now I'm making it more general just as an autocompletion system linked up to a file.)

Link to post
5 hours ago, gandalfsaxe said:

however I was probably being too specific in my request

 

Nope, your description was excellent last time. Specific is good. For my part, at least, that's exactly why I didn't offer to help…

 

The problem was that I thought you needed the .bib file properly parsing (i.e. it's not a simple case of "one entry per line"). Now I read it again, it looks like you might just be interested in the @article{NameYYYY, lines.

 

Is that the case? Does every single entry begin with a single line @article{NameYYYY,? Because that's makes it pretty easy to do.

 

If not, find me a Python or Go library that can parse the .bib file, and I'll whip something up for you.

Edited by deanishe
Link to post

Yes precisely! I'm only interesting in a single string for each BibTeX entry, namely the crossref field, which follows from the @type{crossref, lines.

 

The type itself can be one of 14 standard types (as I confirmed see here, here and here), where @article and @misc are the two most common types (at least for me). Is that still easy to do?

 

 

PS: How do you do monospace code formatting in this forum? It's not just the grave accent `like this` as in Github Markdown.

Link to post

Here you are. I've tried to extract the titles, too. You should be able to search on the title or the citekey, and then use ↩ to copy the citekey or ⌘↩ to copy the citekey and paste it into the active application.

 

You have to set the path to your BibTeX file in the workflow's configuration screen (it's currently pointing at the included sample file):

bibtex-config.thumb.png.3befac432bab86833eab946ad56294f9.png

Edited by deanishe
Link to post
  • 2 years later...

Thank you so much @deanishe for posting this. I was looking for a way to quickly query my BibTeX database and your script is perfect. ZotHero is great too, but probably too complex for my needs.

 

I have a quick question, though! Many of my title entries span across multiple lines (see screenshot). Would you recommend to write a script to change the BibTeX file, or is there an easy way to edit the Python script? Or, should I use a Python BibTeX parser? 

 

Thanks!!

Giovanni

 

bib.png.27d677e8ac0f666258c66e88d20c64e1.png

 

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...