Lets assume you just work in a console or in a some other X11 application. You just select something with a mouse and now you wish to search this in emacs. Of course it is very easy - Control/S, Enter, Paste, Enter. But is it nice and convenient? I don't think so.
If you insert the following code fragment in your .emacs file, you can select
(
Read more... )
Comments 3
Reply
Reply
(global-set-key [f1] '(lambda(beg end)
(interactive "r")
(setq cmd (read-from-minibuffer "Shell command: "))
(shell-command-on-region beg end cmd nil t)
))
Now when you select region in emacs and press F1, you are prompted for a shell command. Then the command is executed with the selected region as stdin and stdout/stderr of the command replaces the selection.
Reply
Leave a comment