Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In dired mode the diff-hl fringe markings keep flickering #92

Closed
hisnawi opened this issue Jul 8, 2017 · 24 comments
Closed

In dired mode the diff-hl fringe markings keep flickering #92

hisnawi opened this issue Jul 8, 2017 · 24 comments

Comments

@hisnawi
Copy link

hisnawi commented Jul 8, 2017

This is my setup:

  (use-package diff-hl
    :ensure t
    :diminish " D"
    :config
    ;; Highlight changed files in the fringe of Dired
    (add-hook 'dired-mode-hook 'diff-hl-dired-mode)
    (global-diff-hl-mode)
    ;; Fall back to the display margin, if the fringe is unavailable
    (unless (display-graphic-p) (diff-hl-margin-mode))
    ;; Highlight changes to the current file in the fringe
    (setq diff-hl-fringe-bmp-function 'diff-hl-fringe-bmp-from-type)
    (diff-hl-margin-mode)
    (setq diff-hl-margin-side 'left)
    )

In the main directory of the project there are multiple ignored files and directories (listed in .hgignore) and I noticed that they keep flickering. moving down the dired list is also tricky as the list keeps moving when the diff-hl symbols flicker. Other directories which don't have ignored files but have modified files are fine and don't show the same behaviour.

@dgutov
Copy link
Owner

dgutov commented Jul 8, 2017

What do you mean flickering? Like, changing over time even when you don't refresh the view?

You might want to post a video, but it sounds like a bug which you should report to Emacs. What's your version?

@hisnawi
Copy link
Author

hisnawi commented Jul 8, 2017

Flickering means the diff-hl highlights and markings (i) keeps disappearing then coming back. Doesn't seem to be an emacs issue since other directories with no (ignored) files are fine.

emacs version 25.2, diff-hl version (latest)

@dgutov
Copy link
Owner

dgutov commented Jul 8, 2017

Does that happen only once, when you enter a new directory?

@hisnawi
Copy link
Author

hisnawi commented Jul 9, 2017

no. it keeps flickering, on and off and scrolling up and down is troubling too. Not until I enter a new directory with no ignored files then things go back to normal.

@hisnawi
Copy link
Author

hisnawi commented Jul 9, 2017

Ok. I noticed that this behaviour happens when I have auto revert on for the dired mode:

(add-hook 'dired-mode-hook 'auto-revert-mode)

@dgutov
Copy link
Owner

dgutov commented Jul 9, 2017

Oh, I see. Not sure what to do about it, though. The obvious approach doesn't seem to change much:

diff --git a/diff-hl-dired.el b/diff-hl-dired.el
index 947c2b6..6f5e9b5 100644
--- a/diff-hl-dired.el
+++ b/diff-hl-dired.el
@@ -93,7 +93,6 @@ status indicators."
         (buffer (current-buffer))
         dirs-alist files-alist)
     (when (and backend (not (memq backend diff-hl-dired-ignored-backends)))
-      (diff-hl-dired-clear)
       (if (buffer-live-p diff-hl-dired-process-buffer)
           (let ((proc (get-buffer-process diff-hl-dired-process-buffer)))
             (when proc (kill-process proc)))
@@ -131,6 +130,7 @@ status indicators."
                                (setcdr (assoc dir dirs-alist) 'change)))))
                        (push (cons file type) files-alist)))))
                (unless more-to-come
+                 (diff-hl-dired-clear)
                  (diff-hl-dired-highlight-items
                   (append dirs-alist files-alist))))
              (unless more-to-come

Probably because the entire buffer is being redrawn, and the existing marks are gone with it.

Here's something for you to investigate, though: normally, Dired does not revert unless dired-buffer-stale-p returns non-nil. At the end that function calls dired-directory-changed-p. You might want to try debugging it.

Is it the case, though, that somewhere within the directory in question a log file is being written to?

@hisnawi
Copy link
Author

hisnawi commented Jul 9, 2017

Looking at my Messages buffer I see these messages, you think they are related?

Invalid face reference: diff-hl-margin-ignored [19 times]
error in process sentinel: vc-exec-after: Unexpected process state
error in process sentinel: Unexpected process state
Invalid face reference: diff-hl-margin-ignored [6 times]
Invalid face reference: diff-hl-margin-ignored [36 times]

@dgutov
Copy link
Owner

dgutov commented Jul 9, 2017

Maybe.

You should try and see if the "error in process sentinel" ones happen without diff-hl-dired-mode.

dgutov added a commit that referenced this issue Jul 10, 2017
For diff-hl-dired-mode together with diff-hl-margin-mode

Reported in #92.
@dgutov
Copy link
Owner

dgutov commented Jul 10, 2017

Invalid face reference: diff-hl-margin-ignored

This should be fixed now (but will probably change nothing for the discussed problem).

@hisnawi
Copy link
Author

hisnawi commented Jul 10, 2017

Well, now the ignores (i) don't show at all in dired mode. Even when enabled in diff-hl.
Was that intended?

@dgutov
Copy link
Owner

dgutov commented Jul 10, 2017

They do show up here. You might have to customize the face diff-hl-margin-ignored, it inherits from dired-ignored (which should be lighter than the default face, but still visible).

@hisnawi
Copy link
Author

hisnawi commented Jul 10, 2017

No my friend. I checked out an older init.el file. Tried removing custom from my .emacs file. Switched themes. nothing worked. The (i) don't show up for me anymore.
I even enabled diff-hl using M-x, disabled auto-dered-revert....nothing.
I am sure your update did something.

@dgutov
Copy link
Owner

dgutov commented Jul 10, 2017

As you can see, it just added two faces.

Could you post your current definitions (using M-x describe-face) of these faces: diff-hl-margin-ignored, dired-ignored, shadow, fringe?

@hisnawi
Copy link
Author

hisnawi commented Jul 10, 2017

Face: diff-hl-margin-ignored (sample) (customize this face)

Documentation:
Face used to highlight changed lines on the margin.

Defined in ‘diff-hl-margin.el’.

           Family: unspecified
          Foundry: unspecified
            Width: unspecified
           Height: unspecified
           Weight: unspecified
            Slant: unspecified
       Foreground: unspecified
DistantForeground: unspecified
       Background: unspecified
        Underline: unspecified
         Overline: unspecified
   Strike-through: unspecified
              Box: unspecified
          Inverse: unspecified
          Stipple: unspecified
             Font: unspecified
          Fontset: unspecified
          Inherit: dired-ignored

Face: dired-ignored (sample) (customize this face)

Documentation:
Face used for files suffixed with ‘completion-ignored-extensions’.

           Family: unspecified
          Foundry: unspecified
            Width: unspecified
           Height: unspecified
           Weight: unspecified
            Slant: unspecified
       Foreground: unspecified
DistantForeground: unspecified
       Background: unspecified
        Underline: unspecified
         Overline: unspecified
   Strike-through: unspecified
              Box: unspecified
          Inverse: unspecified
          Stipple: unspecified
             Font: unspecified
          Fontset: unspecified
          Inherit: shadow

Face: shadow (sample) (customize this face)

Documentation:
Basic face for shadowed text.

           Family: unspecified
          Foundry: unspecified
            Width: unspecified
           Height: unspecified
           Weight: unspecified
            Slant: unspecified
       Foreground: #b0bec5
DistantForeground: unspecified
       Background: unspecified
        Underline: unspecified
         Overline: unspecified
   Strike-through: unspecified
              Box: unspecified
          Inverse: unspecified
          Stipple: unspecified
             Font: unspecified
          Fontset: unspecified
          Inherit: unspecified

Face: fringe (sample) (customize this face)

Documentation:
Basic face for the fringes to the left and right of windows under X.

           Family: unspecified
          Foundry: unspecified
            Width: unspecified
           Height: unspecified
           Weight: unspecified
            Slant: unspecified
       Foreground: unspecified
DistantForeground: unspecified
       Background: #263238
        Underline: unspecified
         Overline: unspecified
   Strike-through: unspecified
              Box: unspecified
          Inverse: unspecified
          Stipple: unspecified
             Font: unspecified
          Fontset: unspecified
          Inherit: unspecified

[back]

@hisnawi
Copy link
Author

hisnawi commented Jul 10, 2017

Ok. after a while browsing other files, coming back to that directory I see the (i)s, but as you mentioned the push is not related to the flickering, so the issue still present.

@dgutov
Copy link
Owner

dgutov commented Jul 10, 2017

You were looking in other directories, then?

as you mentioned the push is not related to the flickering, so the issue still present

Please go back to these questions:

  1. You should try and see if the "error in process sentinel" ones happen without diff-hl-dired-mode.

  2. Here's something for you to investigate, though: normally, Dired does not revert unless dired-buffer-stale-p returns non-nil. At the end that function calls dired-directory-changed-p. You might want to try debugging it.

    Could it be that somewhere within the directory in question a log file is being written to?

@hisnawi
Copy link
Author

hisnawi commented Jul 11, 2017

  1. "error in process sentinel" doesn't show up anymore with or without doff-hl-dired-mode
  2. I kept doing "ls -ltra" on the folder and no files are being updated.

I did not see the (i) mark since yesterday. No markings whatsoever actually. And only in project main directory. Inside the directories headers and source everything is normal.

@dgutov
Copy link
Owner

dgutov commented Jul 11, 2017

I kept doing "ls -ltra" on the folder

Why?

I did not see the (i) mark since yesterday. No markings whatsoever actually

Could you try reproducing the problem in an example project and posting it somewhere, archived?

@hisnawi
Copy link
Author

hisnawi commented Jul 11, 2017

You mentioned the possibility of some logfile getting continuously updated, so ls -ltra will tell you if files has been altered in the directory.

I now found something else. If I start emacs from inside the directory then I wont see any diff-hl markings. If I start emacs in some other directory and then browse to the troubling directory then I see the markings and they flicker and also I see:

error in process sentinel: vc-exec-after: Unexpected process state
error in process sentinel: Unexpected process state

In the Messages buffer.

I am using Mercurial so I have .hg directory with repos info in the main directory.

I will see if I can provide a smaller sample project for you to test.

@hisnawi
Copy link
Author

hisnawi commented Jul 11, 2017

Ok, go to my github and down load the new.tar file:

https://github.com/hisnawi/dotfiles

untar it. It is a mercurial simple project.

Open emacs outside the directory then browse to it.

Try having same as my set up for dired and diff-hl:


  (use-package dired
    :init
    (progn
      ;; Details toggling is bound to "(" in `dired-mode' by default
      (setq diredp-hide-details-initially-flag nil)
      (setq diredp-bind-problematic-terminal-keys nil) ;; "emacs -nw" hangs otherwise
      )
    :config
    (use-package dired+ 
      :ensure t
      :config
      (define-key dired-mode-map (kbd "M-z") 'ivy-switch-buffer)
      )
    (add-hook 'dired-mode-hook 'auto-revert-mode)
    (add-hook 'dired-mode-hook  (lambda () (setq auto-revert-verbose nil)))
    )

  (use-package diff-hl
    :ensure t
    :diminish " D"
    :config
    ;; Highlight changed files in the fringe of Dired
    (add-hook 'dired-mode-hook 'diff-hl-dired-mode)
    (global-diff-hl-mode)
    ;; Fall back to the display margin, if the fringe is unavailable
    (unless (display-graphic-p) (diff-hl-margin-mode))
    ;; Highlight changes to the current file in the fringe
    (setq diff-hl-fringe-bmp-function 'diff-hl-fringe-bmp-from-type)
    ;; Left fringe
    (diff-hl-margin-mode)
    (setq diff-hl-margin-side 'left)
    )

I also want to mention that I removed everything inside my init.el file except these two packages and I still see the issue inside this simple project.
The issue is fixed if I comment the line:

(add-hook 'dired-mode-hook 'auto-revert-mode)

@dgutov
Copy link
Owner

dgutov commented Jul 13, 2017

untar it. It is a mercurial simple project

Thanks. I can see the refreshes, but no other problems that you reported, so far.

ls -ltra will tell you if files has been altered in the directory

That's not what Emacs is looking at, though. It looks at the modification time of the directory itself. And if you cd .. and call ls -ltra there, you should see that its modification time is continually updated.

I'm not sure why this happens. Maybe it's a bug in VC, or auto-revert-mode, or something else. Please go ahead and report it.

@hisnawi hisnawi closed this as completed Jul 13, 2017
@dgutov
Copy link
Owner

dgutov commented Jul 13, 2017

Or maybe it's something we can't do anything about: just calling hg status -mardu in an Hg repository updates its directory's modification time.

@dgutov
Copy link
Owner

dgutov commented Jul 13, 2017

Also note that you are enabling diff-hl-margin-mode twice:

(unless (display-graphic-p) (diff-hl-margin-mode))

(diff-hl-margin-mode)

That's highly unlikely to cause any problems, just unnecessary.

@hisnawi
Copy link
Author

hisnawi commented Jul 13, 2017

Thanks for noting that. I removed the extra (diff-hl-margin-mode).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants