GNU bug report logs - #62958
[PATCH] Set PAGER=cat in comint.el

Previous Next

Package: emacs;

Reported by: Spencer Baugh <sbaugh <at> janestreet.com>

Date: Wed, 19 Apr 2023 21:58:02 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 62958 in the body.
You can then email your comments to 62958 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Wed, 19 Apr 2023 21:58:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Spencer Baugh <sbaugh <at> janestreet.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 19 Apr 2023 21:58:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Set PAGER=cat in comint.el
Date: Wed, 19 Apr 2023 17:57:38 -0400
[Message part 1 (text/plain, inline)]
Tags: patch


Paging is useless and annoying in comint-derived commands such as
async-shell-command and M-x shell.  It is a frequent footgun for new
Emacs users when they try to run commands which start a pager in such
modes.  I know a number of users who set PAGER=cat in their Emacs to
avoid it.

Simply adding (setenv "PAGER" "cat") globally is not correct, since
that will break modes like term, which support paging quite well.
It's only and exactly the comint-derived modes which don't need
paging.

Changing the default to "cat" in this way might be a bit
controversial...

In GNU Emacs 29.0.60 (build 3, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.15.12, Xaw scroll bars) of 2023-03-13 built on
 igm-qws-u22796a
Repository revision: e759905d2e0828eac4c8164b09113b40f6899656
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: CentOS Linux 7 (Core)

Configured using:
 'configure --with-x-toolkit=lucid --with-modules
 --with-gif=ifavailable'

[0001-Set-PAGER-cat-in-comint.el.patch (text/patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Thu, 20 Apr 2023 06:43:01 GMT) Full text and rfc822 format available.

Message #8 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Thu, 20 Apr 2023 09:43:00 +0300
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Date: Wed, 19 Apr 2023 17:57:38 -0400
> 
> Simply adding (setenv "PAGER" "cat") globally is not correct, since
> that will break modes like term, which support paging quite well.
> It's only and exactly the comint-derived modes which don't need
> paging.
> 
> Changing the default to "cat" in this way might be a bit
> controversial...

Sorry, this default cannot be universally correct.  You assume that
'cat' is always available, which is not true on non-Posix platforms.
So at the very least the value should be set according to
executable-find.

Having said that, I'm not really sure the default should be "cat" even
if it is available, since AFAIK you are the only one who is unhappy
with the current situation.  So why not leave the default value as it
is, i.e. nil?

> +(defcustom comint-pager "cat"
> +  "If non-nil, the value to use for PAGER.

This is too terse.  It should at least say that the value should be a
program name, a string.  Bonus point for explaining what is PAGER, for
those who don't necessarily know off-hand.

> +gWhen this is nil, comint doesn't set PAGER at all."
   ^
Typo.  Also, "set PAGER" is again too terse.

> +  :version "30.1"
> +  :type '(choice (const :tag "Don't set PAGER" nil)
> +                 (const :tag "cat" "cat")

The tag of "cat" is too terse again.  It should at least include the
word "program" somewhere.

> @@ -864,6 +873,7 @@ comint-exec-1
>  	 (nconc
>            (comint-term-environment)
>  	  (list (format "INSIDE_EMACS=%s,comint" emacs-version))
> +          (when comint-pager (list (format "PAGER=%s" comint-pager)))

Should this test that comint-pager is a string?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Thu, 20 Apr 2023 15:48:02 GMT) Full text and rfc822 format available.

Message #11 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Thu, 20 Apr 2023 11:47:42 -0400
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Spencer Baugh <sbaugh <at> janestreet.com>
>> Date: Wed, 19 Apr 2023 17:57:38 -0400
>> 
>> Simply adding (setenv "PAGER" "cat") globally is not correct, since
>> that will break modes like term, which support paging quite well.
>> It's only and exactly the comint-derived modes which don't need
>> paging.
>> 
>> Changing the default to "cat" in this way might be a bit
>> controversial...
>
> Sorry, this default cannot be universally correct.  You assume that
> 'cat' is always available, which is not true on non-Posix platforms.
> So at the very least the value should be set according to
> executable-find.

executable-find is not correct in the case of "cat" unfortunately,
because there are programs (git, for one) which if they see PAGER=cat,
just don't start a pager at all, for greater efficiency.  (which is
desirable behavior)

> Having said that, I'm not really sure the default should be "cat" even
> if it is available, since AFAIK you are the only one who is unhappy
> with the current situation.  So why not leave the default value as it
> is, i.e. nil?

Yes okay, I'll leave the default as it is.

>> +(defcustom comint-pager "cat"
>> +  "If non-nil, the value to use for PAGER.
>
> This is too terse.  It should at least say that the value should be a
> program name, a string.  Bonus point for explaining what is PAGER, for
> those who don't necessarily know off-hand.

Hm, yes, I have updated the docstring to explain the issue, it's worth
having a good explanation.  Hopefully this isn't too verbose now :)

>> +gWhen this is nil, comint doesn't set PAGER at all."
>    ^
> Typo.  Also, "set PAGER" is again too terse.
>
>> +  :version "30.1"
>> +  :type '(choice (const :tag "Don't set PAGER" nil)
>> +                 (const :tag "cat" "cat")
>
> The tag of "cat" is too terse again.  It should at least include the
> word "program" somewhere.
>
>> @@ -864,6 +873,7 @@ comint-exec-1
>>  	 (nconc
>>            (comint-term-environment)
>>  	  (list (format "INSIDE_EMACS=%s,comint" emacs-version))
>> +          (when comint-pager (list (format "PAGER=%s" comint-pager)))
>
> 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.

Revised patch:

commit a375cb9c1260edb40a92f11fdec7f6910538135d
Author: Spencer Baugh <sbaugh <at> janestreet.com>
Date:   Wed Apr 19 17:44:54 2023 -0400

  Set PAGER=cat in comint.el
  
  Paging can be undesirable in comint-derived commands such as
  async-shell-command and M-x shell.  It is a frequent footgun for new
  Emacs users when they try to run commands which start a pager in such
  modes.
  
  Simply adding (setenv "PAGER" "cat") globally is not correct, since
  that will break modes like term, which support paging quite well.
  It's only and exactly the comint-derived modes which don't need
  paging.
  
  * lisp/comint.el (comint-pager):
  Add.
  (comint-exec-1):
  Use comint-pager to set PAGER.


diff --git a/lisp/comint.el b/lisp/comint.el
index 682b555a33c..37e189e4bbf 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').")
+  :version "30.1"
+  :type '(choice (const :tag "Don't set PAGER" nil)
+                 (const :tag "Don't do paging (PAGER=cat)" "cat")
+		 string)
+  :group 'comint)
+
 (defvar comint-input-ring-file-prefix nil
   "The prefix to skip when parsing the input ring file.
 This is useful in Zsh when the extended_history option is on.")
@@ -864,6 +907,7 @@ comint-exec-1
 	 (nconc
           (comint-term-environment)
 	  (list (format "INSIDE_EMACS=%s,comint" emacs-version))
+          (when comint-pager (list (format "PAGER=%s" comint-pager)))
 	  process-environment))
 	(default-directory
 	  (if (file-accessible-directory-p default-directory)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Thu, 20 Apr 2023 15:57:02 GMT) Full text and rfc822 format available.

Message #14 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Thu, 20 Apr 2023 18:56:45 +0300
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Cc: 62958 <at> debbugs.gnu.org
> Date: Thu, 20 Apr 2023 11:47:42 -0400
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > Sorry, this default cannot be universally correct.  You assume that
> > 'cat' is always available, which is not true on non-Posix platforms.
> > So at the very least the value should be set according to
> > executable-find.
> 
> executable-find is not correct in the case of "cat" unfortunately,
> because there are programs (git, for one) which if they see PAGER=cat,
> just don't start a pager at all, for greater efficiency.  (which is
> desirable behavior)

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.

> > 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?

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Thu, 20 Apr 2023 16:02:01 GMT) Full text and rfc822 format available.

Message #17 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Thu, 20 Apr 2023 12:01:49 -0400
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Spencer Baugh <sbaugh <at> janestreet.com>
>> Cc: 62958 <at> debbugs.gnu.org
>> Date: Thu, 20 Apr 2023 11:47:42 -0400
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>> > Sorry, this default cannot be universally correct.  You assume that
>> > 'cat' is always available, which is not true on non-Posix platforms.
>> > So at the very least the value should be set according to
>> > executable-find.
>> 
>> executable-find is not correct in the case of "cat" unfortunately,
>> because there are programs (git, for one) which if they see PAGER=cat,
>> just don't start a pager at all, for greater efficiency.  (which is
>> desirable behavior)
>
> 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:

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')."
+  :version "30.1"
+  :type '(choice (const :tag "Use default PAGER" nil)
+                 (const :tag "Don't do paging (PAGER=cat)" "cat")
+		 string)
+  :group 'comint)
+
 (defvar comint-input-ring-file-prefix nil
   "The prefix to skip when parsing the input ring file.
 This is useful in Zsh when the extended_history option is on.")
@@ -864,6 +907,10 @@ comint-exec-1
 	 (nconc
           (comint-term-environment)
 	  (list (format "INSIDE_EMACS=%s,comint" emacs-version))
+          (when comint-pager
+            (if (stringp comint-pager)
+                (list (format "PAGER=%s" comint-pager))
+              (error "comint-pager should be a string: %s" comint-pager)))
 	  process-environment))
 	(default-directory
 	  (if (file-accessible-directory-p default-directory)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Wed, 26 Apr 2023 07:55:02 GMT) Full text and rfc822 format available.

Message #20 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Philip Kaludercic <philipk <at> posteo.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Spencer Baugh <sbaugh <at> janestreet.com>, 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Wed, 26 Apr 2023 07:54:34 +0000
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Spencer Baugh <sbaugh <at> janestreet.com>
>> Date: Wed, 19 Apr 2023 17:57:38 -0400
>> 
>> Simply adding (setenv "PAGER" "cat") globally is not correct, since
>> that will break modes like term, which support paging quite well.
>> It's only and exactly the comint-derived modes which don't need
>> paging.
>> 
>> Changing the default to "cat" in this way might be a bit
>> controversial...
>
> Sorry, this default cannot be universally correct.  You assume that
> 'cat' is always available, which is not true on non-Posix platforms.
> So at the very least the value should be set according to
> executable-find.

What systems respect PAGER (and would have it presumably set to
something like less), but would not provide cat?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Wed, 26 Apr 2023 09:16:02 GMT) Full text and rfc822 format available.

Message #23 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Philip Kaludercic <philipk <at> posteo.net>
Cc: sbaugh <at> janestreet.com, 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Wed, 26 Apr 2023 12:15:34 +0300
> From: Philip Kaludercic <philipk <at> posteo.net>
> Cc: Spencer Baugh <sbaugh <at> janestreet.com>,  62958 <at> debbugs.gnu.org
> Date: Wed, 26 Apr 2023 07:54:34 +0000
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> Changing the default to "cat" in this way might be a bit
> >> controversial...
> >
> > Sorry, this default cannot be universally correct.  You assume that
> > 'cat' is always available, which is not true on non-Posix platforms.
> > So at the very least the value should be set according to
> > executable-find.
> 
> What systems respect PAGER (and would have it presumably set to
> something like less), but would not provide cat?

