From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Rah Guzar via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#61602: 29.0.60; comint-mode redirection Date: Sun, 09 Apr 2023 12:04:28 +0200 Message-ID: <87cz4dbc3a.fsf@zohomail.eu> References: <873573ryft.fsf@zohomail.eu> Reply-To: Rah Guzar Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5238"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.10.1; emacs 29.0.60 Cc: 61602@debbugs.gnu.org To: Rah Guzar Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 09 12:11:24 2023 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 1plS15-0001A0-Kz for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 09 Apr 2023 12:11:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1plS0m-0002Fo-3G; Sun, 09 Apr 2023 06:11:04 -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 1plS0l-0002Fb-5r for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2023 06:11:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1plS0k-0003CH-KI for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2023 06:11:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1plS0k-0007Z5-21 for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2023 06:11:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Rah Guzar Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 09 Apr 2023 10:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61602 X-GNU-PR-Package: emacs X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.168103503429023 (code B ref -1); Sun, 09 Apr 2023 10:11:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 9 Apr 2023 10:10:34 +0000 Original-Received: from localhost ([127.0.0.1]:60290 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1plS0H-0007Y2-9X for submit@debbugs.gnu.org; Sun, 09 Apr 2023 06:10:34 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:39894) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1plS0F-0007Xt-18 for submit@debbugs.gnu.org; Sun, 09 Apr 2023 06:10:32 -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 1plS0D-0002Ct-K8 for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2023 06:10:30 -0400 Original-Received: from sender11-pp-o91.zoho.eu ([31.186.226.249]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1plS09-000355-Qf for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2023 06:10:29 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1681035020; cv=none; d=zohomail.eu; s=zohoarc; b=U1thAHzhFHwGLFPr0ntsBuLsLl7QWH9je+pVH3yv2xlj+3S5Rin8JKbFdgZvlX2ErYSz1YZ4dGWBynO+H16g6/UZ8yeXq9KU6pHywoKQbAnHCI5cqv1ykjUee9aXF+WRBzjUH5U6Woi6RImcxTDkypG6lpKjL2kwyW6pKVd+Tp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1681035020; h=Content-Type:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=ww/RZq/GeFnCl7Sc+A6hT1okSBSoqNpeHRAh5RV1AJg=; b=GAac248Yxp9nk9anYHULltwsxOSazrX78UD337Pcels9Sl6kK/Yq5nKnfvhIU4L1M27HY4ObEAK4D4d8SmRGoleYPQNOgD4kBsH6MBkt/lQIM2372Lq7HU6JHQYKQeCtFdrowTc7/0t8KTIXD30a3V0OH3nprGd7eS3ZQVp/YV4= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=zohomail.eu; spf=pass smtp.mailfrom=rahguzar@zohomail.eu; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1681035020; s=zoho; d=zohomail.eu; i=rahguzar@zohomail.eu; h=References:From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:In-reply-to:Message-ID:MIME-Version:Content-Type:Message-Id:Reply-To; bh=ww/RZq/GeFnCl7Sc+A6hT1okSBSoqNpeHRAh5RV1AJg=; b=qyJOvMRCwFjd/FLFff5ufc7tPfkUdL6ZfK28PaxE5ebSVVjVbqq4rjRHMsQYvnva LMp1Ac4MG01gg8MDqaMsEIKGnwPk0oRsPkCzxFdd1gmTFXwkOJma8xje2GnyFHIsLiQ mVRFNE2p9qPHoaR594Mkm+seviuV5u5Xo1Znq17A= Original-Received: from localhost (81-231-79-170-no600.tbcn.telia.com [81.231.79.170]) by mx.zoho.eu with SMTPS id 1681035019086101.37690014093494; Sun, 9 Apr 2023 12:10:19 +0200 (CEST) In-reply-to: <873573ryft.fsf@zohomail.eu> X-Zoho-Virus-Status: 1 X-ZohoMailClient: External Received-SPF: pass client-ip=31.186.226.249; envelope-from=rahguzar@zohomail.eu; helo=sender11-pp-o91.zoho.eu X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:259512 Archived-At: --=-=-= Content-Type: text/plain Dear Emacs maintainers, Please find attached a patch that addresses these points. If desired I can also separate out the documentation changes which I think are more important from the code changes. I think even code changes are trivial and safe. Please let me know if any changes are required. I have not yet signed the copyright assignment but I am in the process of doing it. I think this change falls within the 15 lines exemption although it saturates it. Thanks, Rah Guzar Rah Guzar writes: > Dear Emacs maintainers, > I have been working on a major mode derived from comint-mode. The mode > uses redirection to show documentation in a separate buffer. Sometimes, > a prompt would appear in the output of the command producing the > documentation and this would end the redirection prematurely. Searching > among variables in comint-mode I found comint-redirect-finished-regexp > and its docstring made me believe that I could set it to change the end > of redirection. However setting it had a no effect and looking at the > sources I found that this is because it is set by comint-redirect-setup > and comint-redirect-send-command-to-process calls comint-redirect-setup > so that it is always set to comint-prompt-regexp during redirection. > > This is confusing behavior because docstring of > comint-redirect-finished-regexp gives no clue that setting it will have > no effect. Similarly the docstring of comint-prompt-regexp states that > its value is only used when comint-use-prompt-regexp is non-nil but > that is not true for redirection. > > Overall I think it would be nice to have an optional argument to > comint-redirect-send-command-to-process which allows a user to > explicitly pass the regexp to use for ending redirection. > > Another issue I had was that I wanted to run some commands when > redirection ended. There didn't seem to be any hooks that accomplished > this but from source of comint-redirect-preoutput-filter I found that > comint-redirect-hook is run when redirection finishes. However > comint-redirect-hook is not defined as a variable and nothing seems to > give any hint of its existence. > > Thanks, > Rahguzar > > > In GNU Emacs 29.0.60 (build 1, x86_64-suse-linux-gnu, GTK+ Version > 3.24.35, cairo version 1.17.6) of 2023-02-17 built on build79 > System Description: openSUSE Tumbleweed > > Configured using: > 'configure --host=x86_64-suse-linux-gnu --build=x86_64-suse-linux-gnu > --program-prefix= --disable-dependency-tracking --prefix=/usr > --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin > --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include > --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var > --sharedstatedir=/var/lib --mandir=/usr/share/man > --infodir=/usr/share/info --with-pgtk --with-native-compilation=aot > --with-cairo --with-libotf --with-jpeg --with-tiff --with-gif > --with-png --with-rsvg --with-xft --with-xml2 --with-dbus --with-sound > --with-json --with-mailutils --with-gnutls --with-tree-sitter > --enable-locallisppath=/usr/share/emacs/29.0.60/site-lisp:/usr/share/emacs/site-lisp > 'CFLAGS=-O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 > -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables > -fstack-clash-protection -Werror=return-type -flto=auto' > LDFLAGS=-Wl,-O2' > > Configured features: > CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON > LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY > PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF > TOOLKIT_SCROLL_BARS TREE_SITTER XIM GTK3 ZLIB > > Important settings: > value of $LANG: en_US.UTF-8 > locale-coding-system: utf-8-unix > > Major mode: mu4e-headers > > Minor modes in effect: > delete-selection-mode: t > projectile-mode: t > recentf-mode: t > save-place-mode: t > global-so-long-mode: t > which-key-mode: t > savehist-mode: t > better-jumper-mode: t > better-jumper-local-mode: t > global-company-mode: t > company-mode: t > vertico-mode: t > all-the-icons-completion-mode: t > marginalia-mode: t > evil-goggles-mode: t > evil-escape-mode: t > evil-snipe-override-mode: t > evil-snipe-mode: t > gcmh-mode: t > winner-mode: t > smartparens-global-mode: t > ws-butler-global-mode: t > global-undo-fu-session-mode: t > undo-fu-mode: t > workroom-mode: t > mu4e-search-minor-mode: t > global-hl-line-mode: t > hl-line-mode: t > mu4e-update-minor-mode: t > mu4e-context-minor-mode: t > dirvish-override-dired-mode: t > server-mode: t > solaire-global-mode: t > solaire-mode: t > shell-dirtrack-mode: t > evil-mode: t > evil-local-mode: t > windmove-mode: t > +popup-mode: t > +modeline-global-mode: t > +modeline-mode: t > override-global-mode: t > general-override-mode: t > global-eldoc-mode: t > eldoc-mode: t > show-paren-mode: t > electric-indent-mode: t > mouse-wheel-mode: t > file-name-shadow-mode: t > global-font-lock-mode: t > font-lock-mode: t > window-divider-mode: t > buffer-read-only: t > size-indication-mode: t > line-number-mode: t > transient-mark-mode: t > auto-composition-mode: t > auto-encryption-mode: t > auto-compression-mode: t > abbrev-mode: t > > Load-path shadows: > /home/azeem/.emacs.d/.local/straight/build-29.0.60/citar-embark/citar-embark hides /home/azeem/.emacs.d/.local/straight/build-29.0.60/citar/citar-embark > > Features: > (shadow disp-table whitespace delsel display-line-numbers adaptive-wrap > spell-fu ispell auto-minor-mode projectile lisp-mnt evil-collection-grep > grep ibuf-ext evil-collection-ibuffer ibuffer ibuffer-loaddefs recentf > tree-widget saveplace evil-collection-so-long so-long emacsbug sort > gnus-cite smiley shr-color mm-archive mail-extr textsec uni-scripts > idna-mapping ucs-normalize uni-confusable textsec-check qp cursor-sensor > vertico-repeat evil-collection-which-key which-key savehist > better-jumper company-capf company evil-collection-vertico vertico > orderless all-the-icons-completion marginalia evil-goggles pulse color > evil-easymotion evil-escape evil-snipe autorevert filenotify gcmh winner > smartparens-config smartparens-text smartparens dash ws-butler > undo-fu-session undo-fu workroom compat desktop frameset > evil-collection-mu4e mu4e mu4e-org evil-collection-org smartparens-org > org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-src > ob-comint org-pcomplete org-list org-footnote org-faces org-entities > noutline outline ob-emacs-lisp org-table ol org-keys oc-natbib oc-csl > bibtex oc-biblatex oc org-loaddefs find-func mu4e-main mu4e-view > gnus-art mm-uu mml2015 mm-view mml-smime smime gnutls dig gnus-sum > gnus-group gnus-undo gnus-start gnus-dbus dbus gnus-cloud nnimap nnmail > mail-source utf7 nnoo parse-time iso8601 gnus-spec gnus-int gnus-range > gnus-win evil-collection-gnus gnus nnheader range > evil-collection-calendar cal-menu calendar cal-loaddefs mu4e-headers > mu4e-compose mu4e-draft mu4e-actions smtpmail mu4e-search mu4e-lists > mu4e-bookmarks mu4e-mark mu4e-message shr pixel-fill kinsoku url-file > svg xml dom browse-url url url-proxy url-privacy url-expand url-methods > url-history url-cookie generate-lisp-file url-domsuf url-util url-parse > auth-source json map url-vars flow-fill mule-util hl-line mu4e-contacts > mu4e-update mu4e-folders mu4e-server mu4e-context mu4e-vars mu4e-helpers > mu4e-config evil-collection-bookmark bookmark ido message sendmail > mailcap yank-media puny dirvish transient eieio eieio-core > evil-collection-dired dired dired-loaddefs rfc822 mml mml-sec > password-cache evil-collection-epa epa epg rfc6068 epg-config gnus-util > time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 > rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils > mailheader server dtrt-indent doom-themes-ext-org solaire-mode > face-remap doom-earl-grey-theme doom-themes doom-themes-base midnight > evil-collection-flymake flymake-proc flymake project > evil-collection-compile evil-collection-custom cus-edit cus-load > wid-edit evil-collection-comint evil-collection annalist compile > text-property-search html2text ob-core org-cycle org-fold org-fold-core > org-compat ob-eval org-version org-macs format-spec ibuf-macs evil > evil-integration evil-maps evil-commands reveal flyspell evil-jumps > evil-command-window evil-search shell pcomplete comint ansi-osc > ansi-color evil-types evil-macros evil-repeat evil-states evil-core comp > comp-cstr warnings icons byte-opt advice evil-common windmove calc > calc-loaddefs calc-macs thingatpt rect evil-digraphs evil-vars ring > all-the-icons all-the-icons-faces data-material data-weathericons > data-octicons data-fileicons data-faicons data-alltheicons let-alist > derived edmacro kmacro use-package-bind-key bind-key rx doom-editor > doom-projects doom-ui easy-mmode doom-keybinds pp cl-extra help-mode > use-package-core bytecomp byte-compile general tex-site doom-start > doom-modules cl-seq doom doom-lib cl-macs cl-loaddefs cl-lib pcase gv > jansson dynamic-modules subr-x rmc iso-transl tooltip cconv eldoc paren > electric uniquify ediff-hook vc-hooks lisp-float-type mwheel > term/pgtk-win pgtk-win term/common-win pgtk-dnd tool-bar dnd fontset > image regexp-opt fringe tabulated-list replace newcomment text-mode > lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch > easymenu timer select scroll-bar mouse jit-lock font-lock syntax > font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic > indonesian philippine cham georgian utf-8-lang misc-lang vietnamese > tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek > romanian slovak czech european ethiopic indian cyrillic chinese > composite emoji-zwj charscript charprop case-table epa-hook > jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs > theme-loaddefs faces cus-face macroexp files window text-properties > overlay sha1 md5 base64 format env code-pages mule custom widget keymap > hashtable-print-readable backquote threads dbusbind inotify > dynamic-setting system-font-setting font-render-setting cairo gtk pgtk > multi-tty make-network-process native-compile emacs) > > Memory information: > ((conses 16 944541 309286) > (symbols 48 41240 1) > (strings 32 291783 19116) > (string-bytes 1 6577740) > (vectors 16 85429) > (vector-slots 8 2190100 207157) > (floats 8 1276 1590) > (intervals 56 12251 9085) > (buffers 984 21)) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=comint-redirect.patch diff --git a/lisp/comint.el b/lisp/comint.el index 682b555a33c..98f4d315d64 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -161,7 +161,10 @@ comint-prompt-regexp Defaults to \"^\", the null string at BOL. This variable is only used if the variable -`comint-use-prompt-regexp' is non-nil. +`comint-use-prompt-regexp' is non-nil. The exception to +this is redirection. Many commands including +`comint-redirect-send-command-to-process' use it as +`comint-redirect-finished-regexp'. Good choices: Canonical Lisp: \"^[^> \\n]*>+:? *\" (Lucid, franz, kcl, T, cscheme, oaklisp) @@ -3637,7 +3640,12 @@ comint-redirect-output-buffer (defvar comint-redirect-finished-regexp nil "Regular expression that determines when to stop redirection in Comint. When the redirection filter function is given output that matches this regexp, -the output is inserted as usual, and redirection is completed.") +the output is inserted as usual, and redirection is completed. +This is an internal variable set by `comint-redirect-setup' and setting it +directly has no effect.") + +(defvar comint-redirect-hook nil + "Hook run when a redirection finishes.") (defvar comint-redirect-insert-matching-regexp nil "If non-nil, the text that ends a redirection is included in it. @@ -3833,11 +3841,13 @@ comint-redirect-send-command ;;;###autoload (defun comint-redirect-send-command-to-process - (command output-buffer process echo &optional no-display) + (command output-buffer process echo &optional no-display finished-regexp) "Send COMMAND to PROCESS, with output to OUTPUT-BUFFER. With prefix arg, echo output in process buffer. -If NO-DISPLAY is non-nil, do not show the output buffer." +If NO-DISPLAY is non-nil, do not show the output buffer. +If FINISHED-REGEXP is non-nil it is used as `comint-redirect-finished-regexp' +instead of `comint-prompt-regexp'." (interactive "sCommand: \nBOutput Buffer: \nbProcess Buffer: \nP") (let* (;; The process buffer (process-buffer (if (processp process) @@ -3858,7 +3868,7 @@ comint-redirect-send-command-to-process (comint-redirect-setup output-buffer (current-buffer) ; Comint Buffer - comint-prompt-regexp ; Finished Regexp + (or finished-regexp comint-prompt-regexp) ; Finished Regexp echo) ; Echo input ;; Set the filter. --=-=-=--