radian-software / straight.el

🍀 Next-generation, purely functional package manager for the Emacs hacker.
MIT License
2.75k stars 151 forks source link

Is this possible to download and build only a single file from git repo? #285

Open valignatev opened 6 years ago

valignatev commented 6 years ago

Hi! First I want to say that straight.el is freaking awesome I don't even have words to describe it! Second, I wonder if there is a way to download and build only a single file from repo. Basically, I want to install font-lock+.el from emacsmirror repo for emacswiki. It's here: https://github.com/emacsmirror/emacswiki.org/blob/master/font-lock+.el

From what I've read in the readme, there is a :files which can customize how symlinks are built, but if I understand things correctly, it'll still download whole repo to my computer (which I don't want, becase emacswiki repo is huge).

Do you have any tips? Am I missing something?

valignatev commented 6 years ago

Regarding my particular case, I just found out that there is a https://github.com/emacsmirror/font-lock-plus which I can install with straight recipe I already know how to build. But the original question about downloading only single file still relevant :)

raxod502 commented 6 years ago

Git doesn't provide any way for you to clone only part of a repository, so straight.el doesn't provide any way to do this either.

It would be a useful feature to have, so if you have any suggestions about how it could be implemented I'm all ears.

It might be possible to do it with the same machinery used to support #149. I would have to muse on this.

See also https://github.com/raxod502/straight.el/pull/284 which might be useful for reducing clone sizes (although I'm not sure if shallow cloning is viable in most cases).

[Of course, the real problem here is Drew. If he'd package his code properly then people wouldn't have problems downloading it. But that's water under the bridge.]

valignatev commented 6 years ago

Thanks for the in-depth and fast answer! Git provides git archive --remote=url BRANCH file_name. Although GitHub doesn't support it AFAIK. It supports downloading raw files though, by constructing https://github.com/user/repository/raw/branch/filename URL. I already predict how painful such implementation might be in the code and that it's a really rare use-case (although if we consider Spacemacs discussion, there might be some gains potentially).

raxod502 commented 6 years ago

I don't think it'll be too bad once #149 is implemented. I added a comment there to explain my idea. There can just be a recipe keyword or something that specifies a single file to use (or multiple, but that would be slower), and then it can download the single file and manage its revisions with the .straight-head file as in the tarball case.

valignatev commented 6 years ago

Won't be saying that I fully understand the plan, but it sounds good, thanks!

raxod502 commented 6 years ago

Out of curiosity, why not https://github.com/emacsmirror/font-lock-plus?

valignatev commented 6 years ago

Oh, that's exactly what I did eventually, I should've been clearer here: https://github.com/raxod502/straight.el/issues/285#issuecomment-397787586 :)

raxod502 commented 6 years ago

Wow, I totally missed that when I re-read this thread. Sorry :(

zzantares commented 4 years ago

Hello!, somewhat having the same question, @raxod502 how do I tell straight.el to pull the package from a specific URL like this? https://www.emacswiki.org/emacs/download/hl-line%2b.el, because it seems to not be in the emacsmirror repo:

Could not find package hl-line+ in recipe repositories: (org-elpa melpa gnu-elpa-mirror emacsmirror-mirror)
raxod502 commented 4 years ago

@ZzAntares this is unsupported. However, that package can be pulled from Emacsmirror under the name hl-line-plus :)