Skip to content
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

Feature request: drop down to just outputting, if dumb terminal #577

Open
epa opened this issue Oct 10, 2024 · 4 comments
Open

Feature request: drop down to just outputting, if dumb terminal #577

epa opened this issue Oct 10, 2024 · 4 comments

Comments

@epa
Copy link

epa commented Oct 10, 2024

less detects when it's running on a dumb terminal and prints a warning "terminal is not fully functional". That warning can be suppressed with the -d flag.

I would like a new option such that if running on a dumb terminal, less copies all its standard input to standard output and then exits. In other words there is no paging when running on a dumb terminal.

This is because I will sometimes run commands that invoke less (such as git help for example) in a terminal window, where I would like the output to be paged, but sometimes in an Emacs shell buffer, where it's better to just print and let Emacs handle the details of scrolling. Of course, I could set the PAGER environment variable differently in those two places, but it would be smoother if less could auto-detect, and get out of the way when it's not required. It already knows whether running on a dumb terminal, so I hope this would not be hard to do.

@avih
Copy link
Contributor

avih commented Oct 10, 2024

I think less is still functional as a pager even in a dumb terminal. Why take that away just because you have a use case where you don't need a pager, but use less anyway, but want less to not be a pager by a condition which happens to be true in your use case - where less detects a dumb terminal? That doesn't make sense to me.

If you don't need a pager in some use cases, just set PAGER=cat .

@epa
Copy link
Author

epa commented Oct 10, 2024

Thanks for looking at this. I agree, on a true dumb terminal (like a teletype or something) you could still want a pager. I am not by any means suggesting to turn off paging by default on dumb terminals! But I think it could be useful as an option.

In this case, the "terminal" provided by Emacs shell-mode is very limited, not supporting any cursor movement commands and the like, but it does provide its own support for pagination and scrolling, provided by the Emacs environment it lives in. So that's the particular kind of dumb terminal where I'd want to just print the text. Note that it's still a tty, because it still accepts user input and interactive commands. I imagine that other development environments where there's the ability to run interactive sub-processes might have a similar requirement.

(I would suggest that in the year 2024 a genuine "dumb terminal" is only found in museums, and if less detects such a thing, it's not caused by limited hardware but because it's running under some kind of environment which captures and displays output in a window. So it's not completely daft to argue that dumb terminals might be treated differently today to how they were decades ago. Nonetheless, this feature request does not ask to change the default behaviour.)

Yes, I could do without the pager altogether or set it to cat. Or set up a wrapper script that checks whether running inside Emacs. I thought, however, that it might be simpler to have less handle it automatically, since it already has the code to detect a dumb terminal. It's a somewhat specialized use case, I guess, but equally I don't think it is a difficult feature for less to implement. I'm happy to hack up a pull request if you'd like.

@avih
Copy link
Contributor

avih commented Oct 10, 2024

I don't think it is a difficult feature for less to implement

I'd guess it might be trivial to implement, but I think it would be equally trivial to write a wrapper script which uses cat instead of less if invoked inside emacs.

I just don't think it belongs in less.

That being said, I don't own less, so my opinion is only an opinion. @gwsw has the final word.

@gwsw
Copy link
Owner

gwsw commented Oct 12, 2024

I tend to agree with avih that this functionality doesn't belong in less. I agree that a true dumb terminal is unlikely to be encountered today, although just a few months ago @fstark opened PR #505 regarding behavior on an ADM-5 terminal, so apparently they are not completely nonexistent. More commonly, there could be terminal-like environments that don't provide cursor addressing. Emacs itself is one of them, and while it offers its own paging, other similar environments might not. If a user were to commonly use both emacs and some other environment that didn't support cursor addressing but also did not support paging, a flag to disable paging in less when the terminal is dumb would not help them. It seems to me that what's really needed is a way to avoid using less specifically in an emacs shell buffer (or any other environment which does not support cursor addressing but does support paging). Setting PAGER or using a wrapper based on the environment seems a better solution to me.

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

No branches or pull requests

3 participants