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

Matt Blaze Testimony

Back in April, Matt Blaze, a cryptographer and security expert from the University of Pennsylvania, testified before Congress concerning proposals to require “back doors” in encryption systems—especially in communication applications. The idea is that law enforcement would have a special key—the infamous golden key—that would enable them to decrypt messages. Since this key would be known only to the proper authorities, it would ensure the security of legitimate communications while still allowing the investigation of terrorist or criminal messages.

Everyone with the slightest bit of technical sophistication knows that such a system is impossible. Even if we pretend for a moment that the key wouldn’t be leaked or sold, once the back door is there it will be discovered and exploited by criminals and foreign state entities. The result is that we will all be less secure and the criminals will move on to other ways of communicating. We will have sacrificed our security without making much real difference in law enforcement effectiveness.

Blaze’s testimony focuses on how difficult it is to build correct software, especially security software. He makes the point that we simply don’t know how to do it. The security of software goes down as its complexity increases and Blaze explains why providing a back door inevitably increases complexity, sometimes dramatically so.

The testimony is about eight and a half pages long and an interesting read so take a look if you have an interest in these matters. We can only hope that Congress takes his testimony to heart.

Posted in General | Tagged | Leave a comment

Make Scroll Up and Scroll Down Symmetric

A handy tip from Wilfred Hughes:

Posted in General | Tagged | Leave a comment

A New Common Lisp Book

Lispers have traditionally eschewed regular expressions but the truth is that they are often useful and sometimes the most practical way to deal with a problem. Because of the bias against regular expressions, the CL specification does not include them.

Happily, there is a de facto standard implementation: CL-PPCRE written by Edi Weitz. Now Weitz is writing a book on Common Lisp. Amazon is claiming it will be released in December by Apress. It will be a collection of Lisp recipes.

As someone who has used many of Weitz’s libraries—especially CL-PPCRE—I am really looking forward to the book. Weitz is a master and we can all learn a lot from him.

Posted in General | Tagged , | Leave a comment

Coffee

Not that we needed any affirmation but the New York Times makes it official.

Posted in General | Leave a comment

Peep-dired

Asok has a nice little utility called peep-dired that’s available from MELPA. It’s a Dired minor mode that displays the file at point in the dired buffer in another window. You don’t have to select the file or do anything special. As you move to another file in dired with 【Ctrl+n】 or 【Ctrl+p】, the new file is displayed.

You can ignore certain files and there are commands for cleaning things up. Take a look at the REAME to see the details. If you have a workflow that involves scrolling through a list of files, you may find this package a real win. My workflows don’t include this so I haven’t used the utility. If you have experience with it, leave a comment.

Posted in General | Tagged | Leave a comment

SBCL 1.2.11 is Out

I downloaded, compiled, and installed SBCL 1.2.11, the latest monthly release of the SBCL system. When I ran the regression tests (on OS X 10.10.3) I got one failure. The main development platform is Linux so I’m assuming this is an OS X anomaly—I don’t see anything on the Web about the failure. I’m not going to worry about it until next month’s release.

This month’s release has four enhancements and two bug fixes. As usual, we all owe to SBCL developers our thanks for the excellent job they do in making monthly releases of this fine tool.

Posted in Programming | Tagged , | Leave a comment