From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#62958: [PATCH] Set PAGER=cat in comint.el Date: Mon, 08 May 2023 15:38:12 -0400 Message-ID: References: <83edof6oln.fsf@gnu.org> <83zg724kea.fsf@gnu.org> <835y97jnfd.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11223"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 62958@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 08 21:39:27 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 1pw6hj-0002kv-3Z for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 08 May 2023 21:39:27 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw6hQ-00089y-5l; Mon, 08 May 2023 15:39:08 -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 1pw6hK-00088m-BM for bug-gnu-emacs@gnu.org; Mon, 08 May 2023 15:39:02 -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 1pw6hK-0001nh-3K for bug-gnu-emacs@gnu.org; Mon, 08 May 2023 15:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pw6hJ-0004kp-Vb for bug-gnu-emacs@gnu.org; Mon, 08 May 2023 15:39:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 08 May 2023 19:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62958 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 62958-submit@debbugs.gnu.org id=B62958.168357470218215 (code B ref 62958); Mon, 08 May 2023 19:39:01 +0000 Original-Received: (at 62958) by debbugs.gnu.org; 8 May 2023 19:38:22 +0000 Original-Received: from localhost ([127.0.0.1]:41700 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pw6gf-0004ji-Nk for submit@debbugs.gnu.org; Mon, 08 May 2023 15:38:22 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:56897) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pw6gd-0004jT-La for 62958@debbugs.gnu.org; Mon, 08 May 2023 15:38:20 -0400 In-Reply-To: <835y97jnfd.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 05 May 2023 09:35:18 +0300") 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:261362 Archived-At: Eli Zaretskii writes: >> From: Spencer Baugh >> Cc: 62958@debbugs.gnu.org >> Date: Thu, 20 Apr 2023 12:01:49 -0400 >> >> Eli Zaretskii writes: >> > Is this about removing the leading directories from the value of >> > executable-find? If so, that is trivial to do, and is not the main >> > point of what I wrote. >> >> Yes. But anyway, the default is nil now, so it should be fine. Unless >> you'd like the custom option of "cat" to not show up on non-UNIX >> platforms, somehow? >> >> >> > Should this test that comint-pager is a string? >> >> >> >> I don't think that's necessary; doing >> >> (if (stringp comint-pager) (list (format "PAGER=%s" comint-pager))) >> >> would have unexpected behavior if comint-pager was accidentally set to a >> >> non-string; doing >> >> (when comint-pager (progn (assert (stringp comint-pager)) >> >> (list (format "PAGER=%s" comint-pager)))) >> >> is a bit verbose and looks weird and is probably not that important. >> > >> > So we are okay with the user setting the variable to a symbol or a >> > list or a vector? >> >> Fair enough, I added a check: > > Thanks. This is almost ready to go, I have only 2 minor comments: > > >> diff --git a/lisp/comint.el b/lisp/comint.el >> index 682b555a33c..a145751565f 100644 >> --- a/lisp/comint.el >> +++ b/lisp/comint.el >> @@ -258,6 +258,49 @@ comint-input-ring-file-name >> file) >> :group 'comint) >> >> +(defcustom comint-pager nil >> + "If non-nil, name of the program to use as a pager. >> + >> +If non-nil, comint sets the PAGER environment variable to this >> +value before starting a subprocess. PAGER controls the pager >> +that will be used. If you prefer to not use a pager, you can set >> +this variable to \"cat\". >> + >> +If nil, the PAGER environment variable is not set and the default >> +pager will be used. On Unix systems, typically this is \"less\". >> + >> +Some programs start a pager before producing output. A pager >> +supports viewing text page by page, so that if the parent program >> +produces more output than will fit on the screen, that output can >> +be viewed incrementally. >> + >> +When a program is running under Emacs, this behavior can be >> +undesirable, since Emacs itself supports viewing text page by >> +page, and a pager requires input from the user before it will >> +show more text. Furthermore, comint is not a full fledged >> +terminal emulator, so a pager will typically behave badly. >> + >> +However, pagers also provide backpressure: They will not consume >> +more output from the parent program than the user has actually >> +viewed, which on Unix means the output pipe will fill up and the >> +parent program will be stopped from producing unnecessary output. >> +Many programs (such as \"git log\") take advantage of this by >> +producing large amounts of output by default and relying on the >> +pager to not consume text that the user doesn't view. >> + >> +Emacs and comint do not keep track of what text the user has >> +viewed, so they can't provide backpressure like a pager does. >> +This means users who do not use a pager should be careful to not >> +run commands which produce a lot of output. Users can avoid this >> +by limiting the amount of output (such as with \"git log -n10\") >> +or by using native Emacs interfaces instead (such as >> +`vc-print-log')." > > This is too long, IMO. There's no need for such a long doc string. I > have tried to make it shorter without losing important details: > > "If non-nil, the program to use to disable pagination of program output. > > Some programs produce large amounts of output, and have provision for > pagination of their output through a filter program, commonly known > as a \"pager\". The pager allows the user to interactively browse > the output one page at a time. > Some programs paginate their output by default, by always starting > a pager. The program they use as the pager is specified by the > environment variable PAGER; if that variable is not defined, they > use some fixed default, such as \"less\". > > Pagination is not needed, and gets in the way, when the output of > the program is directed to an Emacs buffer, so in those cases > pagination should be disabled. To disable pagination, this > variable's value should be a string that names a program, such > as \"cat\", which passes through all of the output without any > filtering or delays. Comint will then set the PAGER variable > to name that program, when it invokes external programs." I think it's worth noting the fact that there are programs which depend on pagination for their normal functionality. How about this short additional paragraph added after your text: "Disabling pagination means programs will produce their entire output immediately. If only part of the output is useful, this can be wasteful. For some programs, this can be avoided by using commands (for example, `vc-print-log') which run the program, limit the output it produces, and let the user interactively browse the output inside Emacs."