Comments (4)
Hi again!
I've though about this some more, and there are several ways you can have some improved behavior. The first one is simply having that git diff
basically run in full whenever Emacs is idle, to update the selected buffer. The patch will look like this:
diff --git a/diff-hl-flydiff.el b/diff-hl-flydiff.el
index e366eec..56be107 100644
--- a/diff-hl-flydiff.el
+++ b/diff-hl-flydiff.el
@@ -36,6 +36,13 @@
"The idle delay in seconds before highlighting is updated."
:type 'number)
+(defcustom diff-hl-flydiff-always-check t
+ "Non-nil to always run the full status check of the current file.
+
+This will make it always pick up changes in HEAD even when commit is made
+outside of Emacs (e.g. in terminal) before any changes to buffers are made."
+ :type 'boolean)
+
(defvar diff-hl-flydiff-modified-tick nil)
(defvar diff-hl-flydiff-timer nil)
(make-variable-buffer-local 'diff-hl-flydiff-modified-tick)
@@ -47,14 +54,16 @@
(defun diff-hl-flydiff-update ()
(unless (or
(not diff-hl-mode)
- (eq diff-hl-flydiff-modified-tick (buffer-chars-modified-tick))
+ (unless diff-hl-flydiff-always-check
+ (eq diff-hl-flydiff-modified-tick (buffer-chars-modified-tick)))
(not buffer-file-name)
(file-remote-p default-directory)
(not (file-exists-p buffer-file-name)))
(diff-hl-update)))
(defun diff-hl-flydiff/modified-p (_state)
- (buffer-modified-p))
+ (or diff-hl-flydiff-always-check
+ (buffer-modified-p)))
;;;###autoload
(define-minor-mode diff-hl-flydiff-mode
Please go ahead and test it when you have the time. The downside is it will produce somewhat wasteful work, and in larger repositories git diff
can take a fair amount of time (up to 200ms in my testing). Whether it will translate in visible stutters sometimes or not, depends on the size of the projects and the speed of the machine.
Another approach would be to use after-focus-change-function
. Then, if you switch to a different window (terminal) and then back, diff-hl-flydiff
could notice that and update all the buffers in visible windows. The main downside is that not all scenarios will be covered: e.g. if you have a tiling WM and want to have Emacs and the terminal side-by-side, make a commit in the terminal and see the contents updated in Emacs more-or-less synchronously, this won't happen. But it will happen when you bring the focus to Emacs again, so maybe it can be a good compromise.
Let me know if you're still around and interesting in trying out the patches -- I will do one for the second option as well.
from diff-hl.
Hi! This actually seems to work fine for me.
Do you have some non-default settings maybe? Try writing a step-by-step reproduction scenario.
from diff-hl.
My settings
(use-package diff-hl
:config
(global-diff-hl-mode)
(diff-hl-flydiff-mode)
(if (not (display-graphic-p))
(diff-hl-margin-mode t)))
Instead of writing a textual description, a gif may give a better demonstration.
So, after saving and committing, the indicators are still there until I run vc-diff
, or revert-buffer
thingy
from diff-hl.
I can see it now. Is that a real nuisance? Do you know if similar editors have this behavior?
Something like VS Code aside, which likely plugs into inotify, which I'm not sure we can do. Not easily, at least.
The alternative would be running the equivalent of git status
on a timer, to see if it changed, and update whenever that happens. Which feels a little wasteful (I don't know) when you can just make an edit and revert to see the updated fringe. But I get the comfort of always seeing up-to-date indicators. Another common problem (which git status
wouldn't solve), is having the file updated after git checkout
. But having global-auto-revert-mode
enabled should take care of that.
from diff-hl.
Related Issues (20)
- Is there a way to prevent diff-hl send the run git command log into *messages*? HOT 2
- question: diff-hl-margin-local-mode HOT 1
- Feature request: stage region HOT 23
- Reverting fails when too close to another hunk HOT 11
- Improve Cross-Platform: Using absolute path to describe `patchfile`. HOT 15
- Feature request: provide more flexibility to set additional settings in vc-git-diff-switches HOT 4
- (un)staging changes in magit does not update file buffer fringe in `diff-hl-flydiff-mode` HOT 2
- diff-hl-flydiff-mode adds a new idle timer even if it already exists HOT 1
- diff-hl-dired-mode inside docker HOT 2
- `diff-hl-after-revert` is completely broken HOT 12
- void-variable revert-buffer-preserve-modes HOT 1
- Issue staging non-root project files HOT 18
- Frame-local diff-hl-margin-mode? HOT 1
- diff-hl-update-async can break magit-commit HOT 14
- Question about `margin-mode` HOT 4
- Margin mode not working HOT 5
- Not work on emacs 30? HOT 2
- Error running timer ‘track-changes--call-signal’: (cl-assertion-failed (eq tracker diff--track-changes)) HOT 7
- Usage of /dev/shm for temporary files not supported on FreeBSD HOT 2
- Set margin size only when there are file changes in `diff-hl-margin-mode` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diff-hl.