[Openmcl-devel] External Programs and Piping

R. Matthew Emerson rme at clozure.com
Thu Jan 1 15:33:16 PST 2015


> On Jan 1, 2015, at 12:46 PM, Steven Núñez <steven.nunez at inference.sg> wrote:
> 
> Hi Ron,
>  
> Thanks. That does look like it will work, but it’s a little more machinery that I want to put in place for a man page viewer. It’s interesting that this topic hasn’t come up before because it seems like something that would be very useful. Essentially I want a help system that will display man pages from the REPL, e.g. (help ‘defun) and then have the man page displayed. Simply, yet surprisingly difficult to do.
>  
> The challenge in both cases (opening Preview or displaying in the REPL terminal) appears to be piping. In the REPL case, man would be piping to the value of PAGER, which might not be set in the environment, which leads me back to piping output of man to less. Unfortunately examples of piping are few, and documentation even rarer.
>  
> Anyone got a formula for taking the output of ‘man’, sending it to ‘less’ and displaying it on the terminal that the REPL is running in?

The usual trick in cases like this is to punt the pipe plumbing to sh:

(run-program "sh" (list "-c" "man -t ls | open -f -a Preview"))

(run-program "sh" (list "-c" "man -P cat ls | colcrt") :output *standard-output*)

I'm not sure you can make a pager work easily.  I haven't really thought about it, though.  There might be a way to do it by using *terminal-io* for some combination of :input, :output, and :error, but it would probably be easier to capture the output in a string stream and page it yourself.






>  
> -          SteveN
>  
>  
> From: Ron Garret [mailto:ron at flownet.com] 
> Sent: Wednesday, 31 December 2014 16:46
> To: Steven Núñez
> Cc: openmcl-devel at clozure.com
> Subject: Re: [Openmcl-devel] External Programs and Piping
>  
> Try using bashlink, which is part of ergolib:
>  
> https://github.com/rongarret/ergolib
>  
> (bash "man -t ls | open -f -a /Applications/Preview.app/“)
>  
> works for me, as does:
>  
> (join (bash “man ls”) #\newline)
>  
> at least when you run CCL at the command prompt.  It doesn’t work in the IDE, probably because the output of MAN has some funky embedded TTY controls in it that the IDE doesn’t know how to deal with.
>  
> rg
>  
> On Dec 31, 2014, at 4:13 PM, Steven Núñez <steven.nunez at inference.sg> wrote:
> 
> 
> Greeting everyone,
>  
> I’m trying to implement a system that will display manpages to the user from the REPL. There’s a neat trick to convince Preview to do this here:
>  
>               http://www.devopsderek.com/blog/2013/03/10/view-man-pages-with-preview-on-mac-os-x/
>  
> But I can’t seem to hit upon the right incantation to make this work from the CCL REPL. As a work-around / substitute I tried:
>  
>               (run-program "/usr/bin/man" '("ls") :output *standard-output*)
>  
> Which put the text of the man page in the REPL’s terminal windows, but the manpage formatting is lost and it comes out as one big string of text. Efforts to pipe it to /usr/bin/less have failed. Seem piping, if working, isn’t obvious.
>  
> Does anyone have any ideas?
>  
> Happy New Year,
>  
> -          SteveN
>  
>  
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> https://lists.clozure.com/mailman/listinfo/openmcl-devel
>  
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> https://lists.clozure.com/mailman/listinfo/openmcl-devel




More information about the Openmcl-devel mailing list