diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2013-04-20 12:24:04 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2013-04-20 12:24:04 -0400 |
commit | bcd7a0a4c55f8226e9322d1ef438040fed2dc57e (patch) | |
tree | 54f28f5694dddc8f391eed169515992bbb46cacb /lisp/progmodes | |
parent | 806bda47ddb469f6206ecc533458eadae6a5b575 (diff) | |
download | emacs-bcd7a0a4c55f8226e9322d1ef438040fed2dc57e.tar.gz |
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/progmodes')
-rw-r--r-- | lisp/progmodes/gdb-mi.el | 30 | ||||
-rw-r--r-- | lisp/progmodes/gud.el | 9 | ||||
-rw-r--r-- | lisp/progmodes/octave-inf.el | 7 | ||||
-rw-r--r-- | lisp/progmodes/prolog.el | 6 | ||||
-rw-r--r-- | lisp/progmodes/xscheme.el | 39 |
5 files changed, 40 insertions, 51 deletions
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index f5e1abdd546..8e15ec6584e 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -574,21 +574,20 @@ NOARG must be t when this macro is used outside `gud-def'" (concat (gdb-gud-context-command ,cmd1 ,noall) " " ,cmd2) ,(when (not noarg) 'arg))) -(defun gdb--check-interpreter (proc string) +(defun gdb--check-interpreter (filter proc string) (unless (zerop (length string)) - (let ((filter (process-get proc 'gud-normal-filter))) - (set-process-filter proc filter) - (unless (memq (aref string 0) '(?^ ?~ ?@ ?& ?* ?=)) - ;; Apparently we're not running with -i=mi. - (let ((msg "Error: you did not specify -i=mi on GDB's command line!")) - (message msg) - (setq string (concat (propertize msg 'font-lock-face 'error) - "\n" string))) - ;; Use the old gud-gbd filter, not because it works, but because it - ;; will properly display GDB's answers rather than hanging waiting for - ;; answers that aren't coming. - (set (make-local-variable 'gud-marker-filter) #'gud-gdb-marker-filter)) - (funcall filter proc string)))) + (remove-function (process-filter proc) #'gdb--check-interpreter) + (unless (memq (aref string 0) '(?^ ?~ ?@ ?& ?* ?=)) + ;; Apparently we're not running with -i=mi. + (let ((msg "Error: you did not specify -i=mi on GDB's command line!")) + (message msg) + (setq string (concat (propertize msg 'font-lock-face 'error) + "\n" string))) + ;; Use the old gud-gbd filter, not because it works, but because it + ;; will properly display GDB's answers rather than hanging waiting for + ;; answers that aren't coming. + (set (make-local-variable 'gud-marker-filter) #'gud-gdb-marker-filter)) + (funcall filter proc string))) (defvar gdb-control-level 0) @@ -662,8 +661,7 @@ detailed description of this mode. ;; Setup a temporary process filter to warn when GDB was not started ;; with -i=mi. (let ((proc (get-buffer-process gud-comint-buffer))) - (process-put proc 'gud-normal-filter (process-filter proc)) - (set-process-filter proc #'gdb--check-interpreter)) + (add-function :around (process-filter proc) #'gdb--check-interpreter)) (set (make-local-variable 'gud-minor-mode) 'gdbmi) (set (make-local-variable 'gdb-control-level) 0) diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 4e31c5e827c..6076f88dea6 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -3387,9 +3387,6 @@ ACTIVATEP non-nil means activate mouse motion events." ;;; Tips for `gud' -(defvar gud-tooltip-original-filter nil - "Process filter to restore after GUD output has been received.") - (defvar gud-tooltip-dereference nil "Non-nil means print expressions with a `*' in front of them. For C this would dereference a pointer expression.") @@ -3423,7 +3420,7 @@ With arg, dereference expr if ARG is positive, otherwise do not dereference." ; gdb-mi.el gets round this problem. (defun gud-tooltip-process-output (process output) "Process debugger output and show it in a tooltip window." - (set-process-filter process gud-tooltip-original-filter) + (remove-function (process-filter process) #'gud-tooltip-process-output) (tooltip-show (tooltip-strip-prompt process output) (or gud-tooltip-echo-area tooltip-use-echo-area))) @@ -3490,8 +3487,8 @@ so they have been disabled.")) (gdb-input (concat cmd "\n") `(lambda () (gdb-tooltip-print ,expr)))) - (setq gud-tooltip-original-filter (process-filter process)) - (set-process-filter process 'gud-tooltip-process-output) + (add-function :override (process-filter process) + #'gud-tooltip-process-output) (gud-basic-call cmd)) expr)))))))) diff --git a/lisp/progmodes/octave-inf.el b/lisp/progmodes/octave-inf.el index de7ca32befe..4a227db7164 100644 --- a/lisp/progmodes/octave-inf.el +++ b/lisp/progmodes/octave-inf.el @@ -348,9 +348,9 @@ the rest to `inferior-octave-output-string'." The elements of LIST have to be strings and are sent one by one. All output is passed to the filter `inferior-octave-output-digest'." (let* ((proc inferior-octave-process) - (filter (process-filter proc)) string) - (set-process-filter proc 'inferior-octave-output-digest) + (add-function :override (process-filter proc) + #'inferior-octave-output-digest) (setq inferior-octave-output-list nil) (unwind-protect (while (setq string (car list)) @@ -360,7 +360,8 @@ output is passed to the filter `inferior-octave-output-digest'." (while inferior-octave-receive-in-progress (accept-process-output proc)) (setq list (cdr list))) - (set-process-filter proc filter)))) + (remove-function (process-filter proc) + #'inferior-octave-output-digest)))) (defun inferior-octave-directory-tracker (string) "Tracks `cd' commands issued to the inferior Octave process. diff --git a/lisp/progmodes/prolog.el b/lisp/progmodes/prolog.el index 85e4172c8fe..8971e97a44e 100644 --- a/lisp/progmodes/prolog.el +++ b/lisp/progmodes/prolog.el @@ -1770,7 +1770,8 @@ This function must be called from the source code buffer." real-file)) (with-current-buffer buffer (goto-char (point-max)) - (set-process-filter process 'prolog-consult-compile-filter) + (add-function :override (process-filter process) + #'prolog-consult-compile-filter) (process-send-string "prolog" command-string) ;; (prolog-build-prolog-command compilep file real-file first-line)) (while (and prolog-process-flag @@ -1781,7 +1782,8 @@ This function must be called from the source code buffer." (insert (if compilep "\nCompilation finished.\n" "\nConsulted.\n")) - (set-process-filter process old-filter)))) + (remove-function (process-filter process) + #'prolog-consult-compile-filter)))) (defvar compilation-error-list) diff --git a/lisp/progmodes/xscheme.el b/lisp/progmodes/xscheme.el index 2ad44b4b1c8..37c3cd37a6c 100644 --- a/lisp/progmodes/xscheme.el +++ b/lisp/progmodes/xscheme.el @@ -35,7 +35,6 @@ ;;;; Internal Variables (defvar xscheme-previous-mode) -(defvar xscheme-previous-process-state) (defvar xscheme-last-input-end) (defvar xscheme-process-command-line nil @@ -388,8 +387,6 @@ with no args, if that value is non-nil. (if (not preserve) (let ((previous-mode major-mode)) (kill-all-local-variables) - (make-local-variable 'xscheme-process-name) - (make-local-variable 'xscheme-previous-process-state) (make-local-variable 'xscheme-runlight-string) (make-local-variable 'xscheme-runlight) (set (make-local-variable 'xscheme-previous-mode) previous-mode) @@ -397,35 +394,29 @@ with no args, if that value is non-nil. (set (make-local-variable 'xscheme-buffer-name) (buffer-name buffer)) (set (make-local-variable 'xscheme-last-input-end) (make-marker)) (let ((process (get-buffer-process buffer))) - (if process - (progn - (setq xscheme-process-name (process-name process)) - (setq xscheme-previous-process-state - (cons (process-filter process) - (process-sentinel process))) - (xscheme-process-filter-initialize t) - (xscheme-mode-line-initialize xscheme-buffer-name) - (set-process-sentinel process 'xscheme-process-sentinel) - (set-process-filter process 'xscheme-process-filter)) - (setq xscheme-previous-process-state (cons nil nil))))))) + (when process + (setq-local xscheme-process-name (process-name process)) + ;; FIXME: Use add-function! + (xscheme-process-filter-initialize t) + (xscheme-mode-line-initialize xscheme-buffer-name) + (add-function :override (process-sentinel process) + #'xscheme-process-sentinel) + (add-function :override (process-filter process) + #'xscheme-process-filter)))))) (scheme-interaction-mode-initialize) (scheme-mode-variables) (run-mode-hooks 'scheme-mode-hook 'scheme-interaction-mode-hook)) (defun exit-scheme-interaction-mode () - "Take buffer out of scheme interaction mode" + "Take buffer out of scheme interaction mode." (interactive) (if (not (derived-mode-p 'scheme-interaction-mode)) (error "Buffer not in scheme interaction mode")) - (let ((previous-state xscheme-previous-process-state)) - (funcall xscheme-previous-mode) - (let ((process (get-buffer-process (current-buffer)))) - (if process - (progn - (if (eq (process-filter process) 'xscheme-process-filter) - (set-process-filter process (car previous-state))) - (if (eq (process-sentinel process) 'xscheme-process-sentinel) - (set-process-sentinel process (cdr previous-state)))))))) + (funcall xscheme-previous-mode) + (let ((process (get-buffer-process (current-buffer)))) + (when process + (remove-function (process-sentinel process) #'xscheme-process-sentinel) + (remove-function (process-filter process) #'xscheme-process-filter)))) (defvar scheme-interaction-mode-commands-alist nil) (defvar scheme-interaction-mode-map nil) |