PAGER is not a system-provided feature, it is provided by the programs
which honor the variable.  Any such program, when ported to a system
where there's no 'cat', will still support PAGER.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Fri, 05 May 2023 06:35:02 GMT) Full text and rfc822 format available.

Message #26 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Fri, 05 May 2023 09:35:18 +0300
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Cc: 62958 <at> debbugs.gnu.org
> Date: Thu, 20 Apr 2023 12:01:49 -0400
> 
> Eli Zaretskii <eliz <at> gnu.org> 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."

> +  :type '(choice (const :tag "Use default PAGER" nil)
> +                 (const :tag "Don't do paging (PAGER=cat)" "cat")
> +		 string)

Could we have a helpful :tag for the 'string' alternative?  It would
be good to explain there what kind of strings should be used: either a
full absolute file name or a basename that can be found via PATH.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Mon, 08 May 2023 19:39:01 GMT) Full text and rfc822 format available.

Message #29 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Mon, 08 May 2023 15:38:12 -0400
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Spencer Baugh <sbaugh <at> janestreet.com>
>> Cc: 62958 <at> debbugs.gnu.org
>> Date: Thu, 20 Apr 2023 12:01:49 -0400
>> 
>> Eli Zaretskii <eliz <at> gnu.org> 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."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Tue, 09 May 2023 05:08:02 GMT) Full text and rfc822 format available.

Message #32 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Tue, 09 May 2023 08:08:51 +0300
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Cc: 62958 <at> debbugs.gnu.org
> Date: Mon, 08 May 2023 15:38:12 -0400
> 
> >   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."

Sorry, I don't understand: why would it matter that a program produces
its output immediately when that output is redirected to an Emacs
buffer?  Whatever the amount of output, the user can always page
through it interactively and conveniently using the normal movement
commands, no?  What am I missing?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Tue, 09 May 2023 14:56:01 GMT) Full text and rfc822 format available.

Message #35 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: sbaugh <at> catern.com
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Spencer Baugh <sbaugh <at> janestreet.com>, 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Tue, 09 May 2023 14:55:31 +0000 (UTC)
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Spencer Baugh <sbaugh <at> janestreet.com>
>> Cc: 62958 <at> debbugs.gnu.org
>> Date: Mon, 08 May 2023 15:38:12 -0400
>> 
>> >   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."
>
> Sorry, I don't understand: why would it matter that a program produces
> its output immediately when that output is redirected to an Emacs
> buffer?  Whatever the amount of output, the user can always page
> through it interactively and conveniently using the normal movement
> commands, no?  What am I missing?

If the command produces a lot of output it can take a long time to run
and slow down Emacs.

For example, if a user disables pagination, runs M-x shell, and then
runs "git log" in the Emacs repo, it takes ~3.5 minutes to run and
produces ~1.5 million lines.  Even if all they want is to see the 10
most recent commits.  There are several negative effects of this, in
decreasing order of importance:

- The shell buffer now has way more output, which slows down navigation
and operations on that buffer forever after, including font lock.
- The user's shell is blocked during that whole time, preventing further
shell commands.
- git log producing unnecessary output wastes CPU and IO.

If "git log" is run with a pager, it can complete as soon as the user
exits the pager, and it only produces a few lines.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Tue, 09 May 2023 15:46:01 GMT) Full text and rfc822 format available.

Message #38 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: sbaugh <at> catern.com
Cc: sbaugh <at> janestreet.com, 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Tue, 09 May 2023 18:46:36 +0300
> From: sbaugh <at> catern.com
> Date: Tue, 09 May 2023 14:55:31 +0000 (UTC)
> Cc: Spencer Baugh <sbaugh <at> janestreet.com>, 62958 <at> debbugs.gnu.org
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> From: Spencer Baugh <sbaugh <at> janestreet.com>
> >> Cc: 62958 <at> debbugs.gnu.org
> >> Date: Mon, 08 May 2023 15:38:12 -0400
> >> 
> >> >   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."
> >
> > Sorry, I don't understand: why would it matter that a program produces
> > its output immediately when that output is redirected to an Emacs
> > buffer?  Whatever the amount of output, the user can always page
> > through it interactively and conveniently using the normal movement
> > commands, no?  What am I missing?
> 
> If the command produces a lot of output it can take a long time to run
> and slow down Emacs.
> 
> For example, if a user disables pagination, runs M-x shell, and then
> runs "git log" in the Emacs repo, it takes ~3.5 minutes to run and
> produces ~1.5 million lines.  Even if all they want is to see the 10
> most recent commits.  There are several negative effects of this, in
> decreasing order of importance:
> 
> - The shell buffer now has way more output, which slows down navigation
> and operations on that buffer forever after, including font lock.
> - The user's shell is blocked during that whole time, preventing further
> shell commands.
> - git log producing unnecessary output wastes CPU and IO.
> 
> If "git log" is run with a pager, it can complete as soon as the user
> exits the pager, and it only produces a few lines.

But this is impossible in general, AFAIU: most comint clients aren't
prepared for interactive paging anyway.  If someone wants paging, they
should use "M-x term" or "M-x ansi-term", the terminal emulators that
Emacs provides.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Tue, 09 May 2023 16:31:02 GMT) Full text and rfc822 format available.

