Defining the Word at Point

I just stumbled upon a new offering from abo-abo. It’s define-word, a very nice package that allows you to get a definition of the word at point. You can also specify the word in the minibuffer if you want.

The package works by connecting to wordnik, grabbing the resulting page, parsing out the definition, and then displaying it as a message. That’s nice because it doesn’t require that you have a dictionary installed to work. Abo-abo says the package is less than 50 lines so there’s no memory overhead to speak of.

OS X has a nice feature where you can three-finger tap on a word in most of the native apps and get a definition from the system dictionary. Unfortunately it doesn’t work with Emacs so I had to manually look up definitions using spotlight. That wasn’t too much trouble but define-word is so much better. I bound the commands to【Hyper+d】 and【Hyper+D】 using use-package like this

(use-package define-word
  :ensure t
  :bind (("H-d" . define-word-at-point)
         ("H-D" . define-word)))

I just installed it as I’m writing this and I’m already in love with it. A really great package.

Posted in General | Tagged | 3 Comments

The Gift That Keeps On Giving

One of the major beefs that many of us have with the NSA is that they keep doing things that make us less secure. Their latest project is trying to convince Congress to mandate back doors in crypto applications. It’s a really bad idea for the same reasons it was the last time they tried it with the Clipper Chip.

Before the Clipper Chip, we had the crypto export restrictions. One of the consequences of those restrictions was that browsers and Internet servers couldn’t be sold overseas without crippling the encryption. That was done by allowing the browser and server to negotiate a less secure key so that browsers sold overseas could still be spied on but domestic browsers could negotiate a more secure key and thus have robust encryption. The policy was doomed for obvious reasons and was eventually relaxed to the point of no longer being an issue.

The problem is that most browsers and servers still support negotiating crippled keys and, of course, criminals and governments have been exploiting that fact for some time. The last time we heard about this it was in conjunction with the FREAK attack. Now we have the Logjam attack that also tricks the browser and server into negotiating a weak key. You can read the details in this paper that describes the attack and you can check if your browser is vulnerable by going to The Logjam Attack site, which also contains a summary of the attack and statistics on how many sites are vulnerable.

As NSA meddling goes, you could consider the export restrictions fairly benign but the results of that particular meddling are still echoing from the past and causing mischief today. Part of the NSA’s mission is to secure our communications and make us all safer. I wish they’d start doing that1.

UPDATE: Matthew Green has an excellent post on Logjam that covers the technical details in a more accessible fashion than the paper. You should definitely read his post if you’re interested in this exploit. He also discusses the speculation that the NSA is using a Logjam type exploit.

Footnotes:

1

The researchers who discovered this attack note that part of Edward Snowden’s disclosures involve the NSA breaking into TLS sessions and they speculate that the Logjam attack is being actively exploited by the NSA to to do.

Posted in General | Tagged , | Leave a comment

Mastering Emacs is Out

Mickey Peterson’s new book, Mastering Emacs, is out.

I’ve already got mine. I haven’t read it yet, obviously, but from my quick scan it looks really good.

Posted in General | Tagged | 1 Comment

Follow the Money

After the Appeals Court ruled the NSA’s mass telephone metadata collection illegal, pundits and congressmen have come out in droves to press their point of view on the issue. I find it hard to understand how anyone could support something that is so obviously in violation of the Fourth Amendment. Even on their own terms, it doesn’t make sense because the Government, after much hemming and hawing, had to admit that they couldn’t point to any examples of their surveillance reaping actionable intelligence1.

If you’re the curious type, you might wonder what’s going on. If you’re a fan of mystery novels, you know the first rule is to follow the money. The//Intercept did that and discovered that the loudest voices in support of the spying have financial incentives. One needn’t be a cynic to find this unsurprising. Doubtless there are honest players who really believe the spying is necessary for our security but many of those supporting the spying are doing so for venal reasons. Keep that in mind the next time you hear someone telling you it’s for your own good.

Footnotes:

1

Well, they did discover that guy who was collecting money to send to sketchy characters in the Middle East but who here thinks that’s worth having your privacy and constitutional rights trashed?

Posted in General | Tagged | Leave a comment

The Greatest Threat

A disturbing thought from Glenn Greenwald. Be sure to follow the link.

Posted in General | Tagged | Leave a comment

Calc Quick Reference

In a comment to one of my posts on calc, Sue D. Nymme (love that handle) mentioned that he was working on a quick reference for calc and kindly provided a sneak preview. Now he reports that he’s ready to release it to the world.

Check out his github repository for the project to get a copy. It’s a really excellent resource that has the subject matter arranged in a more logical way than the others quick references that I’ve seen. You can print it (see qref-config.ps) as 1 page per sheet, a half sheet booklet, or a quarter sheet booklet depending on your needs. There are directions in the README for assembling the output into a booklet. To generate a copy, just edit qref-config.ps to choose how many pages you want on each sheet and then type make.

If you’re a calc user—and you really should be—you’ll definitely want to definitely check this cheat sheet out. I use mine all the time.

Posted in General | Tagged , | 2 Comments

Jumping to use-package Blocks in Your Emacs Configuration

Jordon Biondo published a useful gist that allows you to easily navigate to use-package blocks in your .emacs or init.el file. If you have lots of packages—and therefore lots of use-package blocks—you’ll find it useful.

Biondo recommends that you install imenu-anywhere to make the most use of the hack and I agree. Without imenu-anywhere, you have to first ask imenu for Used.Packages and then the particular block you want. With imenu-anywhere you just specify the block. You also get the choices in ido (or Helm if you have it installed) instead of just a plain prompt. You can probably get imenu to use ido as well but imenu-anywhere takes care of that for you.

Biondo doesn’t say how he invokes his code and that turns out to be a little tricky because imenu-generic-expression= is a local variable. I solved that problem by invoking it through the emacs-lisp-mode-hook. I implemented it like this (based on a comment on reddit by xuchunyang):

(use-package imenu-anywhere
  :ensure t
  :init (global-set-key (kbd "C-.") 'imenu-anywhere)
  :config (defun jcs-use-package ()
            (add-to-list 'imenu-generic-expression
             '("Used Packages"
               "\\(^\\s-*(use-package +\\)\\(\\_<.+\\_>\\)" 2)))
  (add-hook 'emacs-lisp-mode-hook #'jcs-use-package))

This bit of Elisp turns out to be pretty handy—I became addicted almost immediately—so you should consider whether or not it will improve your workflow. In either case, imenu-anywhere is a clear win.

Posted in General | Tagged | 3 Comments

Collecting and Using Data in Schools

Regular Irreal readers have probably figured out that I’m a data freak. I’m always collecting, tabulating, and analyzing data about myself and the things around me. That’s one of the reasons I found the use of digital methods in hospitals so fascinating.

It turns out that some schools have also begun collecting and analyzing data. According to the article, custodians are even collecting information about how much dirt they find under bathroom sinks. Of course, most of the data is about students and their performance. The idea is to provided feedback to students on their progress and to teachers on which teaching methods work and how well their students are learning the material. You can read the article to see some of the ways the data is being used.

Even though I’m a self-confessed data geek, I’m not sure how I feel about this. There are, of course, privacy and security issues. A good general rule, I think, is that any data collection by the government of citizens should be presumed suspect and subject to careful scrutiny. Those issues aside, some parents are against the data collection because of presumed effects on the children.

Concerns about adverse effects on the students are probably overblown but I remember thinking that standardized testing as a means of measuring student progress seemed like a good idea. We all know how that turned out so it’s wise to proceed carefully.

What I find interesting about the program is that it’s another example of how collecting actual data enables you to make much better decisions than depending on intuition or anecdotal evidence. It will be interesting to see if more schools begin adopting these methods.

Posted in General | Tagged , | Leave a comment

Emacs on OS X

If your platform is OS X and you’re an Emacser, Bozhidar Batsov has a nice post on setting up Emacs. He shows you how to get Emacs (if you don’t compile it yourself), how to set the path or alias so you can (also) use Emacs in a terminal, and how to get a dictionary installed for flyspell.

Sadly, proced doesn’t work on OS X but Batsov gives you an alternate utility that does some of the same things. He also mentions that the BSD ls command doesn’t have the same features that GNU ls does and that dired expects those capabilities. He shows how to get the GNU ls but I’ve never had any problem with just using the native ls. I think that Emacs detects that it’s not GNU ls and adds the missing bits.

Finally, he mentions the Dash utility, which is an OS X documentation browser. There is, of course, an Emacs interface. Dash is available from the App Store for free but will nag you occasionally to buy it. It’s only $19.99 so it’s worth rewarding the author for his work. You can check out its features in the App Store and try it for free so there’s no downside to looking into it.

If you’re using OS X, it’s worth checking out Batsov’s post even if you already have Emacs up and running.

Posted in General | Tagged , | Leave a comment

Counting Words

For years, I’ve used this bit of Elisp that I stole from DJCB at Emacs-Fu. The latest versions of Emacs now have this functionality built in so I thought I should move on. The new functionality is bound to the convenient key sequence 【Meta+=】 giving me even more reason to change.

There’s a problem though. The semantics of the command are strange. By default, it counts the lines, words, and characters of the current region even if the region is not active. That’s never what I want and I can’t think of a reasonable use case for such behavior. If the region is active, you get the desired behavior. If you want the entire buffer you can get it by specifying a prefix argument. I adopted the practice of typing 【Meta+0 Meta+=】 to count the words in the current buffer.

That worked fine but it was infuriating. Why should I have to add a keystroke to work around a default that doesn’t make any sense? I decided I’d advise count-words-region to do the sensible thing. Once I started researching the code, I discovered that there’s already a function that does the right thing: count-words. I rebound 【Meta+=】 to count-words and everything worked the way I expected.

The story has a happy ending but it still bothers me a bit. The default behavior was so unexpected that I was suspicious that I’d somehow caused the old binding. There’s nothing in my init.el that does it and when I ran

M-x bug-hunter-init-file RET (string-suffix-p "count-words-region" (describe-key-briefly (kbd "M-=") nil) t)

it told me that 【Meta+=】 is bound to count-words-region even when Emacs is invoked as

emacs -Q

so it appears that the binding is on purpose.

If I’ve overlooked something or you have some guidance on why this behavior is the default, please leave a comment.

Posted in General | Tagged | 3 Comments