aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThien-Thi Nguyen2008-01-24 08:54:00 +0000
committerThien-Thi Nguyen2008-01-24 08:54:00 +0000
commitfddde1f0b5f04dcb96360fb1f88b0aa0d1f251ed (patch)
treee66082acc74db579c62a7861fdc710323b574a43
parent2ee455eaa3cc38e47a5dd29f630b02f19e92c294 (diff)
downloademacs-fddde1f0b5f04dcb96360fb1f88b0aa0d1f251ed.tar.gz
emacs-fddde1f0b5f04dcb96360fb1f88b0aa0d1f251ed.zip
Handle dead buffers in async filters/sentinels.
(vc-process-filter): Do nothing if buffer not live. (vc-diff-finish): Rename from vc-diff-sentinel. No longer take REV1-NAME and REV2-NAME. Instead, take BUFFER-NAME. Do nothing if buffer not live. Don't do window resize if no window displays buffer. (vc-diff-internal): Use vc-diff-finish.
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/vc.el42
2 files changed, 32 insertions, 20 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c08c62621d5..370f63021b3 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,9 +1,17 @@
12008-01-24 Thien-Thi Nguyen <ttn@gnuvola.org>
2
3 * vc.el (vc-process-filter): Do nothing if buffer not live.
4 (vc-diff-finish): Rename from vc-diff-sentinel.
5 No longer take REV1-NAME and REV2-NAME.
6 Instead, take BUFFER-NAME. Do nothing if buffer not live.
7 Don't do window resize if no window displays buffer.
8 (vc-diff-internal): Use vc-diff-finish.
9
12008-01-24 Dan Nicolaescu <dann@ics.uci.edu> 102008-01-24 Dan Nicolaescu <dann@ics.uci.edu>
2 11
3 * vc.el: Add a TODO item about missing files. 12 * vc.el: Add a TODO item about missing files.
4 (vc-exec-after): Add a tooltip to the new mode-line item. 13 (vc-exec-after): Add a tooltip to the new mode-line item.
5 14
6
72008-01-24 Glenn Morris <rgm@gnu.org> 152008-01-24 Glenn Morris <rgm@gnu.org>
8 16
9 * t-mouse.el (gpm-mouse-start): Declare as a function. 17 * t-mouse.el (gpm-mouse-start): Declare as a function.
diff --git a/lisp/vc.el b/lisp/vc.el
index 74bfd045b54..1bb5c28d530 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -952,13 +952,15 @@ However, before executing BODY, find FILE, and after BODY, save buffer."
952 "An alternative output filter for async process P. 952 "An alternative output filter for async process P.
953One difference with the default filter is that this inserts S after markers. 953One difference with the default filter is that this inserts S after markers.
954Another is that undo information is not kept." 954Another is that undo information is not kept."
955 (with-current-buffer (process-buffer p) 955 (let ((buffer (process-buffer p)))
956 (save-excursion 956 (when (buffer-live-p buffer)
957 (let ((buffer-undo-list t) 957 (with-current-buffer buffer
958 (inhibit-read-only t)) 958 (save-excursion
959 (goto-char (process-mark p)) 959 (let ((buffer-undo-list t)
960 (insert s) 960 (inhibit-read-only t))
961 (set-marker (process-mark p) (point)))))) 961 (goto-char (process-mark p))
962 (insert s)
963 (set-marker (process-mark p) (point))))))))
962 964
963(defun vc-setup-buffer (&optional buf) 965(defun vc-setup-buffer (&optional buf)
964 "Prepare BUF for executing a VC command and make it current. 966 "Prepare BUF for executing a VC command and make it current.
@@ -981,10 +983,10 @@ BUF defaults to \"*vc*\", can be a string and will be created if necessary."
981(defun vc-process-sentinel (p s) 983(defun vc-process-sentinel (p s)
982 (let ((previous (process-get p 'vc-previous-sentinel)) 984 (let ((previous (process-get p 'vc-previous-sentinel))
983 (buf (process-buffer p))) 985 (buf (process-buffer p)))
984 (if previous (funcall previous p s))
985 ;; Impatient users sometime kill "slow" buffers; check liveness 986 ;; Impatient users sometime kill "slow" buffers; check liveness
986 ;; to avoid "error in process sentinel: Selecting deleted buffer". 987 ;; to avoid "error in process sentinel: Selecting deleted buffer".
987 (when (buffer-live-p buf) 988 (when (buffer-live-p buf)
989 (if previous (funcall previous p s))
988 (with-current-buffer buf 990 (with-current-buffer buf
989 (setq mode-line-process 991 (setq mode-line-process
990 (let ((status (process-status p))) 992 (let ((status (process-status p)))
@@ -1969,17 +1971,19 @@ the buffer contents as a comment."
1969(defmacro vc-diff-switches-list (backend) `(vc-switches ',backend 'diff)) 1971(defmacro vc-diff-switches-list (backend) `(vc-switches ',backend 'diff))
1970(make-obsolete 'vc-diff-switches-list 'vc-switches "22.1") 1972(make-obsolete 'vc-diff-switches-list 'vc-switches "22.1")
1971 1973
1972(defun vc-diff-sentinel (verbose rev1-name rev2-name) 1974(defun vc-diff-finish (buffer-name verbose)
1973 ;; The empty sync output case has already been handled, so the only 1975 ;; The empty sync output case has already been handled, so the only
1974 ;; possibility of an empty output is for an async process, in which case 1976 ;; possibility of an empty output is for an async process.
1975 ;; it's important to insert the "diffs end here" message in the buffer 1977 (when (buffer-live-p buffer-name)
1976 ;; since the user may miss a message in the echo area. 1978 (with-current-buffer (get-buffer buffer-name)
1977 (and verbose 1979 (and verbose
1978 (zerop (buffer-size)) 1980 (zerop (buffer-size))
1979 (let ((inhibit-read-only t)) 1981 (let ((inhibit-read-only t))
1980 (insert "No differences found.\n"))) 1982 (insert "No differences found.\n")))
1981 (goto-char (point-min)) 1983 (goto-char (point-min))
1982 (shrink-window-if-larger-than-buffer)) 1984 (let ((window (get-buffer-window (current-buffer))))
1985 (when window
1986 (shrink-window-if-larger-than-buffer window))))))
1983 1987
1984(defvar vc-diff-added-files nil 1988(defvar vc-diff-added-files nil
1985 "If non-nil, diff added files by comparing them to /dev/null.") 1989 "If non-nil, diff added files by comparing them to /dev/null.")
@@ -2038,7 +2042,7 @@ returns t if the buffer had changes, nil otherwise."
2038 ;; bindings are nicer for read only buffers. pcl-cvs does the 2042 ;; bindings are nicer for read only buffers. pcl-cvs does the
2039 ;; same thing. 2043 ;; same thing.
2040 (setq buffer-read-only t) 2044 (setq buffer-read-only t)
2041 (vc-exec-after `(vc-diff-sentinel ,verbose ,rev1-name ,rev2-name)) 2045 (vc-exec-after `(vc-diff-finish ,(buffer-name) ,verbose))
2042 ;; Display the buffer, but at the end because it can change point. 2046 ;; Display the buffer, but at the end because it can change point.
2043 (pop-to-buffer (current-buffer)) 2047 (pop-to-buffer (current-buffer))
2044 ;; In the async case, we return t even if there are no differences 2048 ;; In the async case, we return t even if there are no differences