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

man page with colors #33

Closed
arkhan opened this issue Jul 31, 2019 · 18 comments
Closed

man page with colors #33

arkhan opened this issue Jul 31, 2019 · 18 comments

Comments

@arkhan
Copy link

arkhan commented Jul 31, 2019

Hello great job, I have this issue when man pages contains colors

PAGER=less man argv 

img-2019-07-30-194346

PAGER=eless man argv 

img-2019-07-30-194328

Thanks

@kaushalmodi
Copy link
Owner

What is your OS?

I am on GNU/Linux type system: RHEL 6.8 and the same man page show up fine in eless too:

image

@kaushalmodi
Copy link
Owner

Your screenshot looks similar to the one in an earlier issue: #27.

Based off the long debug in that thread, this was the solution: https://eless.scripter.co/#example-eless-config-in-bash [don't set PAGER to eless for man pages on OSX (I am assuming you have that OS)].

@arkhan
Copy link
Author

arkhan commented Jul 31, 2019

Hello @kaushalmodi, I am using archlinux and emacs 27

@kaushalmodi
Copy link
Owner

hmm.. even then, does PAGER=less man -P eless argv work for you (instead of PAGER=eless man argv)?

@kaushalmodi
Copy link
Owner

If that doesn't help, then please provide debug info using the -D switch as explained here: https://eless.scripter.co/#how-to-help-debug.

@arkhan
Copy link
Author

arkhan commented Jul 31, 2019

PAGER=less man -P eless argv

No, I get the same result

@arkhan
Copy link
Author

arkhan commented Jul 31, 2019

If that doesn't help, then please provide debug info using the -D switch as explained here: https://eless.scripter.co/#how-to-help-debug.

I have this:
img-2019-07-30-220656

@kaushalmodi
Copy link
Owner

I am seeing the same value of first_line_piped_data ..

km²~/temp/:> (setenv PAGER "eless -D"; man argv)                                                                                                                                             07/30 11:18pm
Eless Version v0.5
https://github.com/kaushalmodi/eless/tree/v0.5
DEBUG: Piped data file : /tmp/emacs-stdin-kmodi.p5p8VwX
DEBUG: --> Input from pipe/file
DEBUG:     Output to terminal -->
DEBUG: var : -D
DEBUG: Raw Args                       : -D
DEBUG: Emacs Args                     : -nw
DEBUG: Pipe Contents (up to 10 lines) : tclvars(n)                   Tcl Built-In Commands                  tclvars(n)



_______________________________________________________________________________________________________________________________________________________________________________________

NAME
       argc,  argv,  argv0, auto_path, env, errorCode, errorInfo, tcl_interactive, tcl_library, tcl_nonwordchars, tcl_patchLevel, tcl_pkgPath, tcl_platform, tcl_precision, tcl_rcFile-
       Name, tcl_traceCompile, tcl_traceEval, tcl_wordchars, tcl_version - Variables used by Tcl
_______________________________________________________________________________________________________________________________________________________________________________________
DEBUG: first_line_piped_data = tclvars(n)                   Tcl Built-In Commands                  tclvars(n)
DEBUG: Man Page = tclvars(n)
DEBUG: Eless Command : emacs_Q_view_mode                          -nw                          --eval '(progn
                                   (man "tclvars(n)")
                                   ;; Below workaround is only for emacs 24.5.x and older releases
                                   ;; where the man page takes some time to load.
                                   ;; 1-second delay before killing the *scratch* window
                                   ;; seems to be sufficient
                                   (when (version<= emacs-version "24.5.99")
                                      (sit-for 1))
                                   (delete-window))'
DEBUG: Args passed to emacs_Q_view_mode : -nw --eval (progn
                                   (man "tclvars(n)")
                                   ;; Below workaround is only for emacs 24.5.x and older releases
                                   ;; where the man page takes some time to load.
                                   ;; 1-second delay before killing the *scratch* window
                                   ;; seems to be sufficient
                                   (when (version<= emacs-version "24.5.99")
                                      (sit-for 1))
                                   (delete-window))

.. but you are getting "No man page or info manual detected."

So, let's try this.. what do you get when you run the below bash script (it's an excerpt of what I use in eless to detect if man command is called)?

