┃ It would be useful if ed displayed which exactly regex did not match,
┃ and against what. So, instead of
┃
┃ script, line 359: No match
┃
┃ we get
┃
┃ script, line 359: No match of "" against /^[ ]\{2\}[eo][nt][dh]\(er.*\)*$/The "No match" error is generated if the regular expression doesn't match any lines in a range. So the context is a range of lines, with line 359 of the script containing the regular expression that matched nothing in that range. It seems to me that the script line number is more relevant than the actual regular expression, so I'm not sure how more context would help here? Please correct me if I'm misunderstanding. And if typing `359' while editing the script in ed is inadequate, one possibility would be to invoke the script with GNU Emacs in ed-mode (https://github.com/slewsys/ed/blob/main/contrib/ed-mode.el). When ed is invoked with `-f SCRIPT-FILE', or if the script itself begins with the magic: #!/usr/bin/env -S ed -f errors are written in Emacs-compatible format. For example, with the ed script open in Emacs, enable ed-mode and then run the script with Emacs compile: C-x C-f /path/to/ed-script M-x eval-expression <RET> (require 'ed-mode) M-x ed-mode M-x compile <RET> ed -f /path/to/ed-script [file ...] C-x ` ;;; Go to next error (e.g., line 359) Of course, `-f SCRIPT-FILE' is an extension to POSIX, but slewsys/ed is, nonetheless, the most POSIX-compatible version among GNU, macOS and *BSD ed's.