Message #41 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Tue, 09 May 2023 12:30:42 -0400
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: sbaugh <at> catern.com
>> Date: Tue, 09 May 2023 14:55:31 +0000 (UTC)
>> Cc: Spencer Baugh <sbaugh <at> janestreet.com>, 62958 <at> debbugs.gnu.org
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>> >> From: Spencer Baugh <sbaugh <at> janestreet.com>
>> >> Cc: 62958 <at> debbugs.gnu.org
>> >> Date: Mon, 08 May 2023 15:38:12 -0400
>> >> 
>> >> >   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."
>> >
>> > Sorry, I don't understand: why would it matter that a program produces
>> > its output immediately when that output is redirected to an Emacs
>> > buffer?  Whatever the amount of output, the user can always page
>> > through it interactively and conveniently using the normal movement
>> > commands, no?  What am I missing?
>> 
>> If the command produces a lot of output it can take a long time to run
>> and slow down Emacs.
>> 
>> For example, if a user disables pagination, runs M-x shell, and then
>> runs "git log" in the Emacs repo, it takes ~3.5 minutes to run and
>> produces ~1.5 million lines.  Even if all they want is to see the 10
>> most recent commits.  There are several negative effects of this, in
>> decreasing order of importance:
>> 
>> - The shell buffer now has way more output, which slows down navigation
>> and operations on that buffer forever after, including font lock.
>> - The user's shell is blocked during that whole time, preventing further
>> shell commands.
>> - git log producing unnecessary output wastes CPU and IO.
>> 
>> If "git log" is run with a pager, it can complete as soon as the user
>> exits the pager, and it only produces a few lines.
>
> But this is impossible in general, AFAIU: most comint clients aren't
> prepared for interactive paging anyway.  If someone wants paging, they
> should use "M-x term" or "M-x ansi-term", the terminal emulators that
> Emacs provides.

Yes.  I of course know that, that's why I filed this bug :)

Nevertheless, today by default many programs run in comint clients will
run a pager, and even though it is a hassle and gets in the way inside
Emacs, it does prevent some programs from producing lots of output and
yielding the negative effects I mentioned previously:

>> - The shell buffer now has way more output, which slows down navigation
>> and operations on that buffer forever after, including font lock.
>> - The user's shell is blocked during that whole time, preventing further
>> shell commands.
>> - git log producing unnecessary output wastes CPU and IO.

Because of these negative effects which will start happening for some
programs when the user disables pagination, I think it's important for
users to know that there's alternatives for such programs: namely, using
native Emacs interfaces like vc-print-log.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Tue, 09 May 2023 16:43:02 GMT) Full text and rfc822 format available.

Message #44 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Tue, 09 May 2023 19:43:03 +0300
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Cc: sbaugh <at> catern.com,  62958 <at> debbugs.gnu.org
> Date: Tue, 09 May 2023 12:30:42 -0400
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> From: sbaugh <at> catern.com
> >> Date: Tue, 09 May 2023 14:55:31 +0000 (UTC)
> >> Cc: Spencer Baugh <sbaugh <at> janestreet.com>, 62958 <at> debbugs.gnu.org
> >> 
> >> Eli Zaretskii <eliz <at> gnu.org> writes:
> >> 
> >> >> From: Spencer Baugh <sbaugh <at> janestreet.com>
> >> >> Cc: 62958 <at> debbugs.gnu.org
> >> >> Date: Mon, 08 May 2023 15:38:12 -0400
> >> >> 
> >> >> >   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."
> >> >
> >> > Sorry, I don't understand: why would it matter that a program produces
> >> > its output immediately when that output is redirected to an Emacs
> >> > buffer?  Whatever the amount of output, the user can always page
> >> > through it interactively and conveniently using the normal movement
> >> > commands, no?  What am I missing?
> >> 
> >> If the command produces a lot of output it can take a long time to run
> >> and slow down Emacs.
> >> 
> >> For example, if a user disables pagination, runs M-x shell, and then
> >> runs "git log" in the Emacs repo, it takes ~3.5 minutes to run and
> >> produces ~1.5 million lines.  Even if all they want is to see the 10
> >> most recent commits.  There are several negative effects of this, in
> >> decreasing order of importance:
> >> 
> >> - The shell buffer now has way more output, which slows down navigation
> >> and operations on that buffer forever after, including font lock.
> >> - The user's shell is blocked during that whole time, preventing further
> >> shell commands.
> >> - git log producing unnecessary output wastes CPU and IO.
> >> 
> >> If "git log" is run with a pager, it can complete as soon as the user
> >> exits the pager, and it only produces a few lines.
> >
> > But this is impossible in general, AFAIU: most comint clients aren't
> > prepared for interactive paging anyway.  If someone wants paging, they
> > should use "M-x term" or "M-x ansi-term", the terminal emulators that
> > Emacs provides.
> 
> Yes.  I of course know that, that's why I filed this bug :)
> 
> Nevertheless, today by default many programs run in comint clients will
> run a pager, and even though it is a hassle and gets in the way inside
> Emacs, it does prevent some programs from producing lots of output and
> yielding the negative effects I mentioned previously:
> 
> >> - The shell buffer now has way more output, which slows down navigation
> >> and operations on that buffer forever after, including font lock.
> >> - The user's shell is blocked during that whole time, preventing further
> >> shell commands.
> >> - git log producing unnecessary output wastes CPU and IO.
> 
> Because of these negative effects which will start happening for some
> programs when the user disables pagination, I think it's important for
> users to know that there's alternatives for such programs: namely, using
> native Emacs interfaces like vc-print-log.

OK, but what's the purpose of the addition you were proposing?  It
basically says that sometimes paging should not be disabled, but since
this is a defcustom, and the default is not to disable paging, that
already speaks volumes about the same issue, right?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Tue, 09 May 2023 16:54:02 GMT) Full text and rfc822 format available.

