Ex BibliothecaThe life and times of Zack Weinberg.
Saturday, 22 March 2003# 7:15 AMfun with emacs(goto-char (point-min)) (while (re-search-forward (concat "^\\w+\\s-+\\(\\w+\\)\\s-+\\([0-9]+\\)" \\s-+[0-9:]+\\s-+\\(\\w+\\s-+\\)?\\([0-9]+\\)") nil t) (let ((day (match-string 2)) (month (match-string 1)) (year (match-string 4))) (setq month (catch 'found (dotimes (i 12) (if (equal (elt months i) month) (throw 'found (format "%02d" (+ i 1))))) (error "Not a month: %s" month))) (when (= (length day) 1) (setq day (concat "0" day))) (replace-match (concat year "-" month "-" day) t t))) That's a global search and replace operation which turns strings
of the form "Fri Mar 21 23:12:33 CET 2003" into "2003-03-21". Or,
functionally speaking, it converts all the entries in a GNU change
log from the old datestamp format to the new one. It would be
easier to read if Emacs didn't use such a backslash-heavy regular
expression notation. The same construct in Perl's notation would
be politicsSeth has a nice chewy post on the subject of preaching to the choir, specifically, how hard it is to reach people about copyright, DRM, etc when they haven't already got a stake in the issue. This is also a problem I've noticed over in war-protest land. It is really hard to know if any of the political agitation going on has any impact whatsoever on people who didn't already care. And it's the people who didn't already care, the majority of American citizens who don't bother to vote, that any credible political movement has to reach. Unless of course the movement likes the status quo, but then you can hardly call it a movement. rambling on,Seth goes on to talk about how he sees it as a problem that the majority of computer users have neither the ability nor the desire to program. You might wonder, why would they want to? And I point at the above script fragment. I banged it out in fifteen minutes. If I'd tried to do what it does by hand, it would have taken me an hour of unpleasant, tedious effort and probably caused a bout of tendinitis. Further, having written that, it goes in my Emacs configuration and I never have to think about it again. That particular fragment is not of use to anyone but a GNU software maintainer. But I've seen "ordinary users" encounter very similar problems, and have to solve them by hand because the program couldn't be scripted — because scripting is just too complicated and scary to bother with, right? I saw someone number the pages of a 200-page yearbook by hand, clicking through the same five dialog boxes for every page, because he couldn't find any other way to do it. The point being, the utility, the entire point, of a computer is that it can be programmed, and the environments built on top of computer hardware are more useful in proportion to how programmable they are. Being able to script my text editor translates directly to me getting more stuff done and losing fewer sanity points doing it. The point most definitely not being that everyone should sit down right now and learn Emacs Lisp. It, and most other extant computer languages, are just, well, ugly: arcane and confusing and I don't blame people for not wanting to understand them. There is a level of intrinsic complexity involved, but if people are willing to go that far, the computer should come meet them there. (Not that I have any idea how to make it do that.) |