|
Edrx's Emacs page
Home is where my .emacs is.
I use Emacs+eev as my main interface to the
system. Main reason: executable notes.
A quote from Neil Stephenson's "In the Beginning
it was the Command Line":
In other words, the engineer-hours that, in the case of Microsoft
Word, were devoted to features like mail merge, and the ability to
embed feature-length motion pictures in corporate memoranda, were,
in the case of emacs, focused with maniacal intensity on the
deceptively simple-seeming problem of editing text. If you are a
professional writer - i.e., if someone else is getting paid to
worry about how your words are formatted and printed - Emacs
outshines all other editing software in approximately the same way
that the noonday sun does the stars. It is not just bigger and
brighter; it simply makes everything else vanish. For page layout
and printing you can use TeX: a vast corpus of typesetting lore
written in C and also available on the Net for free.
From a paper by RMS on Emacs written in 1981:
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).
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.
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.
Note that eev takes the idea of "...need not be very large..." to
the extreme: most eev "programs" are one-liners. See:
The book "Free as in
Freedom" has a chapter about Emacs.
The best way to see what's going on in the Emacs World is to visit
Sacha Chua's blog.
The rest of this page is very old - pre-2015!
I use GNU Emacs. I don't know how to make my glyphs
work in XEmacs.
These days I tend to use Emacs on X, on Fvwm.
Quick index:
1. General links
I used to use IRC a lot. My favourite IRC client is
rcirc (its EmacsWiki page, rcirc stuff in my .emacs).
Some links on dynamic scoping vs. lexical scoping: an IRC log, a bigger discussion, a section about
that in an old Emacs paper, the "Dynamic Scope Analysis" paper.
Emacs Lisp is a Lisp-2.
CVS Emacs:
Etc:
Org, Howm and Planner
Tramp (and $ASROOT); rcirc, circe, bitlbee
Things to try: screen-lines.el, two-mode-mode.el (see also this)
Do you think that this page is unreadable? Sorry human animal! Xah Lee thinks that
too! But I am a unix moron,
what can I do?
2. What is eev
(2007oct15: Note: this is a very short introduction to eev, written
mainly for people who already know Emacs well enough. The material
that I use to explain Emacs and eev at the same time for people
unfamiliar with Emacs is below. This is very incomplete.)
I use eev to make Emacs be my main interface with the system.
Eev lets me "record" what I do into plain text files, in ways that
can be "played back" later easily; I call these text files
"e-scripts".
There is no way to run an e-script file all at once - e-scripts are
not like scripts, they are more like "executable notes", or
"executable logs"; we can select blocks in them and then say to Emacs
to execute those blocks in a certain way. The two most basic ways are:
(1) "go to the end of this line and execute the sexp before point"
(this is bound to M-e in eev-mode, and is roughly equivalent
to C-e C-x C-e, and (2) "send the current line to a program
(typically a shell) running in another buffer"; this is bound to F8
(`eepitch-this-line').
Way (1) is mainly for recording links to interesting information,
using sexps as hyperlinks. For example:
Way (2) is for recording commands to be sent to external programs -
mainly to the shell. There's a trick: when the current line starts
with a red star glyph the rest of the line is executed as Lisp,
not sent; this is used to set up the "eepitch target". For example:
There are other ways to send commands to external programs, but
they require some setup (like patching rcfiles):
3. A short Emacs tutorial
(Started in 2007jul23. Work in progress.)
Most Emacs tutorials, for example this
"guided tour"
from gnu.org,
treat Emacs as an editor that can "edit" anything that looks like
text -
files,
directories,
manpages,
help,
shell sessions,
the source code of programs,
debugging sessions,
etc. I don't like this approach very much; it makes people feel
overwhelmed. I prefer to see Emacs as a Lisp environment that
people have used to build several kinds of editors and tools.
A bit of history (simplified, but not far from the truth): in the middle of 1970s
people were starting to experiment with programmable (i.e.,
extensible) text editors, but most of the time what they were getting
were systems where one person's extensions wouldn't be easily reusable
by other people. For example, if Alice had programmed some functions
to make it easier to edit e-mails then Bob would find Alice's
extensions very hard to understand, and they would probably not work
if Bob tried to use them together with his own extensions... But then
at some point some people said: "hey, instead of taking an existing
text editor and trying to make it programmable, let's take this
programming language here, Lisp, that is very easy to extend and to
modify, and let's add a few functions to it so that it will also
behave as a very primitive text editor; then we will add the rest" -
and this worked VERY well, and this was the core of Emacs; so Emacs is
a Lisp on top of which hundreds, or thousands, of modules have been
added, and these modules can be understood each one separately from
the others.
In Emacs the Lisp is "very close to the surface", always
accessible, and if we present some basic things about it as soon as
possible - I always do that in the first 5 minutes when I'm
explaining Emacs to people - then everything becomes simpler. In
the boxes below the "(functionname argument ...) " things with
hyperlinks are small Lisp programs - "one-liners" - whose actions
are somehow correspondent to following the hyperlink at the `") '; the link at the `functionname ' points to more detailed
explanations of what those one-line programs do.
Commands, keys, prefixes, aborting, completion
==============================================
Commands in Emacs can be several keys long,
and all commands have names and can be invoked
by their names - for example, `M-x find-file'.
The prefixes "C-" and "M-" mean "Control" and
"Meta"; on most keyboards "Meta" is "Alt".
To abort a partially-typed command use `C-g'.
(find-enode "Keys" "key sequence")
(find-enode "User Input" "`Control-a'" "usually written `C-a'")
(find-enode "User Input" "<META> key")
(find-enode "M-x" "Running Commands by Name")
(find-enode "Quitting" "`C-g'")
The TAB key can be used for completion in M-x,
and in many other situations.
(find-enode "Completion")
|
Files, Buffers, Windows, Frames, Display, etc
=============================================
Emacs can edit several files at the same time, each one
in a "buffer".
(find-enode "Files")
(find-enode "Buffers")
(find-enode "Windows")
(find-enode "Frames")
The display of Emacs looks like this:
(TODO: create a real screenshot.)
__ _ _
______________emacs_______\/|-|X|
/ | | \
| | bla | | Emacs
Window | | | | calls this
managers | | | | a "window".
call | | | /
this a | |--:** foo.txt (Fundamental) ----| <-- Its "modeline".
"window". / | | \
Emacs \ | bla bla | | Another
calls | | bleh | | window.
this a | | | |
"frame". | | | /
| |--:** bar.txt (Fundamental) ----| <-- Its modeline.
\ |Find file: ~/bletch.txt__________| <-- The minibuffer.
The bottom line of a frame is sometimes the "echo area",
sometimes the "minibuffer". The minibuffer acts like a
window when it is active, and `C-x o' can be used to move
from it to the "normal windows" and back. You can also
use the mouse to move between windows.
(find-enode "Other Window")
|
4. A minimal roadmap/tutorial for eev
(Started in 2007aug24. Work in progress.)
Not all links work at this moment - the red words are "future links"...
Sending commands to shells (screenshot):
M-x eev save the region into $EE
M-x eev-bounded save the bounded region into $EE
F3 run the default bounded action
"ee" in a execute the commands in $EE
prepared shell (verbosely; $EE is a temporary script)
Sending one line to a shell:
F8 send to an M-x shell buffer
F9 send to an xterm listening on a channel
F8 and F9 treat red-star lines specially (as Lisp):
* (eepitch-shell) set the target for F8
* (eepitch-kill) kill the current eepitch target
* (eexterm "A") set the target for F9; create an xterm if needed
* (eexterm-kill) kill the current eexterm
|
Commands to convert the current line into hyperlinks (by "wrapping"):
M-F -- wrap the current line in a `find-fline'
M-M -- wrap the current line in a `find-man'
M-S -- wrap the current line in a `find-sh'
M-T -- generate an "* (eepitch-{xxx,kill,xxx})" block (three lines).
Typical usage: type "shell", then `M-T', then `F8's on the result.
M-D -- treat the contents of the current line as the name of a Debian
package and produce three hyperlinks from it
M-C -- treat the contents of the current line as a "code" and a
"directory" and produce a `code-c-d' and a `find-_file' sexps
from it
(Note that the key sequences above use uppercase letters - to obtain
`M-F', type `meta-shift-t').
Commands to generate pages with lists of hyperlinks (in a separate buffer):
M-h f -- hyperlinks to the current file
M-h M-f -- hyperlinks to an Emacs function
M-h M-i -- hyperlinks to the current Info node
M-h M-k -- hyperlinks to a key sequence and to the function
associated to it
M-h M-v -- hyperlinks to an Emacs variable
M-h M-s -- hyperlinks to a face (default: face at point)
M-h M-m -- hyperlinks to a manpage (ask for name)
M-h m -- hyperlinks to a manpage (being viewed)
M-h M-d -- hyperlinks about a Debian package
|
Editing:
C-q C-o insert a red star glyph: "*"
(a typical delimiter for F3 is "\n#*\n")
M-h M-2 duplicate the current line
M-h M-y refine a hyperlink
Basic cut & paste keys (not eev-specific)
C-SPC set the mark
C-x C-x exchange point and mark
M-w copy
C-w cut
C-y paste
C-k kill-this-line
|
Turning eev-mode on (with M-x eev-mode) has only two effects:
the keymap eev-mode-map becomes active, and `pop-up-windows'
becomes nil (this makes `M-e', `M-E', `M-k', and `M-K' behave better).
Turning eev-mode off deactivates the keymap and restores the value of
`pop-up-windows'.
The easy way to try eev is to download and unpack the tarball somewhere,
mkdir ~/eev-current/
cd ~/eev-current/
wget http://angg.twu.net/eev-current.tar.gz
tar -xvzf eev-current.tar.gz
and then load it and activate it with:
(add-to-list 'load-path "~/eev-current/")
(require 'eev-all)
(eev-mode 1)
The effects of "(require 'eev-all)" are: lots of functions are defined
(mainly for hyperlinks); some environment variables are set ($EE,
$EEVTMPDIR, etc), but only in Emacs and in programs started from
Emacs; and a few glyphs are defined.
The "full instalation" for eev involves changing some rcfiles -
.emacs, .bashrc, etc. This can be done semi-automatically (see
eev-rctool and the INSTALL file) and is trivial to undo. If you try
eev without changing rcfiles then M-x eev and F3 will not work
properly, in the sense that the shortcut "ee" to execute the temporary
script file - a shell function - will not be defined.
|
5. A 2D map of eev
(Started in 2010sep10. Work in progress.)
At some point this will be a very compact - yet complete - guide to
all the main ideas and features of eev, in a nice order, with the most
basic ones coming first in each block...
6. Call Diagrams (for some parts of eev)
A diagram for the `find-fline'/`find-node' family:
The `eev' family:
Diagrams for the steppers:
eesteps:
. <f12> ----> eesteps-do-step
| \
| v
M-e ----> eesteps | eesteps-perform
| | |
v v v
eesteps-list eek eek0
eesteps-pos
|
eepaste:
M-P ----> eepaste-one-line
| \
v v
M-w ----> kill-ring (insert line)
(call-interactively (key-binding "\r"))
|
eepitch:
eechannel:
7. Debugging Emacs with elisp hyperlinks
I should have sent this idea to emacs-devel, but I didn't...
http://lists.gnu.org/archive/html/emacs-devel/2007-06/msg00517.html
(find-efunctiondescr 'find-file)
(find-efunctiondescr 'find-file "files.e")
(find-efunctiondescr 'find-file "files.e" '(eek "RET"))
(find-efunctiondescr 'find-file "files.e" '(eek "M-h M-k RET"))
(find-efunctiondescr 'find-file "files.e" '(eek "M-x push-button"))
(find-efunctiondescr 'find-file "files.e" '(push-button (point)))
(find-efunctiondescr 'find-file "files.e" '(progn (debug) (push-button (point))))
(find-efunctiondescr 'find-file "files.e" '(find-epp (button-at (point))))
(find-efunctiondescr 'find-file "files.e" '(button-activate (button-at (point))))
(find-efunctiondescr 'find-file "files.e" '(find-epp (button-get (button-at (point)) 'action)))
(find-efunctiondescr 'find-file "files.e" '(find-epp (button-get (button-at (point)) 'action)))
(find-efunctiondescr 'find-file "files.e" '(help-button-action (button-at (point))))
(find-efunctiondescr 'find-file "files.e" '(find-epp help-button-action (button-at (point))))
(find-efunction 'push-button)
(find-efunction 'button-activate)
(find-efunction 'help-button-action)
(find-efunctiondescr 'find-file "files.e" '(find-epp (button-start (button-at (point)))))
(find-efunctiondescr 'find-file "files.e" '(find-epp (button-get (button-at (point)) 'help-function)))
(find-efunctiondescr 'find-file "files.e" '(find-epp (button-get (button-at (point)) 'help-args)))
(find-efunctiondescr 'find-file "files.e" '(find-epp (button-get (button-at (point)) 'help-function)))
(find-efunctiondescr 'find-file "files.e" '(find-efunctiond (button-get (button-at (point)) 'help-function)))
(find-egrep "grep -nH -e 'Unable to find location in file' $(find * -name '*.el')")
(find-efile "help-mode.el" "define-button-type 'help-function-def")
(find-efile "help-mode.el" "define-button-type 'help-variable-def")
(find-efile "help-mode.el" "define-button-type 'help-face-def")
(load "help-mode.el")
(find-efunctiondescr 'find-file "files.e" '(find-epp (button-get (button-at (point)) 'help-function)))
(load "help-mode.elc")
(find-efunctiondescr 'find-file "files.e" '(find-epp (button-get (button-at (point)) 'help-function)))
|
8. The unibyte<->multibyte bridge
2008oct21: My green guillemet glyphs do not work well in multibyte
buffers - functions based on find-anchor, mkto and
eev-compose-two-keys fail in weird ways. I'm trying to understand how
Emacs converts between unibyte and multibyte, in strings, buffers and
files, to fix this...
;;--------snip,snip--------
;; -*- coding: latin-1 -*-
;; (save-this-block-as "/tmp/4.txt")
(setq <<foo>> "\253foo\273")
(setq <<foo>>uni (string-to-unibyte <<foo>>))
(setq <<foo>>multi (string-to-multibyte <<foo>>))
(setq <<foo>>uni+ (decode-coding-string <<foo>>uni 'iso-8859-1))
(setq <<foo>>multi+ (decode-coding-string <<foo>>multi 'iso-8859-1))
;; Note: <<foo>>uni is unibyte,
;; but <<foo>>uni+ is multibyte
;; (and <<foo>>uni+ = <<foo>>multi+)
(multibyte-string-p <<foo>>)
(multibyte-string-p <<foo>>uni)
(multibyte-string-p <<foo>>multi)
(multibyte-string-p <<foo>>uni+)
(multibyte-string-p <<foo>>multi+)
(insert 171 "foo" 187)
(search-backward <<foo>>uni)
(search-backward <<foo>>multi)
(search-backward <<foo>>uni+)
(search-backward <<foo>>multi+)
;;--------snip,snip--------
|
9. eejump
Here's something that I've been using a lot lately... The full
version is here; the code below is a miniature that
just shows the main idea. Further reading: this and this.
;; eejump (M-j):
;; M-1 M-j opens a certain file,
;; M-2 M-j opens another file,
;; when the argument is 11, 22, 33 or 44 do something special,
;; like changing the font;
;; with no argument or with an unrecognized argument jump to
;; the definition of eejump in ~/.emacs; then we can see which
;; numbers correspond to which actions (the source is the
;; documentation!), and we can change the definition if needed -
;; just run C-x C-e (eval-last-sexp) at the right place to make
;; the changes apply.
;;
(global-set-key (kbd "M-j") 'eejump)
(defun eejump (arg) (interactive "P")
(cond ((eq arg 1) (find-file "~/NOTES"))
((eq arg 2) (find-file "~/otherfile.txt"))
;;
((eq arg 11) (set-frame-font "fixed"))
((eq arg 22) (set-frame-font "terminus-16"))
((eq arg 33) (set-frame-font "terminus-bold-16"))
((eq arg 44) (set-frame-font "10x20"))
(t (find-function 'eejump))))
|
10. palette
This is just a proof of concept for another idea... given a region
and a list of names - say, ("foo" "bar") - go through each word
of the region, and when the word is in the list convert it to a button
whose action is to jump to an anchor with that name in an index buffer
(that index buffer can be something like this, but using anchors and sexps).
The code is here.
11. Flipbooks
eev-sshot.el, for
screenshots and flipbook animations (2006oct02).
Three flipbooks (suggestion: open them in new browser tabs):
Some notes about a javascript-based interface are here.
12. Editing XPM favicons in Emacs
Here: myxpm.el. The favicons can be seen in my
main page. No docs yet.
|