Escape Meta Alt from Word
Escape from Microsoft Word by Edward Mendelson is an interesting short post about writing in Microsoft Word compared to that old classic WordPerfect:
Intelligent writers can produce intelligent prose using almost any instrument, but the medium in which they write will always have some more or less subtle effect on their prose. Karl Popper famously denounced Platonic politics, and the resulting fantasies of a closed, unchanging society, in his book The Open Society and Its Enemies (1945). When I work in Word, for all its luxuriant menus and dazzling prowess, I can’t escape a faint sense of having entered a closed, rule-bound society. When I write in WordPerfect, with all its scruffy, low-tech simplicity, the world seems more open, a place where endings can’t be predicted, where freedom might be real.
But of course if the question is “Word or WordPerfect?” the answer is: Emacs. Everything is text.
Prettifying R in Emacs
Emacs 24.4 has a new feature: prettify-symbols-mode
. Bozhidar Batsov wrote about it and I’ve seen other mentions of it in discussions of what’s coming when this new version is released. It’s not out yet, but I decided to stop waiting and compile from source so I can run the latest development version because there was something I wanted to do.
I use R a lot, and I use Emacs to edit it with ESS mode. In R I’m a great user of Hadley Wickham’s dplyr package (the vignette has examples that show its power), and so I spend a lot of time writing %>%
(“x %>% f(y) turns into f(x, y)” says the docs).
As great as dplyr is, I thought its %>%
wasn’t very eyepleasing, so I made Emacs show me the pipe symbol | when actually the R operator is there. On top of that, the built-in prettifying already takes care of turning <-
into ←
(Unicode LEFTWARDS ARROW).
So when I write this:
usage <- read.csv("refworks-usage.csv")
usage <- tbl_df(usage)
## Which accounts have logged in the most?
usage %>% select(user_id, name, number_of_logins) %>% arrange(desc(number_of_logins))
What I see is:
usage ← read.csv("refworks-usage.csv")
usage ← tbl_df(usage)
## Which accounts have logged in the most?
usage | select(user_id, name, number_of_logins) | arrange(desc(number_of_logins))
I think that’s much nicer. It shows a lot better in a screenshot:
Beautiful!
It also works in the interactive mode, at an R session with a REPL, and does the prettifying on the fly there. Copying and pasting from one to the other works perfectly because what’s copied and executed is different from what I see.
How I got it working
As I said, this requires Emacs 24.4, which will be released soon, so you can wait for that or compile from source. Xah Lee’s How to build Emacs from git Repository and How to build Emacs on Linux are helpful; all I had to do to prepare to get it to compile was add a few missing packages with sudo install libgtk-3-dev libxpm-dev libgif-dev
.
With that done, I was now running 25.0.50.1 (they’re moving from 24.4 to 25), and I added this to ~/.emacs.d/init.el
in my Emacs config:
(when (boundp 'global-prettify-symbols-mode)
(add-hook 'ess-mode-hook
(lambda ()
(push '("%>%" . ?|) prettify-symbols-alist)
))
(add-hook 'inferior-ess-mode-hook
(lambda ()
(push '("%>%" . ?|) prettify-symbols-alist)
))
(global-prettify-symbols-mode +1))
Except it doesn’t actually look like that, it looks like this, with lambda
(an anonymous function) replaced by λ
:
(when (boundp 'global-prettify-symbols-mode)
(add-hook 'ess-mode-hook
(λ ()
(push '("%>%" . ?|) prettify-symbols-alist)
))
(add-hook 'inferior-ess-mode-hook
(λ ()
(push '("%>%" . ?|) prettify-symbols-alist)
))
(global-prettify-symbols-mode +1))
CO₂ sparklines
I updated my jekyll-co2 plugin (first written about here) that shows the change in atmospheric CO₂ at the Mauna Loa observatory in Hawaii. It used to just show three years of data as numbers, but now it shows 20 years in a little text (Unicode) sparkline. In text, it’s this: ▁▁▂▂▂▂▃▃▃▄▄▄▅▅▅▅▆▆▆▇▇.
Graphically, it’s this:
If you hover over a year it shows the exact number in a tooltip. The preventable but unstopping increase is what I want to show, though, and in plain (Unicode) text I think that comes across even without obvious numbers.
I got the mechanism from a nice hack in this gist. I’d like to do more years in a prettier sparkline, but that would require some outside graphical library, and I don’t feel like getting into that right now.
Lehman Libraries
This summer I spied and acquired a copy of The Foolish Gentlewoman by Margery Sharp, who also wrote Cluny Brown and The Rescuers and sequels (none of which I’ve read). It’s the 1948 Canadian edition, published by Wm. Collins Sons & Co., Canada, at 70 Bond Street in Toronto (the Collins in HarperCollins).
What caught my eye was this, on the front endpapers:
I suppose Lehman Libraries was a private subscription library, but I’ve never heard of it and a quick search online didn’t turn anything up. If anyone knows anything about it I’d be happy to hear.
Michael Collins on The Great Eastern
I’ve written about The Great Eastern a couple of times: once in April, when I had just started to listen to all the episodes for the fifth or sixth time, and then briefly in August with a quote about libraries. I finished listening to it all last month. It’s still a masterpiece, one of the finest radio comedies and one of the richest and deepest works of radio fiction ever.
Michael Collins has been writing long pieces about it on his web site and they are mandatory reading if you know the show at all:
- The Great Eastern’s 20th Anniversary: Introduction
- “‘How’s She Goin’, B’y?’ No More”: Season 1, Episode 5 of The Great Eastern, which discusses the early episode where Paul covers the death of sub-monoist Hugh Kuva and the controversial “Writing Through Region” conference.
- “The folly of Newfoundland’s grand colonial experiment”: The Great Eastern’s Oougubomba Saga (Season 4, Episodes 11, 13, and 14), about the stunning three Oougubomba episodes.
Mack Furlong, who played host Paul Moth, won a John Drainie award recently. He was impeccable on the show.
Augustus
A few people recommended Stoner by John Williams to me, and they were right. It’s a gem.
I was in Book City tonight and the clerk was selling a customer on Stoner for a book club. Browsing the new release tables with Williams on my mind I saw a similar new edition from New York Review Books of Augustus, which is about that Augustus.
The first line is a doozy:
… I was with him at Actium, when the sword struck fire from metal, and the blood of soldiers was awash on deck and stained the blue Ionian Sea, and the javelin whistled in the air, and the burning hulls hissed upon the water, and the day was loud with the screams of men whose flesh roasted in the armor they could not fling off; and earlier I was with him at Mutina, where that same Marcus Antonius overran our camp and the sword was thrust into the empty bed where Caesar Augustus had lain, and where we persevered and earned the first power that was to give us the world; and at Philippi, where he traveled so ill he could not stand and yet made himself to be carried among his troops in a litter, and came near death again by the murderer of his father, and where he fought until the murderers of the mortal Julius, who became a god, were destroyed by their own hands.
Moodie's Tale
Somebody said we need a Moo for libraries. We still do. But I just read Moodie’s Tale by Eric Wright and I think it’s the Moo of Canadian academia. I don’t know Susanna Moodie or The Canterbury Tales so I think I’m missing a fair bit, but I still enjoyed it very much.
There are a few mentions of libraries, like this:
“Here’s an example,” the president continued. “I propose that henceforth you fellows be called ‘deans.’ Most places have deans nowadays. Sound the others out to see if there’s a problem. Now what else? What else does a college have? A proper college.”
“A library?”
“We’ve got one of sorts, haven’t we? In the corner room of the Drug Mart.”
“Just a few shelves, Gravely. Not many of the faculty know about it. It ought to have some standard reference works. Encyclopedias, that kind of thing.”
“We can afford a couple of thousand from the cleaning budget. Draw up a list. But now you’ve mentioned it, what is the real mark of a library?”
“Other than books?”
“Yes. What else?”
“A copying machine?”
“What else?”
It was important to guess right. Cunningham was getting impatient. “I am not sure of your emphasis, Gravely,” he hedged.
“Emphasis? How do you know it is a library?”
“The sign on the door?”
“Exactly. The label, William, the label. Get a sign made. And what do people find inside the door?”
“The librarian?”
“Now you’re on to it. Apart from the sign, the cheapest thing in the library is the librarian, especially since they aren’t unionized. We could put anyone in and call him the librarian. Now who have we got?”
“Beckett?”
Beckett was a religious maniac, a clerk in the maintenance department who spent his hours walking the streets with a billboard, warning of the end. His fellow workers complained constantly of his proselytizing in the storeroom.
“Perfect. He’s a bit more eccentric than most librarians, I suppose, but he’ll do. Is he conscientious?”
“It’s the other thing his colleagues dislike about him.”
“Done, then.”
Anonymous August Wikipedia edits from the House of Commons
Since August is done I was curious to see what anonymous edits had been made last month from House of Commons IPs, following on from Anonymous July Wikipedia edits from the House of Commons. It seemed from what I saw on @gccaedits that there was less going on, and indeed there was: only 18 English edits and two French. (I didn’t run through all the others.)
I did it a little differently this time, because I’d read about a simpler R library for handling JSON, jsonlite, and wanted to try it out. For fun I did it all in Org mode, which worked very well.
(I can’t highlight this snippet nicely because Org isn’t one of the languages supported by Pygments, the thing that does the fancy syntax highlighting here. So I will include screenshots!)
I have this in an Org file:
#+NAME: get-edits
#+BEGIN_SRC R :session :colnames yes
library(jsonlite)
t <- fromJSON("https://en.wikipedia.org/w/api.php?action=query&list=usercontribs&ucuserprefix=192.197.82&ucstart=2014-08-01T00:00:00Z&ucend=2014-08-31T23:59:59Z&ucdir=newer&uclimit=500&ucprop=title|timestamp|ids|sizediff&format=json")
edits <- t$query$usercontribs
edits
#+END_SRC
It’s a very simple bit of R that runs when I hit C-c C-c:
- use the
jsonlite
library - download all August anonymous Wikipedia edits made from House of Commons IPs, ingest it and turn it into a data frame
- pick out the bit I’m interested in
- show it (as a table, with column names)
It looks like this in Emacs:
![Screenshot of Org mode](/images/20140902-edits-01-700.png)
I can write another bit of code, this time in Ruby, to read in data from that table and do something with it! I just hit C-c C-c on the Ruby and it generates the output below.
#+NAME: make-links
#+BEGIN_SRC ruby :var edits=get-edits :results output
edits.each do |i|
puts %Q(<a href="https://en.wikipedia.org/w/index.php?pageid=#{i[2]}&oldid=#{i[3]}&diff=prev">#{i[6]}</a>)
end
#+END_SRC
#+RESULTS: make-links
#+begin_example
* [List of Manitoba senators](https://en.wikipedia.org/w/index.php?pageid=2134040&oldid=619454519&diff=prev)
* [Nepean Point](https://en.wikipedia.org/w/index.php?pageid=14210460&oldid=620245661&diff=prev)
* [Costas Menegakis](https://en.wikipedia.org/w/index.php?pageid=31680994&oldid=621366430&diff=prev)
* [Peter Mansbridge](https://en.wikipedia.org/w/index.php?pageid=252543&oldid=622065451&diff=prev)
* [Stephen I of Hungary](https://en.wikipedia.org/w/index.php?pageid=29594&oldid=622065708&diff=prev)
* [Peter Mansbridge](https://en.wikipedia.org/w/index.php?pageid=252543&oldid=622066606&diff=prev)
* [Union Station (Toronto)](https://en.wikipedia.org/w/index.php?pageid=455632&oldid=619445767&diff=prev)
* [Union Station (Toronto)](https://en.wikipedia.org/w/index.php?pageid=455632&oldid=619456111&diff=prev)
* [Panda Game (Ottawa vs. Carleton)](https://en.wikipedia.org/w/index.php?pageid=42957962&oldid=619967585&diff=prev)
* [Thanh Hai Ngo](https://en.wikipedia.org/w/index.php?pageid=36946133&oldid=620135598&diff=prev)
* [Glen Murray (politician)](https://en.wikipedia.org/w/index.php?pageid=643449&oldid=620415644&diff=prev)
* [Bean](https://en.wikipedia.org/w/index.php?pageid=4487&oldid=621354440&diff=prev)
* [Timeline of the Euromaidan](https://en.wikipedia.org/w/index.php?pageid=41793795&oldid=621936488&diff=prev)
* [Party Whip (Canada)](https://en.wikipedia.org/w/index.php?pageid=4050285&oldid=622222552&diff=prev)
* [Voluntary Aid Detachment](https://en.wikipedia.org/w/index.php?pageid=4940035&oldid=622907822&diff=prev)
* [David Anderson (Saskatchewan politician)](https://en.wikipedia.org/w/index.php?pageid=383866&oldid=623206768&diff=prev)
* [Dave Van Kesteren](https://en.wikipedia.org/w/index.php?pageid=3502825&oldid=619967138&diff=prev)
* [Larry Miller (Canadian politician)](https://en.wikipedia.org/w/index.php?pageid=1415770&oldid=621915107&diff=prev)
#+end_example
I wanted the output to be understood as HTML, but I couldn’t get that working. In any case, it’s no big deal, because I can move to a URL and hit C-c C-o to open it in my browser, and I can just copy it here and add explanations of each edit.
From 192.197.82.153
- List of Manitoba senators: subtle wording change, possibly shrewd or sophist
- Nepean Point: update mention of Canadian Museum of History with its new name
- Costas Menegakis: change a fancy apostrophe to a plain one
- Peter Mansbridge: vandalism (change “Mansbridge is a Christian” to “Mansbridge is well known within the BDSM community”)
- Stephen I of Hungary: vandalism (add “Harper” to “Saint Steven”)
- Peter Mansbridge: vandalism (adding a spurious citation)
From 192.197.82.203
- Union Station (Toronto): update “Skydome” to “Rogers Centre”
- Union Station (Toronto): revert the edit that reverted that previous edit
- Panda Game (Ottawa vs. Carleton): good copy-editing
- Thanh Hai Ngo: awkward small self-promoting edit (I emailed him after this edit but haven’t had a reply)
- Glen Murray (politician): add uncited and misspelled details of undergraduate education
- Bean: vandalism (“And still today, they will make you fart like there is no tomorrow.”)
- Timeline of the Euromaidan: useful copy-editing
- Party Whip (Canada): update name of deputy chief whip
- Voluntary Aid Detachment: “added E.M. Delafied to list of famous VAD nurse”
- David Anderson (Saskatchewan politician): change photograph to moustacheless and presumably newer version of MP
- Dave Van Kesteren: major rewrites with new information, some self-promoting, but it’s an improvement
- Larry Miller (Canadian politician): happy news—changed “two grandchildren” to “three grandchildren”
The same odd mix of good and bad we saw before.
What about French Wikipedia? Only two there, each from a different IP than above. Strange.
From 192.197.82.155 (fr)
- Ève Péclet: rewrite entry for this Quebec NDP MP
From 192.197.82.205 (fr)
- Mathieu Ravignat: correct MP’s riding
The useful edits are great, but still with the vandalism! And who knows what edits are being done in named accounts. Twenty anonymous edits this month … I’m curious to see what happens when parliament is sitting.
(Updated 2014-09-03 08:34:27 -0400 to correct the Ruby snippet.)