DaemonForums  

Go Back   DaemonForums > FreeBSD > FreeBSD General

FreeBSD General Other questions regarding FreeBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 23rd October 2011
OS_Stuntman OS_Stuntman is offline
New User
 
Join Date: Oct 2011
Posts: 4
Default How do I pipe a man page into emacs for searches?

Hello,

How do I pipe a man page into emacs for searching, or how do I make grep mimic an html anchor?
Reply With Quote
  #2   (View Single Post)  
Old 23rd October 2011
Oko's Avatar
Oko Oko is offline
Rc.conf Instructor
 
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 1,102
Default

Quote:
Originally Posted by OS_Stuntman View Post
Hello,

How do I pipe a man page into emacs for searching, or how do I make grep mimic an html anchor?
Why would you pipe man pages into an editor if you just need to search? You can do something like this to search through the man pages of let say cat command.

Code:
man cat|less
Reply With Quote
  #3   (View Single Post)  
Old 23rd October 2011
jb_daefo jb_daefo is offline
Spam Deminer
 
Join Date: May 2008
Posts: 303
Default

Quote:
Originally Posted by OS_Stuntman View Post
Hello,

How do I pipe a man page into emacs for searching, or how do I make grep mimic an html anchor?
I'm not familiar with either of those two methodologies, but I set PAGER to
Code:
/usr/ports/sysutils/lookat
because of its "s key" dialogs as well as other keybindings seem to work better from this perspective at least. Edit: forgot to explain HOW to set pager: in one's shell rc file this may work (not a usually seen construct...)
Code:
 alias man='env PAGER=lookat man $1'
__________________
FreeBSD 13-STABLE

Last edited by jb_daefo; 24th October 2011 at 03:31 AM. Reason: Forgot the howto
Reply With Quote
  #4   (View Single Post)  
Old 24th October 2011
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Tcpdump Spy
 
Join Date: Apr 2008
Location: Netherlands
Posts: 2,243
Default

To expand on the previous answers:

From man(1)

Code:
     -P pager
             Use specified pager.  Defaults to “less -sR” if color support is
             enabled, or “more -s”.  Overrides the MANPAGER environment vari‐
             able, which in turn overrides the PAGER environment variable.
Using % man cat | less is exactly the same as just using % man cat.

As for searching, you can either use the / key in less, or use % man ls | egrep pattern

Both methods support regular expressions are are basically the same, the (e)grep method is more suited for commandline/scripted use, while the interactive search in less is for interactive use.
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.

Last edited by Carpetsmoker; 24th October 2011 at 09:44 AM.
Reply With Quote
  #5   (View Single Post)  
Old 24th October 2011
Oko's Avatar
Oko Oko is offline
Rc.conf Instructor
 
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 1,102
Default

Quote:
Originally Posted by Carpetsmoker View Post
To expand on the previous answers:

From man(1)

Code:
     -P pager
             Use specified pager.  Defaults to “less -sR” if color support is
             enabled, or “more -s”.  Overrides the MANPAGER environment vari‐
             able, which in turn overrides the PAGER environment variable.
Using % man cat | less is exactly the same as just using % man less.
I must be missing something here. Could you please explain above. On my (arguably OpenBSD desktop)

% man cat | less

piples man pages for command cat into less thereby allowing regular expression search vi style.
% man less
Just gives me man pages for command less.

You seem to claim that those two are the same. Could you please explain?
Reply With Quote
  #6   (View Single Post)  
Old 24th October 2011
jb_daefo jb_daefo is offline
Spam Deminer
 
Join Date: May 2008
Posts: 303
Default

[FWIW I edited my post above to explain precisely how, it was less than useful originally as written.] Sorry for the oversight.
__________________
FreeBSD 13-STABLE
Reply With Quote
  #7   (View Single Post)  
Old 24th October 2011
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Tcpdump Spy
 
Join Date: Apr 2008
Location: Netherlands
Posts: 2,243
Default

Quote:
Originally Posted by Oko View Post
I must be missing something here. Could you please explain above. On my (arguably OpenBSD desktop)

% man cat | less

piples man pages for command cat into less thereby allowing regular expression search vi style.
% man less
Just gives me man pages for command less.

You seem to claim that those two are the same. Could you please explain?
I'm sorry, I said it wrong. I corrected the original post. What I meant was:

Using % man cat | less is exactly the same as just using % man cat.
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #8   (View Single Post)  
Old 24th October 2011
Oko's Avatar
Oko Oko is offline
Rc.conf Instructor
 
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 1,102
Default

Quote:
Originally Posted by Carpetsmoker View Post
I'm sorry, I said it wrong. I corrected the original post. What I meant was:

Using % man cat | less is exactly the same as just using % man cat.
Pager does indeed works on OpenBSD. But search / doesn't work properly
(it seems that I can input search word but it doesn't get highlighted) With
% man cat|less it does get highlighted. I just checked this on Devio server as I am typing this message from a Windows machine. Actually OpenBSD man command doesn't have switch -P but the pager is on by default.

Maybe I am missing something about highlighting in OpenBSD.
Reply With Quote
  #9   (View Single Post)  
Old 25th October 2011
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

My word you're all useless lol (no offense), I'm a VIM user and I know this.


If you want to read a manual page in emacs, use M-x man and it will prompt you for the name of the man page. It will then open a window with the manual page all nicely formatted for you. If you use emacs a lot, avoid leaving it for crap like manual pages.


If you really want to pipe it *into* emacs without running it through emacs, you will need an external program to simulate the effect of `man ls > tmp-file && emacs tmp-file && rm tmp-file`, because emacs is not really a UNIX program and like the original vi, not entirely friendly to being piped a file on stdin. You can find solutions on emacs wiki or Google.


less generally presents a vi style interface for navigation, or at least it responds to my muscle memory. So if someone is asking to use emacs, probably not going to want /wtf searches. Sometimes I even use vim just for a better known target. I don't know how man -P emacs works on OpenBSD but my Linux work station doesn't work with it either.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
Old 20th November 2011
OS_Stuntman OS_Stuntman is offline
New User
 
Join Date: Oct 2011
Posts: 4
Default

Work and things kept me away, but thanks for the replies.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pipe grep to copy files based on name. Daffy Programming 5 28th May 2011 11:03 PM
Improve searches maxrussell Feedback and Suggestions 3 19th June 2009 09:45 AM
Emacs nox11 unixbsd FreeBSD Ports and Packages 2 18th March 2009 02:17 PM
First time page / Start page bichumo General software and network 7 27th October 2008 10:40 PM
Emacs without X? clevershark FreeBSD Ports and Packages 3 21st May 2008 05:02 PM


All times are GMT. The time now is 09:12 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick