* bug#61602: 29.0.60; comint-mode redirection @ 2023-02-18 11:26 Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-04-09 10:04 ` Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-05-11 17:45 ` bug#61602: [PATCH]: " Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 0 siblings, 2 replies; 12+ messages in thread From: Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-02-18 11:26 UTC (permalink / raw) To: 61602 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)) ^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#61602: 29.0.60; comint-mode redirection 2023-02-18 11:26 bug#61602: 29.0.60; comint-mode redirection Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-04-09 10:04 ` Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-05-11 17:45 ` bug#61602: [PATCH]: " Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 1 sibling, 0 replies; 12+ messages in thread From: Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-04-09 10:04 UTC (permalink / raw) To: Rah Guzar; +Cc: 61602 [-- Attachment #1: Type: text/plain, Size: 10623 bytes --] 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 <rahguzar@zohomail.eu> 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)) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: comint-redirect.patch --] [-- Type: text/x-patch, Size: 2413 bytes --] 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. ^ permalink raw reply related [flat|nested] 12+ messages in thread
* bug#61602: [PATCH]: comint-mode redirection 2023-02-18 11:26 bug#61602: 29.0.60; comint-mode redirection Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-04-09 10:04 ` Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-05-11 17:45 ` Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-05-11 18:14 ` Eli Zaretskii 2023-05-12 2:16 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors 1 sibling, 2 replies; 12+ messages in thread From: Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-05-11 17:45 UTC (permalink / raw) To: 61602 [-- Attachment #1: Type: text/plain, Size: 373 bytes --] Dear Emacs Maintainers, A while back I sent a patch that addresses the points in this bug report. I have since received the confirmation that I have completed the copyright paperwork, so I am bringing it to your attention again. This is my first time contributing so please let me know if I should do somethings differently or if changes are needed. Thanks, Rah Guzar [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: comint-redirect.patch --] [-- Type: text/x-patch, Size: 2413 bytes --] 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. ^ permalink raw reply related [flat|nested] 12+ messages in thread
* bug#61602: [PATCH]: comint-mode redirection 2023-05-11 17:45 ` bug#61602: [PATCH]: " Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-05-11 18:14 ` Eli Zaretskii 2023-05-11 18:35 ` Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-05-12 2:16 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors 1 sibling, 1 reply; 12+ messages in thread From: Eli Zaretskii @ 2023-05-11 18:14 UTC (permalink / raw) To: Rah Guzar; +Cc: 61602 > Date: Thu, 11 May 2023 19:45:09 +0200 > From: Rah Guzar via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> > > Dear Emacs Maintainers, > A while back I sent a patch that addresses the points in this bug report. I have since received the confirmation that I have completed the copyright paperwork, so I am bringing it to your attention again. This is my first time contributing so please let me know if I should do somethings differently or if changes are needed. Thanks, but your paperwork is not yet complete. So please wait a bit longer. ^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#61602: [PATCH]: comint-mode redirection 2023-05-11 18:14 ` Eli Zaretskii @ 2023-05-11 18:35 ` Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-05-12 5:28 ` Eli Zaretskii 0 siblings, 1 reply; 12+ messages in thread From: Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-05-11 18:35 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 61602 Hi Eli, On May 4th, I received an email from Craigh Topham including text, > Hello, > Your assignment/disclaimer process with the FSF is currently > complete; your fully executed PDF will be sent to you in a separate > email immediately following this one. > Please remember to let us know when your employment status changes, as > this may affect your assignment status. > Thank you for your contribution! and I also received the email with the pdf. So I assumed the paperwork was complete. Eli Zaretskii <eliz@gnu.org> writes: >> Date: Thu, 11 May 2023 19:45:09 +0200 >> From: Rah Guzar via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> >> >> Dear Emacs Maintainers, >> A while back I sent a patch that addresses the points in this bug report. I have since received the confirmation that I have completed the copyright paperwork, so I am bringing it to your attention again. This is my first time contributing so please let me know if I should do somethings differently or if changes are needed. > > Thanks, but your paperwork is not yet complete. So please wait a bit > longer. ^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#61602: [PATCH]: comint-mode redirection 2023-05-11 18:35 ` Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-05-12 5:28 ` Eli Zaretskii 0 siblings, 0 replies; 12+ messages in thread From: Eli Zaretskii @ 2023-05-12 5:28 UTC (permalink / raw) To: Rah Guzar; +Cc: 61602 > From: Rah Guzar <rahguzar@zohomail.eu> > Cc: 61602@debbugs.gnu.org > Date: Thu, 11 May 2023 20:35:46 +0200 > > Hi Eli, > On May 4th, I received an email from Craigh Topham including text, > > > Hello, > > > Your assignment/disclaimer process with the FSF is currently > > complete; your fully executed PDF will be sent to you in a separate > > email immediately following this one. > > > Please remember to let us know when your employment status changes, as > > this may affect your assignment status. > > > Thank you for your contribution! > > and I also received the email with the pdf. > > So I assumed the paperwork was complete. I usually wait until the assignment is "officially" on file. It is there as of this morning, so we can accept your contributions. Thanks. ^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#61602: [PATCH]: comint-mode redirection 2023-05-11 17:45 ` bug#61602: [PATCH]: " Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-05-11 18:14 ` Eli Zaretskii @ 2023-05-12 2:16 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-05-12 6:42 ` Eli Zaretskii 2023-05-12 7:11 ` Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 1 sibling, 2 replies; 12+ messages in thread From: Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-05-12 2:16 UTC (permalink / raw) To: Rah Guzar; +Cc: 61602 Thanks for the patch. First of all, when sending a patch(set) for Emacs, you need to run something like this: $ git format-patch and send the generated file(s). Take a look at its manpage and ask if you have any questions. What you have sent is a "diff" file, which bears no commit messages. At least in Emacs contributions, patches should usually come together with their commit messages. And there are guidelines on commit messages, see /CONTRIBUTE on emacs.git. Further in-line comments below. Rah Guzar via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> writes: > Dear Emacs Maintainers, > A while back I sent a patch that addresses the points in this bug report. I > have since received the confirmation that I have completed the copyright > paperwork, so I am bringing it to your attention again. This is my first time > contributing so please let me know if I should do somethings differently or if > changes are needed. > > Thanks, > Rah Guzar > > [2. text/x-patch; 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'. This paragraph sounds a bit weird, but I don't know how to reword it. Maybe someone else can help. > 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.") If this is indeed a private variable, why does it contain no double-dashes in its name prior to your changes? Also, here and elsewhere, except for the first line, there should generally be one empty line between paragraphs. > + > +(defvar comint-redirect-hook nil > + "Hook run when a redirection finishes.") Does it make sense for a user to customize the hook? If so, you should convert this variable into a `defcustom'. > (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'." Please clarify what "it" is. If you are referring to the change below from `cominit-prompt-regexp' to `(or finished-regexp comint-prompt-regexp)', then the current form is ambiguous, and maybe you should say something like this: If F-R is non-nil, it is used as `c-r-f-r'. Otherwise `c-p-r' is used as `c-r-f-r'. > (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. -- Best, RY ^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#61602: [PATCH]: comint-mode redirection 2023-05-12 2:16 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-05-12 6:42 ` Eli Zaretskii 2023-05-12 6:58 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-05-12 7:25 ` Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-05-12 7:11 ` Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 1 sibling, 2 replies; 12+ messages in thread From: Eli Zaretskii @ 2023-05-12 6:42 UTC (permalink / raw) To: Ruijie Yu; +Cc: rahguzar, 61602 > Cc: 61602@debbugs.gnu.org > Date: Fri, 12 May 2023 10:16:48 +0800 > From: Ruijie Yu via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> > > > Thanks for the patch. First of all, when sending a patch(set) for > Emacs, you need to run something like this: > > $ git format-patch > > and send the generated file(s). No, this is not a requirement around here. We prefer format-patch, indeed, but we don't enforce it. Simple diffs are perfectly acceptable. > What you have sent is a "diff" file, which bears no commit messages. > At least in Emacs contributions, patches should usually come > together with their commit messages. That is true. But adding commit log messages doesn't have to be via "git format-patch". > > --- 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'. > > This paragraph sounds a bit weird, but I don't know how to reword it. > Maybe someone else can help. I'm not sure the addition is necessary in the first place. What is its purpose? why is it useful to mention those exceptional cases? > Also, here and elsewhere, except for the first line, there should > generally be one empty line between paragraphs. This is not a requirement. It's a judgment call whether an empty line is needed or not. > > -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'." > > Please clarify what "it" is. I think it's clear in this case: there's no other candidate for being "it" here except FINISHED-REGEXP. ^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#61602: [PATCH]: comint-mode redirection 2023-05-12 6:42 ` Eli Zaretskii @ 2023-05-12 6:58 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-05-12 7:54 ` Andreas Schwab 2023-05-12 7:25 ` Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 1 sibling, 1 reply; 12+ messages in thread From: Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-05-12 6:58 UTC (permalink / raw) To: Eli Zaretskii; +Cc: rahguzar, 61602 Eli Zaretskii <eliz@gnu.org> writes: >> Cc: 61602@debbugs.gnu.org >> Date: Fri, 12 May 2023 10:16:48 +0800 >> From: Ruijie Yu via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> >> >> >> Thanks for the patch. First of all, when sending a patch(set) for >> Emacs, you need to run something like this: >> >> $ git format-patch >> >> and send the generated file(s). > > No, this is not a requirement around here. We prefer format-patch, > indeed, but we don't enforce it. Simple diffs are perfectly > acceptable. Yes, I should have worded that way. I meant exactly what you said: it is a preferred way but not a requirement. >> What you have sent is a "diff" file, which bears no commit messages. >> At least in Emacs contributions, patches should usually come >> together with their commit messages. > > That is true. But adding commit log messages doesn't have to be via > "git format-patch". Yes. >> > --- 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'. >> >> This paragraph sounds a bit weird, but I don't know how to reword it. >> Maybe someone else can help. > > I'm not sure the addition is necessary in the first place. What is > its purpose? why is it useful to mention those exceptional cases? > >> Also, here and elsewhere, except for the first line, there should >> generally be one empty line between paragraphs. > > This is not a requirement. It's a judgment call whether an empty line > is needed or not. Noted. >> > -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'." >> >> Please clarify what "it" is. > > I think it's clear in this case: there's no other candidate for being > "it" here except FINISHED-REGEXP. When I first read this sentence, I interpretted it as: If F-R is non-nil, F-R is used as `c-r-f-r'. Otherwise F-R is used as `c-p-r'. I don't know. Maybe you see it differently, in which case I'm fine with not changing it. -- Best, RY ^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#61602: [PATCH]: comint-mode redirection 2023-05-12 6:58 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-05-12 7:54 ` Andreas Schwab 0 siblings, 0 replies; 12+ messages in thread From: Andreas Schwab @ 2023-05-12 7:54 UTC (permalink / raw) To: 61602; +Cc: ruijie, rahguzar, eliz On Mai 12 2023, Ruijie Yu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote: >>> > -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'." >>> >>> Please clarify what "it" is. >> >> I think it's clear in this case: there's no other candidate for being >> "it" here except FINISHED-REGEXP. > > When I first read this sentence, I interpretted it as: > > If F-R is non-nil, F-R is used as `c-r-f-r'. Otherwise F-R is used > as `c-p-r'. > > I don't know. Maybe you see it differently, in which case I'm fine with > not changing it. Perhaps a better wording: FINISHED-REGEXP is used as `comint-redirect-finished-regexp'. If FINISHED-REGEXP is nil it defaults to `comint-prompt-regexp'. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." ^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#61602: [PATCH]: comint-mode redirection 2023-05-12 6:42 ` Eli Zaretskii 2023-05-12 6:58 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-05-12 7:25 ` Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 1 sibling, 0 replies; 12+ messages in thread From: Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-05-12 7:25 UTC (permalink / raw) To: Eli Zaretskii; +Cc: Ruijie Yu, 61602 Hi Eli, Eli Zaretskii <eliz@gnu.org> writes: >> > 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'. >> >> This paragraph sounds a bit weird, but I don't know how to reword it. >> Maybe someone else can help. > > I'm not sure the addition is necessary in the first place. What is > its purpose? why is it useful to mention those exceptional cases? I think it is useful for those writing a comint derived mode who might be tempted to not set 'comint-prompt-regexp' since it is going to be unused by default. Redirection is an important enough facility in my opinion for this to be pointed out. ^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#61602: [PATCH]: comint-mode redirection 2023-05-12 2:16 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-05-12 6:42 ` Eli Zaretskii @ 2023-05-12 7:11 ` Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 1 sibling, 0 replies; 12+ messages in thread From: Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-05-12 7:11 UTC (permalink / raw) To: Ruijie Yu; +Cc: 61602 [-- Attachment #1: Type: text/plain, Size: 3360 bytes --] Hi Ruijie, Thanks for the comments. Ruijie Yu <ruijie@netyu.xyz> writes: > Thanks for the patch. First of all, when sending a patch(set) for > Emacs, you need to run something like this: > > $ git format-patch > > and send the generated file(s). Take a look at its manpage and ask if > you have any questions. What you have sent is a "diff" file, which > bears no commit messages. At least in Emacs contributions, patches > should usually come together with their commit messages. > > And there are guidelines on commit messages, see /CONTRIBUTE on > emacs.git. I have attached a patch which hopefully is made properly this time. > Further in-line comments below. > > Rah Guzar via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> writes: > >> 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'. > > This paragraph sounds a bit weird, but I don't know how to reword it. > Maybe someone else can help. > I tried some rewording. >> (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.") > > If this is indeed a private variable, why does it contain no > double-dashes in its name prior to your changes? > > Also, here and elsewhere, except for the first line, there should > generally be one empty line between paragraphs. > It is not declared as a private variable but it is in effect used as one, so documenting should prevent confusion. Some context: I wanted to use redirection to display some documentation is a separate buffer. However documentation sometimes contained the usual prompt and that messed up the comint buffer. To get around it I setup the redirected commands so that they had a custom prompt and tried to set c-r-f-r accordingly but that didn't work and I had to fish around the comint source to figure out why. >> +(defvar comint-redirect-hook nil >> + "Hook run when a redirection finishes.") > Does it make sense for a user to customize the hook? If so, you should > convert this variable into a `defcustom'. This for better discoverability. I think comint-mode is too low-level for most users to use it directly. But e.g. for those writing a derived mode it is good to be aware that this hook exists without diving into source. >> +If FINISHED-REGEXP is non-nil it is used as `comint-redirect-finished-regexp' >> +instead of `comint-prompt-regexp'." > > Please clarify what "it" is. > > If you are referring to the change below from `cominit-prompt-regexp' to > `(or finished-regexp comint-prompt-regexp)', then the current form is > ambiguous, and maybe you should say something like this: > > If F-R is non-nil, it is used as `c-r-f-r'. Otherwise `c-p-r' is > used as `c-r-f-r'. > Thanks, I incorporated your suggestion. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-Bug-61602-Tweak-comint-mode-redirection.patch --] [-- Type: text/x-patch, Size: 3268 bytes --] From ac814964e1885d005746e98f5010a2b400293810 Mon Sep 17 00:00:00 2001 From: Rahguzar <rahguzar@zohomail.eu> Date: Fri, 12 May 2023 09:00:34 +0200 Subject: [PATCH] (Bug#61602) Tweak comint-mode redirection * lisp/comint.el (redirection): New optional argument for 'comint-redirect-send-command-to-process' to explicitly set the regexp to end redirection. Define 'comint-redirect-hook' for easier discovery. Miscellaneous documentation fixes. --- lisp/comint.el | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lisp/comint.el b/lisp/comint.el index 682b555a33c..e6ce31f231c 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. An exception to +this is redirection. Many commands including +`comint-redirect-send-command-to-process' use `comint-prompt-regexp' +to detect the end of redirection. Good choices: Canonical Lisp: \"^[^> \\n]*>+:? *\" (Lucid, franz, kcl, T, cscheme, oaklisp) @@ -3637,7 +3640,13 @@ 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 + "Normal 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 +3842,14 @@ 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. +FINISHED-REGEP is set as `comint-redirect-finished-regexp' +when it is non-nil, otherwise `comint-prompt-regexp' is used +as `comint-redirect-finished-regexp'." (interactive "sCommand: \nBOutput Buffer: \nbProcess Buffer: \nP") (let* (;; The process buffer (process-buffer (if (processp process) @@ -3857,9 +3869,9 @@ comint-redirect-send-command-to-process ;; Set up for redirection (comint-redirect-setup output-buffer - (current-buffer) ; Comint Buffer - comint-prompt-regexp ; Finished Regexp - echo) ; Echo input + (current-buffer) ; Comint Buffer + (or finished-regexp comint-prompt-regexp) ; Finished Regexp + echo) ; Echo input ;; Set the filter. (add-function :around (process-filter proc) #'comint-redirect-filter) -- 2.40.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-05-12 7:54 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-02-18 11:26 bug#61602: 29.0.60; comint-mode redirection Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-04-09 10:04 ` Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-05-11 17:45 ` bug#61602: [PATCH]: " Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-05-11 18:14 ` Eli Zaretskii 2023-05-11 18:35 ` Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-05-12 5:28 ` Eli Zaretskii 2023-05-12 2:16 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-05-12 6:42 ` Eli Zaretskii 2023-05-12 6:58 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-05-12 7:54 ` Andreas Schwab 2023-05-12 7:25 ` Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-05-12 7:11 ` Rah Guzar via Bug reports for GNU Emacs, the Swiss army knife of text editors
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.