Ad blocker interference detected!
Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers
Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.
|Scripts quick access edit this|
- Author: Stephen Farrell <firstname.lastname@example.org>
- Authors (fixes): Dave Pearson <email@example.com>, Matthew Hawkins <firstname.lastname@example.org>
- Version: 1.5
- License: GNU GPL 2 or later
- Downloads: services.jl, string2.jl
Send mouse selection to shell program.
Send mouse selection to shell program -- similar to "Services" in NeXTSTEP. The idea is as follows: Say you want to look up a word in your dictionary program, but the current application doesn't know about the dictionary. Normally, this would require putting the selection in the clipboard, locating and launching the dictionary application, pasting the selection into the dictionary (if you're using X, good luck that it's still in your PRIMARY selection!), and finally telling the dictionary application to look up the word. With NeXTSTEP services, the dictionary could add a global keybinding that would act on the current selection. So "Command-=" would send the current selection to Webster.app.
services.jl is not as elegant as the NeXT design since it requires the user to set up the bindings and hook up the wiring to get the selection to the desired application. Sometimes this is trivial, but sometimes it is not. In particular, the example I give assumes you have one of those handy netscape launcher scripts that check if netscape is running and uses -remote if necessary. If you don't, get it... here's something that looks appropriate: http://www.best.com/~lanning/released/ (on FreeBSD, it's /usr/ports/www/netscape-wrapper).
To add actions, call services-add. The first argument is the entry that will appear in the menu, the second is the format of the shell command. All instances of '#' will be replaced with the selection. The final (optional) argument is some code to run on the selection to clean it up before sending it to the shell. I've defined a sample function, services-clean-for-browser, which does basic URL encoding, but you can insert your own function or lambda.
put both waffle.jl and string2.jl in your load-path
(require 'services) (services-add "Google" "netscape 'http://www.google.com/search?q=#'" services-clean-url-query-escaping) (services-add "Google: I'm Feeling Lucky" "netscape 'http://www.google.com/search?q=#&sa=I%27m+Feeling+Lucky'" services-clean-url-query-escaping) (services-add "Netscape" "netscape '#'" services-clean-url) (services-add "Dictionary" "xterm -T 'dict: #' -e dict #") (services-add "Unix man" "xterm -T 'man: #' -e sh -c 'man #; read'")
NOTE: You must add some actions (as above) or else it won't do anything!
Of course you'll want a keybinding to activate services. I use C-M-SPC (bind-keys global-keymap "C-M-SPC" services) or else you can use the sawfish configuration GUI to set up the keybinding.
I've hacked up some string manipulation routines and use them as a separate library... I've included them inline in this package, but would be happy to contribute them to who/whatever is appropriate.