From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jonathan Newsgroups: gmane.emacs.devel Subject: [BUG] comint-strip-ctrl-m doesn't function as documentation states Date: Tue, 19 Mar 2024 19:55:55 +0000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4277"; mail-complaints-to="usenet@ciao.gmane.io" To: "emacs-devel@gnu.org" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Mar 20 04:23:02 2024 Return-path: Envelope-to: ged-emacs-devel@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 1rmmXd-0000sG-9J for ged-emacs-devel@m.gmane-mx.org; Wed, 20 Mar 2024 04:23:01 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rmmX3-000740-U4; Tue, 19 Mar 2024 23:22:25 -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 1rmfZE-00017h-M8 for emacs-devel@gnu.org; Tue, 19 Mar 2024 15:56:12 -0400 Original-Received: from mail-4317.proton.ch ([185.70.43.17]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rmfZB-0002xT-69 for emacs-devel@gnu.org; Tue, 19 Mar 2024 15:56:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jds.work; s=protonmail; t=1710878163; x=1711137363; bh=gxhbSJXp+8UyJSgfMvBiC9msVZVCiKKzu8JNbYy9PQ0=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=mAyc/wRzNta/YlVe9P+KcUvmhgIQTL3aBjBAfFHlbHoIU4R4Plkboy/iwqoXCPVnE X3FV7QeQ5BgDBz7YqJzTHgJ4eCYr/JBCxpnZ+Ga/J3X+n4GB9rVtxt2YWkSXM99gTa ZrjXW8Ttm0GjbDMaLbjRFm41W0e1PuY2g/YFVfJadNt7tSzhAoBfy8gHmEDsEslSti PIF/o+NdAkGM7X7kVp4SzaiAhID+qq+PV/e2Z/7Y80MZyCFNo5WxRGgN4LaZd3/7O9 hV9G7kQQN/UqGy73kNGRBqFFbJyVHALjgOE16oGZOIlbT3m6CsJrHdPaISngBMbzc7 QZJ1MqAFHw3Uw== Feedback-ID: 104505699:user:proton Received-SPF: pass client-ip=185.70.43.17; envelope-from=public@jds.work; helo=mail-4317.proton.ch X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.499, FROM_SUSPICIOUS_NTLD_FP=1.999, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_PDS_OTHER_BAD_TLD=0.01, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 19 Mar 2024 23:22:19 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:317204 Archived-At: Hey folks, There appears to either be a bug or just inaccurate documentation of =3Dcom= int-strip-ctrl-m=3D. At the very bottom, I've included some context about m= y use case by which I discovered this bug that may or may not be relevant t= o 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 =3Dcomint-output-filter-functions=3D states the following: #+begin_quote ...These functions get one argument, a string containing the text as origin= ally inserted. Note that this might not be the same as the buffer contents betw= een 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 =3Dcomint-strip-ctrl-m=3D it appears that = it completely ignores the =3Dstring=3D argument and instead uses =3D(get-bu= ffer-process (current-buffer))=3D. #+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 ke= y." (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 brefity ))) #+end_src This represents unexpected and undocumented behavior, as you anticipate =3D= comint-strip-ctrl-m=3D to behave like any other comint output filter functi= ons. I'd like to propose 3 different possible solutions for a patch and wou= ld 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. 1. Update the documentation and leave as is. This is the simplest solution = and would just require doc-string updates to indicate that =3Dcomint-strip-= ctrl-m=3D is a "unique" filter function among the other filter functions th= at exist. This does not seem preferable to me. 2. Update the implementation of =3Dcomint-strip-ctrl-m=3D itself to conform= it to the documented API. This would mean anything currently depending on = it reading the =3Dcurrent-buffer=3D would break, and since there are plenty= of unknowns in that regard, this also does not seem preferable. 3. Add a new version of the function with a different name that conforms to= the documented API =3Dcomint-strip-ctrl-m-output=3D or something similar a= nd deprecate the original. If we do decide to deprecate the original, I'm happy to include a deprecati= on warning and keep an eye on it popping up in core to ensure that we handl= e those issues over time. Any guidance would be useful. Thank you all for you're hard work. - Jonathan PS: Additional Context as promised: I was developing a package that runs SQL queries in a "hidden" SQLi buffer = and so I needed to strip carriage return characters out of the output. Usin= g this filter I had thought it would perform the task, but it did not. So d= igging through the documentation I discovered this error. I think it's pret= ty reasonable that filter functions conform to the documented api or should= at least be noted otherwise.