aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1995-01-19 18:56:10 +0000
committerRichard M. Stallman1995-01-19 18:56:10 +0000
commitd5a539cd375567e1d5e39d79a9363b73745fb48f (patch)
tree7ce597345d5a983b89b8df91fbcae5e8d07b6af6 /src
parentefcce2d2d10639b8c72c019da6e121319c1bf65c (diff)
downloademacs-d5a539cd375567e1d5e39d79a9363b73745fb48f.tar.gz
emacs-d5a539cd375567e1d5e39d79a9363b73745fb48f.zip
(subst_char_in_region_unwind): New function.
(Fsubst_char_in_region): Use it to make undo_list t temporarily.
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 657aca333f9..6abbe0e9a26 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1266,6 +1266,13 @@ determines whether case is significant or ignored.")
1266 return make_number (0); 1266 return make_number (0);
1267} 1267}
1268 1268
1269static Lisp_Object
1270subst_char_in_region_unwind (arg)
1271 Lisp_Object arg;
1272{
1273 return current_buffer->undo_list = arg;
1274}
1275
1269DEFUN ("subst-char-in-region", Fsubst_char_in_region, 1276DEFUN ("subst-char-in-region", Fsubst_char_in_region,
1270 Ssubst_char_in_region, 4, 5, 0, 1277 Ssubst_char_in_region, 4, 5, 0,
1271 "From START to END, replace FROMCHAR with TOCHAR each time it occurs.\n\ 1278 "From START to END, replace FROMCHAR with TOCHAR each time it occurs.\n\
@@ -1276,6 +1283,7 @@ and don't mark the buffer as really changed.")
1276{ 1283{
1277 register int pos, stop, look; 1284 register int pos, stop, look;
1278 int changed = 0; 1285 int changed = 0;
1286 int count = specpdl_ptr - specpdl;
1279 1287
1280 validate_region (&start, &end); 1288 validate_region (&start, &end);
1281 CHECK_NUMBER (fromchar, 2); 1289 CHECK_NUMBER (fromchar, 2);
@@ -1285,6 +1293,16 @@ and don't mark the buffer as really changed.")
1285 stop = XINT (end); 1293 stop = XINT (end);
1286 look = XINT (fromchar); 1294 look = XINT (fromchar);
1287 1295
1296 /* If we don't want undo, turn off putting stuff on the list.
1297 That's faster than getting rid of things,
1298 and it prevents even the entry for a first change. */
1299 if (!NILP (noundo))
1300 {
1301 record_unwind_protect (subst_char_in_region_unwind,
1302 current_buffer->undo_list);
1303 current_buffer->undo_list = Qt;
1304 }
1305
1288 while (pos < stop) 1306 while (pos < stop)
1289 { 1307 {
1290 if (FETCH_CHAR (pos) == look) 1308 if (FETCH_CHAR (pos) == look)
@@ -1315,6 +1333,7 @@ and don't mark the buffer as really changed.")
1315 signal_after_change (XINT (start), 1333 signal_after_change (XINT (start),
1316 stop - XINT (start), stop - XINT (start)); 1334 stop - XINT (start), stop - XINT (start));
1317 1335
1336 unbind_to (count, Qnil);
1318 return Qnil; 1337 return Qnil;
1319} 1338}
1320 1339