One thing I do a lot is select a region of text, then have it replaced with the output of a command.
The most common job is sorting a number of lines, such as "use XX:YY;" lines in perl scripts.
Finally having gotten annoyed enough about how clunky shell-command-on-region was I wrote my own lisp function:
Only after that did I discover M-x sort-lines. D'oh. Still I guess my solution is more general, and less difficult to use. (I find the use of the Emacs prefix troublesome to type; since you have to do it in advance - I almost always forget.)
I also learnt of M-x list-matching-lines yesterday. Thats a new discovery which really rocks. (I can use "^sub " to find a list of subroutines, etc.)
This could be improved, and fleshed out a lot if there were any interest.
But its neat as-is:#!/bin/sh # # Dump packages in the NEW queue. # # This could be improved, perhaps: # # --show-names --show-dates, etc. Or just show all info in a table. # wget --quiet -O- http://ftp-master.debian.org/new.html | \ perl -ne 'print $1 . "\n" if ( $_ =~ /^<td valign="top" class="sid">([^<]+)<\/td>$/ )'
I thought there was something similar in the devscripts package, or contained within debian-goodies but apparently not.
Tags: debian, emacs, new-queue 2 comments
Check out the documentation for the "interactive" form; it lets you tell Emacs how to prompt for arguments if you don't give them as a prefix: