diff options
| author | Richard M. Stallman | 1994-11-22 04:31:18 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-11-22 04:31:18 +0000 |
| commit | d1280259390d7e614b421d87dd0dee5ec92ad23b (patch) | |
| tree | 0773725b8c36df3c186eb323336fcbb97b8cd796 | |
| parent | 4f734bde414dd92c11fe288753adce26cf12eaa3 (diff) | |
| download | emacs-d1280259390d7e614b421d87dd0dee5ec92ad23b.tar.gz emacs-d1280259390d7e614b421d87dd0dee5ec92ad23b.zip | |
Filters and sentinels now save match data themselves.
| -rw-r--r-- | lispref/searching.texi | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/lispref/searching.texi b/lispref/searching.texi index c6dfc72321f..0de6b907771 100644 --- a/lispref/searching.texi +++ b/lispref/searching.texi | |||
| @@ -1106,15 +1106,10 @@ an error; that sets the match data in a meaningless but harmless way. | |||
| 1106 | @node Saving Match Data | 1106 | @node Saving Match Data |
| 1107 | @subsection Saving and Restoring the Match Data | 1107 | @subsection Saving and Restoring the Match Data |
| 1108 | 1108 | ||
| 1109 | All asynchronous process functions (filters and sentinels) and | 1109 | When you call a function that may do a search, you may need to save |
| 1110 | functions that use @code{recursive-edit} should save and restore the | 1110 | and restore the match data around that call, if you want to preserve the |
| 1111 | match data if they do a search or if they let the user type arbitrary | 1111 | match data from an earlier search for later use. Here is an example |
| 1112 | commands. Saving the match data is useful in other cases as | 1112 | that shows the problem that arises if you fail to save the match data: |
| 1113 | well---whenever you want to access the match data resulting from an | ||
| 1114 | earlier search, notwithstanding another intervening search. | ||
| 1115 | |||
| 1116 | This example shows the problem that can arise if you fail to | ||
| 1117 | attend to this requirement: | ||
| 1118 | 1113 | ||
| 1119 | @example | 1114 | @example |
| 1120 | @group | 1115 | @group |
| @@ -1127,13 +1122,11 @@ attend to this requirement: | |||
| 1127 | @end group | 1122 | @end group |
| 1128 | @end example | 1123 | @end example |
| 1129 | 1124 | ||
| 1130 | In Emacs versions 19 and later, you can save and restore the match | 1125 | You can save and restore the match data with @code{save-match-data}: |
| 1131 | data with @code{save-match-data}: | ||
| 1132 | 1126 | ||
| 1133 | @defspec save-match-data body@dots{} | 1127 | @defspec save-match-data body@dots{} |
| 1134 | This special form executes @var{body}, saving and restoring the match | 1128 | This special form executes @var{body}, saving and restoring the match |
| 1135 | data around it. This is useful if you wish to do a search without | 1129 | data around it. |
| 1136 | altering the match data that resulted from an earlier search. | ||
| 1137 | @end defspec | 1130 | @end defspec |
| 1138 | 1131 | ||
| 1139 | You can use @code{set-match-data} together with @code{match-data} to | 1132 | You can use @code{set-match-data} together with @code{match-data} to |
| @@ -1149,6 +1142,10 @@ useful for writing code that can run in Emacs 18. Here is how: | |||
| 1149 | @end group | 1142 | @end group |
| 1150 | @end example | 1143 | @end example |
| 1151 | 1144 | ||
| 1145 | Emacs automatically saves and restores the match data when it runs | ||
| 1146 | process filter functions (@pxref{Filter Functions}) and process | ||
| 1147 | sentinels (@pxref{Sentinels}). | ||
| 1148 | |||
| 1152 | @ignore | 1149 | @ignore |
| 1153 | Here is a function which restores the match data provided the buffer | 1150 | Here is a function which restores the match data provided the buffer |
| 1154 | associated with it still exists. | 1151 | associated with it still exists. |