[Surfraw-devel] user elvi directory?

Sumant Oemrawsingh soemraws at xs4all.nl
Thu Oct 8 23:19:03 UTC 2009


Hi James,

Thanks for the patch. I was actually already there; the surfraw code is not
difficult to read and quite straightforward, so it didn't take me more than a
minute to get it working. But since you posted this patch, I'll use it
instead. Especially since you have nicely separated out local and global elvi
in the elvi list, which I didn't do in my version.

Can you (i.e. are you allowed to) push this back to the main branch, or will a
developer do this (could someone maybe respond to this thread?)? I think it's
definately worth it, since aside from being able to test elvi with the normal
distro-packaged/managed surfraw, there are some search engines I would like to
add and use, but that don't make sense in surfraw itself (e.g. for internal
websites). I can hardly believe we are the only ones who would find it useful.
So it would be nice to see some confirmation of this from developers. Surfraw
is an awesome tool if you spend most of your computing needs in an rxvtc and
quickly need to look up something. I hope the developers find this patch
useful and will include it.

I also had an idea of expanding some elvi to also dump the html as parsed by
lynx or so, to the screen; great for wikipedia articles! No need even for
opening and running a browser, but read the article in the comfort of the pager
of your choice. I'm not sure, though, if this fits in the current way that
surfraw is laid out, or if it would be better to use surfraw to print the url
and have another surfraw-like collection of scripts to do the retrieving and
dumping. Anyway, this is something to be discussed in another thread, if at
all. I'll look into it a bit more and will post a new message here when I have
it figured out.

Thanks,
Sumant

On Wed, Oct 07, 2009 at 01:34:14AM +0100, James Rowe wrote:
> [This time to the list, sorry Sumant.]
> 
> * Sumant Oemrawsingh (soemraws at xs4all.nl) wrote:
> > Since you support the idea of adding a ~/.elvi directory, I'd like to patch
> > surfraw and surfraw-update-path. So what's the approach I should take here? Do
> > I submit a patch to this list, or can I git push?
> 
>   I support the idea, but I'm just another user so my opinions on
> patching are of little value ;)  That being said...
> 
>   I've attached a patch which implements per-user elvi in ~/.surfraw.d,
> as I had a spare few minutes and I'm familiar with the code.  It updates
> the main script and also the bash completion, it doesn't change
> surfraw-update-path as I don't have a system I could test that on.
> 
> Thanks,
> 
> James
> 

> From ec4faafb75bdbacd66bd2e2950bdf962c22b5738 Mon Sep 17 00:00:00 2001
> From: James Rowe <jnrowe at gmail.com>
> Date: Wed, 7 Oct 2009 00:52:28 +0100
> Subject: [PATCH] Support per-user elvi in ~/.surfraw.d.
> 
> Based on the idea by Sumant Oemrawsingh.
> ---
>  surfraw-bash-completion.IN |    3 ++-
>  surfraw.1.IN               |    3 +++
>  surfraw.IN                 |   13 +++++++++++--
>  3 files changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/surfraw-bash-completion.IN b/surfraw-bash-completion.IN
> index 866d87f..d5d1374 100644
> --- a/surfraw-bash-completion.IN
> +++ b/surfraw-bash-completion.IN
> @@ -11,7 +11,8 @@ _surfraw()
>  	local opts='-browser -elvi -escape-url-args -graphical \
>  		-help -q -quote -quiet -text -version'
>  	local elvi="$(cut -f1 @sysconfdir@/surfraw.bookmarks ~/.surfraw.bookmarks 2>&-
> -			cd @ELVIDIR@ && echo * 2>&-)"
> +			cd @ELVIDIR@ && echo * 2>&-
> +			[ -d ~/.surfraw.d ] && cd ~/.surfraw.d && echo * 2>&-)"
>  	if      [[ $cur == -* ]]
>  	then    COMPREPLY=( $( compgen -W "$opts" -- $cur ) )
>  	# I can't see a way to get the =yes/=no parts to work...
> diff --git a/surfraw.1.IN b/surfraw.1.IN
> index 8c2cb31..680aeec 100644
> --- a/surfraw.1.IN
> +++ b/surfraw.1.IN
> @@ -309,6 +309,9 @@ Default:
>  .B @ELVIDIR@
>  Location of the elvi.
>  
> +.TP
> +.B ${HOME}/.surfraw.d/
> +Per\(hyuser elvi.
>  
>  .TP
>  .B @sysconfdir@/surfraw.conf
> diff --git a/surfraw.IN b/surfraw.IN
> index 880d3e0..22f870c 100644
> --- a/surfraw.IN
> +++ b/surfraw.IN
> @@ -250,7 +250,13 @@ w3_parse_option () {
>      w3_parse_option_hook "$opt" "$optarg" && return 0
>      case "$opt" in
>  	-browser=*)	    setopt   SURFRAW_browser		$optarg	;;
> -	-elvi)		    sed -n 's/^.*elvis: \(.*\)$/\1/p' $elvidir/*; exit 0            ;;
> +	-elvi)		    echo "Global elvi:"
> +			    sed -n 's/^.*elvis: \(.*\)$/  \1/p' $elvidir/*
> +			    if [ -d ~/.surfraw.d ]; then
> +				echo "Local elvi:"
> +				sed -n 's/^.*elvis: \(.*\)$/  \1/p' ~/.surfraw.d/*
> +			    fi
> +			    exit 0 ;;
>  	-escape-url-args=*) setoptyn SURFRAW_escape_url_args	$optarg ;;
>  	-g | -graphical)    setoptyn SURFRAW_graphical		yes	;;
>  	-help | --help)     do_help=1					;;
> @@ -414,7 +420,10 @@ then
>  		surfraw_usage
>  		exit 0
>  	else
> -		if [ -x "$elvidir/$elvi" ]
> +		if [ -x ~/.surfraw.d/$elvi ]
> +		then
> +			sh -c "~/.surfraw.d/$elvi $opts $searchterms"
> +		elif [ -x "$elvidir/$elvi" ]
>  		then
>   			sh -c "$elvidir/$elvi $opts $searchterms"
>  		else
> -- 
> 1.6.4.4
> 




> _______________________________________________
> Surfraw-devel mailing list
> Surfraw-devel at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/surfraw-devel


-- 
Sumant S. R. Oemrawsingh
soemraws at xs4all.nl



More information about the Surfraw-devel mailing list