% -*- coding: raw-text-unix -*-

\documentclass{beamer}
\usepackage{beamerthemesplit}
\usepackage[brazilian,english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}

\catcode`=13 \def{$\bullet$}
\catcode`=13 \def{\item}
\catcode`=13 \long\def{\par}
\def\xtot#1{\xrightarrow{\text{#1}}}
\def\xtote{\xrightarrow{\;\;\;\;}}
\def\mtot#1{\mapstochar\xrightarrow{\text{#1}}}
\def\mtote{\mapstochar\xrightarrow{\;\;\;\;}}

\def\newslide#1{\bigskip \hrule {\bf #1}}
\def\Newslide#1{\newpage \hrule {\bf #1}}
\long\def\myslide#1#2{\frame{\frametitle{#1}#2}}

%-------------------------------
\title{Emacs and eev, or: how to automate almost everything}
\author{Eduardo Ochs - http://angg.twu.net/}
\date{august 20, 2005}

\begin{document}

%-------------------------------
\frame{\maketitle}

%-------------------------------
\myslide{I heard it through the grapevine...}{
That Emacs is a text editor
\begin{itemize}
  \item that is huge,
  \item complicated,
  \item uses a lot of memory,
  \item	has horrible keybindings
\end{itemize}
\bigskip
But Emacs is the simplest {\sl extensible editor} possible.
}

%-------------------------------
\myslide{Another definition for Emacs}{
 Emacs is a {\sl Lisp environment}
 (created in the 1970s)
 and Lisp is a programming language
 (created in the 1950s).

\medskip

{\bf Eeeek, that's {\sl old!}}
 Geometry, integer numbers and fractions have thousands of years.
 The notion of number that we use nowadays is from 1858.\footnote{
    defined by ``Dedekind cuts'': \\
    0.999999999... = 1.0000000000... = 1
  }

\medskip
 {\bf What is a computer?}
 How do we make a machine that executes operations in sequence?
\begin{itemize}
   1822: Difference Engine (Charles Babbage; mechanic)
   1936: Turing Machine (Alan Turing; theoretical)
   ~1940+: electronic computers
\end{itemize}
}

%-------------------------------
\myslide{What is a computer?}{
 = Memory + processor
  \bigskip
 The processor reads a few bytes from the memory and
 ``executes an instruction'' ---
 the memory (the ``state'' of the computer) is modified.
  \bigskip
 A part of the memory corresponds to the pixels of the screen.
 Some positions of the memory correspond to the keyboard.
  \bigskip
 A computer like that is similar to a Turing machine. \\
 It is easy to build but hard to program.
}

%-------------------------------
\myslide{What is a program?}{
 (We're in 1950).
 How do we express a procedure as a series of steps?
 How do we make a machine that executes those steps for us?
\bigskip
 Consider: {\sl the people that are inventing computers and
  programming languages in 1950 are aware of the main ideas in 2500
  years of discussions.}
\bigskip

 {\bf 1950: Lisp.} Is is more natural (for humans) to express \\
algorithms in Lisp than in ``machine language".

\bigskip

Problem $\xtot{\phantom{aaaaaaaaaa} programmer \phantom{aaaaaaaaaa}}$
machine language

\medskip

Problem $\xtot{programmer}$ program in Lisp
}

%-------------------------------
\myslide{Objects in Lisp}{
Objects in Lisp can be of the following kinds:
\begin{itemize}
   Numbers: 0, 1, 2, -20, 3.14
   Strings: "", "AbC", " Foo bar", "(+ 1 2)"
   Symbols: a, b, nil, t, square, +, *
   Lists: (), (2 "two"), \\
    (* (+ 1 2) (+ 3 4)), \\
    (concat "abc" "def")
\end{itemize}

\bigskip

Trick: ALL the complex things will be implemented using lists, and
lists are constructed using `cons'es.

}

%-------------------------------
\myslide{How a traditional Lisp environment works}{

 LISP$>$ (+ 1 2)
 3
 LISP$>$ (* (+ 1 2) (+ 3 4))
 21
 LISP$>$ (setq a 5)
 5
 LISP$>$ a
 5
 LISP$>$ (* a a)
 25

\bigskip

"(+ 1 2)" $\mtot{read}$
(+ 1 2)   $\mtot{eval}$
3         $\mtot{print}$
"3"       $\quad$ (in the screen)
}

%-------------------------------
\myslide{How `eval' works}{

\begin{tabular}{lrrll}
  (* &       3 &       7) & $\mtote$ & 21 \\
  (* & (+ 1 2) & (+ 3 4)) & $\mtote$ & 21
\end{tabular}

\medskip

\begin{tabular}{rclcc}
  (setq & a & 22) & $\mtote$ & 22 \\
        & a &     & $\mtote$ & 22 \\
\end{tabular}

\medskip

\begin{tabular}{lll}
22    & $\mtote$ & 22    \\
"abc" & $\mtote$ & "abc" \\
t     & $\mtote$ & t     \\
nil   & $\mtote$ & nil   \\
()    & $\mtote$ & nil
\end{tabular}

\medskip

\begin{tabular}{lllll}
($<$ 1 2)   & $\mtote$ & t    && (true) \\
($<$ 2 0)   & $\mtote$ & nil  && (false)
\end{tabular}

\bigskip

\begin{tabular}{ccc}
(if ($<$ 1 2) "yes" "no") & $\mtote$ & "yes"
\end{tabular}

}

%-------------------------------
\myslide{Every thing in a Lisp system is a Lisp object}{

Functions (programs):

\begin{tabular}{ccc}
  5 & $\mtot{square}$ & 25      \\
  x & $\mtote$        & (* x x)
\end{tabular}

\medskip

square = (lambda (x) (* x x))

\medskip

 (setq a 22)
 (setq square 33)
 (defun square (x) (* x x))

\medskip

% (find-sh0 "cd /tmp/beamer/ && convert ~/IMAGES/diad_symbols.png symbols.eps")
% (find-eimage0 "~/IMAGES/diad_symbols.png")
$\includegraphics[scale=0.90]{twosymbols.eps}$
}

%-------------------------------
\myslide{How lists are built using "cons"}{

%% http://www.paulgraham.com/lib/paulgraham/jmc.ps
%% (code-ps "pgroots" "$S/http/www.paulgraham.com/lib/paulgraham/jmc.ps")
%% (find-pgrootspage 8)

% (find-sh0 "cd /tmp/beamer/ && convert ~/IMAGES/diad_lambdax.png lambdax.eps")
% (find-eimage0 "~/IMAGES/diad_lambdax.png")
$\includegraphics[scale=0.85]{lambdax.eps}$

\medskip

The state of the system is determined by the values of symbols.

\bigskip

It is possible to explain all Lisp in its entirety ({\sl all} details)
in one hour or less --- the hardest part is `eval'.

We don't have all that time now, but we don't need all the details of
how Lisp works --- and it's better to start by Emacs anyway.

}
%-------------------------------
\myslide{Extensible text editors}{
 The kernel of Emacs is the simplest
 extensible text editor possible.

\bigskip

 Early 1970s: TECO (the first extensible editor)
 Bad programming language, extensions were usually incompatible ---
  but people loved it anyway.
 How can we make the best extensible editor possible?

\bigskip

 Idea: take the most flexible programming language of all ---
  Lisp --- and add functions to make it into a text editor.

\bigskip

 Another important idea: the editor would be developed {\sl
  by the community}.

}

%-------------------------------
\myslide{Emacs = community (1)}{

% http://www.gnu.org/software/emacs/emacs-paper.html#SEC29
From $<$http://www.gnu.org/software/emacs/emacs-paper.html$>$
 (an article by Richard Stallman written in 1979):

\medskip

The programmable editor is an outstanding opportunity to learn to
program! A beginner can see the effect of his simple program on the
text he is editing; this feedback is fast and in an easily understood
form. Educators have found display programming to be very suited for
children experimenting with programming, for just this reason (see
LOGO).

\medskip

Programming editor commands has the additional advantage that a
program need not be very large to be tangibly useful in editing. A
first project can be very simple. One can thus slide very smoothly
from using the editor to edit into learning to program with it.

\medskip

(continues)
}

%-------------------------------
\myslide{Emacs = community (2)}{

(Continuing...)

\medskip

When large numbers of nontechnical workers are using a programmable
editor, they will he tempted constantly to begin programming in the
course of their day-to-day lives. This should contribute greatly to
computer literacy, especially because many of the people thus exposed
will be secretaries taught by society that they are incapable of doing
mathematics, and unable to imagine for a moment that they can learn to
program. But that won't stop them from learning it if they don't know
that it is programming that they are learning! According to Bernard
Greenberg, this is already happening with Multics EMACS.

}

%-------------------------------
\myslide{Emacs = community (3)}{

 How is this done?
 How do people learn Lisp?

\bigskip

 (Just some ideas; I haven't written the rest yet)
 (The Emacs loop: C-x C-f /tmp/foo $\xtote$ (find-file "/tmp/foo")
  $\xtot{eval}$ ...; refresh screen)
 (Windows, buffers, frames, keys, keymaps, modes)
 (The Lisp interpreter is easy to invoke: C-x C-e)
 (The source code is readily accesible, and quite readable)
 (Extensions that are well-written enough and considered important
  enough are included in Emacs, and become available to everyone ``by
  default'')
 (Documentation is considered extremely important: the manuals)
 (Example 1: (+ 1 2))
 (Example 2: source code with hyperlinks)

}


\end{document}



%:::::::::::::::::::::::::::::::::::::::






Idéias ainda não escritas:

aberto: se você quer saber como uma tecla funciona 

slides:
o que a gente programa:
M-?
find-fline
eev

buffers são "arquivos na memória"

Ordem no workshop: avaliação

M-?



#
# (find-eevfile "slides/")
cd ~/eev-current/slides/
latex         slides.tex && \
  dvips -o    slides.ps   slides.dvi   && \
  dvipdf      slides.dvi  slides.pdf   && \
  gzip -c9  < slides.ps > slides.ps.gz && \
  regv-beamer slides.ps
rm         -v slides.{aux,log,nav,out,snm,toc}

#
cd ~/eev-current/slides/
Scp -C {lambdax,twosymbols}.{svg,eps} \
  edrx@angg.twu.net:slow_html/eev-current/slides/

#
cd ~/eev-current/slides/
Scp -C slides.{tex,ps,ps.gz,pdf} \
  edrx@angg.twu.net:slow_html/eev-current/slides/

#

w prep-apti-X
alias apti='aptitude install'
aptitude install expect
aptitude install fvwm xzoom tkdiff
aptitude install latex-beamer gv
aptitude install unclutter
chmod 666 /var/cache/fonts/ls-R
laf /var/cache/fonts/ls-R
prep-apti-eev-full
prep-apti-X
