I consider the name "null" for a goto section as too misleading. I would prefer something like "nokey" or "skipkey".
Cheers, Emil Engler On Thu, Feb 25, 2021 at 07:40:01PM +0000, Mark Lumsden wrote: > I was testing mg's goto-line function via the minibuffer (M-x goto-line) and > I just kept my finger on the '0' key. After a brief time '0's started > appearing in the main buffer, where the cursor had been. For a second I > thought there had been an issue with memory allocation but after looking at > the code I see what happens is when the memory allocated to the minibuffer > fills up, a message "Line too long." should show in the minibuffer. It > probably did, but since I was pressing the '0' key it disappeared instantly > and I didn't realise that mg had tried to inform me of my error. mg then > continued to accept my '0's as normal input. > > This diff soaks up the user input while the the maximum character length > boundary is crossed in the minbuffer and allows the user to see the error > message and respond accordingly. > > There may be other ways to handle this situation (like not pressing the '0' > key so many times) but I think having mg do something is better than > it *seemingly* not do anything. Any suggestions/preferences/better > solutions? > > Mark > > Index: echo.c > =================================================================== > RCS file: /cvs/src/usr.bin/mg/echo.c,v > retrieving revision 1.66 > diff -u -p -u -p -r1.66 echo.c > --- echo.c 24 Oct 2016 17:18:42 -0000 1.66 > +++ echo.c 25 Feb 2021 19:06:21 -0000 > @@ -336,8 +336,8 @@ veread(const char *fp, char *buf, size_t > } > if (!dynbuf && epos + 1 >= nbuf) { > dobeep(); > - ewprintf("Line too long"); > - return (emptyval); > + ewprintf("Line too long. Press Enter."); > + goto null; > } > for (t = epos; t > cpos; t--) > buf[t] = buf[t - 1]; > @@ -492,8 +492,8 @@ veread(const char *fp, char *buf, size_t > } > if (!dynbuf && epos + 1 >= nbuf) { > dobeep(); > - ewprintf("Line too long"); > - return (emptyval); > + ewprintf("Line too long. Press Enter."); > + goto null; > } > for (i = epos; i > cpos; i--) > buf[i] = buf[i - 1]; > @@ -507,6 +507,9 @@ veread(const char *fp, char *buf, size_t > ttmove(rr, cc); > ttflush(); > } > + > +null: /* soak up any continuing key strokes */ > +; > } > done: > if (cwin == TRUE) { >