summaryrefslogtreecommitdiff
path: root/lisp/vc/vc-dispatcher.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2013-04-20 12:24:04 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2013-04-20 12:24:04 -0400
commitbcd7a0a4c55f8226e9322d1ef438040fed2dc57e (patch)
tree54f28f5694dddc8f391eed169515992bbb46cacb /lisp/vc/vc-dispatcher.el
parent806bda47ddb469f6206ecc533458eadae6a5b575 (diff)
downloademacs-bcd7a0a4c55f8226e9322d1ef438040fed2dc57e.tar.gz
emacs-bcd7a0a4c55f8226e9322d1ef438040fed2dc57e.tar.bz2
emacs-bcd7a0a4c55f8226e9322d1ef438040fed2dc57e.zip
Use add/remove-function to manipulate process-filters.
* lisp/emacs-lisp/nadvice.el (advice--where-alist): Add :override. (remove-function): Autoload. * lisp/comint.el (comint-redirect-original-filter-function): Remove. (comint-redirect-cleanup, comint-redirect-send-command-to-process): * lisp/vc/vc-cvs.el (vc-cvs-annotate-process-filter,vc-cvs-annotate-command): * lisp/progmodes/octave-inf.el (inferior-octave-send-list-and-digest): * lisp/progmodes/prolog.el (prolog-consult-compile): * lisp/progmodes/gdb-mi.el (gdb, gdb--check-interpreter): Use add/remove-function instead. * lisp/progmodes/gud.el (gud-tooltip-original-filter): Remove. (gud-tooltip-process-output, gud-tooltip-tips): Use add/remove-function instead. * lisp/progmodes/xscheme.el (xscheme-previous-process-state): Remove. (scheme-interaction-mode, exit-scheme-interaction-mode): Use add/remove-function instead. * lisp/vc/vc-dispatcher.el: Use lexical-binding. (vc--process-sentinel): Rename from vc-process-sentinel. Change last arg to be the code to run. Don't use vc-previous-sentinel and vc-sentinel-commands any more. (vc-exec-after): Allow code to be a function. Use add/remove-function. (compilation-error-regexp-alist, view-old-buffer-read-only): Declare.
Diffstat (limited to 'lisp/vc/vc-dispatcher.el')
-rw-r--r--lisp/vc/vc-dispatcher.el45
1 files changed, 21 insertions, 24 deletions
diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el
index ed61adec1fe..309cf50404c 100644
--- a/lisp/vc/vc-dispatcher.el
+++ b/lisp/vc/vc-dispatcher.el
@@ -1,4 +1,4 @@
-;;; vc-dispatcher.el -- generic command-dispatcher facility.
+;;; vc-dispatcher.el -- generic command-dispatcher facility. -*- lexical-binding: t -*-
;; Copyright (C) 2008-2013 Free Software Foundation, Inc.
@@ -182,32 +182,29 @@ Another is that undo information is not kept."
(defvar vc-sentinel-movepoint) ;Dynamically scoped.
-(defun vc-process-sentinel (p s)
- (let ((previous (process-get p 'vc-previous-sentinel))
- (buf (process-buffer p)))
+(defun vc--process-sentinel (p code)
+ (let ((buf (process-buffer p)))
;; Impatient users sometime kill "slow" buffers; check liveness
;; to avoid "error in process sentinel: Selecting deleted buffer".
(when (buffer-live-p buf)
- (when previous (funcall previous p s))
(with-current-buffer buf
(setq mode-line-process
(let ((status (process-status p)))
;; Leave mode-line uncluttered, normally.
(unless (eq 'exit status)
(format " (%s)" status))))
- (let (vc-sentinel-movepoint)
+ (let (vc-sentinel-movepoint
+ (m (process-mark p)))
;; Normally, we want async code such as sentinels to not move point.
(save-excursion
- (goto-char (process-mark p))
- (let ((cmds (process-get p 'vc-sentinel-commands)))
- (process-put p 'vc-sentinel-commands nil)
- (dolist (cmd cmds)
+ (goto-char m)
;; Each sentinel may move point and the next one should be run
;; at that new point. We could get the same result by having
;; each sentinel read&set process-mark, but since `cmd' needs
;; to work both for async and sync processes, this would be
;; difficult to achieve.
- (vc-exec-after cmd))))
+ (vc-exec-after code)
+ (move-marker m (point)))
;; But sometimes the sentinels really want to move point.
(when vc-sentinel-movepoint
(let ((win (get-buffer-window (current-buffer) 0)))
@@ -226,7 +223,9 @@ Another is that undo information is not kept."
(defun vc-exec-after (code)
"Eval CODE when the current buffer's process is done.
If the current buffer has no process, just evaluate CODE.
-Else, add CODE to the process' sentinel."
+Else, add CODE to the process' sentinel.
+CODE can be either a function of no arguments, or an expression
+to evaluate."
(let ((proc (get-buffer-process (current-buffer))))
(cond
;; If there's no background process, just execute the code.
@@ -237,20 +236,14 @@ Else, add CODE to the process' sentinel."
((or (null proc) (eq (process-status proc) 'exit))
;; Make sure we've read the process's output before going further.
(when proc (accept-process-output proc))
- (eval code))
+ (if (functionp code) (funcall code) (eval code)))
;; If a process is running, add CODE to the sentinel
((eq (process-status proc) 'run)
(vc-set-mode-line-busy-indicator)
- (let ((previous (process-sentinel proc)))
- (unless (eq previous 'vc-process-sentinel)
- (process-put proc 'vc-previous-sentinel previous))
- (set-process-sentinel proc 'vc-process-sentinel))
- (process-put proc 'vc-sentinel-commands
- ;; We keep the code fragments in the order given
- ;; so that vc-diff-finish's message shows up in
- ;; the presence of non-nil vc-command-messages.
- (append (process-get proc 'vc-sentinel-commands)
- (list code))))
+ (letrec ((fun (lambda (p _msg)
+ (remove-function (process-sentinel p) fun)
+ (vc--process-sentinel p code))))
+ (add-function :after (process-sentinel proc) fun)))
(t (error "Unexpected process state"))))
nil)
@@ -388,6 +381,8 @@ Display the buffer in some window, but don't select it."
(set-window-start window new-window-start))
buffer))
+(defvar compilation-error-regexp-alist)
+
(defun vc-compilation-mode (backend)
"Setup `compilation-mode' after with the appropriate `compilation-error-regexp-alist'."
(let* ((error-regexp-alist
@@ -479,7 +474,7 @@ Used by `vc-restore-buffer-context' to later restore the context."
(vc-position-context (mark-marker))))
;; Make the right thing happen in transient-mark-mode.
(mark-active nil))
- (list point-context mark-context nil)))
+ (list point-context mark-context)))
(defun vc-restore-buffer-context (context)
"Restore point/mark, and reparse any affected compilation buffers.
@@ -518,6 +513,8 @@ ARG and NO-CONFIRM are passed on to `revert-buffer'."
(make-variable-buffer-local 'vc-mode-line-hook)
(put 'vc-mode-line-hook 'permanent-local t)
+(defvar view-old-buffer-read-only)
+
(defun vc-resynch-window (file &optional keep noquery reset-vc-info)
"If FILE is in the current buffer, either revert or unvisit it.
The choice between revert (to see expanded keywords) and unvisit