Git Product home page Git Product logo

vc-defer's Introduction

Introduction

This package makes (some) Emacs VC operations fast(er).

The Vc-Defer package aims to make Emacs faster by deferring non-essential work related to Emacs' built in "VC" mode, with a minimum negative impact. In particular, all VC commands should still work normally when invoked explicitly, even in buffers that Emacs has not yet determined the VC state for.

Warning: Some modes that depend on VC such as diff-hl will break, however.

Usage is simple: require the package, configure the list of problematic backends (there are no defaults), and enable vc-defer-mode (a global mode). For example:

(require 'vc-defer)
(add-to-list 'vc-defer-backends 'Hg)
(vc-defer-mode)

...or a similar use-package incantation:

(use-package vc-defer
  :config
  (add-to-list 'vc-defer-backends 'Hg)
  (vc-defer-mode))

The vc-defer customization group used for a similar effect.

Regardless of the configuration approach, when vc-defer-mode is on, opening files no longer enables VC mode for the set of configured backends. Instead, the per-file status in those backends are determined on a deferred, as needed, basis. The VC status will no longer be displayed in the mode line (at least, until the first VC command is issued), but basic operations like `find-file' will be fast. Emacs will still be slow when VC functionality is actually used, but at that point the performance issue will make more sense to the user.

Background

Emacs' built in VC implementation slows Emacs down. This is most evident when the VC backend is slow. The code refreshes information displayed in the mode line synchronously whenever a file is loaded. The rest of the VC subsystem is designed with this assumption; there is no support for deferring this work until the user explicitly invokes a command actually requires the status.

Evidence that users find this annoying is easy to find.

A thread in r/emacs on Reddit claimed that disabling VC mode was "The biggest performance improvement to Emacs I've made in years": http://redd.it/4c0mi3, and it amounts to:

(remove-hook 'find-file-hooks 'vc-find-file-hook)

This hack, however totally disables VC mode for the affected files. For example, later invoking "M-x vc-diff" results in an error.

VC has a supported ways of disabling itself, which are preferable to the above. Customizing the vc-ignore-dir-regexp variable can be used to disable it on a directory basis, and customizing the vc-handled-backends variable can be used to disable some or all backends entirely. Neither approach is satisfactory if the user still wants to use VC commands!

There are other threads. "Git slows Emacs to Death" at https://stackoverflow.com/questions/6724471/git-slows-down-emacs-to-death-how-to-fix-this and its companion piece "Mercurial slows Emacs to Death" at https://stackoverflow.com/questions/17323841/mercurial-slows-emacs-to-death-when-opening-saving-files. In each case, I find it telling that the user(s) did not find it easy to diagnose and mitigate the performance issues for themselves, which suggests that Emacs could do better here. There may be some hope to fix this problem in Emacs itself. See https://lists.gnu.org/archive/html/emacs-devel/2016-02/msg00440.html.

Until then, this little hack can ease the pain.

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

See LICENSE for details.

Disclaimer

This project is not an official Google project. It is not supported by Google and Google specifically disclaims all warranties as to its quality, merchantability, or fitness for a particular purpose.

vc-defer's People

Contributors

jcs090218 avatar matta avatar phst avatar syohex avatar tomfitzhenry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vc-defer's Issues

Cannot find package on MELPA

Hi, I could not find this package listed on MELPA. I'm currently using Spacemacs on the develop branch, but I couldn't install this through use-package either. So, I guess there are two questions:

  1. Are there plans to provide this on MELPA?
  2. What are the instructions for manual installation?

Thanks!

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.