From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thomas Hisch Newsgroups: gmane.emacs.bugs Subject: bug#48129: 28.0.50; Per file-handle (stdin, stdout and stderr) process-connection-type variable Date: Sat, 1 May 2021 01:10:10 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9706"; mail-complaints-to="usenet@ciao.gmane.io" To: 48129@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat May 01 01:11:52 2021 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 1lccIZ-0002Qo-In for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 01 May 2021 01:11:51 +0200 Original-Received: from localhost ([::1]:35244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lccIY-0002it-MD for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 30 Apr 2021 19:11:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lccHm-0002LK-7p for bug-gnu-emacs@gnu.org; Fri, 30 Apr 2021 19:11:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48445) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lccHl-0007dc-UU for bug-gnu-emacs@gnu.org; Fri, 30 Apr 2021 19:11:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lccHl-0005GY-Oy for bug-gnu-emacs@gnu.org; Fri, 30 Apr 2021 19:11:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Thomas Hisch Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 30 Apr 2021 23:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48129 X-GNU-PR-Package: emacs X-Debbugs-Original-To: Original-Received: via spool by submit@debbugs.gnu.org id=B.161982422320191 (code B ref -1); Fri, 30 Apr 2021 23:11:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Apr 2021 23:10:23 +0000 Original-Received: from localhost ([127.0.0.1]:59991 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lccH8-0005FY-KQ for submit@debbugs.gnu.org; Fri, 30 Apr 2021 19:10:23 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:35334) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lccH6-0005FP-KH for submit@debbugs.gnu.org; Fri, 30 Apr 2021 19:10:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lccH6-0001zw-8I for bug-gnu-emacs@gnu.org; Fri, 30 Apr 2021 19:10:20 -0400 Original-Received: from mail.ims.co.at ([81.92.245.88]:21292) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lccH1-00077l-Tu for bug-gnu-emacs@gnu.org; Fri, 30 Apr 2021 19:10:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=ims.co.at; s=ims; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=dRC6r2MuieRdZx3gLFo672TEwiNTzQaHwrk/JirnNlA=; b=NM/nhbpOciGfgTp0ZZnkpejptRtIexhHq3mO/jSxu7aD5gCxCVRu3TQ8 7MuuDmjeuNAz8WVRJBQDU+jRG+pRA1ff6m1mgNTrQpu8TFhBNUrePzwAS HVPCtGo0ndqyBkg66P2urWpfjKSkZMluak9ntybX8qWOk0Ivm+z3f2EmK k=; IronPort-SDR: 4YDt1g9GbkuGZ/mX1sHxvMwfUlVCb0uWEhOm0i2g/h6i4qw/WHWLlICxZO4ygtnDCnFYbCsPJT iNmzdtUu8G6Q== X-IronPort-AV: E=Sophos;i="5.82,264,1613430000"; d="scan'208";a="905646" X-Originating-IP: [77.118.130.167] X-ClientProxiedBy: srv-xchg-02.ims.co.at (10.120.20.62) To srv-xchg-02.ims.co.at (10.120.20.62) Received-SPF: pass client-ip=81.92.245.88; envelope-from=prvs=747a22a11=thomas.hisch@ims.co.at; helo=mail.ims.co.at 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, 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" Xref: news.gmane.io gmane.emacs.bugs:205303 Archived-At: I would like that the configuration options of the three file handles (stdin, stdout and stderr), when a new process is created in emacs, are improved. What I'm specifically asking for is to add support for individually specifying for each file-handle whether it should be connected to a pty or not. Currently the value of the process-connection-type variable applies to all three file handles at once, which leads to a problem with the following use-case: Usually a program outputs ANSI escape sequences when its stdout file-handle is connected to a pty. It is currently not possible to communicate with a subprocess that is created by `start-file-process' by writing to a pty (via stdin) and avoiding that this subprocess writes ANSI escape sequences to stdout. This use-case is needed by magit, which currently doesn't have support for displaying ANSI escape sequences but it needs to communicate with it's started subprocesses via a PTY (https://github.com/magit/magit/issues/3549). The reason why I need this feature is that ANSI escape sequences may be output by git-hooks (scripts stored in .git/hooks) if git is run from a terminal/pty. Magit uses (setq process-connection-type t) when creating subprocesses s.t. it can commuicate via the stdin file-handle that is connected to a pty with the subprocess. Here is an small example that shows that all file handles can either be connected to a pty (process-connection-type t) or none of them (process-connection-type nil). (let ((process-connection-type nil) (process-buf (generate-new-buffer "*temp*"))) (apply #'start-file-process "isatty" process-buf "/tmp/output-isatty.py" nil)) The output-isatty.pt looks like #!/usr/bin/env python3 import sys print(f'in: {sys.stdin.isatty()}') print(f'out: {sys.stdout.isatty()}') print(f'err: {sys.stderr.isatty()}') If the above elisp code is run in: False out: False err: False is written to the *temp* buffer if process-connection-type is nil. And in: True out: True err: True is written to the *temp* buffer if process-connection-type is t. In the 'subprocess' and the 'pty' modules in the python stdlib the above use-case is already supported (see the possible values for the stdin,stdout and stderr params). Here is a small demo that attaches a pty to stdin and two normal pipes to stdout and stderr: import os import pty import subprocess master, slave =3D pty.openpty() # see https://docs.python.org/3.5/library/subprocess.html#popen-constructor proc =3D subprocess.Popen( ('./t.py',), stdin=3Dslave, stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, ) os.close(slave) with os.fdopen(master, 'wb', 0) as stdin: stdin.write(b'hello\n') out, err =3D proc.communicate() print('RETC:') print(proc.returncode) print('OUT:') print(out.decode(), end=3D'') print('ERR:') print(err.decode(), end=3D'') In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.28, c= airo version 1.16.0) of 2021-04-29 built on NBPF1PQX4B Repository revision: 0e8c8628854d786e2f99dd2ac35ace88a5ee7924 Repository branch: master Windowing system distributor 'Fedora Project', version 11.0.12011000 System Description: Fedora 33 (Workstation Edition) Configured using: 'configure 'CFLAGS=3D-march=3Dnative -O3' --prefix=3D/opt/emacs --with-pgt= k --with-xpm --with-jpeg --with-gif --with-tiff --with-modules --with-native-compilation --with-json' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB Important settings: value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=3Dibus locale-coding-system: utf-8-unix Major mode: ELisp/d Minor modes in effect: persp-mode: t counsel-projectile-mode: t counsel-mode: t ivy-rich-mode: t ivy-mode: t global-ethan-wspace-mode: t ethan-wspace-mode: t ethan-wspace-clean-many-nls-eof-mode: t ethan-wspace-clean-no-nl-eof-mode: t ethan-wspace-clean-eol-mode: t ethan-wspace-clean-tabs-mode: t save-place-mode: t show-paren-mode: t delete-selection-mode: t global-hi-lock-mode: t hi-lock-mode: t winner-mode: t winum-mode: t global-undo-tree-mode: t undo-tree-mode: t thi::spell-fu-mode: t spell-fu-mode: t savehist-mode: t rainbow-delimiters-mode: t idle-highlight-mode: t async-bytecomp-package-mode: t highlight-function-calls-mode: t recentf-mode: t global-git-commit-mode: t magit-auto-revert-mode: t global-flycheck-mode: t flycheck-mode: t flx-ido-mode: t evil-mode: t evil-local-mode: t envrc-global-mode: t envrc-mode: t yas-minor-mode: t shell-dirtrack-mode: t projectile-mode: t outline-minor-mode: t override-global-mode: t bug-reference-prog-mode: t url-handler-mode: t tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t global-prettify-symbols-mode: t prettify-symbols-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t size-indication-mode: t column-number-mode: t line-number-mode: t transient-mark-mode: t hs-minor-mode: t Load-path shadows: /home/thomas.hisch/.emacs.d/user-lisp/custom hides /opt/emacs/share/emacs/2= 8.0.50/lisp/custom Features: (shadow sort mail-extr emacsbug sendmail shortdoc cl-print url-cache rng-xsd xsd-regexp rng-cmpct rng-nxml rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns nxml-mode nxml-outln nxml-rap sgml-mode facemenu nxml-util nxml-enc xmltok vc-mtn vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs hippie-exp magit-extras origami origami-parsers origami-util yapfify python pulse tramp-archive tramp-gvfs zeroconf deadgrep perspective org-element avl-tree generator ol-eww eww url-queue mm-url ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect gnus-search eieio-opt speedbar ezimage dframe gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-sum shr kinsoku svg dom gnus-group gnus-undo gnus-start gnus-dbus dbus xml gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo gnus-spec gnus-int gnus-range gnus-win gnus nnheader ol-docview doc-view jka-compr image-mode exif ol-bibtex bibtex ol-bbdb ol-w3m org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-footnote org-src ob-comint org-pcomplete org-list org-faces org-entities org-version ob-emacs-lisp ob-core ob-eval org-table ol org-keys org-compat org-macs org-loaddefs cal-menu calendar cal-loaddefs vc-git misearch multi-isearch mule-util magit-bookmark bookmark counsel-projectile counsel swiper ivy-rich ivy-hydra ivy ivy-faces ivy-overlay colir smart-mode-line-respectful-theme smart-mode-line-dark-theme sanityinc-tomorrow-night-theme ethan-wspace hideshow url-tramp ims-jira saveplace ffap paren delsel hi-lock thi-projects winner py-isort format-all language-id reformatter winum which-key wgrep-ag vterm-toggle tramp-sh vterm vterm-module term/xterm xterm visual-regexp visual-fill-column undo-tree tree-sitter-langs tree-sitter-langs-build tar-mode arc-mode archive-mode tree-sitter-hl tree-sitter tree-sitter-load tree-sitter-cli tsc tsc-dyn tsc-dyn-get dired-aux tsc-obsolete typescript-mode stickyfunc-enhance semantic/util-modes semantic/util semantic semantic/tag semantic/lex semantic/fw mode-local cedet ssh-config-mode sphinx-doc spell-fu smex smart-mode-line rich-minority savehist rust-utils rust-mode rust-rustfmt rust-playpen rust-compile rust-cargo rg rg-info-hack rg-menu rg-ibuffer rg-result wgrep-rg wgrep rg-history rg-header cus-edit pp cus-load rainbow-delimiters python-docstring pyimport shut-up protobuf-mode paredit lsp-ui lsp-ui-flycheck lsp-ui-doc goto-addr lsp-ui-imenu lsp-ui-peek lsp-ui-sideline face-remap lsp-ui-util dap-chrome dap-utils kubernetes kubernetes-overview kubernetes-services kubernetes-secrets kubernetes-namespaces kubernetes-jobs kubernetes-pod-line kubernetes-ingress kubernetes-errors kubernetes-nodes kubernetes-statefulsets kubernetes-deployments kubernetes-contexts kubernetes-configmaps kubernetes-logs kubernetes-labels kubernetes-pods kubernetes-yaml kubernetes-loading-container kubernetes-commands kubernetes-utils kubernetes-timers kubernetes-kubectl kubernetes-process term disp-table ehelp kubernetes-props kubernetes-popups kubernetes-state kubernetes-vars kubernetes-modes kubernetes-ast idle-highlight-mode helm-projectile helm-files helm-tags helm-buffers helm-occur helm-grep helm-regexp helm-utils helm-locate helm-help helm-types helm async-bytecomp helm-global-bindings helm-easymenu helm-source helm-multi-match helm-lib async highlight-indentation highlight-function-calls gerrit gerrit-rest recentf forge-list forge-commands forge-semi forge-bitbucket buck forge-gogs gogs forge-gitea gtea forge-gitlab glab forge-github ghub-graphql treepy gsexp ghub gnutls forge-notify forge-revnote forge-pullreq forge-issue forge-topic forge-post forge-repo forge forge-core forge-db closql emacsql-sqlite emacsql emacsql-compiler url-http url-auth url-gw magit-submodule magit-obsolete magit-popup magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit magit-sequence magit-notes magit-worktree magit-tag magit-merge magit-branch magit-reset magit-files magit-refs magit-status magit magit-repos magit-apply magit-wip magit-log which-func magit-diff smerge-mode diff diff-mode git-commit log-edit message rfc822 mml mml-sec epa derived gnus-util rmail rmail-loaddefs mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log magit-core magit-libgit libgit libegit2 magit-autorevert magit-margin magit-transient magit-process with-editor server magit-mode transient magit-git magit-utils crm flycheck-package package-lint let-alist finder flycheck find-func flx-ido ido flx evil evil-keybindings evil-integration evil-maps evil-commands reveal flyspell ispell evil-jumps evil-command-window evil-types evil-search evil-ex evil-macros evil-repeat evil-states evil-core advice evil-common windmove calc calc-loaddefs calc-macs rect evil-digraphs evil-vars equake envrc inheritenv ediff ediff-merg ediff-mult ediff-wind ediff-diff ediff-help ediff-init ediff-util cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs dumb-jump popup dracula-theme dired dired-loaddefs doom-themes doom-themes-base dap-mode dap-launch posframe dap-overlays lsp-mode lsp-protocol yasnippet-snippets yasnippet tree-widget wid-edit spinner network-stream puny nsm rmc inline imenu ht ewoc epg epg-config color-theme-sanityinc-tomorrow cargo cargo-process docker-tramp tramp-cache tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat shell pcomplete ls-lisp format-spec markdown-mode edit-indirect color bufler projectile grep compile text-property-search comint ansi-color ibuf-ext ibuffer ibuffer-loaddefs thingatpt pretty-hydra hydra lv bufler-group-tree magit-section f s dash-functional dash noutline outline vc vc-dispatcher diminish autorevert filenotify quelpa-use-package parse-time iso8601 time-date quelpa mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr lisp-mnt help-fns radix-tree use-package use-package-ensure use-package-delight use-package-diminish use-package-bind-key bind-key use-package-core finder-inf xref project ring bug-reference xdg tab-line pcase easy-mmode edmacro kmacro info package browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf url-util mailcap url-handlers url-parse auth-source eieio eieio-core eieio-loaddefs password-cache json map url-vars comp comp-cstr warnings subr-x rx cl-seq cl-macs cl-extra help-mode seq byte-opt gv cl-loaddefs cl-lib bytecomp byte-compile cconv iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-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 cl-generic 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 charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty make-network-process nativecomp emacs) Memory information: ((conses 16 2215206 1909118) (symbols 48 145665 937) (strings 32 583224 150267) (string-bytes 1 18958140) (vectors 16 200384) (vector-slots 8 6002760 1568162) (floats 8 1240 1330) (intervals 56 119338 63212) (buffers 992 87)) Diese E-Mail enth=E4lt vertrauliche und/oder rechtlich gesch=FCtzte Informa= tionen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrt=FC= mlich erhalten haben, informieren Sie bitte sofort den Absender und vernich= ten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe = dieser Mail ist nicht gestattet. This e-mail may contain confidential and/or privileged information. If you = are not the intended recipient (or have received this e-mail in error) plea= se notify the sender immediately and destroy this e-mail. Any unauthorized = copying, disclosure or distribution of the material in this e-mail is stric= tly prohibited. IMS Nanofabrication GmbH FN: 208021 p, FB-Gericht: Wien; Sitz: Schreygasse = 3, 1020, Vienna (Austria),Tel. +43 1 214 48 94; E-Mail: imsoffice@ims.co.at= ; DVR-Nr: 0374369; www.ims.co.at