Giter Site home page Giter Site logo

alvarogonzalezsotillo / diff-hl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dgutov/diff-hl

1.0 2.0 0.0 38.44 MB

Emacs package for highlighting uncommitted changes

License: GNU General Public License v3.0

Emacs Lisp 99.26% Makefile 0.74%

diff-hl's Introduction

About

diff-hl-mode highlights uncommitted changes on the left side of the window, allows you to jump between and revert them selectively.

For the usage instructions and the list of commands, see the Commentary section inside the file.

Tested with Git, Mercurial, Bazaar and SVN. May work with other VC backends, too.

The package also contains auxiliary modes:

  • diff-hl-dired-mode provides similar functionality in Dired.
  • diff-hl-margin-mode changes the highlighting function to use the margin instead of the fringe.
  • diff-hl-amend-mode shifts the reference revision back by one.
  • diff-hl-flydiff-mode implements highlighting changes on the fly. It requires Emacs 24.4 or newer.

Usage

Put this into your init script:

(global-diff-hl-mode)

Check out the Commentary section in each file for more detailed usage instructions.

Screenshots

diff-hl-mode

Top window: a buffer in this minor mode, bottom window: the corresponding diff.

screenie

diff-hl-dired-mode

screenie

diff-hl-margin-mode

screenie

Requirements

Emacs 24.3+.

Notes

  • By default diff-hl-mode uses the corresponding VC diff command, so it's only accurate when the buffer is in saved state. Check out diff-hl-flydiff-mode, it aims to handle unsaved buffers as well.

  • To use an alternative diff algorithm with Git, add a corresponding argument to vc-git-diff-switches, e.g. (setq vc-git-diff-switches '("--histogram")). Using the diff.algorithm option doesn't work because vc-git-diff calls git diff-index. diff-hl-flydiff-mode does not support alternative algorithms, because it uses the external diff program.

  • We conflict with other modes when they put indicators on the fringe, such as Flycheck. This is rarely a significant problem, since if you're using such a mode, you'd usually want to fix all errors and warnings before continuing, and then the conflicting indicators go away.

  • There's no fringe when Emacs is running in the console, but the navigation and revert commands still work. Consider turning diff-hl-margin-mode on, to show the indicators in the margin instead.

  • Frame-local and buffer-local values of line-spacing are not supported.

  • Fringe width up to 16 works best (because we can't define a bitmap with width above that number).

  • emacs-git-gutter shows indicators in the margin by default, allows you to customize how the indicators look more easily, and has a "stage hunk" command.

Integration

If you're using some package other than vc to commit changes, it might not run vc-checkin-hook after commits. In that case, you'll need to either add diff-hl-update to the hook it does run, or advise some function that's called in the buffer after its state has changed.

psvn

(advice-add 'svn-status-update-modeline :after #'diff-hl-update)

Magit

If you're using a version before 2.4.0, it defines magit-revert-buffer-hook (or magit-not-reverted-hook), which we use.

When using Magit 2.4 or newer, add this to your init script:

(add-hook 'magit-pre-refresh-hook 'diff-hl-magit-pre-refresh)
(add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh)

diff-hl's People

Contributors

dgutov avatar edkolev avatar epich avatar erickgnavar avatar holocronweaver avatar jamessan avatar mookid avatar pashky avatar phst avatar pythonnut avatar ryuslash avatar sunesimonsen avatar tarsius avatar walseb avatar wilfred avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.