#!/usr/bin/env bash
perl --version | grep 'perl.*version'

first_line_piped_data="tclvars(n)                   Tcl Built-In Commands                  tclvars(n)"
man_page=$(echo "${first_line_piped_data}" \
               | perl -ne '/^([A-Za-z0-9-_]+\([a-z0-9]+\))(?=\s+.*?\1$)/ and print $1' \
               | perl -pe 's/bash_builtins/builtins/i' \
               | perl -pe 's/xsel\(1x\)/xsel/i' \
               | perl -pe 's/^[A-Z0-9-_()]+$/\L$_/' \
               || true)
echo "Man page = ${man_page}"

The output I get is:

This is perl 5, version 22, subversion 0 (v5.22.0) built for x86_64-linux
Man page = tclvars(n)

@arkhan
Copy link
Author

arkhan commented Jul 31, 2019

@kaushalmodi, I get this:

This is perl 5, version 30, subversion 0 (v5.30.0) built for x86_64-linux-thread-multi
Man page = tclvars(n)

@kaushalmodi
Copy link
Owner

@arkhan

To what I said in my previous comment:

I am seeing the same value of first_line_piped_data

I see that your first_line_piped_data is wrapping around.. is that wrapping because of terminal width or does that line actually break with a newline?

@kaushalmodi
Copy link
Owner

kaushalmodi commented Jul 31, 2019

@arkhan Can you share the first 10 lines of your "piped data file" to a gist or ix.io or just paste it here in a code block while preserving all whitespaces and newlines .. the file path following:

DEBUG: Piped data file : ..

@kaushalmodi
Copy link
Owner

Also can you edit your copy of eless and add the below debug line after these lines:

eless/eless

Lines 553 to 558 in 0065c3b

man_page=$(echo "${first_line_piped_data}" \
| perl -ne '/^([A-Za-z0-9-_]+\([a-z0-9]+\))(?=\s+.*?\1$)/ and print $1' \
| perl -pe 's/bash_builtins/builtins/i' \
| perl -pe 's/xsel\(1x\)/xsel/i' \
| perl -pe 's/^[A-Z0-9-_()]+$/\L$_/' \
|| true)

.. add

debug "man_page = ${man_page}"

Run the same command with -D and this time, please paste the whole text output here between

```
```

instead of pasting the screenshot.

@kaushalmodi
Copy link
Owner

And finally, can you also paste the output of:

/usr/bin/env bash --version

Mine is:

GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)

@kaushalmodi
Copy link
Owner

I recently added few more debug commands to eless.

So please update your eless version to the HEAD of the master branch, and paste the output of your eless command with the -D switch within triple backquotes in this thread.

@arkhan
Copy link
Author

arkhan commented Aug 1, 2019

Update eless and now I get this:

img-2019-08-01-082946

img-2019-08-01-082903

Thanks

@kaushalmodi
Copy link
Owner

  1. Does evaluating (man "tclvars(n)") in an emacs -Q work for you [I just tested that and it works for me]? As you see in your screenshot, that's exactly what eless does.
  2. Do you want to try PAGER="eless -D" man grep? (and please paste the ascii text from the terminal instead of pasting the image; that would allow me to quickly copy/paste stuff from there if I need).

Also, what changed on your system? Earlier you got "No man page or info man detected", and now you get "Man page = tclvars(n)". There was no change with man page detection in the recent eless update.

@arkhan
Copy link
Author

arkhan commented Aug 1, 2019

Whit (man "tclvars(n)") get this
img-2019-08-01-085957

But PAGER="eless -D" man grep works
img-2019-08-01-090056

@kaushalmodi
Copy link
Owner

.. so it looks like you do not have tclvars in your MANPATH? Does a simple man tclvars (without eless) work for you?

If you try to view arbitrary man pages like:

  • PAGER="eless -D" man grep
  • PAGER="eless -D" man ls
  • PAGER="eless -D" man tclvars

and for tclvars, if eless is actually trying to do (man "tclvars(n)") and if that doesn't work, then the problem seems to be outside emacs and eless. What do you think?

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

No branches or pull requests

2 participants