unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: public@jds.work
Cc: 69914@debbugs.gnu.org
Subject: bug#69914: comint-strip-ctrl-m doesn't function as documentation states
Date: Sat, 06 Apr 2024 11:58:51 +0300	[thread overview]
Message-ID: <865xwu50l0.fsf@gnu.org> (raw)
In-Reply-To: <86il1dz9pz.fsf@gnu.org> (message from Eli Zaretskii on Sat, 23 Mar 2024 09:30:16 +0200)

Ping! Could you please answer my questions below?

> Cc: 69914@debbugs.gnu.org
> Date: Sat, 23 Mar 2024 09:30:16 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> 
> > Date: Wed, 20 Mar 2024 14:15:39 +0000
> > From:  Jonathan via "Bug reports for GNU Emacs,
> >  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> > 
> > There appears to either be a bug or just inaccurate documentation of =comint-strip-ctrl-m=. At the very bottom, I've included some context about my use case by which I discovered this bug that may or may not be relevant to you. The documentation for that function states:
> > 
> > #+begin_quote
> > Strip trailing ^M characters from the current output group.
> > 
> > This function could be on comint-output-filter-functions or bound to a key.
> > #+end_quote
> > 
> > =comint-output-filter-functions= states the following:
> > 
> > #+begin_quote
> > ...These functions get one argument, a string containing the text as originally
> > inserted.  Note that this might not be the same as the buffer contents between
> > comint-last-output-start and the buffer's process-mark, if other filter
> > functions have already modified the buffer.
> > #+end_quote
> > 
> > Looking at the implementation of =comint-strip-ctrl-m= it appears that it completely ignores the =string= argument and instead uses =(get-buffer-process (current-buffer))= in direct contradiction to the documentation.
> 
> Actually, AFAICT, almost all of the filtering functions intended for
> comint-output-filter-functions ignore its string argument.  Isn't that
> so?
> 
> > #+begin_src emacs-lisp
> > (defun comint-strip-ctrl-m (&optional _string interactive)
> >   "Strip trailing `^M' characters from the current output group.
> > This function could be on `comint-output-filter-functions' or bound to a key."
> >   (interactive (list nil t))
> >   (let ((process (get-buffer-process (current-buffer))))
> >     (if (not process)
> >         ;; This function may be used in
> >         ;; `comint-output-filter-functions', and in that case, if
> >         ;; there's no process, then we should do nothing.  If
> >         ;; interactive, report an error.
> >         (when interactive
> >           (error "No process in the current buffer"))
> >       ;;; rest omitted for brevity
> >       )))
> > #+end_src
> > 
> > This represents unexpected and undocumented behavior, as you anticipate =comint-strip-ctrl-m= to behave like any other comint output filter functions. I'd like to propose 3 different possible solutions for a patch and would like input on which is preferred as this code was originally introduced in 1994. I can submit a patch once a solution has been determined.
> 
> Given that almost all the filter functions behave the same (unless you
> disagree), it sounds like ignoring the string is a de-facto standard
> behavior.  So we should document that, and I guess adding a new
> function, without deprecating the existing one, is the most reasonable
> way ahead?
> 
> 
> 
> 





  reply	other threads:[~2024-04-06  8:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20 14:15 bug#69914: comint-strip-ctrl-m doesn't function as documentation states Jonathan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-23  7:30 ` Eli Zaretskii
2024-04-06  8:58   ` Eli Zaretskii [this message]
2024-04-18  9:01     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=865xwu50l0.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=69914@debbugs.gnu.org \
    --cc=public@jds.work \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).