diff options
| author | Stefan Monnier | 2013-04-20 12:24:04 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2013-04-20 12:24:04 -0400 |
| commit | bcd7a0a4c55f8226e9322d1ef438040fed2dc57e (patch) | |
| tree | 54f28f5694dddc8f391eed169515992bbb46cacb | |
| parent | 806bda47ddb469f6206ecc533458eadae6a5b575 (diff) | |
| download | emacs-bcd7a0a4c55f8226e9322d1ef438040fed2dc57e.tar.gz 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.
| -rw-r--r-- | lisp/ChangeLog | 30 | ||||
| -rw-r--r-- | lisp/comint.el | 15 | ||||
| -rw-r--r-- | lisp/emacs-lisp/nadvice.el | 3 | ||||
| -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 | ||||
| -rw-r--r-- | lisp/vc/vc-cvs.el | 12 | ||||
| -rw-r--r-- | lisp/vc/vc-dispatcher.el | 45 |
10 files changed, 101 insertions, 95 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9bb155b74da..8758eb33e77 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,7 +1,33 @@ | |||
| 1 | 2013-04-20 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * emacs-lisp/nadvice.el (advice--where-alist): Add :override. | ||
| 4 | (remove-function): Autoload. | ||
| 5 | |||
| 6 | * comint.el (comint-redirect-original-filter-function): Remove. | ||
| 7 | (comint-redirect-cleanup, comint-redirect-send-command-to-process): | ||
| 8 | * vc/vc-cvs.el (vc-cvs-annotate-process-filter,vc-cvs-annotate-command): | ||
| 9 | * progmodes/octave-inf.el (inferior-octave-send-list-and-digest): | ||
| 10 | * progmodes/prolog.el (prolog-consult-compile): | ||
| 11 | * progmodes/gdb-mi.el (gdb, gdb--check-interpreter): | ||
| 12 | Use add/remove-function instead. | ||
| 13 | * progmodes/gud.el (gud-tooltip-original-filter): Remove. | ||
| 14 | (gud-tooltip-process-output, gud-tooltip-tips): | ||
| 15 | Use add/remove-function instead. | ||
| 16 | * progmodes/xscheme.el (xscheme-previous-process-state): Remove. | ||
| 17 | (scheme-interaction-mode, exit-scheme-interaction-mode): | ||
| 18 | Use add/remove-function instead. | ||
| 19 | |||
| 20 | * vc/vc-dispatcher.el: Use lexical-binding. | ||
| 21 | (vc--process-sentinel): Rename from vc-process-sentinel. | ||
| 22 | Change last arg to be the code to run. Don't use vc-previous-sentinel | ||
| 23 | and vc-sentinel-commands any more. | ||
| 24 | (vc-exec-after): Allow code to be a function. Use add/remove-function. | ||
| 25 | (compilation-error-regexp-alist, view-old-buffer-read-only): Declare. | ||
| 26 | |||
| 1 | 2013-04-19 Masatake YAMATO <yamato@redhat.com> | 27 | 2013-04-19 Masatake YAMATO <yamato@redhat.com> |
| 2 | 28 | ||
| 3 | * progmodes/sh-script.el (sh-imenu-generic-expression): Handle | 29 | * progmodes/sh-script.el (sh-imenu-generic-expression): |
| 4 | function names with a single character. (Bug#11182) | 30 | Handle function names with a single character. (Bug#11182) |
| 5 | 31 | ||
| 6 | 2013-04-19 Dima Kogan <dima@secretsauce.net> (tiny change) | 32 | 2013-04-19 Dima Kogan <dima@secretsauce.net> (tiny change) |
| 7 | 33 | ||
diff --git a/lisp/comint.el b/lisp/comint.el index 93db4e24f2a..13a38e6e16e 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -3491,11 +3491,6 @@ buffer. The idea is that this regular expression should match a prompt | |||
| 3491 | string, and that there ought to be at least one copy of your prompt string | 3491 | string, and that there ought to be at least one copy of your prompt string |
| 3492 | in the process buffer already.") | 3492 | in the process buffer already.") |
| 3493 | 3493 | ||
| 3494 | (defvar comint-redirect-original-filter-function nil | ||
| 3495 | "The process filter that was in place when redirection is started. | ||
| 3496 | When redirection is completed, the process filter is restored to | ||
| 3497 | this value.") | ||
| 3498 | |||
| 3499 | (defvar comint-redirect-subvert-readonly nil | 3494 | (defvar comint-redirect-subvert-readonly nil |
| 3500 | "Non-nil means `comint-redirect' can insert into read-only buffers. | 3495 | "Non-nil means `comint-redirect' can insert into read-only buffers. |
| 3501 | This works by binding `inhibit-read-only' around the insertion. | 3496 | This works by binding `inhibit-read-only' around the insertion. |
| @@ -3558,8 +3553,8 @@ and does not normally need to be invoked by the end user or programmer." | |||
| 3558 | ;; Release the last redirected string | 3553 | ;; Release the last redirected string |
| 3559 | (setq comint-redirect-previous-input-string nil) | 3554 | (setq comint-redirect-previous-input-string nil) |
| 3560 | ;; Restore the process filter | 3555 | ;; Restore the process filter |
| 3561 | (set-process-filter (get-buffer-process (current-buffer)) | 3556 | (remove-function (process-filter (get-buffer-process (current-buffer))) |
| 3562 | comint-redirect-original-filter-function) | 3557 | #'comint-redirect-filter) |
| 3563 | ;; Restore the mode line | 3558 | ;; Restore the mode line |
| 3564 | (setq mode-line-process comint-redirect-original-mode-line-process) | 3559 | (setq mode-line-process comint-redirect-original-mode-line-process) |
| 3565 | ;; Set the completed flag | 3560 | ;; Set the completed flag |
| @@ -3701,10 +3696,8 @@ If NO-DISPLAY is non-nil, do not show the output buffer." | |||
| 3701 | comint-prompt-regexp ; Finished Regexp | 3696 | comint-prompt-regexp ; Finished Regexp |
| 3702 | echo) ; Echo input | 3697 | echo) ; Echo input |
| 3703 | 3698 | ||
| 3704 | ;; Set the filter | 3699 | ;; Set the filter. |
| 3705 | (setq comint-redirect-original-filter-function ; Save the old filter | 3700 | (add-function :override (process-filter proc) #'comint-redirect-filter) |
| 3706 | (process-filter proc)) | ||
| 3707 | (set-process-filter proc 'comint-redirect-filter) | ||
| 3708 | 3701 | ||
| 3709 | ;; Send the command | 3702 | ;; Send the command |
| 3710 | (process-send-string (current-buffer) (concat command "\n")) | 3703 | (process-send-string (current-buffer) (concat command "\n")) |
diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el index a3dfb0326e6..12166553a14 100644 --- a/lisp/emacs-lisp/nadvice.el +++ b/lisp/emacs-lisp/nadvice.el | |||
| @@ -41,6 +41,7 @@ | |||
| 41 | '((:around "\300\301\302\003#\207" 5) | 41 | '((:around "\300\301\302\003#\207" 5) |
| 42 | (:before "\300\301\002\"\210\300\302\002\"\207" 4) | 42 | (:before "\300\301\002\"\210\300\302\002\"\207" 4) |
| 43 | (:after "\300\302\002\"\300\301\003\"\210\207" 5) | 43 | (:after "\300\302\002\"\300\301\003\"\210\207" 5) |
| 44 | (:override "\300\301\"\207" 4) | ||
| 44 | (:after-until "\300\302\002\"\206\013\000\300\301\002\"\207" 4) | 45 | (:after-until "\300\302\002\"\206\013\000\300\301\002\"\207" 4) |
| 45 | (:after-while "\300\302\002\"\205\013\000\300\301\002\"\207" 4) | 46 | (:after-while "\300\302\002\"\205\013\000\300\301\002\"\207" 4) |
| 46 | (:before-until "\300\301\002\"\206\013\000\300\302\002\"\207" 4) | 47 | (:before-until "\300\301\002\"\206\013\000\300\302\002\"\207" 4) |
| @@ -228,6 +229,7 @@ call OLDFUN here: | |||
| 228 | `:before' (lambda (&rest r) (apply FUNCTION r) (apply OLDFUN r)) | 229 | `:before' (lambda (&rest r) (apply FUNCTION r) (apply OLDFUN r)) |
| 229 | `:after' (lambda (&rest r) (prog1 (apply OLDFUN r) (apply FUNCTION r))) | 230 | `:after' (lambda (&rest r) (prog1 (apply OLDFUN r) (apply FUNCTION r))) |
| 230 | `:around' (lambda (&rest r) (apply FUNCTION OLDFUN r)) | 231 | `:around' (lambda (&rest r) (apply FUNCTION OLDFUN r)) |
| 232 | `:override' (lambda (&rest r) (apply FUNCTION r)) | ||
| 231 | `:before-while' (lambda (&rest r) (and (apply FUNCTION r) (apply OLDFUN r))) | 233 | `:before-while' (lambda (&rest r) (and (apply FUNCTION r) (apply OLDFUN r))) |
| 232 | `:before-until' (lambda (&rest r) (or (apply FUNCTION r) (apply OLDFUN r))) | 234 | `:before-until' (lambda (&rest r) (or (apply FUNCTION r) (apply OLDFUN r))) |
| 233 | `:after-while' (lambda (&rest r) (and (apply OLDFUN r) (apply FUNCTION r))) | 235 | `:after-while' (lambda (&rest r) (and (apply OLDFUN r) (apply FUNCTION r))) |
| @@ -263,6 +265,7 @@ is also interactive. There are 3 cases: | |||
| 263 | (setf (gv-deref ref) | 265 | (setf (gv-deref ref) |
| 264 | (advice--make where function (gv-deref ref) props)))) | 266 | (advice--make where function (gv-deref ref) props)))) |
| 265 | 267 | ||
| 268 | ;;;###autoload | ||
| 266 | (defmacro remove-function (place function) | 269 | (defmacro remove-function (place function) |
| 267 | "Remove the FUNCTION piece of advice from PLACE. | 270 | "Remove the FUNCTION piece of advice from PLACE. |
| 268 | If FUNCTION was not added to PLACE, do nothing. | 271 | If FUNCTION was not added to PLACE, do nothing. |
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'" | |||
| 574 | (concat (gdb-gud-context-command ,cmd1 ,noall) " " ,cmd2) | 574 | (concat (gdb-gud-context-command ,cmd1 ,noall) " " ,cmd2) |
| 575 | ,(when (not noarg) 'arg))) | 575 | ,(when (not noarg) 'arg))) |
| 576 | 576 | ||
| 577 | (defun gdb--check-interpreter (proc string) | 577 | (defun gdb--check-interpreter (filter proc string) |
| 578 | (unless (zerop (length string)) | 578 | (unless (zerop (length string)) |
| 579 | (let ((filter (process-get proc 'gud-normal-filter))) | 579 | (remove-function (process-filter proc) #'gdb--check-interpreter) |
| 580 | (set-process-filter proc filter) | 580 | (unless (memq (aref string 0) '(?^ ?~ ?@ ?& ?* ?=)) |
| 581 | (unless (memq (aref string 0) '(?^ ?~ ?@ ?& ?* ?=)) | 581 | ;; Apparently we're not running with -i=mi. |
| 582 | ;; Apparently we're not running with -i=mi. | 582 | (let ((msg "Error: you did not specify -i=mi on GDB's command line!")) |
| 583 | (let ((msg "Error: you did not specify -i=mi on GDB's command line!")) | 583 | (message msg) |
| 584 | (message msg) | 584 | (setq string (concat (propertize msg 'font-lock-face 'error) |
| 585 | (setq string (concat (propertize msg 'font-lock-face 'error) | 585 | "\n" string))) |
| 586 | "\n" string))) | 586 | ;; Use the old gud-gbd filter, not because it works, but because it |
| 587 | ;; Use the old gud-gbd filter, not because it works, but because it | 587 | ;; will properly display GDB's answers rather than hanging waiting for |
| 588 | ;; will properly display GDB's answers rather than hanging waiting for | 588 | ;; answers that aren't coming. |
| 589 | ;; answers that aren't coming. | 589 | (set (make-local-variable 'gud-marker-filter) #'gud-gdb-marker-filter)) |
| 590 | (set (make-local-variable 'gud-marker-filter) #'gud-gdb-marker-filter)) | 590 | (funcall filter proc string))) |
| 591 | (funcall filter proc string)))) | ||
| 592 | 591 | ||
| 593 | (defvar gdb-control-level 0) | 592 | (defvar gdb-control-level 0) |
| 594 | 593 | ||
| @@ -662,8 +661,7 @@ detailed description of this mode. | |||
| 662 | ;; Setup a temporary process filter to warn when GDB was not started | 661 | ;; Setup a temporary process filter to warn when GDB was not started |
| 663 | ;; with -i=mi. | 662 | ;; with -i=mi. |
| 664 | (let ((proc (get-buffer-process gud-comint-buffer))) | 663 | (let ((proc (get-buffer-process gud-comint-buffer))) |
| 665 | (process-put proc 'gud-normal-filter (process-filter proc)) | 664 | (add-function :around (process-filter proc) #'gdb--check-interpreter)) |
| 666 | (set-process-filter proc #'gdb--check-interpreter)) | ||
| 667 | 665 | ||
| 668 | (set (make-local-variable 'gud-minor-mode) 'gdbmi) | 666 | (set (make-local-variable 'gud-minor-mode) 'gdbmi) |
| 669 | (set (make-local-variable 'gdb-control-level) 0) | 667 | (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." | |||
| 3387 | 3387 | ||
| 3388 | ;;; Tips for `gud' | 3388 | ;;; Tips for `gud' |
| 3389 | 3389 | ||
| 3390 | (defvar gud-tooltip-original-filter nil | ||
| 3391 | "Process filter to restore after GUD output has been received.") | ||
| 3392 | |||
| 3393 | (defvar gud-tooltip-dereference nil | 3390 | (defvar gud-tooltip-dereference nil |
| 3394 | "Non-nil means print expressions with a `*' in front of them. | 3391 | "Non-nil means print expressions with a `*' in front of them. |
| 3395 | For C this would dereference a pointer expression.") | 3392 | For C this would dereference a pointer expression.") |
| @@ -3423,7 +3420,7 @@ With arg, dereference expr if ARG is positive, otherwise do not dereference." | |||
| 3423 | ; gdb-mi.el gets round this problem. | 3420 | ; gdb-mi.el gets round this problem. |
| 3424 | (defun gud-tooltip-process-output (process output) | 3421 | (defun gud-tooltip-process-output (process output) |
| 3425 | "Process debugger output and show it in a tooltip window." | 3422 | "Process debugger output and show it in a tooltip window." |
| 3426 | (set-process-filter process gud-tooltip-original-filter) | 3423 | (remove-function (process-filter process) #'gud-tooltip-process-output) |
| 3427 | (tooltip-show (tooltip-strip-prompt process output) | 3424 | (tooltip-show (tooltip-strip-prompt process output) |
| 3428 | (or gud-tooltip-echo-area tooltip-use-echo-area))) | 3425 | (or gud-tooltip-echo-area tooltip-use-echo-area))) |
| 3429 | 3426 | ||
| @@ -3490,8 +3487,8 @@ so they have been disabled.")) | |||
| 3490 | (gdb-input | 3487 | (gdb-input |
| 3491 | (concat cmd "\n") | 3488 | (concat cmd "\n") |
| 3492 | `(lambda () (gdb-tooltip-print ,expr)))) | 3489 | `(lambda () (gdb-tooltip-print ,expr)))) |
| 3493 | (setq gud-tooltip-original-filter (process-filter process)) | 3490 | (add-function :override (process-filter process) |
| 3494 | (set-process-filter process 'gud-tooltip-process-output) | 3491 | #'gud-tooltip-process-output) |
| 3495 | (gud-basic-call cmd)) | 3492 | (gud-basic-call cmd)) |
| 3496 | expr)))))))) | 3493 | expr)))))))) |
| 3497 | 3494 | ||
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'." | |||
| 348 | The elements of LIST have to be strings and are sent one by one. All | 348 | The elements of LIST have to be strings and are sent one by one. All |
| 349 | output is passed to the filter `inferior-octave-output-digest'." | 349 | output is passed to the filter `inferior-octave-output-digest'." |
| 350 | (let* ((proc inferior-octave-process) | 350 | (let* ((proc inferior-octave-process) |
| 351 | (filter (process-filter proc)) | ||
| 352 | string) | 351 | string) |
| 353 | (set-process-filter proc 'inferior-octave-output-digest) | 352 | (add-function :override (process-filter proc) |
| 353 | #'inferior-octave-output-digest) | ||
| 354 | (setq inferior-octave-output-list nil) | 354 | (setq inferior-octave-output-list nil) |
| 355 | (unwind-protect | 355 | (unwind-protect |
| 356 | (while (setq string (car list)) | 356 | (while (setq string (car list)) |
| @@ -360,7 +360,8 @@ output is passed to the filter `inferior-octave-output-digest'." | |||
| 360 | (while inferior-octave-receive-in-progress | 360 | (while inferior-octave-receive-in-progress |
| 361 | (accept-process-output proc)) | 361 | (accept-process-output proc)) |
| 362 | (setq list (cdr list))) | 362 | (setq list (cdr list))) |
| 363 | (set-process-filter proc filter)))) | 363 | (remove-function (process-filter proc) |
| 364 | #'inferior-octave-output-digest)))) | ||
| 364 | 365 | ||
| 365 | (defun inferior-octave-directory-tracker (string) | 366 | (defun inferior-octave-directory-tracker (string) |
| 366 | "Tracks `cd' commands issued to the inferior Octave process. | 367 | "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." | |||
| 1770 | real-file)) | 1770 | real-file)) |
| 1771 | (with-current-buffer buffer | 1771 | (with-current-buffer buffer |
| 1772 | (goto-char (point-max)) | 1772 | (goto-char (point-max)) |
| 1773 | (set-process-filter process 'prolog-consult-compile-filter) | 1773 | (add-function :override (process-filter process) |
| 1774 | #'prolog-consult-compile-filter) | ||
| 1774 | (process-send-string "prolog" command-string) | 1775 | (process-send-string "prolog" command-string) |
| 1775 | ;; (prolog-build-prolog-command compilep file real-file first-line)) | 1776 | ;; (prolog-build-prolog-command compilep file real-file first-line)) |
| 1776 | (while (and prolog-process-flag | 1777 | (while (and prolog-process-flag |
| @@ -1781,7 +1782,8 @@ This function must be called from the source code buffer." | |||
| 1781 | (insert (if compilep | 1782 | (insert (if compilep |
| 1782 | "\nCompilation finished.\n" | 1783 | "\nCompilation finished.\n" |
| 1783 | "\nConsulted.\n")) | 1784 | "\nConsulted.\n")) |
| 1784 | (set-process-filter process old-filter)))) | 1785 | (remove-function (process-filter process) |
| 1786 | #'prolog-consult-compile-filter)))) | ||
| 1785 | 1787 | ||
| 1786 | (defvar compilation-error-list) | 1788 | (defvar compilation-error-list) |
| 1787 | 1789 | ||
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 @@ | |||
| 35 | ;;;; Internal Variables | 35 | ;;;; Internal Variables |
| 36 | 36 | ||
| 37 | (defvar xscheme-previous-mode) | 37 | (defvar xscheme-previous-mode) |
| 38 | (defvar xscheme-previous-process-state) | ||
| 39 | (defvar xscheme-last-input-end) | 38 | (defvar xscheme-last-input-end) |
| 40 | 39 | ||
| 41 | (defvar xscheme-process-command-line nil | 40 | (defvar xscheme-process-command-line nil |
| @@ -388,8 +387,6 @@ with no args, if that value is non-nil. | |||
| 388 | (if (not preserve) | 387 | (if (not preserve) |
| 389 | (let ((previous-mode major-mode)) | 388 | (let ((previous-mode major-mode)) |
| 390 | (kill-all-local-variables) | 389 | (kill-all-local-variables) |
| 391 | (make-local-variable 'xscheme-process-name) | ||
| 392 | (make-local-variable 'xscheme-previous-process-state) | ||
| 393 | (make-local-variable 'xscheme-runlight-string) | 390 | (make-local-variable 'xscheme-runlight-string) |
| 394 | (make-local-variable 'xscheme-runlight) | 391 | (make-local-variable 'xscheme-runlight) |
| 395 | (set (make-local-variable 'xscheme-previous-mode) previous-mode) | 392 | (set (make-local-variable 'xscheme-previous-mode) previous-mode) |
| @@ -397,35 +394,29 @@ with no args, if that value is non-nil. | |||
| 397 | (set (make-local-variable 'xscheme-buffer-name) (buffer-name buffer)) | 394 | (set (make-local-variable 'xscheme-buffer-name) (buffer-name buffer)) |
| 398 | (set (make-local-variable 'xscheme-last-input-end) (make-marker)) | 395 | (set (make-local-variable 'xscheme-last-input-end) (make-marker)) |
| 399 | (let ((process (get-buffer-process buffer))) | 396 | (let ((process (get-buffer-process buffer))) |
| 400 | (if process | 397 | (when process |
| 401 | (progn | 398 | (setq-local xscheme-process-name (process-name process)) |
| 402 | (setq xscheme-process-name (process-name process)) | 399 | ;; FIXME: Use add-function! |
| 403 | (setq xscheme-previous-process-state | 400 | (xscheme-process-filter-initialize t) |
| 404 | (cons (process-filter process) | 401 | (xscheme-mode-line-initialize xscheme-buffer-name) |
| 405 | (process-sentinel process))) | 402 | (add-function :override (process-sentinel process) |
| 406 | (xscheme-process-filter-initialize t) | 403 | #'xscheme-process-sentinel) |
| 407 | (xscheme-mode-line-initialize xscheme-buffer-name) | 404 | (add-function :override (process-filter process) |
| 408 | (set-process-sentinel process 'xscheme-process-sentinel) | 405 | #'xscheme-process-filter)))))) |
| 409 | (set-process-filter process 'xscheme-process-filter)) | ||
| 410 | (setq xscheme-previous-process-state (cons nil nil))))))) | ||
| 411 | (scheme-interaction-mode-initialize) | 406 | (scheme-interaction-mode-initialize) |
| 412 | (scheme-mode-variables) | 407 | (scheme-mode-variables) |
| 413 | (run-mode-hooks 'scheme-mode-hook 'scheme-interaction-mode-hook)) | 408 | (run-mode-hooks 'scheme-mode-hook 'scheme-interaction-mode-hook)) |
| 414 | 409 | ||
| 415 | (defun exit-scheme-interaction-mode () | 410 | (defun exit-scheme-interaction-mode () |
| 416 | "Take buffer out of scheme interaction mode" | 411 | "Take buffer out of scheme interaction mode." |
| 417 | (interactive) | 412 | (interactive) |
| 418 | (if (not (derived-mode-p 'scheme-interaction-mode)) | 413 | (if (not (derived-mode-p 'scheme-interaction-mode)) |
| 419 | (error "Buffer not in scheme interaction mode")) | 414 | (error "Buffer not in scheme interaction mode")) |
| 420 | (let ((previous-state xscheme-previous-process-state)) | 415 | (funcall xscheme-previous-mode) |
| 421 | (funcall xscheme-previous-mode) | 416 | (let ((process (get-buffer-process (current-buffer)))) |
| 422 | (let ((process (get-buffer-process (current-buffer)))) | 417 | (when process |
| 423 | (if process | 418 | (remove-function (process-sentinel process) #'xscheme-process-sentinel) |
| 424 | (progn | 419 | (remove-function (process-filter process) #'xscheme-process-filter)))) |
| 425 | (if (eq (process-filter process) 'xscheme-process-filter) | ||
| 426 | (set-process-filter process (car previous-state))) | ||
| 427 | (if (eq (process-sentinel process) 'xscheme-process-sentinel) | ||
| 428 | (set-process-sentinel process (cdr previous-state)))))))) | ||
| 429 | 420 | ||
| 430 | (defvar scheme-interaction-mode-commands-alist nil) | 421 | (defvar scheme-interaction-mode-commands-alist nil) |
| 431 | (defvar scheme-interaction-mode-map nil) | 422 | (defvar scheme-interaction-mode-map nil) |
diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el index 407e691439b..334683898be 100644 --- a/lisp/vc/vc-cvs.el +++ b/lisp/vc/vc-cvs.el | |||
| @@ -562,14 +562,13 @@ Will fail unless you have administrative privileges on the repo." | |||
| 562 | 562 | ||
| 563 | (defconst vc-cvs-annotate-first-line-re "^[0-9]") | 563 | (defconst vc-cvs-annotate-first-line-re "^[0-9]") |
| 564 | 564 | ||
| 565 | (defun vc-cvs-annotate-process-filter (process string) | 565 | (defun vc-cvs-annotate-process-filter (filter process string) |
| 566 | (setq string (concat (process-get process 'output) string)) | 566 | (setq string (concat (process-get process 'output) string)) |
| 567 | (if (not (string-match vc-cvs-annotate-first-line-re string)) | 567 | (if (not (string-match vc-cvs-annotate-first-line-re string)) |
| 568 | ;; Still waiting for the first real line. | 568 | ;; Still waiting for the first real line. |
| 569 | (process-put process 'output string) | 569 | (process-put process 'output string) |
| 570 | (let ((vc-filter (process-get process 'vc-filter))) | 570 | (remove-function (process-filter process) #'vc-cvs-annotate-process-filter) |
| 571 | (set-process-filter process vc-filter) | 571 | (funcall filter process (substring string (match-beginning 0))))) |
| 572 | (funcall vc-filter process (substring string (match-beginning 0)))))) | ||
| 573 | 572 | ||
| 574 | (defun vc-cvs-annotate-command (file buffer &optional revision) | 573 | (defun vc-cvs-annotate-command (file buffer &optional revision) |
| 575 | "Execute \"cvs annotate\" on FILE, inserting the contents in BUFFER. | 574 | "Execute \"cvs annotate\" on FILE, inserting the contents in BUFFER. |
| @@ -583,9 +582,8 @@ Optional arg REVISION is a revision to annotate from." | |||
| 583 | (let ((proc (get-buffer-process buffer))) | 582 | (let ((proc (get-buffer-process buffer))) |
| 584 | (if proc | 583 | (if proc |
| 585 | ;; If running asynchronously, use a process filter. | 584 | ;; If running asynchronously, use a process filter. |
| 586 | (progn | 585 | (add-function :around (process-filter proc) |
| 587 | (process-put proc 'vc-filter (process-filter proc)) | 586 | #'vc-cvs-annotate-process-filter) |
| 588 | (set-process-filter proc 'vc-cvs-annotate-process-filter)) | ||
| 589 | (with-current-buffer buffer | 587 | (with-current-buffer buffer |
| 590 | (goto-char (point-min)) | 588 | (goto-char (point-min)) |
| 591 | (re-search-forward vc-cvs-annotate-first-line-re) | 589 | (re-search-forward vc-cvs-annotate-first-line-re) |
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 @@ | |||
| 1 | ;;; vc-dispatcher.el -- generic command-dispatcher facility. | 1 | ;;; vc-dispatcher.el -- generic command-dispatcher facility. -*- lexical-binding: t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2008-2013 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2008-2013 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -182,32 +182,29 @@ Another is that undo information is not kept." | |||
| 182 | 182 | ||
| 183 | (defvar vc-sentinel-movepoint) ;Dynamically scoped. | 183 | (defvar vc-sentinel-movepoint) ;Dynamically scoped. |
| 184 | 184 | ||
| 185 | (defun vc-process-sentinel (p s) | 185 | (defun vc--process-sentinel (p code) |
| 186 | (let ((previous (process-get p 'vc-previous-sentinel)) | 186 | (let ((buf (process-buffer p))) |
| 187 | (buf (process-buffer p))) | ||
| 188 | ;; Impatient users sometime kill "slow" buffers; check liveness | 187 | ;; Impatient users sometime kill "slow" buffers; check liveness |
| 189 | ;; to avoid "error in process sentinel: Selecting deleted buffer". | 188 | ;; to avoid "error in process sentinel: Selecting deleted buffer". |
| 190 | (when (buffer-live-p buf) | 189 | (when (buffer-live-p buf) |
| 191 | (when previous (funcall previous p s)) | ||
| 192 | (with-current-buffer buf | 190 | (with-current-buffer buf |
| 193 | (setq mode-line-process | 191 | (setq mode-line-process |
| 194 | (let ((status (process-status p))) | 192 | (let ((status (process-status p))) |
| 195 | ;; Leave mode-line uncluttered, normally. | 193 | ;; Leave mode-line uncluttered, normally. |
| 196 | (unless (eq 'exit status) | 194 | (unless (eq 'exit status) |
| 197 | (format " (%s)" status)))) | 195 | (format " (%s)" status)))) |
| 198 | (let (vc-sentinel-movepoint) | 196 | (let (vc-sentinel-movepoint |
| 197 | (m (process-mark p))) | ||
| 199 | ;; Normally, we want async code such as sentinels to not move point. | 198 | ;; Normally, we want async code such as sentinels to not move point. |
| 200 | (save-excursion | 199 | (save-excursion |
| 201 | (goto-char (process-mark p)) | 200 | (goto-char m) |
| 202 | (let ((cmds (process-get p 'vc-sentinel-commands))) | ||
| 203 | (process-put p 'vc-sentinel-commands nil) | ||
| 204 | (dolist (cmd cmds) | ||
| 205 | ;; Each sentinel may move point and the next one should be run | 201 | ;; Each sentinel may move point and the next one should be run |
| 206 | ;; at that new point. We could get the same result by having | 202 | ;; at that new point. We could get the same result by having |
| 207 | ;; each sentinel read&set process-mark, but since `cmd' needs | 203 | ;; each sentinel read&set process-mark, but since `cmd' needs |
| 208 | ;; to work both for async and sync processes, this would be | 204 | ;; to work both for async and sync processes, this would be |
| 209 | ;; difficult to achieve. | 205 | ;; difficult to achieve. |
| 210 | (vc-exec-after cmd)))) | 206 | (vc-exec-after code) |
| 207 | (move-marker m (point))) | ||
| 211 | ;; But sometimes the sentinels really want to move point. | 208 | ;; But sometimes the sentinels really want to move point. |
| 212 | (when vc-sentinel-movepoint | 209 | (when vc-sentinel-movepoint |
| 213 | (let ((win (get-buffer-window (current-buffer) 0))) | 210 | (let ((win (get-buffer-window (current-buffer) 0))) |
| @@ -226,7 +223,9 @@ Another is that undo information is not kept." | |||
| 226 | (defun vc-exec-after (code) | 223 | (defun vc-exec-after (code) |
| 227 | "Eval CODE when the current buffer's process is done. | 224 | "Eval CODE when the current buffer's process is done. |
| 228 | If the current buffer has no process, just evaluate CODE. | 225 | If the current buffer has no process, just evaluate CODE. |
| 229 | Else, add CODE to the process' sentinel." | 226 | Else, add CODE to the process' sentinel. |
| 227 | CODE can be either a function of no arguments, or an expression | ||
| 228 | to evaluate." | ||
| 230 | (let ((proc (get-buffer-process (current-buffer)))) | 229 | (let ((proc (get-buffer-process (current-buffer)))) |
| 231 | (cond | 230 | (cond |
| 232 | ;; If there's no background process, just execute the code. | 231 | ;; If there's no background process, just execute the code. |
| @@ -237,20 +236,14 @@ Else, add CODE to the process' sentinel." | |||
| 237 | ((or (null proc) (eq (process-status proc) 'exit)) | 236 | ((or (null proc) (eq (process-status proc) 'exit)) |
| 238 | ;; Make sure we've read the process's output before going further. | 237 | ;; Make sure we've read the process's output before going further. |
| 239 | (when proc (accept-process-output proc)) | 238 | (when proc (accept-process-output proc)) |
| 240 | (eval code)) | 239 | (if (functionp code) (funcall code) (eval code))) |
| 241 | ;; If a process is running, add CODE to the sentinel | 240 | ;; If a process is running, add CODE to the sentinel |
| 242 | ((eq (process-status proc) 'run) | 241 | ((eq (process-status proc) 'run) |
| 243 | (vc-set-mode-line-busy-indicator) | 242 | (vc-set-mode-line-busy-indicator) |
| 244 | (let ((previous (process-sentinel proc))) | 243 | (letrec ((fun (lambda (p _msg) |
| 245 | (unless (eq previous 'vc-process-sentinel) | 244 | (remove-function (process-sentinel p) fun) |
| 246 | (process-put proc 'vc-previous-sentinel previous)) | 245 | (vc--process-sentinel p code)))) |
| 247 | (set-process-sentinel proc 'vc-process-sentinel)) | 246 | (add-function :after (process-sentinel proc) fun))) |
| 248 | (process-put proc 'vc-sentinel-commands | ||
| 249 | ;; We keep the code fragments in the order given | ||
| 250 | ;; so that vc-diff-finish's message shows up in | ||
| 251 | ;; the presence of non-nil vc-command-messages. | ||
| 252 | (append (process-get proc 'vc-sentinel-commands) | ||
| 253 | (list code)))) | ||
| 254 | (t (error "Unexpected process state")))) | 247 | (t (error "Unexpected process state")))) |
| 255 | nil) | 248 | nil) |
| 256 | 249 | ||
| @@ -388,6 +381,8 @@ Display the buffer in some window, but don't select it." | |||
| 388 | (set-window-start window new-window-start)) | 381 | (set-window-start window new-window-start)) |
| 389 | buffer)) | 382 | buffer)) |
| 390 | 383 | ||
| 384 | (defvar compilation-error-regexp-alist) | ||
| 385 | |||
| 391 | (defun vc-compilation-mode (backend) | 386 | (defun vc-compilation-mode (backend) |
| 392 | "Setup `compilation-mode' after with the appropriate `compilation-error-regexp-alist'." | 387 | "Setup `compilation-mode' after with the appropriate `compilation-error-regexp-alist'." |
| 393 | (let* ((error-regexp-alist | 388 | (let* ((error-regexp-alist |
| @@ -479,7 +474,7 @@ Used by `vc-restore-buffer-context' to later restore the context." | |||
| 479 | (vc-position-context (mark-marker)))) | 474 | (vc-position-context (mark-marker)))) |
| 480 | ;; Make the right thing happen in transient-mark-mode. | 475 | ;; Make the right thing happen in transient-mark-mode. |
| 481 | (mark-active nil)) | 476 | (mark-active nil)) |
| 482 | (list point-context mark-context nil))) | 477 | (list point-context mark-context))) |
| 483 | 478 | ||
| 484 | (defun vc-restore-buffer-context (context) | 479 | (defun vc-restore-buffer-context (context) |
| 485 | "Restore point/mark, and reparse any affected compilation buffers. | 480 | "Restore point/mark, and reparse any affected compilation buffers. |
| @@ -518,6 +513,8 @@ ARG and NO-CONFIRM are passed on to `revert-buffer'." | |||
| 518 | (make-variable-buffer-local 'vc-mode-line-hook) | 513 | (make-variable-buffer-local 'vc-mode-line-hook) |
| 519 | (put 'vc-mode-line-hook 'permanent-local t) | 514 | (put 'vc-mode-line-hook 'permanent-local t) |
| 520 | 515 | ||
| 516 | (defvar view-old-buffer-read-only) | ||
| 517 | |||
| 521 | (defun vc-resynch-window (file &optional keep noquery reset-vc-info) | 518 | (defun vc-resynch-window (file &optional keep noquery reset-vc-info) |
| 522 | "If FILE is in the current buffer, either revert or unvisit it. | 519 | "If FILE is in the current buffer, either revert or unvisit it. |
| 523 | The choice between revert (to see expanded keywords) and unvisit | 520 | The choice between revert (to see expanded keywords) and unvisit |