mnewt / git-package

Install Emacs packages using use-package and git

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

git-package

Abandoned

git-package has been abandoned. I recommend you use straight.el instead.

git-package

A fast and simple way to install and manage Emacs packages from git repositories.

It is not monolithic. git-package doesn’t interfere with package.el or the use-package ensure mechanism when the :git keyword isn’t specified. So you can install a few packages via git and continue to install other packages from ELPA and MELPA.

Under the hood, it uses package.el to resolve and install dependencies, run build commands, and install Info files.

Features

  • A function to install git packages as needed from your Emacs config file.
  • Interactive commands to install, update, and delete git packages.
  • A :git keyword for use-package.
  • A workflow to use while developing Emacs packages.

Usage Examples

Simple

Use a string value to install the latest revision of the repository’s default branch.

Standalone

(git-package "https://github.com/mnewt/eg.el")

With use-package

(use-package eg
  :ensure t
  :git "https://github.com/mnewt/eg.el")

Advanced

Standalone

(git-package eg
             :url "https://github.com/mnewt/eg.el"
             :dir "eg"
             :files '("*.el" "another/dir/*.el")
             :ref "tags/1.0"
             :command "make")

With use-package

Add a :git keyword to a use-package declaration and the package will be automatically installed. git-package hooks into use-package’s :ensure mechanism to clone, byte compile, and add the package to the load path.

(use-package eg
  :ensure t
  :git (eg :url "https://github.com/mnewt/eg.el"
           :dir "eg"
           :files '("*.el" "another/dir/*.el")
           :ref "tags/1.0"
           :command "make"))

Configuration

The package config is a list where the first element is a symbol and the rest of the list is a Plist. The elements are described in more detail below.

(eg :url "https://github.com/mnewt/eg.el"
    :dir "eg"
    :files ("*.el" "another/dir/*.el")
    :ref "tags/1.0"
    :command "make")

Package config properties

(first element)

If the first element is a symbol, then it will be used as the name of the package. Otherwise, the name from the use-package declaration or the directory name is used. The name is used to track the package and identify it (e.g. when running git-package-upgrade-package).

:url

The Git Repository URL. Git will fetch the new and updated repository files from this URL.

:dir

The local directory where the files should be cloned. It is relative to the custom variable git-package-user-dir.

:files

The files which should be byte compiled. This can be specified as a string or list of strings. Glob style wildcards are accepted.

:ref

The Git Reference. A reference can be a commit hash, tag, or branch.

:command

Run a shell command in the package directory after cloning and before installing the package. This can be used to run build commands.

Commands

git-package-install

Check if a package is installed and install it if not.

git-package-reinstall

Reinstall a package. It is useful mainly if you have modified some of the package files and you want Emacs to pick up the changes. All you have to do is M-x git-package-reinstall RET and the package is byte compiled, autoloads are generated, and it is reloaded.

git-package-clean-unused

Delete any package directories in git-package-user-dir which have not been loaded using git-package.

git-package-upgrade

Upgrade a package.

git-package-upgrade-all-packages

Upgrade all packages.

Installation

Bootstrap

Install git-package and set it up to work with use-package.

(let ((dir (expand-file-name "git/git-package" user-emacs-directory)))
  (unless (file-exists-p dir)
    (make-directory dir 'parents)
    (shell-command
     (format "git clone https://github.com/mnewt/git-package '%s'" dir)))
  (add-to-list 'load-path dir)
  (require 'git-package-use-package
           (expand-file-name "git-package-use-package.el" dir))
  (git-package-setup-use-package))

Via MELPA

NOTE: =git-package= isn’t in MELPA yet After setting up package.el and use-package, install it in the normal way.

(use-package git-package
  :ensure t
  :config
  (git-package-setup-use-package))

Manually

Download git-package somewhere and load it.

(add-to-list 'load-path "path/to/git-package-use-package.el")
(require 'git-package-use-package)
(git-package-setup-use-package)

Related packages

Why make something new when there are already great alternatives out there? Because I can. Also, git-package is different in some key ways. I wanted something simple, fast, and targeted to the use cases I care about.

In my informal and subjective testing, I have found that the package.el=/=git-package combination can often be a second or more faster to load 200 packages than straight or quelpa.

straight.el

I used to use and still love straight.el but I wanted to do a couple things differently. For most packages I want to use package.el, which is well supported and fast. I don’t want to tinker with most of my packages; when I do want to contribute to them, I’ll create and configure a repo explicitly for that purpose. For those packages I’m working on, it’s likely I’ll want to check out a specific branch, tag, or commit. As of this writing, straight can’t do that.

quelpa

Quelpa can do this but it is much more complex, slower, and not actively maintained. Also, many packages which aren’t in ELPA/MELPA don’t fully adhere to the package.el specification. Quelpa doesn’t handle those cases gracefully but this package makes an effort to do so.

Make the logs in *git-package* useful.

Test install and activation for more themes.

Clean command should check if repo directories are clean before deleting them.

About

Install Emacs packages using use-package and git

License:GNU General Public License v3.0


Languages

Language:Emacs Lisp 100.0%