Message #47 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Tue, 09 May 2023 12:53:24 -0400
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Spencer Baugh <sbaugh <at> janestreet.com>
>> Cc: sbaugh <at> catern.com,  62958 <at> debbugs.gnu.org
>> Date: Tue, 09 May 2023 12:30:42 -0400
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>> >> From: sbaugh <at> catern.com
>> >> Date: Tue, 09 May 2023 14:55:31 +0000 (UTC)
>> >> Cc: Spencer Baugh <sbaugh <at> janestreet.com>, 62958 <at> debbugs.gnu.org
>> >> 
>> >> Eli Zaretskii <eliz <at> gnu.org> writes:
>> >> 
>> >> >> From: Spencer Baugh <sbaugh <at> janestreet.com>
>> >> >> Cc: 62958 <at> debbugs.gnu.org
>> >> >> Date: Mon, 08 May 2023 15:38:12 -0400
>> >> >> 
>> >> >> >   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."
>> >> >
>> >> > Sorry, I don't understand: why would it matter that a program produces
>> >> > its output immediately when that output is redirected to an Emacs
>> >> > buffer?  Whatever the amount of output, the user can always page
>> >> > through it interactively and conveniently using the normal movement
>> >> > commands, no?  What am I missing?
>> >> 
>> >> If the command produces a lot of output it can take a long time to run
>> >> and slow down Emacs.
>> >> 
>> >> For example, if a user disables pagination, runs M-x shell, and then
>> >> runs "git log" in the Emacs repo, it takes ~3.5 minutes to run and
>> >> produces ~1.5 million lines.  Even if all they want is to see the 10
>> >> most recent commits.  There are several negative effects of this, in
>> >> decreasing order of importance:
>> >> 
>> >> - The shell buffer now has way more output, which slows down navigation
>> >> and operations on that buffer forever after, including font lock.
>> >> - The user's shell is blocked during that whole time, preventing further
>> >> shell commands.
>> >> - git log producing unnecessary output wastes CPU and IO.
>> >> 
>> >> If "git log" is run with a pager, it can complete as soon as the user
>> >> exits the pager, and it only produces a few lines.
>> >
>> > But this is impossible in general, AFAIU: most comint clients aren't
>> > prepared for interactive paging anyway.  If someone wants paging, they
>> > should use "M-x term" or "M-x ansi-term", the terminal emulators that
>> > Emacs provides.
>> 
>> Yes.  I of course know that, that's why I filed this bug :)
>> 
>> Nevertheless, today by default many programs run in comint clients will
>> run a pager, and even though it is a hassle and gets in the way inside
>> Emacs, it does prevent some programs from producing lots of output and
>> yielding the negative effects I mentioned previously:
>> 
>> >> - The shell buffer now has way more output, which slows down navigation
>> >> and operations on that buffer forever after, including font lock.
>> >> - The user's shell is blocked during that whole time, preventing further
>> >> shell commands.
>> >> - git log producing unnecessary output wastes CPU and IO.
>> 
>> Because of these negative effects which will start happening for some
>> programs when the user disables pagination, I think it's important for
>> users to know that there's alternatives for such programs: namely, using
>> native Emacs interfaces like vc-print-log.
>
> OK, but what's the purpose of the addition you were proposing?  It
> basically says that sometimes paging should not be disabled, but since
> this is a defcustom, and the default is not to disable paging, that
> already speaks volumes about the same issue, right?

My addition says:
- sometimes paging should not be disabled (for programs like "git log")
- but if you're going to disable it anyway, commands like `vc-print-log'
  become more useful (because it's an alternative to "git log")

The purpose of the addition is to communicate the second part.  (And
since I think the primary way most people will encounter this is through
"git log", I think it's worth mentioning `vc-print-log' specifically)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Tue, 09 May 2023 16:59:01 GMT) Full text and rfc822 format available.

Message #50 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Tue, 09 May 2023 19:59:35 +0300
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Cc: sbaugh <at> catern.com,  62958 <at> debbugs.gnu.org
> Date: Tue, 09 May 2023 12:53:24 -0400
> 
> > OK, but what's the purpose of the addition you were proposing?  It
> > basically says that sometimes paging should not be disabled, but since
> > this is a defcustom, and the default is not to disable paging, that
> > already speaks volumes about the same issue, right?
> 
> My addition says:
> - sometimes paging should not be disabled (for programs like "git log")
> - but if you're going to disable it anyway, commands like `vc-print-log'
>   become more useful (because it's an alternative to "git log")
> 
> The purpose of the addition is to communicate the second part.  (And
> since I think the primary way most people will encounter this is through
> "git log", I think it's worth mentioning `vc-print-log' specifically)

I'm asking why this is not already obvious from the fact that this is
a defcustom, by default off.  All your addition says is "don't disable
paging in all cases, sometimes it can be useful".  But we already said
that, in effect, by making the paging enabled by default.  So there's
no reason to have that text, as it isn't instrumental, and doesn't add
anything.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Tue, 09 May 2023 17:02:02 GMT) Full text and rfc822 format available.

Message #53 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Tue, 9 May 2023 13:01:07 -0400
[Message part 1 (text/plain, inline)]
On Tue, May 9, 2023, 12:58 Eli Zaretskii <eliz <at> gnu.org> wrote:

