Kitchin: Day Two with Hy

Yesterday, I wrote about John Kitchin’s post on Hy, a Lisp dialect that essentially compiles to Python allowing you to write in Lisp while still having access to the Python RTL. Kitchin has published a new post describing his second day with Hy.

You can feel his excitement as he writes about experimenting with the language and seeing what it can do. As in the first post, he gives several examples including a first attempt at an Elisp macro that allows you to embed Hy in Elisp. As Kitchin notes, the language is still new and evolving so it’s apt to get better and better over time.

In the mean time, there are already resources for it. Emacs, of course, has a major mode for it that provides syntax highlighting and a REPL and abo-abo has added support for it to his lispy package. There’s also a survival guide and, of course, it’s on twitter.

I don’t really have a need for the Python RTL but I am, nevertheless, really excited to see how this all works out. I used to use Python a lot until I moved on to Lisp. Perhaps Hy will entice me to return to Python for at least some tasks.

Once again, thanks to Karl Voit for the pointer.

Posted in General | Tagged , , | Leave a comment

What if Elisp and Python Had a Child?

John Kitchin, as Irreal has covered many times, is doing a lot of excellent work with Org mode and Emacs. Most of his scientific computation is done in Python, a language he’s been using for 15 years and is very comfortable with. He’s managed to integrate Python and Org mode by using Babel code blocks.

He discovered, though, that it’s a lot more fun to program in Lisp than in Python. That’s something that many of us have discovered so I’m entirely sympathetic to is desire to do his scientific work in Lisp. The problem is that Python has really great support for scientific calculations that isn’t generally available in Lisp environments. What’s really needed, he says, is a way of accessing the Python library from Lisp. Happily, there is a way of doing this with Hy, a Lisp dialect that compiles to a Python abstract syntax tree that can executed by Python.

Kitchin tries a few simple experiments in his post and discovers that it’s amazingly simple to write in Lisp and still have all the numerical goodness of Python. Take a look at his post to see easy and natural it is. If, like Kitchin, you have a large investment in Python knowledge, need the scientific libraries that Python provides, and would rather be writing in Lisp be sure to check out his post and then head over to the Hy site. It’s pretty easy to install and get started with Hy so you can try it out with little effort.

Hat tip to Karl Voit for pointing me to Kitchin’s post.

Posted in General | Tagged , , , | 2 Comments

Moving to the Next/Previous Link in Org Mode

Here’s something I didn’t know. You probably won’t need this often but it’s a useful thing to add to your toolbox.

Posted in General | Tagged , | Leave a comment

Email Strategy

As Scooby-Doo would say, RUH?

Posted in General | Tagged | Leave a comment

Molecule Representations in Org Mode

This will be of no use to most of us but it’s so darn neat I had to write about. John Kitchin, who’s a genius a finding ways to move nearly everything into Org mode, has a blog post on drawing molecule representations in Org. Kitchin, of course, is a chemical engineer so this is something very useful for him, especially since his group uses Org to write most of their papers.

Sure, you can argue that all the real work is being done by SMILES and Open Babel but what’s nice about this approach is that it brings everything into Org, which has important reproducible research and organizational consequences. In a subsequent post, Kitchin explores another method of doing the same thing.

As I say, most of us won’t have a use for this but it is neat and it does show how flexible Org is and that it can meet much more of your publishing needs than you might imagine.

Posted in General | Tagged , | Leave a comment

Some Oldies but Goodies

When I find a useful Emacs package or tip, I almost always write about it so others can take advantage of them too. The other day I was using one of those packages and thought, “Gee, this is really neat. Everybody should be using it.” That coupled with the fact that I keep seeing posts or tweets asking about how to do some of these things made me think that it would be worth revisiting some of them. These tips/packages are ones that I use almost everyday and wouldn’t want to live without.

Without further ado, here’s a list of tips/packages that I find very useful along with the original Irreal post that discussed them:

  1. Looking up a word from Emacs. Abo-abo has a very nice small package, Defining the Word at Point, that will look up the word at point and give you the definition in the minibuffer. It’s incredibly useful; I’ve already used it in this post.
  2. Everyone agrees that zap-to-char is useful but then go on to complain that it should really zap up to the character. It turns out that there’s already an Emacs function that lets you Zap Up To A Character. Read the post to see how to enable it.
  3. We all know about 【Ctrl+h f】 and 【Ctrl+h k】 to bring up documentation about a specified function or a function bound to a key. One of Irreal’s frequent commenters, Phil, notes that you can also bring up the source for those functions too (Help From Phil) using the functions:

    • find-function
    • find-function-on-key
    • find-variable
    • find-library

    I bind these to the keys corresponding to the documentation functions but with the letter after the 【Ctrl+h】 modified with 【Ctrl】 so that find-function, for example, is bound to the 【Ctrl+h Ctrl+f】 shortcut.

  4. A trick I learned from Tim Visher is evaluating an sexp in an Emacs buffer and replacing the sexp by the result. I wrote about that and the code I used to accomplish it in Eval and Replace in Emacs. I’ve since replaced the code with

    ;; From Lars Tveito: https://github.com/larstvei/dot-emacs/blob/master/init.org
    ;; This avoids overloading C-c C-e in org-mode
    (defadvice eval-last-sexp (around replace-sexp (arg) activate)
      "Evaluate and replace when called with a prefix argument."
      (if arg
          (let ((pos (point)))
            ad-do-it
            (goto-char pos)
            (backward-kill-sexp)
            (forward-sexp))
        ad-do-it))
    
  5. From one of Sacha’s chats, Sacha Chats with Steve Purcell, I learned about one of the most useful packages I have: whole-line-or-region. It lets you use certain commands, like 【Meta+w】 that normally work on a region, on the entire current line if no region is defined. I can’t tell you how useful this is. I use it every single day including several times in writing this post.
  6. I often want to do a ping or traceroute and used to switch to a terminal to run them. Then I found out about the Emacs Net Utilities that lets me run them from within Emacs. Later I improved that a bit by making them run in a temporary screen: Running Ping in Emacs.

I hope you find some or all of these tips/packages as useful as I do.

Posted in General | Tagged | Leave a comment

Inserting Underscores

John Kitchin offers a nice tip for Emacs users who write in Python, C, or some other language that makes heavy use of underscores.

You’ll need key-chord.el (available from Melpa) but it’s so useful you should have it installed anyway. Don’t take my word for it, ask Magnar.

Posted in General | Tagged | 6 Comments

Note Taking with Org Mode

I thought I’d written about Tony Pelaez’s video on Taking Notes in Emacs Org-Mode before but I couldn’t find the post. Even if I did write about it, it’s a nice introduction to one of Org mode’s most useful functionalities and worth mentioning again. This is especially true since I’ve been seeing a lot of tweets lately from people just discovering Org mode.

Pelaez’s introduction is very elementary in the sense that he mostly ignores the standard keyboard shortcuts and uses menus or 【Meta+x】 command sequences instead. When he gets to demonstrating the outlining functionality—in the guise of making a TODO list—he does use the shortcuts. If you don’t use Org mode everyday, it’s easy to forget these so it serves as a nice review even if you’re not a n00b.

If you’re just starting with Org, this video will introduce you to one of its major use cases. Be warned though: you’ll soon be using Org for an ever increasing portion of your workflow.

Posted in General | Tagged , | Leave a comment

USB versus the U.S. Government

Posted in General | Tagged | Leave a comment

The Reality of Key Escrow

Back in 2000 PGP, a mature and capable company with significant experience in encryption and security, decided that it would be a good idea to provide key escrow for its corporate users.

It did not, of course, end well.

The feature ended up making all PGP keys vulnerable. Here’s a thread describing the bug. If you read through the posts, you’ll see that the problem was that a programmer essentially neglected to check a return value. Also notice how easy the vulnerability is for anyone to exploit. Once again we have confirmation that security is hideously hard to get right.

This was supposed to be a benign feature that Network Associates—owner of PGP—added to assist with key recovery. The result was a devastating, unfixable bug that could only be eliminated by retiring two versions of PGP. What possible reason is there to believe that a government mandated key escrow would do any better?

Posted in General | Tagged , | 2 Comments