Skip to content

Commit

Permalink
Improve buffer list cleanup by excluding inaccessible files.
Browse files Browse the repository at this point in the history
  • Loading branch information
phst committed Dec 3, 2015
1 parent 060247b commit 264f9ec
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions p4.el
Original file line number Diff line number Diff line change
Expand Up @@ -1334,13 +1334,26 @@ update (oldest first)."
(sort (loop for pending in p4-update-status-pending-alist
do (setf (third pending)
(loop for b in (third pending)
if (and (buffer-live-p b)
(buffer-file-name b))
if (p4--buffer-accessible-file-p b)
collect b))
if (third pending)
collect pending)
(lambda (a b) (time-less-p (second a) (second b))))))

(defun p4--buffer-accessible-file-p (buffer)
"Return t if the BUFFER is visiting an accessible file.
BUFFER is a buffer in `p4-update-status-pending-alist'. Return t
only if BUFFER exists, is visiting a readable file, and has an
accessible `default-directory'; then
`p4-update-status-pending-sort' should keep it in the list of
pending buffers."
(and (buffer-live-p buffer)
(with-current-buffer buffer
(file-accessible-directory-p default-directory))
(let ((file (buffer-file-name buffer)))
(and file
(file-readable-p file)))))

(defun p4-update-mode (buffer status revision)
"Turn p4-mode on or off in BUFFER according to Perforce status.
Argument STATUS is a symbol (see `p4-vc-status' for the possible
Expand Down

0 comments on commit 264f9ec

Please sign in to comment.