> > From: Spencer Baugh <sbaugh <at> janestreet.com>
> > Cc: sbaugh <at> catern.com,  62958 <at> debbugs.gnu.org
> > Date: Tue, 09 May 2023 12:53:24 -0400
> >
> > > OK, but what's the purpose of the addition you were proposing?  It
> > > basically says that sometimes paging should not be disabled, but since
> > > this is a defcustom, and the default is not to disable paging, that
> > > already speaks volumes about the same issue, right?
> >
> > My addition says:
> > - sometimes paging should not be disabled (for programs like "git log")
> > - but if you're going to disable it anyway, commands like `vc-print-log'
> >   become more useful (because it's an alternative to "git log")
> >
> > The purpose of the addition is to communicate the second part.  (And
> > since I think the primary way most people will encounter this is through
> > "git log", I think it's worth mentioning `vc-print-log' specifically)
>
> I'm asking why this is not already obvious from the fact that this is
> a defcustom, by default off.  All your addition says is "don't disable
> paging in all cases, sometimes it can be useful".  But we already said
> that, in effect, by making the paging enabled by default.  So there's
> no reason to have that text, as it isn't instrumental, and doesn't add
> anything.
>

How does "this is a defcustom, by default off" communicate "you should use
vc-print-log if you turn this on"?

>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Tue, 09 May 2023 17:03:02 GMT) Full text and rfc822 format available.

Message #56 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: sbaugh <at> janestreet.com
Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Tue, 09 May 2023 20:03:14 +0300
> Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
> Date: Tue, 09 May 2023 19:59:35 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> 
> I'm asking why this is not already obvious from the fact that this is
> a defcustom, by default off.  All your addition says is "don't disable
> paging in all cases, sometimes it can be useful".  But we already said
> that, in effect, by making the paging enabled by default.  So there's
> no reason to have that text, as it isn't instrumental, and doesn't add
> anything.

Or let me turn the table and ask whether the following minor
rephrasing of what I proposed will satisfy you:

  Pagination is normally not needed, and might get in the way, when
  the output of the program is directed to an Emacs buffer, so in
  those cases pagination might need to 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."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Tue, 09 May 2023 17:05:01 GMT) Full text and rfc822 format available.

Message #59 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Tue, 09 May 2023 20:05:48 +0300
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Date: Tue, 9 May 2023 13:01:07 -0400
> Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
> 
>  I'm asking why this is not already obvious from the fact that this is
>  a defcustom, by default off.  All your addition says is "don't disable
>  paging in all cases, sometimes it can be useful".  But we already said
>  that, in effect, by making the paging enabled by default.  So there's
>  no reason to have that text, as it isn't instrumental, and doesn't add
>  anything.
> 
> How does "this is a defcustom, by default off" communicate "you should use vc-print-log if you turn this
> on"?

Why are we suddenly talking about vc-print-log when discussing a much
more general feature?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Tue, 09 May 2023 17:15:02 GMT) Full text and rfc822 format available.

Message #62 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Tue, 09 May 2023 13:13:56 -0400
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Spencer Baugh <sbaugh <at> janestreet.com>
>> Date: Tue, 9 May 2023 13:01:07 -0400
>> Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
>> 
>>  I'm asking why this is not already obvious from the fact that this is
>>  a defcustom, by default off.  All your addition says is "don't disable
>>  paging in all cases, sometimes it can be useful".  But we already said
>>  that, in effect, by making the paging enabled by default.  So there's
>>  no reason to have that text, as it isn't instrumental, and doesn't add
>>  anything.
>> 
>> How does "this is a defcustom, by default off" communicate "you should use vc-print-log if you turn this
>> on"?
>
> Why are we suddenly talking about vc-print-log when discussing a much
> more general feature?

Because disabling pagination effectively breaks the shell command "git
log" and vc-print-log is one alternative to running "git log", and I
don't know how else the user would realize that.  (In my experience with
talking to users about this, they usually don't)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Tue, 09 May 2023 18:58:02 GMT) Full text and rfc822 format available.

Message #65 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Tue, 09 May 2023 21:58:06 +0300
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Cc: sbaugh <at> catern.com,  62958 <at> debbugs.gnu.org
> Date: Tue, 09 May 2023 13:13:56 -0400
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> From: Spencer Baugh <sbaugh <at> janestreet.com>
> >> Date: Tue, 9 May 2023 13:01:07 -0400
> >> Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
> >> 
> >>  I'm asking why this is not already obvious from the fact that this is
> >>  a defcustom, by default off.  All your addition says is "don't disable
> >>  paging in all cases, sometimes it can be useful".  But we already said
> >>  that, in effect, by making the paging enabled by default.  So there's
> >>  no reason to have that text, as it isn't instrumental, and doesn't add
> >>  anything.
> >> 
> >> How does "this is a defcustom, by default off" communicate "you should use vc-print-log if you turn this
> >> on"?
> >
> > Why are we suddenly talking about vc-print-log when discussing a much
> > more general feature?
> 
> Because disabling pagination effectively breaks the shell command "git
> log" and vc-print-log is one alternative to running "git log", and I
> don't know how else the user would realize that.  (In my experience with
> talking to users about this, they usually don't)

A doc string of a general option is not the proper place for talking
about some very specific case when that option is used.  If the main
problem is vc-print-log, we should find another way of dealing with
it.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Wed, 10 May 2023 16:58:01 GMT) Full text and rfc822 format available.

Message #68 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: sbaugh <at> catern.com
Cc: Spencer Baugh <sbaugh <at> janestreet.com>, Eli Zaretskii <eliz <at> gnu.org>,
 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Wed, 10 May 2023 19:39:12 +0300
>> Sorry, I don't understand: why would it matter that a program produces
>> its output immediately when that output is redirected to an Emacs
>> buffer?  Whatever the amount of output, the user can always page
>> through it interactively and conveniently using the normal movement
>> commands, no?  What am I missing?
>
> If the command produces a lot of output it can take a long time to run
> and slow down Emacs.

