Magit
Magit is a complete text-based user interface to Git. It fills the glaring gap between the Git command-line interface and various GUIs, letting you perform trivial as well as elaborate version control tasks with just a couple of mnemonic key presses. Magit looks like a prettified version of what you get after running a few Git commands but in Magit every bit of visible information is also actionable to an extent that goes far beyond what any Git GUI provides and it takes care of automatically refreshing this output when it becomes outdated. In the background Magit just runs Git commands and if you wish you can see what exactly is being run, making it possible for you to learn the git command-line by using Magit1.
Actually, Emacs already has a built-in version control package (aptly named vc
). But to me the UI is rather cryptic. I’ve used magit
since forever, and old habit die hard.
Installation
use-package
|
|
Notes:
magit-revision-show-gravatars
will enable gravatars when viewing commits. The service used by default is Libgravatar.
extensions
There are lots of extensions for magit which adds more features or functionalities. These are the ones I use:
git-link
Interactive Emacs functions that create URLs for files and commits in GitHub/Bitbucket/GitLab/… repositories2.
|
|
Notes:
git-link returns the URL for the current buffer’s file location at the current line number or active region.
git-link-commit returns the URL for the commit at point.
git-link-homepage returns the URL for the repository’s homepage.
All the URLs are added to the kill ring automatically.
git-messenger
git-messenger.el
is Emacs port of git-messenger.vim3.
git-messenger.el
provides function that popup commit message at current line. This is useful when you want to know why this line was changed.
|
|
git-timemachine
Walk through git revisions of a file4.
1 2 3 4 5 6 7
(use-package git-timemachine :ensure :after magit :config (with-eval-after-load 'general (+config/leader-go "Gt" 'git-timemachine-toggle)))
magit-todos
This package displays keyword entries from source code comments and Org files in the Magit status buffer. Activating an item jumps to it in its file. By default, it uses keywords from hl-todo, minus a few (like NOTE).
Projectile
Projectile is a project interaction library for Emacs. Its goal is to provide a nice set of features operating on a project level without introducing external dependencies (when feasible). For instance - finding project files has a portable implementation written in pure Emacs Lisp without the use of GNU find
(but for performance sake an indexing mechanism backed by external commands exists as well).
Installation
|
|
This is the basic configuration, however, projectile is highly configurable. This is how I setup my configuration for projectile:
|
|
Notes:
- if you use https://github.com/emacs-dashboard/emacs-dashboarddashboard, projectile will automatically set
dashboard-projects-backend
to'projectile
.
External tools
Projectile will work without any external dependencies out of the box. However, if you have various tools installed, they will be automatically used when appropriate to improve performance. If you use git, install the system package as well.
fd
File searching tool, if available, will be use as an alternative to git ls-files
.
ag / ripgrep
To benefit from the projectile-ag and projectile-ripgrep commands to perform file search, it’s recommended to install ag (the_silver_searcher) and/or rg (ripgrep). You should also install the Emacs packages ag
, ripgrep
or rg
if you want to make sure of Projectile’s commands projectile-ag and projectile-ripgrep.
|
|
Useful commands
projectile-find-file
, bound toSPC p f
in my configuration. Find file in current project.projectile-switch-project
, bound toSPC p p
, you can also switch to between open projects withSPC p q
.projectile-grep
, bound toSPC p s g
, search for text/regexp in project.projectile-replace
, bound toSPC p r
, replace in project.projectile-commander
, execute any projectile command with a single letter. See the variableprojectile-commander-methods
to see the list of methods used.projectile-find-other-file
, switch between files with the same name but different extensions (e.g.foo.h
tofoo.c
).projectile-run-shell-command-in-root
andprojectile-run-async-shell-comand-in-root
, bound toSPC p !
andSPC p &
, Run a shell command in the root of the project.- other commands described in the documentation.
Packages that interacts with projectile
diff-hl
diff-hl-mode
highlights uncommitted changes on the left side of the window (area also known as the “gutter”), allows you to jump between and revert them selectively5.
|
|
Perspective
The Perspective package provides multiple named workspaces (or “perspectives”) in Emacs, similar to multiple desktops in window managers like Awesome and XMonad, and Spaces on the Mac. Each perspective has its own buffer list and its own window layout, along with some other isolated niceties, like the xref ring. This makes it easy to work on many separate projects without getting lost in all the buffers. Switching to a perspective activates its window configuration, and when in a perspective, only its buffers are available (by default). Each Emacs frame has a distinct list of perspectives6.
|
|
Notes:
The persp-consult-source
is added to the consult-buffer-sources
for the consult-buffer
command. The prefix keybinding I use is SPC TAB
.