diff options
| author | Mattias EngdegÄrd | 2020-05-28 16:37:27 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2020-05-28 16:58:57 +0200 |
| commit | 2bdb2cd10d08a1d9c9a187c7d967fdc64b8e6743 (patch) | |
| tree | 4fc24048cdf3148f3b94fe51bb30531f9fd37896 | |
| parent | 4939beacb33ea91cd35e18fa7d43a4392d47f6f4 (diff) | |
| download | emacs-2bdb2cd10d08a1d9c9a187c7d967fdc64b8e6743.tar.gz emacs-2bdb2cd10d08a1d9c9a187c7d967fdc64b8e6743.zip | |
Document that {en,de}code-coding-string preserve match data
* lisp/international/mule.el (define-coding-system):
Require :pre-write-conversion and :post-read-conversion functions
to leave the match data untouched.
* src/coding.c (Fdecode_coding_string, Fencode_coding_string):
Document functions as match-data-preserving.
Suggested by Stefan Monnier (see bug#41445).
| -rw-r--r-- | lisp/international/mule.el | 25 | ||||
| -rw-r--r-- | src/coding.c | 4 |
2 files changed, 15 insertions, 14 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el index 72e8cad9d62..df71205d515 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el | |||
| @@ -769,11 +769,12 @@ decoded by the coding system itself and before any functions in | |||
| 769 | `after-insert-functions' are called. This function is passed one | 769 | `after-insert-functions' are called. This function is passed one |
| 770 | argument: the number of characters in the text to convert, with | 770 | argument: the number of characters in the text to convert, with |
| 771 | point at the start of the text. The function should leave point | 771 | point at the start of the text. The function should leave point |
| 772 | unchanged, and should return the new character count. Note that | 772 | and the match data unchanged, and should return the new character |
| 773 | this function should avoid reading from files or receiving text | 773 | count. Note that this function should avoid reading from files |
| 774 | from subprocesses -- anything that could invoke decoding; if it | 774 | or receiving text from subprocesses -- anything that could invoke |
| 775 | must do so, it should bind `coding-system-for-read' to a value | 775 | decoding; if it must do so, it should bind |
| 776 | other than the current coding-system, to avoid infinite recursion. | 776 | `coding-system-for-read' to a value other than the current |
| 777 | coding-system, to avoid infinite recursion. | ||
| 777 | 778 | ||
| 778 | `:pre-write-conversion' | 779 | `:pre-write-conversion' |
| 779 | 780 | ||
| @@ -781,13 +782,13 @@ VALUE must be a function to call after all functions in | |||
| 781 | `write-region-annotate-functions' and `buffer-file-format' are | 782 | `write-region-annotate-functions' and `buffer-file-format' are |
| 782 | called, and before the text is encoded by the coding system | 783 | called, and before the text is encoded by the coding system |
| 783 | itself. This function should convert the whole text in the | 784 | itself. This function should convert the whole text in the |
| 784 | current buffer. For backward compatibility, this function is | 785 | current buffer, and leave the match data unchanged. For backward |
| 785 | passed two arguments which can be ignored. Note that this | 786 | compatibility, this function is passed two arguments which can be |
| 786 | function should avoid writing to files or sending text to | 787 | ignored. Note that this function should avoid writing to files |
| 787 | subprocesses -- anything that could invoke encoding; if it | 788 | or sending text to subprocesses -- anything that could invoke |
| 788 | must do so, it should bind `coding-system-for-write' to a | 789 | encoding; if it must do so, it should bind |
| 789 | value other than the current coding-system, to avoid infinite | 790 | `coding-system-for-write' to a value other than the current |
| 790 | recursion. | 791 | coding-system, to avoid infinite recursion. |
| 791 | 792 | ||
| 792 | `:default-char' | 793 | `:default-char' |
| 793 | 794 | ||
diff --git a/src/coding.c b/src/coding.c index 34f36d5a86a..071124b4ef1 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -10395,7 +10395,7 @@ representation of the decoded text. | |||
| 10395 | 10395 | ||
| 10396 | This function sets `last-coding-system-used' to the precise coding system | 10396 | This function sets `last-coding-system-used' to the precise coding system |
| 10397 | used (which may be different from CODING-SYSTEM if CODING-SYSTEM is | 10397 | used (which may be different from CODING-SYSTEM if CODING-SYSTEM is |
| 10398 | not fully specified.) */) | 10398 | not fully specified.) The function does not change the match data. */) |
| 10399 | (Lisp_Object string, Lisp_Object coding_system, Lisp_Object nocopy, Lisp_Object buffer) | 10399 | (Lisp_Object string, Lisp_Object coding_system, Lisp_Object nocopy, Lisp_Object buffer) |
| 10400 | { | 10400 | { |
| 10401 | return code_convert_string (string, coding_system, buffer, | 10401 | return code_convert_string (string, coding_system, buffer, |
| @@ -10415,7 +10415,7 @@ case, the return value is the length of the encoded text. | |||
| 10415 | 10415 | ||
| 10416 | This function sets `last-coding-system-used' to the precise coding system | 10416 | This function sets `last-coding-system-used' to the precise coding system |
| 10417 | used (which may be different from CODING-SYSTEM if CODING-SYSTEM is | 10417 | used (which may be different from CODING-SYSTEM if CODING-SYSTEM is |
| 10418 | not fully specified.) */) | 10418 | not fully specified.) The function does not change the match data. */) |
| 10419 | (Lisp_Object string, Lisp_Object coding_system, Lisp_Object nocopy, Lisp_Object buffer) | 10419 | (Lisp_Object string, Lisp_Object coding_system, Lisp_Object nocopy, Lisp_Object buffer) |
| 10420 | { | 10420 | { |
| 10421 | return code_convert_string (string, coding_system, buffer, | 10421 | return code_convert_string (string, coding_system, buffer, |