+;;; Speed considerations and a few caveats
+;;; --------------------------------------
+;;;
+;;; While the message passing and the colorization surely introduce some
+;;; overhead this has became so small that IMHO is surely outweighted by
+;;; the benefits you get but, as usual, YMMV
+;;;
+;;; Important caveat, when deciding the cursor/'grey keys' keycodes I had to
+;;; make a choice: on my Linux box this choice allows me to run all the
+;;; ncurses applications without problems but make these keys
+;;; uncomprehensible to all the cursesX programs. Your mileage may vary so
+;;; you may consider changing the default 'emulation'. Just search for this
+;;; piece of code and modify it as you like:
+;;;
+;;; ;; Which would be better: "\e[A" or "\eOA"? readline accepts either.
+;;; ;; For my configuration it's definitely better \eOA but YMMV. -mm
+;;; ;; For example: vi works with \eOA while elm wants \e[A ...
+;;; (defun term-send-up () (interactive) (term-send-raw-string "\eOA"))
+;;; (defun term-send-down () (interactive) (term-send-raw-string "\eOB"))
+;;; (defun term-send-right () (interactive) (term-send-raw-string "\eOC"))
+;;; (defun term-send-left () (interactive) (term-send-raw-string "\eOD"))
+;;;
+;;;
+;;; IMPORTANT: additions & changes
+;;; ------------------------------
+;;;
+;;; With this enhanced ansi-term.el you will get a reliable mechanism of
+;;; directory/username/host tracking: the only drawback is that you will
+;;; have to modify your shell start-up script. It's worth it, believe me :).
+;;;
+;;; When you rlogin/su/telnet and the account you access has a modified
+;;; startup script, you will be able to access the remote files as usual
+;;; with C-x C-f, if it's needed you will have to enter a password,
+;;; otherwise the file should get loaded straight away.
+;;;
+;;; This is useful even if you work only on one host: it often happens that,
+;;; for maintenance reasons, you have to edit files 'as root': before
+;;; patching term.el, I su-ed in a term.el buffer and used vi :), now I
+;;; simply do a C-x C-f and, via ange-ftp, the file is automatically loaded
+;;; 'as-root'. ( If you don't want to enter the root password every time you
+;;; can put it in your .netrc: note that this is -not- advisable if you're
+;;; connected to the internet or if somebody else works on your workstation!)
+;;;
+;;; If you use wu-ftpd you can use some of its features to avoid root ftp
+;;; access to the rest of the world: just put in /etc/ftphosts something like
+;;;
+;;; # Local access
+;;; allow root 127.0.0.1
+;;;
+;;; # By default nobody can't do anything
+;;; deny root *
+;;;
+;;;
+;;; ----------------------------------------
+;;;
+;;; If, instead of 'term', you call 'ansi-term', you get multiple term
+;;; buffers, after every new call ansi-term opens a new *ansi-term*<xx> window,
+;;; where <xx> is, as usual, a number...
+;;;
+;;; ----------------------------------------
+;;;
+;;; With the term-buffer-maximum-size you can finally decide how many
+;;; scrollback lines to keep: its default is 2048 but you can change it as
+;;; usual.
+;;;
+;;; ----------------------------------------
+;;;
+;;;
+;;; ANSI colorization should work well, I've decided to limit the interpreter
+;;; to five outstanding commands (like ESC [ 01;04;32;41;07m.
+;;; You shouldn't need more, if you do, tell me and I'll increase it. It's
+;;; so easy you could do it yourself...
+;;;
+;;; Blink, is not supported. Currently it's mapped as bold.
+;;;
+;;; Important caveat:
+;;; -----------------
+;;; if you want custom colors in term.el redefine term-default-fg-color
+;;; and term-default-bg-color BEFORE loading it.
+;;;
+;;; ----------------------------------------
+;;;
+;;; If you'd like to check out my complete configuration, you can download
+;;; it from http://www.polito.it/~s64912/things.html, it's ~500k in size and
+;;; contains my .cshrc, .emacs and my whole site-lisp subdirectory. (notice
+;;; that this term.el may be newer/older than the one in there, please
+;;; check!)
+;;;
+;;; This complete configuration contains, among other things, a complete
+;;; rectangular marking solution (based on rect-mark.el and
+;;; pc-bindings.el) and should be a good example of how extensively Emacs
+;;; can be configured on a ppp-connected ws.
+;;;
+;;; ----------------------------------------
+;;;
+;;; TODO:
+;;;
+;;; - Add hooks to allow raw-mode keys to be configurable
+;;; - Which keys are better ? \eOA or \e[A ?
+;;;
+;;;
+;;; Changes:
+;;;
+;;; V4.0 January 1997
+;;;
+;;; - Huge reworking of the faces code: now we only have roughly 20-30
+;;; faces for everything so we're even faster than the old md-term.el !
+;;; - Finished removing all the J-Shell code.
+;;;
+;;; V3.0 January 1997
+;;;
+;;; - Now all the supportable ANSI commands work well.
+;;; - Reworked a little the code: much less jsh-inspired stuff
+;;;
+;;; V2.3 November
+;;;
+;;; - Now all the faces are accessed through an array: much cleaner code.
+;;;
+;;; V2.2 November 4 1996
+;;;
+;;; - Implemented ANSI output colorization ( a bit rough but enough for
+;;; color_ls )
+;;;
+;;; - Implemented a maximum limit for the scroll buffer (stolen from
+;;; comint.el)
+;;;
+;;; v2.1 October 28 1996, first public release
+;;;
+;;; - Some new keybindings for term-char mode ( notably home/end/...)
+;;; - Directory, hostname and username tracking via ange-ftp
+;;; - Multi-term capability via the ansi-term call
+;;;
+;;; ----------------------------------------------------------------
+;;; You should/could have something like this in your .emacs to take
+;;; full advantage of this package
+;;;
+;;; (add-hook 'term-mode-hook
+;;; (function
+;;; (lambda ()
+;;; (setq term-prompt-regexp "^[^#$%>\n]*[#$%>] *")
+;;; (make-local-variable 'mouse-yank-at-point)
+;;; (make-local-variable 'transient-mark-mode)
+;;; (setq mouse-yank-at-point t)
+;;; (setq transient-mark-mode nil)
+;;; (auto-fill-mode -1)
+;;; (setq tab-width 8 ))))
+;;;
+;;;
+;;; ----------------------------------------
+;;;
+;;; If you want to use color ls the best setup is to have a different file
+;;; when you use eterm ( see above, mine is named .emacs_dircolors ). This
+;;; is necessary because some terminals, rxvt for example, need non-ansi
+;;; hacks to work ( for example on my rxvt white is wired to fg, and to
+;;; obtain normal white I have to do bold-white :)
+;;;
+;;; ----------------------------------------
+;;;
+;;;
+;;; # Configuration file for the color ls utility
+;;; # This file goes in the /etc directory, and must be world readable.
+;;; # You can copy this file to .dir_colors in your $HOME directory to
+;;; # override the system defaults.
+;;;
+;;; # COLOR needs one of these arguments: 'tty' colorizes output to ttys, but
+;;; # not pipes. 'all' adds color characters to all output. 'none' shuts
+;;; # colorization off.
+;;; COLOR tty
+;;; OPTIONS -F
+;;;
+;;; # Below, there should be one TERM entry for each termtype that is
+;;; # colorizable
+;;; TERM eterm
+;;;
+;;; # EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)
+;;; EIGHTBIT 1
+;;;
+;;; # Below are the color init strings for the basic file types. A color init
+;;; # string consists of one or more of the following numeric codes:
+;;; # Attribute codes:
+;;; # 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
+;;; # Text color codes:
+;;; # 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
+;;; # Background color codes:
+;;; # 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
+;;; NORMAL 00 # global default, although everything should be something.
+;;; FILE 00 # normal file
+;;; DIR 00;37 # directory
+;;; LINK 00;36 # symbolic link
+;;; FIFO 00;37 # pipe
+;;; SOCK 40;35 # socket
+;;; BLK 33;01 # block device driver
+;;; CHR 33;01 # character device driver
+;;;
+;;; # This is for files with execute permission:
+;;; EXEC 00;32
+;;;
+;;; # List any file extensions like '.gz' or '.tar' that you would like ls
+;;; # to colorize below. Put the extension, a space, and the color init
+;;; # string. (and any comments you want to add after a '#')
+;;; .tar 01;33 # archives or compressed
+;;; .tgz 01;33
+;;; .arj 01;33
+;;; .taz 01;33
+;;; .lzh 01;33
+;;; .zip 01;33
+;;; .z 01;33
+;;; .Z 01;33
+;;; .gz 01;33
+;;; .jpg 01;35 # image formats
+;;; .gif 01;35
+;;; .bmp 01;35
+;;; .xbm 01;35
+;;; .xpm 01;35
+;;;
+;;;
+;;; ----------------------------------------
+;;;
+;;; Notice: for directory/host/user tracking you need to have something
+;;; like this in your shell startup script ( this is for tcsh but should
+;;; be quite easy to port to other shells )
+;;;
+;;; ----------------------------------------
+;;;
+;;;
+;;; set os = `uname`
+;;; set host = `hostname`
+;;; set date = `date`
+;;;
+;;; # su does not change this but I'd like it to
+;;;
+;;; set user = `whoami`
+;;;
+;;; # ...
+;;;
+;;; if ( eterm =~ $TERM ) then
+;;;
+;;; echo --------------------------------------------------------------
+;;; echo Hello $user
+;;; echo Today is $date
+;;; echo We are on $host running $os under Emacs term mode
+;;; echo --------------------------------------------------------------
+;;;
+;;; setenv EDITOR emacsclient
+;;;
+;;; # Notice: $host and $user have been set before to 'hostname' and 'whoami'
+;;; # this is necessary because, f.e., certain versions of 'su' do not change
+;;; # $user, YMMV: if you don't want to fiddle with them define a couple
+;;; # of new variables and use these instead.
+;;; # NOTICE that there is a space between "AnSiT?" and $whatever NOTICE
+;;;
+;;; # These are because we want the real cwd in the messages, not the login
+;;; # time one !
+;;;
+;;; set cwd_hack='$cwd'
+;;; set host_hack='$host'
+;;; set user_hack='$user'
+;;;
+;;; # Notice that the ^[ character is an ESC, not two chars. You can
+;;; # get it in various ways, for example by typing
+;;; # echo -e '\033' > escape.file
+;;; # or by using your favourite editor
+;;;
+;;; foreach temp (cd pushd)
+;;; alias $temp "$temp \!* ; echo '\eAnSiTc' $cwd_hack"
+;;; end
+;;; alias popd 'popd ;echo "\eAnSiTc" $cwd'
+;;;
+;;; # Every command that can modify the user/host/directory should be aliased
+;;; # as follows for the tracking mechanism to work.
+;;;
+;;; foreach temp ( rlogin telnet rsh sh ksh csh tcsh zsh bash tcl su )
+;;; alias $temp "$temp \!* ; echo '\eAnSiTh' $host_hack ; \
+;;; echo '\eAnSiTu' $user_hack ;echo '\eAnSiTc' $cwd_hack"
+;;; end
+;;;
+;;; # Start up & use color ls
+;;;
+;;; echo "\eAnSiTh" $host
+;;; echo "\eAnSiTu" $user
+;;; echo "\eAnSiTc" $cwd
+;;;
+;;; # some housekeeping
+;;;
+;;; unset cwd_hack
+;;; unset host_hack
+;;; unset user_hack
+;;; unset temp
+;;;
+;;; eval `/bin/dircolors /home/marco/.emacs_dircolors`
+;;; endif
+;;;
+;;; # ...
+;;;
+;;; # Let's not clutter user space
+;;;
+;;; unset os
+;;; unset date
+;;;
+;;;