From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#69914: comint-strip-ctrl-m doesn't function as documentation states Date: Sat, 06 Apr 2024 11:58:51 +0300 Message-ID: <865xwu50l0.fsf@gnu.org> References: <86il1dz9pz.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26605"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 69914@debbugs.gnu.org To: public@jds.work Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 06 11:00:21 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rt1uP-0006k2-DF for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Apr 2024 11:00:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rt1u4-0007iM-LA; Sat, 06 Apr 2024 05:00:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rt1u0-0007h4-S1 for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2024 04:59:57 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rt1u0-0007uD-JU for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2024 04:59:56 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rt1u6-00072C-Gc for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2024 05:00:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 06 Apr 2024 09:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69914 X-GNU-PR-Package: emacs Original-Received: via spool by 69914-submit@debbugs.gnu.org id=B69914.171239394926706 (code B ref 69914); Sat, 06 Apr 2024 09:00:02 +0000 Original-Received: (at 69914) by debbugs.gnu.org; 6 Apr 2024 08:59:09 +0000 Original-Received: from localhost ([127.0.0.1]:38242 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rt1tF-0006wg-5H for submit@debbugs.gnu.org; Sat, 06 Apr 2024 04:59:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50356) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rt1tD-0006wU-70 for 69914@debbugs.gnu.org; Sat, 06 Apr 2024 04:59:07 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rt1t1-0007nj-OW; Sat, 06 Apr 2024 04:58:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=y9qd6qi0WWHi976OiASI9Do7P+1qzH4bNavqiUaUTgo=; b=rQUf78/kkGE4 0oKO7OqCvA3TgAqf9TBiKuDdxmvgKeu0wKJsjKQJywtEGzwh2bbPXc6GUs7Yp4WOcRSlxraExKHW8 eQX6s0aooABGGxnNAbdckjkdlxzXL79hMNoMdnWEKsz3Vgwtd8W3akkXdihjwuEzdPeIPUTNHGyfN /gmDAoIEFQu/3Rc9FFo841oHRyoIcvd9d+/tV8xGU1t+wsU6I9/Jja/Bxcb712XLAOXROGdJOAf/y xdmc+/djQYj0B+emMiqPhc34uR9TgSkI6GjeNy3YMGjE41Br/3KKHifAO9TqE34DGKE2vnwXadr/i HswRS9mUx9uM0gOPXXYAdA==; In-Reply-To: <86il1dz9pz.fsf@gnu.org> (message from Eli Zaretskii on Sat, 23 Mar 2024 09:30:16 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:282764 Archived-At: 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 > > > Date: Wed, 20 Mar 2024 14:15:39 +0000 > > From: Jonathan via "Bug reports for GNU Emacs, > > the Swiss army knife of text editors" > > > > 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? > > > >