Jump to content
gandalfsaxe

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.)

Share this post


Link to post
Posted (edited)
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

Share this post


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.

Share this post


Link to post

Could you upload a sample .bib file somewhere and post a link? Or post a URL to one. Then I'll have a look.

Share this post


Link to post
Posted (edited)

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

Share this post


Link to post

Thank you so much! That is exactly what I need. Much appreciated! :)

 

Where can I find the actual script you made? I see a reference to `citations.py`, but where is this python script?

Share this post


Link to post
1 hour ago, gandalfsaxe said:

Where can I find the actual script you made? I see a reference to `citations.py`, but where is this python script?

 

Right-click the Workflow name on the list and do “Open in Finder.” 

Share this post


Link to post
23 hours ago, gandalfsaxe said:

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

 

Write in Markdown and then convert it to BBCode using one of @vitor's workflows: MarkdownTransform.

Share this post


Link to post
Posted (edited)
46 minutes ago, Tsunami said:

As @deanishe's screenshot explains, you need a variable with the name BIBFILE. The value is the path to the file.

 

 

Oops, missed that. Works now, thanks.

Edited by gandalfsaxe

Share this post


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
×