I will definitely customize the new option 'comint-pager' to "cat"
as soon as it arrives to master.  But for such cases when some
commands produce too long output, would it be also possible
to provide an additional option to set the number of lines
to output before stopping?

It seems not possible just to set the ENV variable 'LINES'.
From 'man less':

  LINES  Sets the number of lines on the screen.  Takes precedence over the number  of
         lines  specified  by  the TERM variable.  (But if you have a windowing system
         which supports TIOCGWINSZ or WIOCGETD, the window system's idea of the screen
         size takes precedence over the LINES and COLUMNS environment variables.)

And indeed it has no effect when I tried.  Maybe because window size
adjustments are explicitly coded in 'window--adjust-process-windows'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Wed, 10 May 2023 16:59:02 GMT) Full text and rfc822 format available.

Message #71 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org, sbaugh <at> janestreet.com
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Wed, 10 May 2023 19:59:43 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  Spencer Baugh <sbaugh <at> janestreet.com>,
>   62958 <at> debbugs.gnu.org
> Date: Wed, 10 May 2023 19:39:12 +0300
> 
> It seems not possible just to set the ENV variable 'LINES'.
> >From 'man less':
> 
>   LINES  Sets the number of lines on the screen.  Takes precedence over the number  of
>          lines  specified  by  the TERM variable.  (But if you have a windowing system
>          which supports TIOCGWINSZ or WIOCGETD, the window system's idea of the screen
>          size takes precedence over the LINES and COLUMNS environment variables.)
> 
> And indeed it has no effect when I tried.  Maybe because window size
> adjustments are explicitly coded in 'window--adjust-process-windows'.

Almost definitely because of that.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Wed, 10 May 2023 18:15:01 GMT) Full text and rfc822 format available.

Message #74 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Gregory Heytings <gregory <at> heytings.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: sbaugh <at> catern.com, Eli Zaretskii <eliz <at> gnu.org>, 62958 <at> debbugs.gnu.org,
 Spencer Baugh <sbaugh <at> janestreet.com>
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Wed, 10 May 2023 18:13:59 +0000
>
> I will definitely customize the new option 'comint-pager' to "cat" as 
> soon as it arrives to master.  But for such cases when some commands 
> produce too long output, would it be also possible to provide an 
> additional option to set the number of lines to output before stopping?
>

Did you try "cat | head -N"?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Fri, 12 May 2023 17:53:02 GMT) Full text and rfc822 format available.

Message #77 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: sbaugh <at> catern.com, Eli Zaretskii <eliz <at> gnu.org>, 62958 <at> debbugs.gnu.org,
 Spencer Baugh <sbaugh <at> janestreet.com>
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Fri, 12 May 2023 20:49:05 +0300
>> I will definitely customize the new option 'comint-pager' to "cat" as
>> soon as it arrives to master.  But for such cases when some commands
>> produce too long output, would it be also possible to provide an
>> additional option to set the number of lines to output before stopping?
>
> Did you try "cat | head -N"?

Now I tried out, and it works as expected.  Only there is no indication
that the output is truncated.  But probably such indication is not important
with overly long output.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Fri, 12 May 2023 22:22:01 GMT) Full text and rfc822 format available.

Message #80 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Gregory Heytings <gregory <at> heytings.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: sbaugh <at> catern.com, Eli Zaretskii <eliz <at> gnu.org>, 62958 <at> debbugs.gnu.org,
 Spencer Baugh <sbaugh <at> janestreet.com>
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Fri, 12 May 2023 22:21:19 +0000
>>> I will definitely customize the new option 'comint-pager' to "cat" as 
>>> soon as it arrives to master.  But for such cases when some commands 
>>> produce too long output, would it be also possible to provide an 
>>> additional option to set the number of lines to output before 
>>> stopping?
>>
>> Did you try "cat | head -N"?
>
> Now I tried out, and it works as expected.  Only there is no indication 
> that the output is truncated.  But probably such indication is not 
> important with overly long output.
>

If you want such an indication, I suggest using sed instead of head:

cat | sed -e "<N>aOUTPUT TRUNCATED" -e "<N>q"

(Of course, replace <N> with the number of lines of output you want.  And 
of course you can replace the string "OUTPUT TRUNCATED" with whatever you 
want.)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Tue, 16 May 2023 19:50:01 GMT) Full text and rfc822 format available.

Message #83 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Tue, 16 May 2023 15:49:21 -0400
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Spencer Baugh <sbaugh <at> janestreet.com>
>> Cc: sbaugh <at> catern.com,  62958 <at> debbugs.gnu.org
>> Date: Tue, 09 May 2023 13:13:56 -0400
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>> >> From: Spencer Baugh <sbaugh <at> janestreet.com>
>> >> Date: Tue, 9 May 2023 13:01:07 -0400
>> >> Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
>> >> 
>> >>  I'm asking why this is not already obvious from the fact that this is
>> >>  a defcustom, by default off.  All your addition says is "don't disable
>> >>  paging in all cases, sometimes it can be useful".  But we already said
>> >>  that, in effect, by making the paging enabled by default.  So there's
>> >>  no reason to have that text, as it isn't instrumental, and doesn't add
>> >>  anything.
>> >> 
>> >> How does "this is a defcustom, by default off" communicate "you should use vc-print-log if you turn this
>> >> on"?
>> >
>> > Why are we suddenly talking about vc-print-log when discussing a much
>> > more general feature?
>> 
>> Because disabling pagination effectively breaks the shell command "git
>> log" and vc-print-log is one alternative to running "git log", and I
>> don't know how else the user would realize that.  (In my experience with
>> talking to users about this, they usually don't)
>
> A doc string of a general option is not the proper place for talking
> about some very specific case when that option is used.  If the main
> problem is vc-print-log, we should find another way of dealing with
> it.

