emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 27b3adb 06/22: Check if the original Dired buffer is still


From: Dmitry Gutov
Subject: [elpa] master 27b3adb 06/22: Check if the original Dired buffer is still alive
Date: Fri, 02 Jan 2015 23:46:27 +0000

branch: master
commit 27b3adbe7af7e720e84b4523adbc73976cccb1ed
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Check if the original Dired buffer is still alive
    
    SVN can be awfully slow, and the user might call 
`dired-find-alternate-file'.
---
 diff-hl-dired.el |   56 +++++++++++++++++++++++++++--------------------------
 1 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/diff-hl-dired.el b/diff-hl-dired.el
index 2bbf12b..f1effda 100644
--- a/diff-hl-dired.el
+++ b/diff-hl-dired.el
@@ -84,25 +84,26 @@
         (vc-call-backend
          backend 'dir-status def-dir
          (lambda (entries &optional more-to-come)
-           (with-current-buffer buffer
-             (dolist (entry entries)
-               (cl-destructuring-bind (file state &rest) entry
-                 (let ((type (plist-get
-                              '(edited change added insert removed delete
-                                unregistered unknown)
-                              state)))
-                   (if (string-match "\\`\\([^/]+\\)/" file)
-                       (let* ((dir (match-string 1 file))
-                              (value (cdr (assoc dir dirs-alist))))
-                         (unless (eq value type)
-                           (if (null value)
-                               (push (cons dir type) dirs-alist)
-                             (setcdr (assoc dir dirs-alist) 'change))))
-                     (push (cons file type) files-alist)))))
-             (unless more-to-come
-               (diff-hl-dired-highlight-items (append dirs-alist
-                                                      files-alist))
-               (diff-hl-dired-update-ignores backend def-dir))))
+           (when (buffer-live-p buffer)
+             (with-current-buffer buffer
+               (dolist (entry entries)
+                 (cl-destructuring-bind (file state &rest) entry
+                   (let ((type (plist-get
+                                '(edited change added insert removed delete
+                                         unregistered unknown)
+                                state)))
+                     (if (string-match "\\`\\([^/]+\\)/" file)
+                         (let* ((dir (match-string 1 file))
+                                (value (cdr (assoc dir dirs-alist))))
+                           (unless (eq value type)
+                             (if (null value)
+                                 (push (cons dir type) dirs-alist)
+                               (setcdr (assoc dir dirs-alist) 'change))))
+                       (push (cons file type) files-alist)))))
+               (unless more-to-come
+                 (diff-hl-dired-highlight-items (append dirs-alist
+                                                        files-alist))
+                 (diff-hl-dired-update-ignores backend def-dir)))))
          )))))
 
 (defun diff-hl-dired-update-ignores (backend def-dir)
@@ -117,14 +118,15 @@
                 collect file)
        nil
        (lambda (entries &optional more-to-come)
-         (with-current-buffer buffer
-           (dolist (entry entries)
-             (cl-destructuring-bind (file state &rest) entry
-               (when (eq state 'ignored)
-                 (push (cons (directory-file-name file)
-                             'ignored) entries-alist))))
-           (unless more-to-come
-             (diff-hl-dired-highlight-items entries-alist))))
+         (when (buffer-live-p buffer)
+           (with-current-buffer buffer
+             (dolist (entry entries)
+               (cl-destructuring-bind (file state &rest) entry
+                 (when (eq state 'ignored)
+                   (push (cons (directory-file-name file)
+                               'ignored) entries-alist))))
+             (unless more-to-come
+               (diff-hl-dired-highlight-items entries-alist)))))
        ))))
 
 (defun diff-hl-dired-highlight-items (alist)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]