diff options
| author | Thien-Thi Nguyen | 2008-01-21 14:03:09 +0000 |
|---|---|---|
| committer | Thien-Thi Nguyen | 2008-01-21 14:03:09 +0000 |
| commit | b49fd377e88c4e6517342e2b61a6f0db2a0eab83 (patch) | |
| tree | 5beb592ed17cbe68025ffcae062eeb05c1212425 | |
| parent | 040f578c57c69724835561134dd9d01480f043a3 (diff) | |
| download | emacs-b49fd377e88c4e6517342e2b61a6f0db2a0eab83.tar.gz emacs-b49fd377e88c4e6517342e2b61a6f0db2a0eab83.zip | |
(vc-process-sentinel): After calling the
previous sentinel, do nothing if the process' buffer is not live.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/vc.el | 61 |
2 files changed, 37 insertions, 29 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7b05fb9c568..b3e010f9b93 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2008-01-21 Thien-Thi Nguyen <ttn@gnuvola.org> | ||
| 2 | |||
| 3 | * vc.el (vc-process-sentinel): After calling the previous | ||
| 4 | sentinel, do nothing if the process' buffer is not live. | ||
| 5 | |||
| 1 | 2008-01-21 Vinicius Jose Latorre <viniciusjl@ig.com.br> | 6 | 2008-01-21 Vinicius Jose Latorre <viniciusjl@ig.com.br> |
| 2 | 7 | ||
| 3 | * blank-mode.el: Fix a problem of cleaning blank faces when turning off | 8 | * blank-mode.el: Fix a problem of cleaning blank faces when turning off |
diff --git a/lisp/vc.el b/lisp/vc.el index 497ba1e0df4..ffe38a68521 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -958,36 +958,39 @@ BUF defaults to \"*vc*\", can be a string and will be created if necessary." | |||
| 958 | (defvar vc-sentinel-movepoint) ;Dynamically scoped. | 958 | (defvar vc-sentinel-movepoint) ;Dynamically scoped. |
| 959 | 959 | ||
| 960 | (defun vc-process-sentinel (p s) | 960 | (defun vc-process-sentinel (p s) |
| 961 | (with-current-buffer (process-buffer p) | 961 | (let ((previous (process-get p 'vc-previous-sentinel)) |
| 962 | (setq mode-line-process | 962 | (buf (process-buffer p))) |
| 963 | (let ((status (process-status p))) | ||
| 964 | ;; Leave mode-line uncluttered, normally. | ||
| 965 | ;; (Let known any weirdness in-form-ally. ;-) --ttn | ||
| 966 | (unless (eq 'exit status) | ||
| 967 | (format " (%s)" status))))) | ||
| 968 | (let ((previous (process-get p 'vc-previous-sentinel))) | ||
| 969 | (if previous (funcall previous p s)) | 963 | (if previous (funcall previous p s)) |
| 970 | (with-current-buffer (process-buffer p) | 964 | ;; Impatient users sometime kill "slow" buffers; check liveness |
| 971 | (let (vc-sentinel-movepoint) | 965 | ;; to avoid "error in process sentinel: Selecting deleted buffer". |
| 972 | ;; Normally, we want async code such as sentinels to not move point. | 966 | (when (buffer-live-p buf) |
| 973 | (save-excursion | 967 | (with-current-buffer buf |
| 974 | (goto-char (process-mark p)) | 968 | (setq mode-line-process |
| 975 | (let ((cmds (process-get p 'vc-sentinel-commands))) | 969 | (let ((status (process-status p))) |
| 976 | (process-put p 'vc-sentinel-commands nil) | 970 | ;; Leave mode-line uncluttered, normally. |
| 977 | (dolist (cmd cmds) | 971 | ;; (Let known any weirdness in-form-ally. ;-) --ttn |
| 978 | ;; Each sentinel may move point and the next one should be run | 972 | (unless (eq 'exit status) |
| 979 | ;; at that new point. We could get the same result by having | 973 | (format " (%s)" status)))) |
| 980 | ;; each sentinel read&set process-mark, but since `cmd' needs | 974 | (let (vc-sentinel-movepoint) |
| 981 | ;; to work both for async and sync processes, this would be | 975 | ;; Normally, we want async code such as sentinels to not move point. |
| 982 | ;; difficult to achieve. | 976 | (save-excursion |
| 983 | (vc-exec-after cmd)))) | 977 | (goto-char (process-mark p)) |
| 984 | ;; But sometimes the sentinels really want to move point. | 978 | (let ((cmds (process-get p 'vc-sentinel-commands))) |
| 985 | (if vc-sentinel-movepoint | 979 | (process-put p 'vc-sentinel-commands nil) |
| 986 | (let ((win (get-buffer-window (current-buffer) 0))) | 980 | (dolist (cmd cmds) |
| 987 | (if (not win) | 981 | ;; Each sentinel may move point and the next one should be run |
| 988 | (goto-char vc-sentinel-movepoint) | 982 | ;; at that new point. We could get the same result by having |
| 989 | (with-selected-window win | 983 | ;; each sentinel read&set process-mark, but since `cmd' needs |
| 990 | (goto-char vc-sentinel-movepoint))))))))) | 984 | ;; to work both for async and sync processes, this would be |
| 985 | ;; difficult to achieve. | ||
| 986 | (vc-exec-after cmd)))) | ||
| 987 | ;; But sometimes the sentinels really want to move point. | ||
| 988 | (if vc-sentinel-movepoint | ||
| 989 | (let ((win (get-buffer-window (current-buffer) 0))) | ||
| 990 | (if (not win) | ||
| 991 | (goto-char vc-sentinel-movepoint) | ||
| 992 | (with-selected-window win | ||
| 993 | (goto-char vc-sentinel-movepoint)))))))))) | ||
| 991 | 994 | ||
| 992 | (defun vc-exec-after (code) | 995 | (defun vc-exec-after (code) |
| 993 | "Eval CODE when the current buffer's process is done. | 996 | "Eval CODE when the current buffer's process is done. |