reddit / emacs

[ANN]: vc-use-package

slinchisl · 2022-12-22 16:32
[deleted] · 2022-12-22 17:34
[deleted]
alternateved · 2022-12-22 17:36
Amazing! Thanks once more.
m4xxed_v1 · 2022-12-23 08:03
Wait, since when is use-package builtin?!?!? Did I miss that? Damn, Emacs develops fast sometimes! And yes please continue this, I wanted to switch to a built-in alternative to use-package+straight for ages!
slinchisl · 2022-12-23 08:58
> Wait, since when is use-package builtin?!?!? > > Did I miss that? Damn, Emacs develops fast sometimes! Indeed! This change was made [relatively recently](https://git.savannah.gnu.org/cgit/emacs.git/commit/?h=emacs-29&id=e950f5a663ad3501e50f43ef6c0a7fd220e0c1f2), but still in time for Emacs 29!
oldjawbone · 2022-12-23 11:46
This looks cool, thanks! Is it always necessary to include :fetcher and :repo parameters? Or would it be possible to do something like ":vc t" to initiate package-vc-install on the package name? For example: (use-package vertico :vc t :init (vertico-mode)) would initiate a call to (package-vc-install 'vertico) EDIT: Sometimes the feature name and the package name are different, as in the case of tex / auctex, so it might be necessary to allow a package name instead of t, for example: (use-package tex :vc auctex)
slinchisl · 2022-12-23 12:50
> Or would it be possible to do something like ":vc t" to initiate package-vc-install on the package name? > > For example: > > […] > > would initiate a call to (package-vc-install 'vertico) I've never seen `package-vc-install` take a symbol before; how does that work? Is there some alist in which one can put the repository information beforehand?
terminal_cope · 2022-12-23 14:05
This seems great. Has there been talk of merging this directly into use-package?
slinchisl · 2022-12-23 14:41
This would be ideal, but I think my mind is poisoned at this point :). To quote the conclusion: > As I’ve said in the corresponding Reddit post, now that both package-vc.el and use-package are built-in, someone should really add this to Emacs proper. Alas, since I copied the idea and most of the initial implementation from quelpa-use-package—and thus copyright assignment is a bit iffy—it will not be me. Still, implementing this from scratch does not sound so hard. If anyone feels inspired to do exactly this, I’d be delighted!
oldjawbone · 2022-12-23 15:20
I've haven't looked into it too deeply, but it seems that `package-vc-install` can take a symbol in certain cases, when it can find the VC data on its own from somewhere. (Not sure where it gets it, but again, haven't looked into it too far.) Sometimes it returns a "no VC data" error. So, it's not as straightforward as I'd hoped. ;)
github-alphapapa · 2022-12-23 18:09
I'm not an expert, but I don't think your mind is "poisoned" so that you would be ineligible to contribute a from-scratch implementation of this feature. It's straightforward to code, just a matter of rearranging some symbols and calling existing functions. There are only so many ways one could do such a thing. It's not a very creative endeavor. So I'd encourage you to take the knowledge you have, sit down at an empty buffer, type out a new implementation of the feature, and contribute it to emacs.git. :)
slinchisl · 2022-12-23 20:20
Ah, I see. I tried coming up with something [here](https://github.com/slotThe/vc-use-package/commit/c0adbf0a6931d6d4a5d537eaebd52b17ffa90354). Not to say I'm confident in this, but `(use-package package :vc t)` should work iff `(package-vc-install 'package)` works on its own :)
art_else · 2022-12-23 22:59
Just posted this on the GH repo: [https://github.com/slotThe/vc-use-package/issues/3#issue-1509828779](https://github.com/slotThe/vc-use-package/issues/3#issue-1509828779) This could be my config, but am unsure what the problem is. I try to fetch following package: `(use-package expenses :vc (:fetcher "github" :repo "md-arif-shaikh/expenses")` And get this error below. Before changing to `package-vc` I used `straight` with `use-package` just fine. Any ideas? Debugger entered--Lisp error: (file-error "[https://melpa.org/packages/elpa-packages.eld](https://melpa.org/packages/elpa-packages.eld)" "Not found") signal(file-error ("[https://melpa.org/packages/elpa-packages.eld](https://melpa.org/packages/elpa-packages.eld)" "Not found")) package--with-response-buffer-1("[https://melpa.org/packages/](https://melpa.org/packages/)" #f(compiled-function () #<bytecode -0x15ea84ea0ecdb6ba>) :file "elpa-packages.eld" :async nil :error-function #f(compiled-function () #<bytecode -0x3d0ec9bee8a587c>) :noerror nil) package--download-one-archive(("melpa" . "[https://melpa.org/packages/](https://melpa.org/packages/)") "elpa-packages.eld" nil) package-vc--download-and-read-archives() package-vc--archives-initialize() package-vc-install("[https://github.com/md-arif-shaikh/expenses](https://github.com/md-arif-shaikh/expenses)" expenses nil nil) vc-use-package--install(:fetcher "[https://github.com/](https://github.com/)" :repo "md-arif-shaikh/expenses" :name expenses) apply(vc-use-package--install (:fetcher "[https://github.com/](https://github.com/)" :repo "md-arif-shaikh/expenses" :name expenses)) (if (package-installed-p 'expenses) nil (apply #'vc-use-package--install '(:fetcher "[https://github.com/](https://github.com/)" :repo "md-arif-shaikh/expenses" :name expenses)))
oldjawbone · 2022-12-24 05:40
Awesome! I’ll give it a try.
wunderspud7575 · 2022-12-25 22:42
Nice. I didnt look at the code, but, with the keyword fetcher specifying github, why is it still necessary to specify the backend keyword? Seems like that could be designed out of the UI for known fetchers?
AsterOps · 2022-12-27 09:28
I used your snippet from tak [blog post](https://tony-zorman.com/posts/2022-11-30-package-vc-install.html#customising-package-vc-install) which is great and works but I have a problem with that improvement. Does it work with built-in `use-package`? I've following configuration in my `init.el`: ``` (require 'use-package-ensure) (setq use-package-always-ensure t) (unless (package-installed-p 'vc-use-package) (package-vc-install "https://github.com/slotThe/vc-use-package")) (require 'vc-use-package) ``` and after evaluating installation of sample package: ``` (use-package math-delimiters :vc (:fetcher github :repo oantolin/math-delimiters)) ``` I receive an error: ``` Error (use-package): Failed to parse package math-delimiters: use-package: :vc declaration contains unknown keywords: :fetcher. Known keywords are: (:fetcher :repo :rev :backend) ```
slinchisl · 2022-12-28 07:13
It's not! Instructions like `:vc (:fetcher github :repo blah/blah)` work completely fine! I'm currently working on a redesign of the whole thing that should be more intuitive (using instead the keywords present in `package-vc-selected-packages`), but that has a different goal (namely, getting this merged into Emacs)
slinchisl · 2022-12-28 07:28
Thanks, this should be fixed by https://github.com/slotThe/vc-use-package/commit/0c18a5fc91f3a7a7e0cb0672a9dc14a61af4783b I received some patches (like ripping out the `dash.el` dependency) and apparently I should've read them a little bit more carefully! Also do note that `packag-vc.el` is a little in flux itself at the moment (with arguments being shuffled around), so please do report any issues with the package straight away :)
wunderspud7575 · 2022-12-28 10:44
Cool, am glad to hear you're pushing it forward. This will be a great addition!
AsterOps · 2022-12-28 17:33
Thanks! Any chance to include this in emacs core as previously `use-package` or new `vc-package`? :)
slinchisl · 2022-12-30 08:17
[Working on it!](https://lists.gnu.org/archive/html/bug-gnu-emacs/2022-12/msg02500.html)