├── Slides_Functional_Elisp_from_the_beginning.pdf ├── LICENSE.txt ├── README.md └── source.tex /Slides_Functional_Elisp_from_the_beginning.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MooersLab/EmacsATX4May2022/main/Slides_Functional_Elisp_from_the_beginning.pdf -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Blaine Mooers and the University of Oklahoma Board of Regents 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Functional programming in Emacs Lisp 2 | 3 | ![Version](https://img.shields.io/static/v1?label=EmacsATX4May2022&message=0.3&color=brightcolor) 4 | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) 5 | 6 | 7 | This repo contains the PDF of slides for a talk I presented virtually on May 4th, 2022 at the EmacsATX Meetup. 8 | This is a basic introduction to functional programming in elisp. 9 | 10 | The slides also include several ways to run elisp code, including from the terminal outside Emacs via an elisp REPL (very cool!) and a script file. 11 | The former lets you do calculations in the terminal without firing up Emacs. 12 | The latter is helpful for automated data analysis pipelines where you run an elisp function on an input file and gather the output in another file. 13 | This lets you harness the full power of Emacs full a bash script without using the GUI. 14 | This opens up all kinds of possibilities. 15 | 16 | 17 | ## Update history 18 | 19 | |Version | Changes | Date | 20 | |:-----------:|:------------------------------------------------------------------------------------------------------------------------------------------|:--------------------:| 21 | | Version 0.2 | Added badges, funding, and update table. | 2024 May 24 | 22 | | Version 0.3 | Added the source tex file to ease copying and reusing the elisp code. | 2024 July 24 | 23 | 24 | ## Sources of funding 25 | 26 | - NIH: R01 CA242845 27 | - NIH: R01 AI088011 28 | - NIH: P30 CA225520 (PI: R. Mannel) 29 | - NIH: P20 GM103640 and P30 GM145423 (PI: A. West) 30 | -------------------------------------------------------------------------------- /source.tex: -------------------------------------------------------------------------------- 1 | % !TEX TS-program = pdflatex --shell-escape 2 | %\documentclass[handout]{beamer} %slides+notes only 3 | %\documentclass[10pt,t]{beamer} %slides only 4 | % The laulatex is being updated. The following RequirePackage line is needed for now. 5 | % 6 | % Under Menu, select compiler 2017 (Legacy) to get animate to make a pdf with a working animation. 7 | % The 2019 compiler does not work as of 18 September 2020. 8 | % 9 | % Hold down the wheel or middle mouse button pause the animation. 10 | % Add the control keyword to see the controls. 11 | % 12 | \documentclass[aspectratio=169]{beamer} 13 | \RequirePackage{luatex85} 14 | \usepackage{animate} 15 | \usepackage{pgfpages} 16 | 17 | \usepackage{moresize} 18 | \usepackage{multicol} 19 | \usetheme{default} 20 | \beamertemplatenavigationsymbolsempty 21 | \hypersetup{pdfpagemode=UseNone} % don't show bookmarks on initial view 22 | %tables 23 | \usepackage{booktabs}% http://ctan.org/pkg/booktabs 24 | % font 25 | \usepackage{amsmath} 26 | \usepackage{amssymb} 27 | \usepackage{minted} 28 | \usepackage{fix-cm} 29 | \usepackage{fontspec} 30 | \usepackage{gensymb} 31 | \usepackage{tabularx,booktabs} 32 | \usepackage[T1]{fontenc} 33 | \usepackage{textcomp} 34 | \usepackage{upquote} 35 | \AtBeginDocument{% 36 | \def\PYZsq{\textquotesingle}% 37 | } 38 | 39 | 40 | \usepackage{enumitem} 41 | 42 | \newminted{python}{fontsize=\normalsize, 43 | linenos=false, 44 | numbersep=8pt, 45 | gobble=4, 46 | breaklines, 47 | frame=lines, 48 | bgcolor=bgpython, 49 | framesep=3mm} 50 | 51 | \newminted{bash}{fontsize=\largesize, 52 | linenos=false, 53 | numbersep=8pt, 54 | breaklines, 55 | gobble=4, 56 | frame=lines, 57 | bgcolor=bgbash, 58 | framesep=3mm} 59 | 60 | \newminted{elisp}{fontsize=\largesize, 61 | linenos=false, 62 | numbersep=8pt, 63 | breaklines, 64 | gobble=4, 65 | frame=lines, 66 | bgcolor=bgelisp, 67 | framesep=3mm} 68 | 69 | \definecolor{bgpython}{rgb}{0.95,0.95,0.95} 70 | \definecolor{bgbash}{rgb}{0.95,0.85,0.75} 71 | \definecolor{bgelisp}{rgb}{0.95,0.85,0.75} 72 | 73 | %\setbeameroption{show only notes} 74 | \setsansfont{TeX Gyre Heros} 75 | \setbeamerfont{note page}{family*=pplx,size=\footnotesize} % Palatino for notes 76 | % "TeX Gyre Heros can be used as a replacement for Helvetica" 77 | % In Unix, unzip the following into ~/.fonts 78 | % In Mac, unzip it, double-click the .otf files, and install using "FontBook" 79 | % http://www.gust.org.pl/projects/e-foundry/tex-gyre/heros/qhv2.004otf.zip 80 | 81 | % Center the title and increase its size 82 | \setbeamertemplate{frametitle}[default][center] 83 | \setbeamerfont{frametitle}{size=\huge} 84 | 85 | 86 | % named colors 87 | \definecolor{offwhite}{RGB}{249,242,255} 88 | \definecolor{foreground}{RGB}{25,25,25} 89 | \definecolor{background}{RGB}{255,255,255} 90 | \definecolor{title}{RGB}{100,0,0} 91 | \definecolor{gray}{RGB}{155,155,155} 92 | \definecolor{subtitle}{RGB}{50,0,0} 93 | \definecolor{hilight}{RGB}{102,255,204} 94 | \definecolor{vhilight}{RGB}{255,111,207} 95 | \definecolor{lolight}{RGB}{155,155,155} 96 | %\definecolor{green}{RGB}{125,250,125} 97 | 98 | % use those colors 99 | \setbeamercolor{titlelike}{fg=title} 100 | \setbeamercolor{subtitle}{fg=subtitle} 101 | \setbeamercolor{institute}{fg=gray} 102 | \setbeamercolor{normal text}{fg=foreground,bg=background} 103 | \setbeamercolor{item}{fg=foreground} % color of bullets 104 | \setbeamercolor{subitem}{fg=gray} 105 | \setbeamercolor{itemize/enumerate subbody}{fg=gray} 106 | \setbeamertemplate{itemize subitem}{{\textendash}} 107 | \setbeamerfont{itemize/enumerate subbody}{size=\footnotesize} 108 | \setbeamerfont{itemize/enumerate subitem}{size=\footnotesize} 109 | 110 | % page number 111 | \setbeamertemplate{footline}{% 112 | \raisebox{5pt}{\makebox[\paperwidth]{\hfill\makebox[20pt]{\color{gray} 113 | \scriptsize\insertframenumber}}}\hspace*{5pt}} 114 | 115 | % add a bit of space at the top of the notes page 116 | \addtobeamertemplate{note page}{\setlength{\parskip}{12pt}} 117 | 118 | % a few macros 119 | \newcommand{\bi}{\begin{itemize}} 120 | \newcommand{\ei}{\end{itemize}} 121 | \newcommand{\ig}{\includegraphics} 122 | \newcommand{\subt}[1]{{\footnotesize \color{subtitle} {#1}}} 123 | 124 | \usepackage{latexsym} % for squares for the check-list environment 125 | \newenvironment{checklist}{% 126 | \begin{list}{}{}% whatever you want the list to be 127 | \let\olditem\item 128 | \renewcommand\item{\olditem[$\Box$] } 129 | }{% 130 | \end{list} 131 | } 132 | 133 | 134 | % title info 135 | \title{Functional elisp from the beginning} 136 | \author{\textbf{\large{Blaine Mooers, PhD} \\ blaine-mooers@ouhsc.edu \\ 405-271-8300}} 137 | \institute{{Department of Biochemistry \& Molecular Biology}\\[2pt]{University of Oklahoma Health Sciences Center, Oklahoma City} } 138 | % to hide auto date,use \date{} 139 | \date{Austin Emacs Meetup\\ Austin, Texas\\ Virtual Meeting\\ 4 May 2022} 140 | 141 | \begin{document} 142 | 143 | % title slide 144 | { 145 | \setbeamertemplate{footline}{} % no page number here 146 | \frame{ 147 | \titlepage 148 | \note{ 149 | Hi, I am Blaine Mooers. 150 | I am an associate professor of Biochemistry and Molecular Biology at the University of Oklahoma Health Sciences Center in Oklahoma City, Oklahoma. 151 | I am protein crystallographer or a so-called structural biology. 152 | I work at the insection of chemistry, biology, physics, and computing. 153 | 154 | I attended the meeting in February and volunteered to give a talk on functional programming with Emacs lisp to force myself to learn some elisp and a little about functional programming. 155 | I first started popping open Emacs several years ago for the purpose of making a yasnippet snippet library for doing literate programming with the molecular graphics program PyMOL. 156 | I was making this library available for 20 leading text editors. 157 | At the time, my favorite text editor for getting things done fast was TextMate. 158 | In the process, I learned some basic Vim. 159 | A year ago, I decided to give Emacs a try. 160 | Several months ago, I ditched evil, mode and I am trying to master the Emacs Key bindings. 161 | 162 | I poked around in Spacemacs, Doom, Prelude and SciMax long enough to decide to go back to the basics in Gnu Emacs. 163 | In the 164 | I have built and rebuilt my configuration file several times. 165 | I discovered that the chemacs2, the Emacs profiler switcher, is great for retaining a broken configuration while rebuilding a second one. 166 | } 167 | } } 168 | 169 | \section{Introduction} 170 | \subsection{Who am I} 171 | 172 | \section{Workflow in the Mooers Lab} 173 | \begin{frame} 174 | \frametitle{Workflow in the Mooers Lab} 175 | \begin{center} 176 | \includegraphics[width=0.79\textwidth, angle=0]{./Figures/workflow} 177 | \end{center} 178 | \end{frame} 179 | \note{ 180 | My lab uses X-ray crystallography to determine the atomic structures of protiens and nucleic acids important in human medicine. 181 | This figure shows our workflow 182 | We grow crystals of purified proteins and RNA like the crystal of RNA in the upper left. 183 | We shoot the crystal with X-rays as we slowly rotate the crystal on a X-ray diffraction instrument, as shown in the top center. 184 | The image in the upper right shows thousands of diffraction spots from a two degree rotation. 185 | We rotate the crystal 180 degrees to collect a full dataset with 90 images. 186 | 187 | %We integrate, merge, and scale the diffraction spots. and then 188 | We take an inverse Fourier transform of the diffraction data to generate an electron density map like the one shown in the bottom, center panel. 189 | We fit molecular models into the maps on computers and refine the model using maximum likelihood methods to improve its fit. 190 | The final model is then used in a molecular graphics program like PyMOL to make images for publication like the one in the lower right. 191 | } 192 | 193 | 194 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 195 | % Slide 3 196 | \section{Cover images made with PyMOL} 197 | \begin{frame} 198 | \frametitle{Cover images made with PyMOL} 199 | 200 | \begin{center} 201 | \includegraphics[width=0.79\textwidth, angle=0]{./Figures/trimmedCoverFigs} 202 | \end{center} 203 | 204 | \end{frame} 205 | \note{ 206 | PyMOL has over 100,000 users and is the most popular program for making images of protein structures for publication. 207 | PyMOL has about 500 commands and 600 parameters that enable the user to exert exquisite control over the appearance of the image. 208 | Shown are four examples of images made with PyMOL on the covers of several top journals. 209 | 210 | } 211 | 212 | 213 | 214 | %%%%%%%%%%%%%%%%%%%%%%%% 4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 215 | % Slide 4 216 | \section{PyMOL GUI} 217 | \begin{frame} 218 | %\frametitle{PyMOL GUI} 219 | 220 | \begin{center} 221 | \includegraphics[width=0.72\textwidth, angle=0]{./Figures/retkinase} 222 | \end{center} 223 | 224 | \end{frame} 225 | \note{ 226 | This the GUI for PyMOL. 227 | Python can be run with pulldown menus, commands at the PyMOL prompt, or with scripts. 228 | The PyMOL prompt is actually an interactive Python prompt. 229 | PyMOL is written in C for speed, but wrapped with Python for ease of extensibility. 230 | There are about 300 plugins that users have made for PyMOL. 231 | } 232 | 233 | 234 | %%%%%%%%%%%%%%%%%%%%%%%% 5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 235 | % Slide 5 236 | \section{Customized molecular representations} 237 | \begin{frame} 238 | \frametitle{Customized molecular representations} 239 | 240 | \begin{center} 241 | \includegraphics[width=0.72\textwidth, angle=0]{./Figures/cartoonsHairpin} 242 | \end{center} 243 | 244 | \end{frame} 245 | \note{ 246 | These are four representations of a 27-nucleotide RNA hairpin. 247 | The default cartoon from PyMOL is on the left. 248 | The three representations to the right were made using Python scripts that access the PyMOL API. 249 | Their code is in our snippet library. 250 | These examples demonstarte that PyMOL can be extended. 251 | } 252 | 253 | %%%%%%%%%%%%%%%%%%%%%%%% 5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 254 | % Slide 5 255 | \section{Missing molecular representations} 256 | \begin{frame} 257 | \frametitle{Missing molecular representations} 258 | 259 | \begin{center} 260 | \includegraphics[width=0.65\textwidth, angle=0]{./Figures/hairpinAOs} 261 | \end{center} 262 | \url{https://github.com/MooersLab/pymolshortcuts}\\ 263 | \url{https://github.com/MooersLab/pymolsnips} 264 | \end{frame} 265 | \note{ 266 | These are four representations of a 27-nucleotide RNA hairpin. 267 | The default cartoon from PyMOL is on the left. 268 | The three representations to the right were made using Python scripts that access the PyMOL API. 269 | Their code is in our snippet library. 270 | These examples demonstarte that PyMOL can be extended. 271 | } 272 | 273 | %%%%%%%%%%%%%%%%%%%%%%%% 7 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 274 | % Slide 7 275 | \section{org-yas pull down} 276 | \begin{frame} 277 | \frametitle{orgpymolpysnips} 278 | 279 | \begin{center} 280 | \includegraphics[width=0.8\textwidth, angle=0]{./Figures/org-yas.png} 281 | \end{center} 282 | \url{https://github.com/MooersLab/orgpymolpysnips} 283 | \end{frame} 284 | \note{ 285 | The orgpymolpysnips librarys has 260 snippet divided into 20 categories for use in org-mode docuements. 286 | These categories serve as groups in yasnippets that appear as submenus in the org-mode pulldown. 287 | They are prepended with pymolpy- to distinguish them from non-PyMOL related groups of snippets. 288 | } 289 | 290 | %%%%%%%%%%%%%%%%%%%%%%%% 8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 291 | % Slide 8 292 | \section{Code block} 293 | \begin{frame} 294 | \frametitle{Code block to make one image} 295 | 296 | \begin{center} 297 | \includegraphics[width=0.8\textwidth, angle=0]{./Figures/combined1.png} 298 | \end{center} 299 | \url{https://emacsconf.org/2021/talks/molecular/} 300 | \end{frame} 301 | \note{ 302 | Each snippet is flanked by the org-mode source block begin and end lines. 303 | The top line specifies the kernel that calls PyMOL's Python API to run the code. 304 | You place cursor on the top line or in the code block and enter C-c C-c. 305 | } 306 | 307 | 308 | \section{Result block} 309 | \begin{frame} 310 | %\frametitle{Code block to make one image} 311 | 312 | \begin{center} 313 | \includegraphics[width=0.80\textwidth, angle=0]{./Figures/pymol1out.png} 314 | \end{center} 315 | 316 | \end{frame} 317 | \note{ 318 | I sent the output to a drawer. 319 | This enables seeing the image in the file but it needs to be modest in size else scrolling will be difficult. 320 | It may be best to close most of the code blocks and result blocks most of the time to avoid lags. 321 | } 322 | 323 | 324 | % %%%%%%%%%%%%%%%%%%% 2 %%%%%%%%%%%%%%%%%%%%%%% 325 | % % Slide 2 326 | \begin{frame} 327 | \frametitle{Levels of expertise} 328 | \begin{center} 329 | \includegraphics[scale=0.79]{./Figures/Dreyfus} 330 | \end{center} 331 | \small{Dreyfus, S. E. and Dreyfus, H. L. (1980) A five-stage model of the mental activities involved in directed skill acquisition. DTIC Document.} 332 | \end{frame} 333 | \note{ 334 | Two Dreyfus brothers at UC Berkely proposed a model of expertise that had five levels in a report to the Department of Defense in the later 1970s. 335 | I find this model to be very useful. 336 | The report describes the features the different levels of expertise. 337 | I would put XXX XXX, the speaker at the last meeting, was in the proficient to expert category. 338 | I put myself in the advanced beginner category. 339 | One way to move from beginning an advanced beginner to a competant user is to give talks about topics that you yet to have mastered. 340 | 341 | I will assume no prior knowledge of emacs lisp. 342 | I spent several years editing my config file to add packages without understanidng the code in my config file. 343 | I got away with installing hundreds of packages without undering any elisp. 344 | This talk is for such a person. 345 | I will cover just enough elisp that you will be able to follow along the introduciton to the functional features of elisp. 346 | Of course, I do not have time to cover all of elisp. 347 | I will assume that you have done at least a modest amount of programming. 348 | } 349 | 350 | 351 | % %%%%%%%%%%%%%%%%%%% 3 %%%%%%%%%%%%%%%%%%%%%%% 352 | % % Slide 2 353 | \begin{frame} 354 | \begin{center} 355 | \includegraphics[scale=0.2]{./Figures/FunctionalProgrammingSimplified} 356 | \end{center} 357 | \end{frame} 358 | \note{ 359 | } 360 | 361 | 362 | %%%%%%%%%%%%%%%%%%%%%% 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 363 | % Slide 2 364 | \begin{frame} 365 | \frametitle{Functional Programmming} 366 | \Large{ 367 | \begin{itemize}[font=$\bullet$\scshape\bfseries] 368 | \item A programming paradigm characterized by the use of \textbf{mathematical functions} and the avoidance of \textbf{side effects}. 369 | \vspace{5mm} 370 | \item A programming style that uses only \textbf{pure functions} without \textbf{side effects}. 371 | \end{itemize} 372 | } 373 | \end{frame} 374 | \note{ 375 | Functional programming has a 60+ year history. 376 | 377 | These are the traditional definitions of functional programmming. 378 | Eric Normand discuss why this traditional definition is programmatic. } 379 | 380 | %%%%%%%%%%%%%%%%%%%%%% 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 381 | % Slide 2 382 | \begin{frame} 383 | \frametitle{Features of functional programmming} 384 | \Large{ 385 | \begin{itemize}[font=$\bullet$\scshape\bfseries] 386 | \item Variables are immutable. 387 | \item Recursion instead of loops. 388 | \item Pure functions without side effects. 389 | \item Higher order functions 390 | (functions that take functions as arguments) 391 | \item Division of programs into actions, calculations, and data (functional thinking). 392 | \end{itemize} 393 | } 394 | \end{frame} 395 | \note{ 396 | Functional programming has a 60+ year history. 397 | 398 | These are the traditional definitions of functional programmming. 399 | Eric Normand discuss why this traditional definition is programmatic. } 400 | 401 | 402 | 403 | 404 | \begin{frame} 405 | \frametitle{Why learn functional programming \\(at least programming with functional thinking)?} 406 | \Large{ 407 | \begin{itemize}[font=$\bullet$\scshape\bfseries] 408 | \item Cleaner code that is easier to debug and maintain 409 | \item More elegant 410 | \item Sometimes faster code 411 | \item Makes you a better programmer 412 | \vspace{5mm} 413 | \end{itemize} 414 | } 415 | \end{frame} 416 | \note{ 417 | Functional programming has a 60+ year history. 418 | 419 | These are the traditional definitions of functional programmming. 420 | Eric Normand discuss why this traditional definition is programmatic. } 421 | 422 | 423 | 424 | % %%%%%%%%%%%%%%%%%%% 2 %%%%%%%%%%%%%%%%%%%%%%% 425 | % % Slide 2 426 | \begin{frame} 427 | \frametitle{Two topics} 428 | \Large{ 429 | \vspace{5mm} 430 | \begin{itemize}[font=$\bullet$\scshape\bfseries] 431 | \item Ways to execute elisp code 432 | \vspace{5mm} 433 | \item Functional features of elisp 434 | \end{itemize} 435 | } 436 | \end{frame} 437 | \note{ 438 | The cover of this book by Alvin Alexander was to good to be pass over. 439 | It expresses the angst about functional programming that is similar to 440 | the angst that procedural-only programmers have when the topic of object-oriented 441 | programming is raised. 442 | } 443 | 444 | 445 | \section{Methods of running elisp} 446 | 447 | %%%%%%%%%%%%%%%%%%%%%% 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 448 | % Slide 2 449 | \begin{frame} 450 | \frametitle{Methods of running elisp} 451 | \Large{ 452 | % requires the enumitem package 453 | \begin{itemize}[font=$\bullet$\scshape\bfseries] 454 | \item elisp file (.el)\\ 455 | (documentation 'main) ; C-x C-e at space to right of `)'.\\ 456 | (documentation 'main) ; C-M-x inside of the parentheses. 457 | \vspace{4mm} 458 | \item scratch buffer ; C-j 459 | \vspace{4mm} 460 | \item M-x eval-buffer ; evaluate whole buffer 461 | \item M-x eval-region ; evaluate region 462 | \end{itemize} 463 | } 464 | \end{frame} 465 | \note{ 466 | LISP is a contraction of List Processing. 467 | Lists are the 468 | ElISP Here are some examples of images made in PyMOL on the covers of leading journals. 469 | } 470 | 471 | %%%%%%%%%%%%%%%%%%%%%% 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 472 | 473 | 474 | % Slide 2 475 | \begin{frame} 476 | \frametitle{Elisp REPLs (3 options inside Emacs)} 477 | \Large{ 478 | % requires the enumitem package 479 | \begin{itemize}[font=$\bullet$\scshape\bfseries] 480 | \item M-: ; REPL in mini buffer 481 | \vspace{4mm} 482 | \item M-x ielm ; eval one expression at a time\\ 483 | (defalias 'erepl 'ielm) \\ 484 | M-x erepl 485 | \vspace{4mm} 486 | \item M-x eshell 487 | \end{itemize}} 488 | \end{frame} 489 | \note{ 490 | The first option is to use ielm, which is in MELPA. 491 | This name is not easy to remember. 492 | I defined an alias to erepl. 493 | 494 | Outside of Emacs, you define an alias. 495 | 496 | https://github.com/kanaka/mal 497 | } 498 | 499 | 500 | \defverbatim[colored]\exampleCodeA{ 501 | \large{ 502 | \begin{elispcode} 503 | alias erepl="rlwarp emacs --batch --eval \"(progn (require 'cl) (loop (print (eval (read)))))\"" 504 | \end{elispcode} 505 | } 506 | } 507 | 508 | % Slide 2 509 | \begin{frame} 510 | \frametitle{elisp REPL ouside of Emacs} 511 | \Large{ 512 | \exampleCodeA 513 | Source: \url{https://www.reddit.com/r/emacs/comments/58ciar/question_can_elis_be_run_outside_of_emacs/} 514 | } 515 | \end{frame} 516 | \note{ 517 | The first option is to use ielm, which is in MELPA. 518 | This name is not easy to remember. 519 | I defined an alias to erepl. 520 | 521 | Outside of Emacs, you define an alias. 522 | 523 | https://github.com/kanaka/mal 524 | } 525 | 526 | 527 | 528 | 529 | \defverbatim[colored]\exampleCodeC{ 530 | \large{ 531 | \begin{pythoncode} 532 | #!emacs --script 533 | (defun main () 534 | "Print the version of Emacs and print arguments as a list. 535 | Example: chmod +x test5.el && ./test5.el dog cat 536 | Modified test4.el script by Dr. John Kitchin found here: 537 | https://kitchingroup.cheme.cmu.edu/blog 538 | /2014/08/06/Writing-scripts-in-Emacs-lisp/" 539 | (print (version)) 540 | (print (format "Called with %s" command-line-args)) 541 | (print (format "You did it! You passed in %s!" command-line-args-left)) 542 | (print (format "This is the documentation string for main(): 543 | %s" (documentation 'main))) ) 544 | (when (member "-scriptload" command-line-args) (main)) 545 | \end{pythoncode} 546 | } 547 | } 548 | % Slide 24 549 | \begin{frame} 550 | \frametitle{Elisp script} 551 | \exampleCodeC 552 | \end{frame} 553 | 554 | 555 | 556 | 557 | 558 | \defverbatim[colored]\exampleCodeC{ 559 | \large{ 560 | \begin{pythoncode} 561 | #+BEGIN_SRC emacs-lisp :results value scalar 562 | (*40 1000 1000 1000 1000 1000 1000 1000) 563 | #+END_SRC 564 | #+RESULTS: 565 | : 40000000000000000000 566 | \end{pythoncode} 567 | } 568 | } 569 | % Slide 24 570 | \begin{frame} 571 | \frametitle{Code block with output in the RESULTS drawer} 572 | Place cursor inside code block and enter C-c C-c to run the code. 573 | \exampleCodeC 574 | Note that the ``:results value scalar'' was needed with emacs-lisp. 575 | In the org-babel configuration, emacs-lisp has to be in the list of languages. 576 | \end{frame} 577 | 578 | 579 | \defverbatim[colored]\exampleCodeC{ 580 | \large{ 581 | \begin{pythoncode} 582 | (setq show-paren-delay 0) 583 | (show-paren-mode t) 584 | \end{pythoncode} 585 | } 586 | } 587 | % Slide 24 588 | \begin{frame} 589 | \frametitle{Config for matching parentheses} 590 | \exampleCodeC 591 | \textquotesingle{} 592 | \end{frame} 593 | 594 | --------------------------------------------------------------------------------