diff options
| author | Glenn Morris | 2019-08-20 09:04:53 -0700 |
|---|---|---|
| committer | Glenn Morris | 2019-08-20 09:04:53 -0700 |
| commit | af103ef3c9d6df07475e2b3a2f846246d7fd2a8b (patch) | |
| tree | a7e0a0cb7db56b68b8b3a0c3c29a6b90d61edff7 | |
| parent | 989c85e799b7c3a425d3d03f98ecd55d5cf76022 (diff) | |
| parent | 615cff42580a3521c1a4ea7c3ec467eb8259e1c7 (diff) | |
| download | emacs-af103ef3c9d6df07475e2b3a2f846246d7fd2a8b.tar.gz emacs-af103ef3c9d6df07475e2b3a2f846246d7fd2a8b.zip | |
Merge from origin/emacs-26
615cff4 (origin/emacs-26) Fix process filter documentation (Bug#13400)
beb1d22 Fix query-replace-regexp undo feature
# Conflicts:
# test/lisp/replace-tests.el
| -rw-r--r-- | doc/lispref/processes.texi | 29 | ||||
| -rw-r--r-- | lisp/replace.el | 7 | ||||
| -rw-r--r-- | test/lisp/replace-tests.el | 27 |
3 files changed, 44 insertions, 19 deletions
diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index 7a696f7c3ea..21bc32e88b6 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi | |||
| @@ -596,9 +596,8 @@ process}. After an asynchronous process is created, it runs in | |||
| 596 | parallel with Emacs, and Emacs can communicate with it using the | 596 | parallel with Emacs, and Emacs can communicate with it using the |
| 597 | functions described in the following sections (@pxref{Input to | 597 | functions described in the following sections (@pxref{Input to |
| 598 | Processes}, and @pxref{Output from Processes}). Note that process | 598 | Processes}, and @pxref{Output from Processes}). Note that process |
| 599 | communication is only partially asynchronous: Emacs sends data to the | 599 | communication is only partially asynchronous: Emacs sends and receives |
| 600 | process only when certain functions are called, and Emacs accepts data | 600 | data to and from a process only when those functions are called. |
| 601 | from the process only while waiting for input or for a time delay. | ||
| 602 | 601 | ||
| 603 | @cindex pty, when to use for subprocess communications | 602 | @cindex pty, when to use for subprocess communications |
| 604 | @cindex pipe, when to use for subprocess communications | 603 | @cindex pipe, when to use for subprocess communications |
| @@ -1245,8 +1244,9 @@ the defaulting mechanism (@pxref{Default Coding Systems}). | |||
| 1245 | because the input buffer is full. When this happens, the send functions | 1244 | because the input buffer is full. When this happens, the send functions |
| 1246 | wait a short while, accepting output from subprocesses, and then try | 1245 | wait a short while, accepting output from subprocesses, and then try |
| 1247 | again. This gives the subprocess a chance to read more of its pending | 1246 | again. This gives the subprocess a chance to read more of its pending |
| 1248 | input and make space in the buffer. It also allows filters, sentinels | 1247 | input and make space in the buffer. It also allows filters (including |
| 1249 | and timers to run---so take account of that in writing your code. | 1248 | the one currently running), sentinels and timers to run---so take |
| 1249 | account of that in writing your code. | ||
| 1250 | 1250 | ||
| 1251 | In these functions, the @var{process} argument can be a process or | 1251 | In these functions, the @var{process} argument can be a process or |
| 1252 | the name of a process, or a buffer or buffer name (which stands | 1252 | the name of a process, or a buffer or buffer name (which stands |
| @@ -1461,9 +1461,10 @@ output, Emacs won't receive that output. | |||
| 1461 | 1461 | ||
| 1462 | Output from a subprocess can arrive only while Emacs is waiting: when | 1462 | Output from a subprocess can arrive only while Emacs is waiting: when |
| 1463 | reading terminal input (see the function @code{waiting-for-user-input-p}), | 1463 | reading terminal input (see the function @code{waiting-for-user-input-p}), |
| 1464 | in @code{sit-for} and @code{sleep-for} (@pxref{Waiting}), and in | 1464 | in @code{sit-for} and @code{sleep-for} (@pxref{Waiting}), in |
| 1465 | @code{accept-process-output} (@pxref{Accepting Output}). This | 1465 | @code{accept-process-output} (@pxref{Accepting Output}), and in |
| 1466 | minimizes the problem of timing errors that usually plague parallel | 1466 | functions which send data to processes (@pxref{Input to Processes}). |
| 1467 | This minimizes the problem of timing errors that usually plague parallel | ||
| 1467 | programming. For example, you can safely create a process and only | 1468 | programming. For example, you can safely create a process and only |
| 1468 | then specify its buffer or filter function; no output can arrive | 1469 | then specify its buffer or filter function; no output can arrive |
| 1469 | before you finish, if the code in between does not call any primitive | 1470 | before you finish, if the code in between does not call any primitive |
| @@ -1639,14 +1640,10 @@ outputs directly to the process buffer. | |||
| 1639 | By default, the error output from the process, if any, is also | 1640 | By default, the error output from the process, if any, is also |
| 1640 | passed to the filter function, unless the destination for the standard | 1641 | passed to the filter function, unless the destination for the standard |
| 1641 | error stream of the process was separated from the standard output | 1642 | error stream of the process was separated from the standard output |
| 1642 | when the process was created (@pxref{Output from Processes}). | 1643 | when the process was created. Emacs will only call the filter |
| 1643 | 1644 | function during certain function calls. @xref{Output from Processes}. | |
| 1644 | The filter function can only be called when Emacs is waiting for | 1645 | Note that if any of those functions are called by the filter, the |
| 1645 | something, because process output arrives only at such times. Emacs | 1646 | filter may be called recursively. |
| 1646 | waits when reading terminal input (see the function | ||
| 1647 | @code{waiting-for-user-input-p}), in @code{sit-for} and | ||
| 1648 | @code{sleep-for} (@pxref{Waiting}), and in | ||
| 1649 | @code{accept-process-output} (@pxref{Accepting Output}). | ||
| 1650 | 1647 | ||
| 1651 | A filter function must accept two arguments: the associated process | 1648 | A filter function must accept two arguments: the associated process |
| 1652 | and a string, which is output just received from it. The function is | 1649 | and a string, which is output just received from it. The function is |
diff --git a/lisp/replace.el b/lisp/replace.el index 7c6c6fc9b7f..ad9be77a79b 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -2728,7 +2728,8 @@ characters." | |||
| 2728 | (setq real-match-data | 2728 | (setq real-match-data |
| 2729 | (save-excursion | 2729 | (save-excursion |
| 2730 | (goto-char (match-beginning 0)) | 2730 | (goto-char (match-beginning 0)) |
| 2731 | (looking-at search-string) | 2731 | ;; We must quote the string (Bug#37073) |
| 2732 | (looking-at (regexp-quote search-string)) | ||
| 2732 | (match-data t (nth 2 elt))) | 2733 | (match-data t (nth 2 elt))) |
| 2733 | noedit | 2734 | noedit |
| 2734 | (replace-match-maybe-edit | 2735 | (replace-match-maybe-edit |
| @@ -2738,7 +2739,9 @@ characters." | |||
| 2738 | real-match-data | 2739 | real-match-data |
| 2739 | (save-excursion | 2740 | (save-excursion |
| 2740 | (goto-char (match-beginning 0)) | 2741 | (goto-char (match-beginning 0)) |
| 2741 | (looking-at next-replacement) | 2742 | (if regexp-flag |
| 2743 | (looking-at next-replacement) | ||
| 2744 | (looking-at (regexp-quote next-replacement))) | ||
| 2742 | (match-data t (nth 2 elt)))) | 2745 | (match-data t (nth 2 elt)))) |
| 2743 | ;; Set replaced nil to keep in loop | 2746 | ;; Set replaced nil to keep in loop |
| 2744 | (when (eq def 'undo-all) | 2747 | (when (eq def 'undo-all) |
diff --git a/test/lisp/replace-tests.el b/test/lisp/replace-tests.el index c908d4e2a71..f7bf2d93658 100644 --- a/test/lisp/replace-tests.el +++ b/test/lisp/replace-tests.el | |||
| @@ -411,6 +411,9 @@ Each element has the format: | |||
| 411 | (defvar replace-tests-bind-read-string nil | 411 | (defvar replace-tests-bind-read-string nil |
| 412 | "A string to bind `read-string' and avoid the prompt.") | 412 | "A string to bind `read-string' and avoid the prompt.") |
| 413 | 413 | ||
| 414 | (defvar replace-tests-perform-replace-regexp-flag t | ||
| 415 | "Value for regexp-flag argument passed to `perform-replace' in undo tests.") | ||
| 416 | |||
| 414 | (defmacro replace-tests-with-undo (input from to char-nums def-chr &rest body) | 417 | (defmacro replace-tests-with-undo (input from to char-nums def-chr &rest body) |
| 415 | "Helper to test `query-replace' undo feature. | 418 | "Helper to test `query-replace' undo feature. |
| 416 | INPUT is a string to insert in a temporary buffer. | 419 | INPUT is a string to insert in a temporary buffer. |
| @@ -463,7 +466,7 @@ Return the last evalled form in BODY." | |||
| 463 | ((symbol-function 'replace-highlight) | 466 | ((symbol-function 'replace-highlight) |
| 464 | (lambda (&rest _args) | 467 | (lambda (&rest _args) |
| 465 | (string-match "[A-Z ]" "ForestGreen")))) | 468 | (string-match "[A-Z ]" "ForestGreen")))) |
| 466 | (perform-replace ,from ,to t t nil)) | 469 | (perform-replace ,from ,to t replace-tests-perform-replace-regexp-flag nil)) |
| 467 | ,@body)))) | 470 | ,@body)))) |
| 468 | 471 | ||
| 469 | (defun replace-tests--query-replace-undo (&optional comma) | 472 | (defun replace-tests--query-replace-undo (&optional comma) |
| @@ -505,4 +508,26 @@ Return the last evalled form in BODY." | |||
| 505 | input "a" "B" ((?\s . (1 2 3)) (?E . (4)) (?U . (5))) ?q | 508 | input "a" "B" ((?\s . (1 2 3)) (?E . (4)) (?U . (5))) ?q |
| 506 | (string= input (buffer-string)))))) | 509 | (string= input (buffer-string)))))) |
| 507 | 510 | ||
| 511 | (ert-deftest query-replace-undo-bug37073 () | ||
| 512 | "Test for https://debbugs.gnu.org/37073 ." | ||
| 513 | (let ((input "theorem 1\ntheorem 2\ntheorem 3")) | ||
| 514 | (should | ||
| 515 | (replace-tests-with-undo | ||
| 516 | input "theorem \\([0-9]+\\)" | ||
| 517 | "theorem \\\\ref{theo_\\1}" | ||
| 518 | ((?\s . (1 2)) (?U . (3))) | ||
| 519 | ?q | ||
| 520 | (string= input (buffer-string))))) | ||
| 521 | ;; Now run a test with regexp-flag arg in `perform-replace' set to nil | ||
| 522 | (let ((input " ^theorem$ 1\n ^theorem$ 2\n ^theorem$ 3") | ||
| 523 | (replace-tests-perform-replace-regexp-flag nil) | ||
| 524 | (expected " theo 1\n ^theorem$ 2\n ^theorem$ 3")) | ||
| 525 | (should | ||
| 526 | (replace-tests-with-undo | ||
| 527 | input "^theorem$" | ||
| 528 | "theo" | ||
| 529 | ((?\s . (1 2 4)) (?U . (3))) | ||
| 530 | ?q | ||
| 531 | (string= expected (buffer-string)))))) | ||
| 532 | |||
| 508 | ;;; replace-tests.el ends here | 533 | ;;; replace-tests.el ends here |