aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-08-03 16:00:20 +0200
committerLars Ingebrigtsen2019-08-03 16:00:20 +0200
commit18e163fd3455deaa30b1effd19f51a5094bc0885 (patch)
tree3eb2bab1fe2b981c1f2e04b75e9dc53cb63e4310
parentf77a39514687f57c947e9105172c3d3821a759cc (diff)
downloademacs-18e163fd3455deaa30b1effd19f51a5094bc0885.tar.gz
emacs-18e163fd3455deaa30b1effd19f51a5094bc0885.zip
Fix error message in replace-match for subexpressions
* src/search.c (Freplace_match): Output a more understandable error message when replacing a subexpression (bug#19208).
-rw-r--r--src/search.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/search.c b/src/search.c
index 2fa8b277195..0e2ae059e81 100644
--- a/src/search.c
+++ b/src/search.c
@@ -2404,6 +2404,12 @@ since only regular expressions have distinguished subexpressions. */)
2404 args_out_of_range (subexp, make_fixnum (search_regs.num_regs)); 2404 args_out_of_range (subexp, make_fixnum (search_regs.num_regs));
2405 } 2405 }
2406 2406
2407 /* Check whether the subexpression to replace is greater than the
2408 number of subexpressions in the regexp. */
2409 if (sub > 0 && search_regs.start[sub] == -1)
2410 args_out_of_range (build_string ("Attempt to replace regexp subexpression that doesn't exist"),
2411 subexp);
2412
2407 /* Sanity check to see whether the text to replace is present in the 2413 /* Sanity check to see whether the text to replace is present in the
2408 buffer/string. */ 2414 buffer/string. */
2409 if (NILP (string)) 2415 if (NILP (string))