dash-docs-el / helm-dash

Browse Dash docsets inside emacs
510 stars 59 forks source link

Refactor install docset functions #176

Open canatella opened 5 years ago

canatella commented 5 years ago

As of today, they are docsets named for example Ruby_on_Rails_4 or Ruby_on_Rails_5 that contains a top level directory in their archived named "Ruby on Rails". This causes multiple problems.

  1. When using helm-dash-ensure-package-installed, helm-dash checks for Ruby_on_Rails_4 in the docsets path but it does not find it as it is named after the top directory in the archive, "Ruby on Rails".

  2. It's not possible to install both Ruby_on_Rails_4 and Ruby_on_Rails_5 docsets.

To fix this, this pull requests refactors the code for helm-dash-install-docset and helm-dash-async-install-docset to share more codes by making the synchronous function call the asynchronous function. To simplify the asynchronous function, macros are used as they are expanded at compile time and so can be used in the async-start lambda. With this in place, the install function is made to strip the top level directory of a docset tarball and install in a directory named after the original docset name. The helm-dash-docset-installedp function is updated to check for the right name.

The helm-dash-ensure-docset-installed function is also changed to use the asynchronous install method to avoid blocking the Emacs initialization process.