As suggested by Stefan Monnier.
* src/lread.c (read_escape):
Signal an error for ?\LF since it cannot reasonably be intended.
* test/src/lread-tests.el (lread-escaped-lf): Update test.
* etc/NEWS: Announce.
called by both of these, the hook is now run by all 3 of these
functions.
+---
+** '?\' at the end of a line now signals an error.
+Previously it produced a nonsense value, -1, that was never intended.
\f
* Lisp Changes in Emacs 29.1
case 'v':
return '\v';
+ case '\n':
+ /* ?\LF is an error; it's probably a user mistake. */
+ error ("Invalid escape character syntax");
+
case 'M':
c = READCHAR;
if (c != '-')
'(## . 2))))
(ert-deftest lread-escaped-lf ()
- ;; ?\LF should produce LF (only inside string literals do we ignore \LF).
- (should (equal (read-from-string "?\\\n") '(?\n . 3)))
+ ;; ?\LF should signal an error; \LF is ignored inside string literals.
+ (should-error (read-from-string "?\\\n x"))
(should (equal (read-from-string "\"a\\\nb\"") '("ab" . 6))))
;;; lread-tests.el ends here