Added a Getting Started section

Coming along, but we might want to think about a templating system to
make this easy.
This commit is contained in:
Howard Abrams 2024-08-03 21:38:51 -07:00
parent 76c2f69cca
commit f81f9b4487

View file

@ -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. Lets 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. Well start to file away such roughness to your workflow. This book contains a lot of tips, and youll 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. Well 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 dont 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 =<s= and hit ~TAB~ to have a src block expanded, with the cursor left at the end of first line, allowing you to type =emacs-lisp=.
This is Emacs, you probably have your favorite template expansion, like [[https://elpa.gnu.org/packages/doc/tempel/tempel.html][TempEL]] or [[https://www.emacswiki.org/emacs/Yasnippet][Yasnippet]], as any system that can generate your text works fine.The magic isnt hidden in markers, but shines plainly in the text itself.
Create a code block.
* Working with Python
* Calling out to the Shell
Can we do both Bash, Fish and Powershell?