Skip to content

gh-65824: Improve help() when MANPAGER and PAGER variables are not set #21520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

ZackerySpytz
Copy link
Contributor

@ZackerySpytz ZackerySpytz commented Jul 17, 2020

Display "(q to quit)" when using help(). Use the --quit-at-eof
option to make less quit if enter is pressed on the last line.

https://bugs.python.org/issue21625

Display "(q to quit)" when using help().  Use the --quit-at-eof
option to make less quit if enter is pressed on the last line.
@@ -1574,7 +1574,8 @@ def getpager():
if sys.platform == 'win32':
return lambda text: tempfilepager(plain(text), 'more <')
if hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0:
return lambda text: pipepager(text, 'less')
cmd = 'less "-P?e(END) .(q to quit)" --quit-at-eof'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do also considering adding the -X and -F (latter is the same as --quit-if-one-screen) flags.

From the less documentation,

-X causes less to not clear screen upon quit

-X or --no-init

Disables sending the termcap initialization and deinitialization strings to the terminal. This is sometimes desirable if the deinitialization string does something unnecessary, like clearing the screen.

and with -F, it quits if the help fits in one screen

-F or --quit-if-one-screen

Causes less to automatically exit if the entire file can be displayed on the first screen.
Suggested change
cmd = 'less "-P?e(END) .(q to quit)" --quit-at-eof'
cmd = 'less "-P?e(END) .(q to quit)" -X --quit-if-one-screen --quit-at-eof'

@@ -0,0 +1,2 @@
When the ``MANPAGER`` and ``PAGER`` environment variables are not set,
interactive :func:`help` now quits if enter is pressed on the last line.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add info about "(q to quit)" message on the status line?

@erlend-aasland erlend-aasland changed the title bpo-21625: Improve help() when MANPAGER and PAGER variables are not set gh-65824: Improve help() when MANPAGER and PAGER variables are not set Jan 5, 2024
@serhiy-storchaka
Copy link
Member

See also #116050.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants