2022-05 Austin Emacs Meetup

There was another meeting a few weeks ago of EmacsATX, the Austin Emacs Meetup group. For the third month in a row we had a predetermined topic.

The speaker was Blaine Mooers, Director of the Laboratory of Biomolecular Structure and Function at the University of Oklahoma Health Sciences Center in Oklahoma City. They engage in crystallography, which according to Wikipedia is “the experimental science of determining the arrangement of atoms in crystalline solids”. He gave a talk on what his lab does and how they use Emacs at the 2021 EmacsConf. The talk is Reproducible molecular graphics with Org-mode. He posted the slides for his EmacsATX talk to his Github repository.

His lab uses software called PyMOL. I have not gotten around to going through all the EmacsConf talks, but I think he spoke about calling PyMOL from Org files, and using Org mode to incorporate the code for the molecular visualizations in journal articles.

His presentation at EmacsATX dealt briefly with what his lab does (slides 2 to 9). Then he talked about functional programming (slides 10 to 14), different ways to invoke Emacs Lisp (slides 16 to 20), and he went over some of the Emacs Lisp functions he used (slides 21 to 36). I won’t repeat too much of it here. Go look at it; it’s pretty good.

The section that interested me the most was the section on the different ways to run Emacs Lisp code. I had always restarted Emacs and invoking functions over and over until I got what I wanted. The methods are:

  • elisp file (.el)
    (documentation ‘main) ; C-x C-e at space of right of )
    Or C-M-x inside parens
  • scratch buffer: C-j (for me, C-j is mapped to paredit-newline; the default mapping for C-j is eval-print-last-sexp)
  • M-x eval-buffer
  • M-x eval-region
  • M-: ; REPL in mini buffer
  • M-x ielm ; eval one expression at a time
    (defalias ‘erepl ‘ielm): M-x erepl
  • M-x eshell
  • elisp REPL outside of Emacs (from a question on the Emacs Reddit):
    alias erepl="rlwarp emacs --batch --eval \"(progn (require 'cl) (loop (print (eval (read)))))\""
  • Could run scripts in the terminal without running Emacs
    “#!emacs –script” in file
    or emacs –script in comment line
  • In Org docs in source blocks
    To execute the code blocks in Org file, you use M-x org-babel-execute-src-block. The “RESULTS” line will be updated with your result, and the universe will open up in all its heavenly glory.

    #+BEGIN_SRC emacs-lisp :results value scalar
        (* 40 1001 1001 1001 1001 1001)
    : 40200400400200040    

The Emacs Lisp overview included lambda functions, required and optional arguments, and three mapping funtion: mapcar (applies a function to a list), mapcan (similar, but always returns a list) and mapconcat (similar, but returns a single string). During the Q&A, someone pointed out Emacs Lisp now has seq* functions, that work with lists and arrays. I think those were inspired by Clojure.

You’re welcome.

Under the Stoner Chatham House Rules in previous EmacsATX write-ups, the speaker was referred to either as “The Esteemed Gentleman From Oklahoma”, or “Attendee Number Three”.

Image from an 11-th century Byzantine manuscript; image from The Walters Art Museum, assumed allowed under Public Domain.