Prettify my Emacs symbols

Emacs Redux made me aware of a new nifty feature of Emacs 24.4 (the upcoming release; I am currently using one of the nightlies). Emacs 24.4 includes a new mode called prettify-symbols-mode, which replaces tokens within code with more compact symbols (typically unicode characters like λ).

I am using the mode to replace the “function” token in JavaScript — which is used all over the place, since it is the syntax to create functions, modules and closures — with the single character λ. This results in significantly more lightweight expressions:

    
initialize: λ() {
    this.listenTo(this, "planet:drag planet:dragvelocity", 
        λ() { this.elements(true); });
}

The mode is smart enough to only replace tokens (it doesn’t replace function within a string, e.g., var a = "This is a function"; will appear unmodified). To activate the mode, use (global-prettify-symbols-mode 1) in one of your init files, and add new symbols to the mode hooks:

(add-hook 'js2-mode-hook
            (lambda ()
              (push '("function" . ?λ) prettify-symbols-alist)))

Ever been annoyed with the Emacs bell? Aside from disabling it, you can make it slightly less annoying by using a visual error indicator in place of an audible bell. There’s a Visible Bell setting included by default, but I find it quite aesthetically displeasing (at least on my nightly Mac build). I like this snipped a lot better (from EmacsWiki):

 (defun my-terminal-visible-bell ()
   "A friendlier visual bell effect."
   (invert-face 'mode-line)
   (run-with-timer 0.1 nil 'invert-face 'mode-line))
 
 (setq visible-bell nil
       ring-bell-function 'my-terminal-visible-bell)

This snippet will flash your mode line instead.

Setting up a nice AucTeX environment on Mac OS X

Most people I know use TeXShop on Mac OS X. While it’s a pretty good TeX editor, I think Emacs is overall vastly superior. Of course, I’m rather biased since I already use Emacs for everything else… Perhaps this post will be useful to other Emacs-addicted astronomers.

In my setup, I use the AUCTeX package coupled with the Skim PDF viewer (if you’re not using Skim, download it, it’s brilliant!). One of the advantages of this combination is that Emacs and Skim can be kept in sync, like in the screenshot below.

Skim + Emacs/AUCTeX nirvana. Note that the current highlighted line in Skim corresponds to the cursor position in Emacs.
Skim + Emacs/AUCTeX nirvana. Note that the current highlighted line in Skim corresponds to the cursor position in Emacs.

I found it a bit difficult to set up the AUCTeX package with sensible defaults, so I’ll reproduce here my configuration in hopes that it will be useful to someone else.

The salient lines are the ones configuring latexmk and Skim. You should have latexmk installed if you are using the TeX Live distribution; Skim can be downloaded for free here. You can stick this script in your Emacs initialization file (see my dotemacs repository if you’d like to see my other Emacs configs). I shamelessly copied those lines from this Stack Overflow answer.

AstroTRENDS: Weasel words

Credit: Cliff

I added a bunch of new keywords to AstroTRENDS, mostly suggested by friends and people in the community who had read my Facebook post.

A thought I had yesterday is the following: has the astronomical literature become more speculative, and perhaps less committed to audacious claims, in recent times? It is difficult to test this hypothesis  by merely querying ADS for abstract keywords. It would certainly be better served by a natural-language processing analysis of the full text, although this is just my uninformed speculation.

A much simpler way is to search for the so-called “weasel words” (such a funny way of describing them from a non-native speaker POV!). Matthew Might (a CS professor from the University of Utah) has a really interesting article about the different abuses of language that are common among technical writers, and he created some automated tools for detecting them. It’s a great read. (There’s even an emacs minor mode called writegood based on his recommendations, which I will be testing for sure). Although I don’t necessarily agree with a strict adherence to all of his points, there are certainly some great pieces of advice there.

Taking his post as a reference, I added a new “weasel words” pseudo-keyword to AstroTRENDS. The “weasel words” keyword shows the result of an ADS query of refereed abstracts containing the following boolean expression:

Could OR Possibly OR Might OR Maybe OR Perhaps OR Quite OR Fairly OR Various OR Very OR Several OR Exceedingly OR Vastly OR Interestingly OR Surprisingly OR Remarkably OR Clearly OR Significantly OR Substantially OR Relatively OR Completely OR Extremely

We can easily disagree on whether using these words in an abstract constitutes “weaseling”, or has any sort of nefarious purpose (I certainly pepper my writing with more than my fair share of those). It is still an interesting exercise to verify whether usage of those words has increased over time. The following plot shows the fraction of articles containing those words (i.e. number of articles containing the words normalized by the total article count) each year.

chart-2

 

Keeping all the caveats above in mind, there is a definite upward, pretty linear-by-eye trend going on. I’m not sure whether it has to do with simple evolution of language and style, less boastful writing, an accident of fate/bug on my part, or some other factor.

This is of course a super-shallow analysis that would require far more insight than what I offered in this post, but it’s still intriguing. I tried to altavista whether this is well-known, but have come empty handed so far. Any ideas?

You can play with the interactive plot itself by clicking this link.

UPDATE: Ben Weiner made a really good point on the Facebook astronomer group.   He suggests that an additional, alternative explanation could simply be that abstracts have become, on average, more verbose with time, which would explain the higher frequency of fluffy adjectives and adverbs. This could be checked with a control set of non-weasel words… which I will definitely try.


How did this post do with writegood-mode? Pretty nicely… but I got a grade of “11” on Hemingway, with about 9 out 24 sentences being hard to read.  Oh well.
Weasel image credit: Cliff

Two useful tools: git-flow and git-gutter+

This is just a quick post linking to two very useful tools I just started incorporating into my workflow.

The first is git-flow. Git-flow gives a very nice structure to feature development using git: it imposes some discipline on branching and committing features to the “master” branch, while also providing a very helpful branching naming scheme and a clear path from developing a feature to incorporating it into a release. This post gives a clear overview on how to get started with it.

Fringe Git indicators in Emacs.
Fringe Git indicators in Emacs.

The second is an Emacs package called git-gutter+ (in its “fringe” flavor). It lets you view Git changes directly from the current buffer (the graphical symbols in the fringe shown in the screenshot). Install it from the package manager (MELPA) and add to one of your .el initialization scripts.