diff --git a/lp-in-org.org b/lp-in-org.org index bca0909..1f2e280 100644 --- a/lp-in-org.org +++ b/lp-in-org.org @@ -128,9 +128,48 @@ Since Emacs comes with Org, and Org comes with the ability to write literate pro Since Emacs comes with Lisp, this *Getting Started* guide will use that language for our examples. In subsequent chapters, we will describe how to use different languages. ** Create a File -Create an org file. Set some variables. +Create or open an Org file, and type the following: + +#+begin_example +,#+begin_src emacs-lisp + "Hello World" +,#+end_src +#+end_example + +Next, type ~C-c C-c~ (Control-c twice) and Emacs asks if you want to evaluate this code. To see the /results/ of evaluating that expression inserted back into your buffer after the marker, =RESULTS=, type =yes=. + +While a classic, not a very good example. Let’s try again with the following code block: + +#+begin_example +,#+begin_src emacs-lisp + (truncate (* (sin .438) 100)) +,#+end_src +#+end_example + +Now type ~C-c C-c~ again. Notice the answer to the Great Question of Life, the Universe, and Everything appears as the =RESULTS= of evaluating your amazing Lisp code. + +That, my friend, is the beginning of your adventure. + +A few points. First, you typed a lot of stuff to see a number or string. We’ll start to file away such roughness to your workflow. This book contains a lot of tips, and you’ll see that programming literately can be just as fast as regular programming. + +Second, the part, =emacs-lisp= is the language or subsystem to call for evaluation of a code block. We’ll show how you can use your favorite language, or even systems to generate images, call web services, and update tables in a database. + +** Creating src Blocks Quickly + +You don’t have to type the entire text for src blocks, as Org comes with this ability, [[info:org#Structure Templates][Structure Templates]]. Type ~C-c C-,~ and a buffer appears allowing you to type ~s~ to have the bulk of the =src= code block inserted into your buffer. + +Another approach is to use =org-tempo=, a template expansion feature. To kick-start this feature, press ~M-S-;~ and type the following: + +#+begin_src emacs-lisp + (require 'org-tempo) +#+end_src + +Note: If you are reading this in an Emacs buffer, you can also place your cursor at the end of that parenthesized s-expression and type ~C-x C-e~ to evaluate it. + +At this point, you can begin a line with =