Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bart's urlglobber question



On Oct 3,  8:28am, Paul Lew wrote:
}
} Seems noglob does not handle the '&'

Of course not.  It's not a glob character, it's a statement separator.

} then how can I ever achieve the original goal of not supplying quotes
} when using w3m?

Did you see my url-magic-space posting?

    http://www.zsh.org/cgi-bin/mla/redirect?USERNUMBER=5319

Here's a slight variation on it:

---- 8< ---- snip ---- 8< ----
function url-quote-magic {
    local words back=0
    words=("${(@Q)${(q)=LBUFFER}}")
    [[ "$KEYS" != [[:space:]] ]] && back=1
    case "$words[-1]" in
    (*[\'\"]*) back=0;;
    (ftp://(|localhost)/(~|*([][?#*]|\(|\)))*)
	local left="${(qqM)${words[-1]}##ftp://(localhost|)}"
	local right="${${words[-1]}##ftp://(localhost|)}"
	right="${right/#\/~/~}"
	words[-1]="$left"'"${(f)^$(print -lr -- '"$right"')}"'
	((back)) && back=3;;
    (http(|s)|ftp):*) words[-1]="${(qq)words[-1]}" ;;
    esac
    LBUFFER="${(j: :)words}"
    ((CURSOR-=back))
    zle .self-insert
}
zle -N url-quote-magic
for key in ' ' '?' '&'; do bindkey "$key" url-quote-magic; done
---- 8< ---- snip ---- 8< ----

The above could use some improvement in for multi-line buffers; check the
value of BUFFERLINES and save and elide everything not on the current line
before manipulating $words, then restore it to the beginning of LBUFFER at
the end.  I don't have time to fiddle with that just now.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



Messages sorted by: Reverse Date, Date, Thread, Author