OK, how about this doc string?

  "If non-nil, the program to use for 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 limits the amount of output produced and
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\".

The interactive browsing aspects of pagination are not needed, and get
in the way, when the output of the program is directed to an Emacs
buffer, so in those cases pagination might need to be disabled.
Disabling pagination means that some programs will produce large
amounts of output, but most such programs have other ways to limit
their output, such as additional arguments or Emacs interfaces.
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."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Wed, 17 May 2023 11:33:01 GMT) Full text and rfc822 format available.

Message #86 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Wed, 17 May 2023 14:32:12 +0300
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Cc: sbaugh <at> catern.com,  62958 <at> debbugs.gnu.org
> Date: Tue, 16 May 2023 15:49:21 -0400
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> OK, how about this doc string?
> 
>   "If non-nil, the program to use for 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 limits the amount of output produced and
> 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\".
> 
> The interactive browsing aspects of pagination are not needed, and get
> in the way, when the output of the program is directed to an Emacs
> buffer, so in those cases pagination might need to be disabled.
> Disabling pagination means that some programs will produce large
> amounts of output, but most such programs have other ways to limit
> their output, such as additional arguments or Emacs interfaces.
> 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."

SGTM, thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Wed, 17 May 2023 14:56:02 GMT) Full text and rfc822 format available.

Message #89 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Wed, 17 May 2023 10:55:16 -0400
[Message part 1 (text/plain, inline)]
Updated patch.

[0001-Support-setting-PAGER-cat-in-comint.el-bug-62958.patch (text/x-patch, inline)]
From 94db0faf148960eeace9279fea9e173b1d1ea516 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh <at> janestreet.com>
Date: Wed, 19 Apr 2023 17:44:54 -0400
Subject: [PATCH] Support setting PAGER=cat in comint.el (bug#62958)

Paging can be undesirable in comint-derived commands such as
async-shell-command and M-x shell.  It is a frequent footgun for new
Emacs users when they try to run commands which start a pager in such
modes.

Simply adding (setenv "PAGER" "cat") globally is not correct, since
that will break modes like term, which support paging quite well.
It's only and exactly the comint-derived modes which don't need
paging.

* lisp/comint.el (comint-pager): Add. (bug#62958)
(comint-exec-1): Use comint-pager to set PAGER.
---
 lisp/comint.el | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/lisp/comint.el b/lisp/comint.el
index 682b555a33c..b956bd6f697 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -258,6 +258,35 @@ comint-input-ring-file-name
 		 file)
   :group 'comint)
 
+(defcustom comint-pager nil
+  "If non-nil, the program to use for 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 limits the amount of output produced and
+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\".
+
+The interactive browsing aspects of pagination are not needed, and get
+in the way, when the output of the program is directed to an Emacs
+buffer, so in those cases pagination might need to be disabled.
+Disabling pagination means that some programs will produce large
+amounts of output, but most such programs have other ways to limit
+their output, such as additional arguments or Emacs interfaces.
+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."
+  :version "30.1"
+  :type '(choice (const :tag "Use default PAGER" nil)
+                 (const :tag "Don't do paging (PAGER=cat)" "cat")
+                 (string :tag "Program name or absolute path of pager"))
+  :group 'comint)
+
 (defvar comint-input-ring-file-prefix nil
   "The prefix to skip when parsing the input ring file.
 This is useful in Zsh when the extended_history option is on.")
@@ -864,6 +893,10 @@ comint-exec-1
 	 (nconc
           (comint-term-environment)
 	  (list (format "INSIDE_EMACS=%s,comint" emacs-version))
+          (when comint-pager
+            (if (stringp comint-pager)
+                (list (format "PAGER=%s" comint-pager))
+              (error "comint-pager should be a string: %s" comint-pager)))
 	  process-environment))
 	(default-directory
 	  (if (file-accessible-directory-p default-directory)
-- 
2.30.2


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62958; Package emacs. (Fri, 19 May 2023 06:10:02 GMT) Full text and rfc822 format available.

Message #92 received at 62958 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Fri, 19 May 2023 09:09:54 +0300
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Cc: sbaugh <at> catern.com,  62958 <at> debbugs.gnu.org
> Date: Wed, 17 May 2023 10:55:16 -0400
> 
> Updated patch.

LGTM, thanks.




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Fri, 26 May 2023 11:32:01 GMT) Full text and rfc822 format available.

Notification sent to Spencer Baugh <sbaugh <at> janestreet.com>:
bug acknowledged by developer. (Fri, 26 May 2023 11:32:01 GMT) Full text and rfc822 format available.

Message #97 received at 62958-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: sbaugh <at> janestreet.com
Cc: sbaugh <at> catern.com, 62958-done <at> debbugs.gnu.org
Subject: Re: bug#62958: [PATCH] Set PAGER=cat in comint.el
Date: Fri, 26 May 2023 14:31:58 +0300
> Cc: sbaugh <at> catern.com, 62958 <at> debbugs.gnu.org
> Date: Fri, 19 May 2023 09:09:54 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> 
> > From: Spencer Baugh <sbaugh <at> janestreet.com>
> > Cc: sbaugh <at> catern.com,  62958 <at> debbugs.gnu.org
> > Date: Wed, 17 May 2023 10:55:16 -0400
> > 
> > Updated patch.
> 
> LGTM, thanks.

No further comment, so I've now installed this on the master branch,
and I'm therefore closing this bug.

Thanks.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 24 Jun 2023 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 305 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.