From f617db13b0685c674817a6c7c1d148da3c07081f Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Thu, 16 Feb 2006 14:18:50 +0000 Subject: [PATCH] Initial import of my profile. Organization: Straylight/Edgeware From: Mark Wooding --- Xdefaults | 191 ++++++ bash_logout | 8 + bash_profile | 190 ++++++ bashrc | 226 ++++++ clisprc.lisp | 1 + cmucl-init.lisp | 1 + dircolors | 80 +++ dot-emacs.el | 1742 +++++++++++++++++++++++++++++++++++++++++++++++ emacs | 503 ++++++++++++++ emacs-Makefile | 7 + emacs-calc | 111 +++ lisp-init.lisp | 7 + mailrc | 14 + sbclrc | 1 + screenrc | 3 + setup | 184 +++++ signature | 1 + vm | 98 +++ xinitrc | 113 +++ xsession | 8 + 20 files changed, 3489 insertions(+) create mode 100644 Xdefaults create mode 100644 bash_logout create mode 100644 bash_profile create mode 100644 bashrc create mode 120000 clisprc.lisp create mode 120000 cmucl-init.lisp create mode 100644 dircolors create mode 100644 dot-emacs.el create mode 100644 emacs create mode 100644 emacs-Makefile create mode 100644 emacs-calc create mode 100644 lisp-init.lisp create mode 100644 mailrc create mode 120000 sbclrc create mode 100644 screenrc create mode 100755 setup create mode 100644 signature create mode 100644 vm create mode 100755 xinitrc create mode 100755 xsession diff --git a/Xdefaults b/Xdefaults new file mode 100644 index 0000000..31331a2 --- /dev/null +++ b/Xdefaults @@ -0,0 +1,191 @@ +! +! .Xdefaults +! + +#define NICEFONT -adobe-helvetica-medium-r-normal--10-*-*-p-*-iso8859-1 +#define FIXED fixed + +! --- General configuration --- + +?*font: NICEFONT +?*background: lightgrey +?*foreground: black + +*cursor: left_ptr + +! --- Athena-related settings --- + +?*Text.background: white +?*AsciiSink*background: white +*Label.borderColor: lightgrey +?*List.background: white +*highlightThickness: 0 +*beNiceToColormap: false + +*useRight: true +*useBottom: true + +! --- Wily things --- + +wily*p9font: FIXED +wily*font: FIXED +wily*fixed: FIXED + +! --- Edwin --- + +edwin*font: FIXED + +! --- Special settings for xterm --- + +XTerm.vt100.geometry: 80x35 +XTerm.vt100.font: FIXED +XTerm.vt100.foreground: white +XTerm.vt100.background: black +XTerm*scrollBar: true +XTerm*saveLines: 1000 +XTerm*scrollTtyOutput: false +XTerm*scrollKey: true +XTerm*rightScrollBar: true + +XTerm*VT100*translations: #override \ + : scroll-back(1,halfpage) \n\ + : scroll-forw(1,halfpage) + +! --- XConsole settings --- + +XConsole*font: FIXED +XConsole*background: #002000 +XConsole*foreground: #54ff9f +XConsole*geometry: 485x455 + +! --- Emacs settings --- + +emacs.geometry: 78x33 +Emacs.pane.menubar.font: NICEFONT +Emacs.menu*.font: NICEFONT +Emacs.font: FIXED +Emacs.cursorColor: red +Emacs.bitmapIcon: true +Emacs*foreground: white +Emacs*background: black +Emacs.pane.menubar.foreground: black +Emacs.pane.menubar.background: lightgrey +Emacs.menu*foreground: black +Emacs.menu*background: lightgrey +Emacs.scrollbar*attributeBackground: lightgrey +Emacs.toolBar: 0 +Emacs.verticalScrollBars: right + +! --- VNC --- + +xvncviewer*shareDesktop: true +xvncviewer*desktop.translations: #override\n\ + F8: SendRFBEvent()\n\ + !CtrlEscape: ShowPopup() + +! --- Ytalk settings --- + +YTalk*font: FIXED + +! --- Xman --- + +xman*bothShown: true +xman*topBox: false +xman*manualBrowser.geometry: 500x888 +xman*manualPage.translations: #augment\n\ + Down: Page(Line, 1)\n\ + Up: Page(Line, -1)\n\ + Next: Page(Forward)\n\ + Prior: Page(Back) + +! --- Xlock --- + +xlock.mode: random +xlock.enablesaver: true +xlock*background: black +xlock*foreground: white +xlock*erasedelay: 100 +xlock*boil: true +xlock*trek: 0 + +phosphor*cursor: 333 +phosphor*delay: 60000 +phosphor*program: /usr/games/fortune +phosphor*font: fixed +phosphor*scale: 3 +phosphor*ticks: 20 +noseguy*program: /usr/games/fortune -s + +! --- XDvi --- + +XDvi.keepPosition: true +XDvi.shrinkFactor: 6 + +XDvi.background: white +XDvi.expert: true +XDvi.statusline: false +XDvi.Hush: true +XDvi.thorough: true +XDvi.gsAlpha: true +XDvi.not1lib: true + +xdvirv.background: black +xdvirv.foreground: white +xdvirv.highlight: black + +! --- xbiff --- + +xbiff*volume: 0 + +! --- tkinfo --- + +tkinfo*pagesep: 0 +tkinfo*showballoons: 0 +tkinfo*geometry: 80x54 +tkinfo*linkfont: FIXED +tkinfo*highlightfont: FIXED +tkinfo*searchfont: FIXED +tkinfo*Text.font: FIXED + +! --- xdaliclock --- + +xdaliclock*mode: 24 +xdaliclock*datemode: yy/mm/dd +xdaliclock*cycle: true +xdaliclock*memory: low +! xdaliclock*font: -*-palatino-bold-i-normal--*-360-*-*-p-*-iso8859-1 +xdaliclock*font: BUILTIN + +! --- xboard --- + +xboard*boardSize: small +xboard*firstChessProgram: crafty +xboard*secondChessProgram: crafty + +! --- Nasty window manager --- + +dtwm*iconPlacement: top right tight + +! --- XLess --- + +xless*labelFont: NICEFONT +xless*buttonFont: NICEFONT +xless*textFont: FIXED +xless*editorDoesWindows: true + +! --- Ghostview --- + +ghostview*page.background: white +ghostview*magstep: 2 + +! --- XZX --- + +xzx*scale: 2 +xzx*joyUp: q +xzx*joyDown: a +xzx*joyLeft: i +xzx*joyRight: o +xzx*joyFire: space +xzx*sound: true +xzx*mf128: true +xzx*libDir: .:/usr/lib/xzx:/usr/local/share/spectrum diff --git a/bash_logout b/bash_logout new file mode 100644 index 0000000..766d852 --- /dev/null +++ b/bash_logout @@ -0,0 +1,8 @@ +# +# $Id$ +# +# Bash logout things +# + +#[ -n "$__mdw_started_pixie" ] && \ +# pixie -C quit diff --git a/bash_profile b/bash_profile new file mode 100644 index 0000000..02a40c8 --- /dev/null +++ b/bash_profile @@ -0,0 +1,190 @@ +# +# $Id: .profile,v 1.3 1997/01/09 20:30:23 mdw Exp $ +# +# Bash startup things +# + +if [ -z "$__mdw_profile" ]; then + +export __mdw_profile=done + +# --- Add elements to a path string --- + +__mdw_addto () { + local var=$1 val dir=$2 new="" + eval "val=\$$var" + shift 2 + for i in "$@"; do + case "$new:" in *:$i:*) continue;; esac + [ -d $i ] || continue + case "X$val" in + X) + val=$i + continue + ;; + X$i) + continue + ;; + X*:$i:*) + val=`echo $val | sed -e "s=:$i:=:="` + ;; + X$i:*) + val=${val#$i:} + ;; + X*:$i) + val=${val%:$i} + ;; + esac + new=$new:$i + done + case $dir in + l) val=${new#:}:$val;; + r) val=$val$new;; + esac + export $var=$val +} + +# --- What sort of machine am I running on? --- + +export arch=`echo $MACHTYPE | tr 'A-Z' 'a-z'` + +# --- Set the path variable --- + +__mdw_addto PATH l \ + {,/usr{,/local}{,/X11R6}}{/bin,/sbin,/games} \ + $HOME{,/arch/{$arch,any-any-any}}/bin \ + /opt/nfast{/bin,/sbin} \ + $HOME/src/ncipher/scripts +export PLAN9=/usr/local/plan9 +__mdw_addto PATH r \ + $PLAN9/bin + +# --- And the same for manual pages --- + +case "$arch" in + *linux*) + MANPATH=`manpath -q` + ;; +esac +__mdw_addto MANPATH l \ + {/usr{,/local}{,/X11R6}{,/share}}/{man,catman} \ + $HOME/man + +# --- Work out my home directory --- +# +# This horrible trick resolves symbolic links. It enables resolving links, +# changes directory and displays the name of the directory in a subshell +# to avoid changing the current state. + +HOME=`(set -P; cd $HOME; pwd)` +cd $HOME + +# --- Where my mail comes from --- + +export MAIL=$HOME/Mailbox +export NAME="Mark Wooding" +export EMAIL="mdw@distorted.org.uk" +export QMAILINJECT=c + +# --- GIT environment things --- + +export GIT_AUTHOR_NAME=$NAME +export GIT_AUTHOR_EMAIL=$EMAIL +export GIT_COMMITTER_NAME=$NAME +export GIT_COMMITTER_EMAIL=$EMAIL + +# --- Various options for programs --- + +umask 002 + +[ -z "$HOST" ] && export HOST=`hostname` + +export EDITOR="emacs -nw"; export VISUAL="$EDITOR" +export TEXINPUTS=".:$HOME/lib/tex//:" + +__mdw_addto INFOPATH r $HOME/info /usr/info /usr/share/info /usr/local/info +__mdw_addto PERLLIB r $HOME/lib/perl + +[ -z "$LS_OPTIONS" ] && export LS_OPTIONS="-F" + +export RMBKP="-abc +q -i" + +export BASCAT="-l +n" + +export CVS_RSH=ssh +case $HOST in + metalzone | metalzone.* ) + export CVSROOT="/home/cvs/cvs" + export SVNROOT="file:///home/cvs/svn" + ;; + *) + export CVSROOT="metalzone.distorted.org.uk:/home/cvs/cvs" + export SVNROOT="svn+ssh://metalzone.distorted.org.uk/home/cvs/svn" + ;; +esac +export BECOME="--preserve-environment" + +export PAGER=`type -p less` METAMAIL_PAGER=`type -p less` +export LESS="-iqgRh1" +export LESSOPEN="|lesspipe.sh %s" +export LESSCHARSET=latin1 +# export MAKEFLAGS="-j4" +[ "$TMPDIR"] || eval `tmpdir -b` +export TMP=$TMPDIR +export PERL_READLINE_NOWARN=yes + +[ -z "$NNTPSERVER" ] && export NNTPSERVER=metalzone.distorted.org.uk +[ -z "$http_proxy" ] && export http_proxy="http://metalzone.distorted.org.uk:3128/" +[ -z "$ftp_proxy" ] && export ftp_proxy=$http_proxy + +export XUSERFILESEARCHPATH="$HOME/.Xapps/%N:/usr/lib/X11/%T/%N%S" + +export PS_PERSONALITY=gnu + +export NC_SITES=cam:bos + +# -- Disable core dumps --- + +ulimit -S -c 0 + +# --- Start an ssh authentication agent --- + +eval `start-ssh-agent -b` + +if [ -z "$__mdw_bashrc" ] && [ "$__mdw_force_secure_session" = "yes" ] || + ( tty="`tty`" devtty="(/dev/)?${tty#/dev/}" + { { { [ -e /etc/securetty ] && sectty=/etc/securetty; } || + { [ -e /etc/securettys ] && sectty=/etc/securettys; }; } && + egrep "$devtty" $sectty >/dev/null; } || + { [ -e /etc/default/login ] && + egrep "^CONSOLE=$devtty" /etc/default/login >/dev/null; } || + case "${tty#/dev/}" in + console|systty|tty[0-9]) true ;; + *) false ;; + esac ) +then + export __mdw_sechost="`hostname`" +fi + +[ -n "$DT" ] && trap "source $HOME/.bash_logout" EXIT + +# --- And a passphrase pixie --- + +if pixie --version >/dev/null 2>&1; then + pixie=${CATACOMB_PIXIE-$HOME/.catacomb/pixie} + if [ -S "$pixie" ] && pixie -C help >/dev/null 2>/dev/null; then + : + else + pixie -d 2>>$HOME/.catacomb/pixie.log + __mdw_started_pixie=yes + fi +fi + +# --- Now, if my .bashrc hasn't been run yet, run it --- +# +# Oh, don't do that if we don't have a terminal. + +[ -z "$__mdw_bashrc" ] && [ -t 0 ] && \ + [ -r $HOME/.bashrc ] && . $HOME/.bashrc + +fi diff --git a/bashrc b/bashrc new file mode 100644 index 0000000..6587800 --- /dev/null +++ b/bashrc @@ -0,0 +1,226 @@ +# +# $Id: .bashrc,v 1.6 1996/12/08 20:33:42 mdw Exp $ +# +# Bash session things +# + +if [ -z "$__mdw_bashrc" ]; then + +__mdw_bashrc=done + +[ -z "$__mdw_profile" -a -r $HOME/.bash_profile ] && . $HOME/.bash_profile +[ -r /etc/bashrc ] && . /etc/bashrc + +# --- First of all, set up the prompt string --- + +if [ -t 0 ]; then + + if [ "$TERM" = "dumb" ]; then + if (( EUID == 0 )); then PS1="# "; else PS1="\$ "; fi + PS2="> " + PS4="+ " + else + + case "$TERM" in + linux*|screen*|xterm*|vt100*) + bold='\[\]' unbold='\[\]' nl='\[ \]' ;; + *) + bold='' unbold='' nl='' ;; + esac + + if (( EUID == 0 )); then + left="«" right="»" + elif [ "$__mdw_tty" = "`tty`" ]; then + left="<" right=">" + else + left="[" right="]" + export __mdw_tty="`tty`" + fi + + if [ -z "$SSH_CLIENT" ] && + [ "$__mdw_sechost" != "`hostname`" ] + then + sec_l='(' sec_r=')' + fi + + PS1="$nl$bold$left$sec_l\\h$sec_r \\w$right$unbold" + PS2="$PS1 $bold>$unbold " + fi + +fi # is stdin a tty? + +# --- Little preferences --- + +notify=1 +set -b +shopt -u cdable_vars +shopt -s cdspell +shopt -s checkhash +shopt -s checkwinsize +shopt -s cmdhist +shopt -u dotglob +shopt -s expand_aliases +shopt -s extglob +shopt -s histappend +shopt -s histreedit +shopt -u histverify +shopt -s hostcomplete +shopt -s huponexit +shopt -s interactive_comments +shopt -s lithist +shopt -u mailwarn +shopt -u nocaseglob +shopt -u nullglob +shopt -s promptvars +shopt -u shift_verbose +shopt -s sourcepath + +# --- Set the CDPATH --- +# +# CDPATH=~/src:/usr/src:/usr/lib:/usr/share +# dots=.. +# i=6 +# while (( i > 0 )); do +# CDPATH=$CDPATH:$dots +# dots=$dots/.. +# (( i -= 1 )) +# done +# CDPATH=$CDPATH:/ + +# --- Some colour `ls' support --- + +[ "${TMPDIR+yes}" ] || eval `tmpdir -b` +if [ -x /usr/bin/dircolors -o -x /usr/local/bin/dircolors ] && + [ "$TERM" != "dumb" ]; then + eval `dircolors -b ~/.dircolors` +else + unset LS_COLORS +fi + +ls () { + if [ -t 1 ]; then + command ls $LS_OPTIONS ${LS_COLORS+--color=auto} "$@" + else + command ls "$@" + fi +} + +# --- Setting xterm titles --- +# +# This doesn't work so well any more. :-( + +# if [ -e /usr/lib/bash/xtitle.so ]; then +# enable -f /usr/lib/bash/xtitle.so xtitle +# elif [ -e /usr/local/lib/xtitle.so ]; then +# enable -f /usr/local/lib/xtitle.so xtitle +# elif [ -e $HOME/lib/bash/xtitle.so ]; then +# enable -f $HOME/lib/bash/xtitle.so xtitle +# else +# xtitle () { return 1; } +# fi +xtitle () { return 1; } + +entitle () { + local t="`xtitle -q`" st + xtitle "$t $1" + shift + "$@"; st=$? + xtitle "$t" + return $st +} + +# --- Set up some simple aliases --- + +alias cx='chmod a+x' +alias which="command -v" +alias ssync="rsync -e ssh" +alias rootly="entitle root become -g0 root" +alias r=rootly +alias eh="entitle 'Egham Hills 90210' tf eh" +alias news="entitle Usenet slrn" +alias splitvt='splitvt -t "`xtitle -q || echo xterm` splitvt"' +alias pstree="pstree -Ghl" +alias cdtmp='cd ${TMPDIR-/tmp}' +alias pushtmp='pushd ${TMPDIR-/tmp}' +alias e="sensible-editor" +alias svn=svnwrap + +@ () { + local t="`xtitle -q`" host="$1" + shift + xtitle "$t [$host]" + ssh "$host" "$@" + xtitle "$t" +} + +# --- Make `xt' start an xterm, maybe logging into a remote host --- + +xt () { + case "$1" in + @*) + local remote=${1#@} title + shift + if [ $# -gt 0 ]; then + title="xterm [$remote] $1" + else + title="xterm [$remote]" + fi + (xterm -title "$title" -e ssh $remote "$@" &) + ;; + *) + (xterm "$@" &) + ;; + esac +} + +# --- Turning on and off core dumps --- + +core () { + case "x$1" in + xon|xy|xyes) + ulimit -Sc `ulimit -Hc` + ;; + xoff|xn|xno) + ulimit -Sc 0 + ;; + x) + local l=`ulimit -Sc` + case $l in + 0) echo "Core dumps disabled" ;; + unlimited) echo "Core dumps enabled" ;; + *) echo "Core dump limit is $l blocks" ;; + esac + ;; + *) + echo >&2 "usage: core [yn]" + return 1 + ;; + esac +} + +# --- Fix `man' under Slowaris --- + +case "$MACHTYPE" in + *solaris*) + man () { + declare -i i=0 + declare arg + declare -a man + + for arg; do + case "$arg" in [0-9]*) man[i+=1]="-s" ;; esac + man[i+=1]="$arg" + done + command man "${man[@]}" + } + ;; +esac + +# --- For `root' use -- some simple molly-guards --- + +if (( UID == 0 )); then + alias rm='rm -i' cp='cp -i' mv='mv -i' + set -o noclobber +fi + +fi diff --git a/clisprc.lisp b/clisprc.lisp new file mode 120000 index 0000000..b812362 --- /dev/null +++ b/clisprc.lisp @@ -0,0 +1 @@ +lisp-init.lisp \ No newline at end of file diff --git a/cmucl-init.lisp b/cmucl-init.lisp new file mode 120000 index 0000000..b812362 --- /dev/null +++ b/cmucl-init.lisp @@ -0,0 +1 @@ +lisp-init.lisp \ No newline at end of file diff --git a/dircolors b/dircolors new file mode 100644 index 0000000..dc8d925 --- /dev/null +++ b/dircolors @@ -0,0 +1,80 @@ +# Configuration file for dircolors, a utility to help you set the +# LS_COLORS environment variable used by GNU ls with the --color option. + +# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the +# slackware version of dircolors) are recognized but ignored. + +# Below, there should be one TERM entry for each termtype that is colorizable +TERM linux +TERM console +TERM con132x25 +TERM con132x30 +TERM con132x43 +TERM con132x60 +TERM con80x25 +TERM con80x28 +TERM con80x30 +TERM con80x43 +TERM con80x50 +TERM con80x60 +TERM xterm +TERM xterm-debian +TERM vt100 +TERM screen +TERM screen-w + +# 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 01;36 # directory +LINK 36 # symbolic link +FIFO 32 # pipe +SOCK 01;32 # socket +BLK 01;35 # block device driver +CHR 35 # character device driver +ORPHAN 40;31;01 # symlink to nonexistent file + +# This is for files with execute permission: +EXEC 01 + +# 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 '#') + +# If you use DOS-style suffixes, you may want to uncomment the following: +#.cmd 01;32 # executables (bright green) +#.exe 01;32 +#.com 01;32 +#.btm 01;32 +#.bat 01;32 + +.tar 01;31 # archives or compressed (bright red) +.tgz 01;31 +.arj 01;31 +.taz 01;31 +.lzh 01;31 +.zip 01;31 +.z 01;31 +.Z 01;31 +.gz 01;31 +.bz2 01;31 +.deb 01;31 +# .jpg 01;35 # image formats +# .gif 01;35 +# .bmp 01;35 +# .ppm 01;35 +# .tga 01;35 +# .xbm 01;35 +# .xpm 01;35 +# .tif 01;35 +# .mpg 01;37 +# .avi 01;37 +# .gl 01;37 +# .dl 01;37 diff --git a/dot-emacs.el b/dot-emacs.el new file mode 100644 index 0000000..66f9190 --- /dev/null +++ b/dot-emacs.el @@ -0,0 +1,1742 @@ +;;; -*-emacs-lisp-*- +;;; +;;; $Id$ +;;; +;;; Functions and macros for .emacs +;;; +;;; (c) 2004 Mark Wooding +;;; + +;;;----- Licensing notice --------------------------------------------------- +;;; +;;; This program is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 2 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program; if not, write to the Free Software Foundation, +;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +;;;----- Some general utilities --------------------------------------------- + +;; --- Some error trapping --- +;; +;; If individual bits of this file go tits-up, we don't particularly want +;; the whole lot to stop right there and then, because it's bloody annoying. + +(defmacro trap (&rest forms) + "Execute FORMS without allowing errors to propagate outside." + `(condition-case err + ,(if (cdr forms) (cons 'progn forms) (car forms)) + (error (message "Error (trapped): %s" (error-message-string err))))) + +;; --- Splitting windows --- + +(defconst mdw-scrollbar-width (if window-system 6 1) + "Guessed width of scroll bar.") +(defun mdw-divvy-window (&optional w) + "Split a wide window into appropriate widths." + (interactive) + (or w (setq w 78)) + (let ((win (selected-window)) + (c (/ (+ (window-width) mdw-scrollbar-width) + (+ w mdw-scrollbar-width)))) + (while (> c 1) + (setq c (1- c)) + (split-window-horizontally (+ w mdw-scrollbar-width)) + (other-window 1)) + (select-window win))) + +;; --- Functions for sexp diary entries --- + +(defun mdw-weekday (l) + "Return non-nil if `date' falls on one of the days of the week in L. + +L is a list of day numbers (from 0 to 6 for Sunday through to Saturday) or +symbols `sunday', `monday', etc. (or a mixture). If the date stored in +`date' falls on a listed day, then the function returns non-nil." + (let ((d (calendar-day-of-week date))) + (or (memq d l) + (memq (nth d '(sunday monday tuesday wednesday + thursday friday saturday)) l)))) + +(defun mdw-todo (&optional when) + "Return non-nil today, or on WHEN, whichever is later." + (let ((w (calendar-absolute-from-gregorian (calendar-current-date))) + (d (calendar-absolute-from-gregorian date))) + (if when + (setq w (max w (calendar-absolute-from-gregorian + (cond + ((not european-calendar-style) + when) + ((> (car when) 100) + (list (nth 1 when) + (nth 2 when) + (nth 0 when))) + (t + (list (nth 1 when) + (nth 0 when) + (nth 2 when)))))))) + (eq w d))) + +;;;----- Utility functions -------------------------------------------------- + +;; --- mdw-uniquify-alist --- + +(defun mdw-uniquify-alist (&rest alists) + + "Return the concatenation of the ALISTS with duplicate elements removed. + +The first association with a given key prevails; others are ignored. The +input lists are not modified, although they'll probably become garbage." + + (and alists + (let ((start-list (cons nil nil))) + (mdw-do-uniquify start-list + start-list + (car alists) + (cdr alists))))) + +;; --- mdw-do-uniquify --- +;; +;; The DONE argument is a list whose first element is `nil'. It contains the +;; uniquified alist built so far. The leading `nil' is stripped off at the +;; end of the operation; it's only there so that DONE always references a +;; cons cell. END refers to the final cons cell in the DONE list; it is +;; modified in place each time to avoid the overheads of `append'ing all the +;; time. The L argument is the alist we're currently processing; the +;; remaining alists are given in REST. + +(defun mdw-do-uniquify (done end l rest) + "A helper function for mdw-uniquify-alist." + + ;; --- There are several different cases to deal with here --- + + (cond + + ;; --- Current list isn't empty --- + ;; + ;; Add the first item to the DONE list if there's not an item with the + ;; same KEY already there. + + (l (or (assoc (car (car l)) done) + (progn + (setcdr end (cons (car l) nil)) + (setq end (cdr end)))) + (mdw-do-uniquify done end (cdr l) rest)) + + ;; --- The list we were working on is empty --- + ;; + ;; Shunt the next list into the current list position and go round again. + + (rest (mdw-do-uniquify done end (car rest) (cdr rest))) + + ;; --- Everything's done --- + ;; + ;; Remove the leading `nil' from the DONE list and return it. Finished! + + (t (cdr done)))) + +;; --- Insert a date --- + +(defun date () + "Insert the current date in a pleasing way." + (interactive) + (insert (save-excursion + (let ((buffer (get-buffer-create "*tmp*"))) + (unwind-protect (progn (set-buffer buffer) + (erase-buffer) + (shell-command "date +%Y-%m-%d" t) + (goto-char (mark)) + (delete-backward-char 1) + (buffer-string)) + (kill-buffer buffer)))))) + +;; --- UUencoding --- + +(defun uuencode (file &optional name) + "UUencodes a file, maybe calling it NAME, into the current buffer." + (interactive "fInput file name: ") + + ;; --- If NAME isn't specified, then guess from the filename --- + + (if (not name) + (setq name + (substring file + (or (string-match "[^/]*$" file) 0)))) + + (print (format "uuencode `%s' `%s'" file name)) + + ;; --- Now actually do the thing --- + + (call-process "uuencode" file t nil name)) + +(defvar np-file "~/.np" + "*Where the `now-playing' file is.") + +(defun np (&optional arg) + "Grabs a `now-playing' string." + (interactive) + (save-excursion + (or arg (progn + (goto-char (point-max)) + (insert "\nNP: ") + (insert-file np-file))))) + +(trap + (require 'tramp) + (require 'autorevert) + (defun mdw-check-autorevert () + (if (and (buffer-file-name) + (tramp-tramp-file-p (buffer-file-name))) + (unless global-auto-revert-ignore-buffer + (setq global-auto-revert-ignore-buffer 'tramp)) + (if (eq global-auto-revert-ignore-buffer 'tramp) + (setq global-auto-revert-ignore-buffer nil)))) + (defadvice find-file (after mdw-autorevert activate) + (mdw-check-autorevert)) + (defadvice write-file (after mdw-autorevert activate) + (mdw-check-autorevert))) + +(defun mdwmail-mode () + "Major mode for editing news and mail messages from external programs +Not much right now. Just support for doing MailCrypt stuff." + (interactive) + (kill-all-local-variables) + (use-local-map text-mode-map) + (setq local-abbrev-table text-mode-abbrev-table) + (setq major-mode 'mdwmail-mode) + (setq mode-name "[mdw] mail") + (make-local-variable 'paragraph-separate) + (make-local-variable 'paragraph-start) + (setq paragraph-start (concat "[ \t]*[-_][-_][-_]+$\\|^-- \\|-----\\|" + paragraph-start)) + (setq paragraph-separate (concat "[ \t]*[-_][-_][-_]+$\\|^-- \\|-----\\|" + paragraph-separate)) + (run-hooks 'text-mode-hook 'mdwmail-mode-hook 'mail-setup-hook)) + +;; --- How to encrypt in mdwmail --- + +(defun mdwmail-mc-encrypt (&optional recip scm start end from sign) + (or start + (setq start (save-excursion + (goto-char (point-min)) + (or (search-forward "\n\n" nil t) (point-min))))) + (or end + (setq end (point-max))) + (mc-encrypt-generic recip scm start end from sign)) + +;; --- How to sign in mdwmail --- + +(defun mdwmail-mc-sign (key scm start end uclr) + (or start + (setq start (save-excursion + (goto-char (point-min)) + (or (search-forward "\n\n" nil t) (point-min))))) + (or end + (setq end (point-max))) + (mc-sign-generic key scm start end uclr)) + +;; --- Some signature mangling --- + +(defun mdwmail-mangle-signature () + (save-excursion + (goto-char (point-min)) + (perform-replace "\n-- \n" "\n-- " nil nil nil))) +(add-hook 'mail-setup-hook 'mdwmail-mangle-signature) + +;;;----- Paragraph filling -------------------------------------------------- + +;; --- Useful variables --- + +(defvar mdw-fill-prefix nil + "*Used by `mdw-line-prefix' and `mdw-fill-paragraph'. If there's +no fill prefix currently set (by the `fill-prefix' variable) and there's +a match from one of the regexps here, it gets used to set the fill-prefix +for the current operation. + +The variable is a list of items of the form `REGEXP . PREFIX'; if the +REGEXP matches, the PREFIX is used to set the fill prefix. It in turn is +a list of things: + + STRING -- insert a literal string + (match . N) -- insert the thing matched by bracketed subexpression N + (pad . N) -- a string of whitespace the same width as subexpression N + (expr . FORM) -- the result of evaluating FORM") + +(make-variable-buffer-local 'mdw-fill-prefix) + +(defvar mdw-hanging-indents + "\\(\\(\\([*o]\\|--\\|[0-9]+\\.\\|\\[[0-9]+\\]\\|([a-zA-Z])\\)[ \t]+\\)?\\)" + "*Standard regular expression matching things which might be part of a +hanging indent. This is mainly useful in `auto-fill-mode'.") + +;; --- Setting things up --- + +(fset 'mdw-do-auto-fill (symbol-function 'do-auto-fill)) + +;; --- Utility functions --- + +(defun mdw-tabify (s) + "Tabify the string S. This is a horrid hack." + (save-excursion + (save-match-data + (let (start end) + (beginning-of-line) + (setq start (point-marker)) + (insert s "\n") + (setq end (point-marker)) + (tabify start end) + (setq s (buffer-substring start (1- end))) + (delete-region start end) + (set-marker start nil) + (set-marker end nil) + s)))) + +(defun mdw-examine-fill-prefixes (l) + "Given a list of dynamic fill prefixes, pick one which matches context and +return the static fill prefix to use. Point must be at the start of a line, +and match data must be saved." + (cond ((not l) nil) + ((looking-at (car (car l))) + (mdw-tabify (apply (function concat) + (mapcar (function mdw-do-prefix-match) + (cdr (car l)))))) + (t (mdw-examine-fill-prefixes (cdr l))))) + +(defun mdw-maybe-car (p) + "If P is a pair, return (car P), otherwise just return P." + (if (consp p) (car p) p)) + +(defun mdw-padding (s) + "Return a string the same width as S but made entirely from whitespace." + (let* ((l (length s)) (i 0) (n (make-string l ? ))) + (while (< i l) + (if (= 9 (aref s i)) + (aset n i 9)) + (setq i (1+ i))) + n)) + +(defun mdw-do-prefix-match (m) + "Expand a dynamic prefix match element. See `mdw-fill-prefix' for +details." + (cond ((not (consp m)) (format "%s" m)) + ((eq (car m) 'match) (match-string (mdw-maybe-car (cdr m)))) + ((eq (car m) 'pad) (mdw-padding (match-string + (mdw-maybe-car (cdr m))))) + ((eq (car m) 'eval) (eval (cdr m))) + (t ""))) + +(defun mdw-choose-dynamic-fill-prefix () + "Work out the dynamic fill prefix based on the variable `mdw-fill-prefix'." + (cond ((and fill-prefix (not (string= fill-prefix ""))) fill-prefix) + ((not mdw-fill-prefix) fill-prefix) + (t (save-excursion + (beginning-of-line) + (save-match-data + (mdw-examine-fill-prefixes mdw-fill-prefix)))))) + +(defun do-auto-fill () + "Handle auto-filling, working out a dynamic fill prefix in the case where +there isn't a sensible static one." + (let ((fill-prefix (mdw-choose-dynamic-fill-prefix))) + (mdw-do-auto-fill))) + +(defun mdw-fill-paragraph () + "Fill paragraph, getting a dynamic fill prefix." + (interactive) + (let ((fill-prefix (mdw-choose-dynamic-fill-prefix))) + (fill-paragraph nil))) + +(defun mdw-standard-fill-prefix (rx &optional mat) + "Set the dynamic fill prefix, handling standard hanging indents and stuff. +This is just a short-cut for setting the thing by hand, and by design it +doesn't cope with anything approximating a complicated case." + (setq mdw-fill-prefix + `((,(concat rx mdw-hanging-indents) + (match . 1) + (pad . ,(or mat 2)))))) + +;;;----- Other common declarations ------------------------------------------ + +(defun mdw-set-frame-transparency (&optional n) + (interactive "P") + (let* ((alist (frame-parameters)) + (trans (assq 'transparency alist))) + (if trans + (rplacd trans (not (if n (zerop n) (cdr trans)))) + (setq trans (cons 'transparency (not (equal 0 n))))) + (modify-frame-parameters (selected-frame) (list trans)))) + +;; --- Mouse wheel support --- + +(defconst mdw-wheel-scroll-amount 15) +(defun mdw-wheel-up (click) + (interactive "@e") + (mdw-wheel-scroll click (function scroll-down))) +(defun mdw-wheel-down (click) + (interactive "@e") + (mdw-wheel-scroll click (function scroll-up))) + +(defun mdw-wheel-scroll (click func) + (let ((win (selected-window))) + (unwind-protect + (progn + (select-window (posn-window (event-start click))) + (let ((arg 2)) + (funcall func (/ (window-height) 2)))) + (select-window win)))) + +;; --- Going backwards --- + +(defun other-window-backwards (arg) + (interactive "p") + (other-window (- arg))) + +;; --- Common mode settings --- + +(defvar mdw-auto-indent t + "Whether to indent automatically after a newline.") + +(defun mdw-misc-mode-config () + (and mdw-auto-indent + (cond ((eq major-mode 'lisp-mode) + (local-set-key "\C-m" 'mdw-indent-newline-and-indent)) + ((eq major-mode 'slime-repl-mode) nil) + (t + (local-set-key "\C-m" 'newline-and-indent)))) + (local-set-key [C-return] 'newline) + (local-set-key [?\;] 'self-insert-command) + (local-set-key [?\#] 'self-insert-command) + (local-set-key [?\"] 'self-insert-command) + (setq comment-column 40) + (auto-fill-mode 1) + (setq fill-column 77) + (mdw-set-font)) + +;; --- Set up all sorts of faces --- + +(defvar mdw-set-font nil) + +(defvar mdw-punct-face 'mdw-punct-face "Face to use for punctuation") +(make-face 'mdw-punct-face) +(defvar mdw-number-face 'mdw-number-face "Face to use for numbers") +(make-face 'mdw-number-face) + +;;;----- General fontification ---------------------------------------------- + +(defun mdw-set-fonts (frame ff) + (if ff (progn (set-face-attribute (caar ff) frame + :family 'unspecified + :width 'unspecified + :height 'unspecified + :weight 'unspecified + :slant 'unspecified + :foreground 'unspecified + :background 'unspecified + :underline 'unspecified + :overline 'unspecified + :strike-through 'unspecified + :box 'unspecified + :inverse-video 'unspecified + :stipple 'unspecified +; :font 'unspecified + :inherit 'unspecified + ) + (apply 'set-face-attribute (caar ff) frame (cdar ff)) + (mdw-set-fonts frame (cdr ff))))) + +(defun mdw-do-set-font (&optional frame) + (interactive) + (mdw-set-fonts (and (boundp 'frame) frame) `( + (default :foreground "white" :background "black" + ,@(cond ((eq window-system 'w32) + '(:family "courier new" :height 85)) + ((eq window-system 'x) + '(:family "misc-fixed" :width semi-condensed)))) + (modeline :foreground "blue" :background "yellow" + :box (:line-width 1 :style released-button)) + (scroll-bar :foreground "black" :background "lightgrey") + (fringe :foreground "yellow" :background "grey30") + (show-paren-match-face :background "darkgreen") + (show-paren-mismatch-face :background "red") + (font-lock-warning-face :background "red" :weight bold) + (highlight :background "DarkSeaGreen4") + (holiday-face :background "red") + (calendar-today-face :foreground "yellow" :weight bold) + (comint-highlight-prompt :weight bold) + (comint-highlight-input) + (font-lock-builtin-face :weight bold) + (font-lock-type-face :weight bold) + (region :background "grey30") + (isearch :background "palevioletred2") + (mdw-punct-face :foreground ,(if window-system "burlywood2" "yellow")) + (mdw-number-face :foreground "yellow") + (font-lock-function-name-face :weight bold) + (font-lock-variable-name-face :slant italic) + (font-lock-comment-face + :foreground ,(if window-system "SeaGreen1" "green") + :slant italic) + (font-lock-string-face :foreground ,(if window-system "SkyBlue1" "cyan")) + (font-lock-keyword-face :weight bold) + (font-lock-constant-face :weight bold) + (font-lock-reference-face :weight bold) + (woman-bold-face :weight bold) + (woman-italic-face :slant italic) + (diff-header-face :foreground "skyblue1") + (diff-index-face :weight bold) + (diff-file-header-face) + (diff-context-face :foreground "grey70") + (diff-added-face :foreground "white") + (diff-removed-face :foreground "white" :slant italic) + (whizzy-slice-face :background "grey10") + (whizzy-error-face :background "darkred") +))) + +(defun mdw-set-font () + (trap + (turn-on-font-lock) + (if (not mdw-set-font) + (progn + (setq mdw-set-font t) + (mdw-do-set-font nil))))) + +;;;----- C programming configuration ---------------------------------------- + +;; --- Linux kernel hacking --- + +(defvar linux-c-mode-hook) + +(defun linux-c-mode () + (interactive) + (c-mode) + (setq major-mode 'linux-c-mode) + (setq mode-name "Linux C") + (run-hooks 'linux-c-mode-hook)) + +;; --- Make C indentation nice --- + +(defun mdw-c-style () + (c-add-style "[mdw] C and C++ style" + '((c-basic-offset . 2) + (c-tab-always-indent . nil) + (comment-column . 40) + (c-class-key . "class") + (c-offsets-alist (substatement-open . 0) + (label . 0) + (case-label . +) + (access-label . -) + (inclass . ++) + (inline-open . ++) + (statement-cont . 0) + (statement-case-intro . +))) + t)) + +(defun mdw-fontify-c-and-c++ () + + ;; --- Fiddle with some syntax codes --- + + (modify-syntax-entry ?_ "w") + (modify-syntax-entry ?* ". 23") + (modify-syntax-entry ?/ ". 124b") + (modify-syntax-entry ?\n "> b") + + ;; --- Other stuff --- + + (mdw-c-style) + (setq c-hanging-comment-ender-p nil) + (setq c-backslash-column 72) + (setq c-label-minimum-indentation 0) + (setq comment-start "/* ") + (setq comment-end " */") + (setq mdw-fill-prefix + `((,(concat "\\([ \t]*/?\\)" + "\\([\*/][ \t]*\\)" + "\\([A-Za-z]+:[ \t]*\\)?" + mdw-hanging-indents) + (pad . 1) (match . 2) (pad . 3) (pad . 4)))) + + ;; --- Now define things to be fontified --- + + (make-local-variable 'font-lock-keywords) + (let ((c-keywords + (make-regexp '( + ;; "and" ;C++ + ;; "and_eq" ;C++ + "asm" ;K&R, GCC + "auto" ;K&R, C89 + ;; "bitand" ;C++ + ;; "bitor" ;C++ + "bool" ;C++, C9X macro + "break" ;K&R, C89 + "case" ;K&R, C89 + "catch" ;C++ + "char" ;K&R, C89 + "class" ;C++ + "complex" ;C9X macro, C++ template type + ;; "compl" ;C++ + "const" ;C89 + "const_cast" ;C++ + "continue" ;K&R, C89 + "defined" ;C89 preprocessor + "default" ;K&R, C89 + "delete" ;C++ + "do" ;K&R, C89 + "double" ;K&R, C89 + "dynamic_cast" ;C++ + "else" ;K&R, C89 + ;; "entry" ;K&R -- never used + "enum" ;C89 + "explicit" ;C++ + ;; "export" ;C++ + "extern" ;K&R, C89 + "false" ;C++, C9X macro + "float" ;K&R, C89 + "for" ;K&R, C89 + "fortran" ;K&R + "friend" ;C++ + "goto" ;K&R, C89 + "if" ;K&R, C89 + "imaginary" ;C9X macro + "inline" ;C++, C9X, GCC + "int" ;K&R, C89 + "long" ;K&R, C89 + "mutable" ;C++ + "namespace" ;C++ + "new" ;C++ + "operator" ;C++ + ;; "or" ;C++ + ;; "or_eq" ;C++ + "private" ;C++ + "protected" ;C++ + "public" ;C++ + "register" ;K&R, C89 + "reinterpret_cast" ;C++ + "restrict" ;C9X + "return" ;K&R, C89 + "short" ;K&R, C89 + "signed" ;C89 + "sizeof" ;K&R, C89 + "static" ;K&R, C89 + "static_cast" ;C++ + "struct" ;K&R, C89 + "switch" ;K&R, C89 + "template" ;C++ + "this" ;C++ + "throw" ;C++ + "true" ;C++, C9X macro + "try" ;C++ + "this" ;C++ + "typedef" ;C89 + "typeid" ;C++ + "typeof" ;GCC + "typename" ;C++ + "union" ;K&R, C89 + "unsigned" ;K&R, C89 + "using" ;C++ + "virtual" ;C++ + "void" ;C89 + "volatile" ;C89 + "wchar_t" ;C++, C89 library type + "while" ;K&R, C89 + ;; "xor" ;C++ + ;; "xor_eq" ;C++ + "_Bool" ;C9X + "_Complex" ;C9X + "_Imaginary" ;C9X + "_Pragma" ;C9X preprocessor + "__alignof__" ;GCC + "__asm__" ;GCC + "__attribute__" ;GCC + "__complex__" ;GCC + "__const__" ;GCC + "__extension__" ;GCC + "__imag__" ;GCC + "__inline__" ;GCC + "__label__" ;GCC + "__real__" ;GCC + "__signed__" ;GCC + "__typeof__" ;GCC + "__volatile__" ;GCC + ))) + (preprocessor-keywords + (make-regexp '("assert" "define" "elif" "else" "endif" "error" + "ident" "if" "ifdef" "ifndef" "import" "include" + "line" "pragma" "unassert" "undef" "warning"))) + (objc-keywords + (make-regexp '("class" "defs" "encode" "end" "implementation" + "interface" "private" "protected" "protocol" "public" + "selector")))) + + (setq font-lock-keywords + (list + 't + + ;; --- Fontify include files as strings --- + + (list (concat "^[ \t]*\\#[ \t]*" + "\\(include\\|import\\)" + "[ \t]*\\(<[^>]+\\(>\\|\\)\\)") + '(2 font-lock-string-face)) + + ;; --- Preprocessor directives are `references'? --- + + (list (concat "^\\([ \t]*#[ \t]*\\(\\(" + preprocessor-keywords + "\\)\\>\\|[0-9]+\\|$\\)\\)") + '(1 font-lock-keyword-face)) + + ;; --- Handle the keywords defined above --- + + (list (concat "@\\<\\(" objc-keywords "\\)\\>") + '(0 font-lock-keyword-face)) + + (list (concat "\\<\\(" c-keywords "\\)\\>") + '(0 font-lock-keyword-face)) + + ;; --- Handle numbers too --- + ;; + ;; This looks strange, I know. It corresponds to the + ;; preprocessor's idea of what a number looks like, rather than + ;; anything sensible. + + (list (concat "\\(\\<[0-9]\\|\\.[0-9]\\)" + "\\([Ee][+-]\\|[0-9A-Za-z_.]\\)*") + '(0 mdw-number-face)) + + ;; --- And anything else is punctuation --- + + (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" + '(0 mdw-punct-face)))))) + +;;;----- AP calc mode ------------------------------------------------------- + +(defun apcalc-mode () + (interactive) + (c-mode) + (setq major-mode 'apcalc-mode) + (setq mode-name "AP Calc") + (run-hooks 'apcalc-mode-hook)) + +(defun mdw-fontify-apcalc () + + ;; --- Fiddle with some syntax codes --- + + (modify-syntax-entry ?_ "w") + (modify-syntax-entry ?* ". 23") + (modify-syntax-entry ?/ ". 14") + + ;; --- Other stuff --- + + (mdw-c-style) + (setq c-hanging-comment-ender-p nil) + (setq c-backslash-column 72) + (setq comment-start "/* ") + (setq comment-end " */") + (setq mdw-fill-prefix + `((,(concat "\\([ \t]*/?\\)" + "\\([\*/][ \t]*\\)" + "\\([A-Za-z]+:[ \t]*\\)?" + mdw-hanging-indents) + (pad . 1) (match . 2) (pad . 3) (pad . 4)))) + + ;; --- Now define things to be fontified --- + + (make-local-variable 'font-lock-keywords) + (let ((c-keywords + (make-regexp '("break" "case" "cd" "continue" "define" "default" + "do" "else" "exit" "for" "global" "goto" "help" "if" + "local" "mat" "obj" "print" "quit" "read" "return" + "show" "static" "switch" "while" "write")))) + + (setq font-lock-keywords + (list + 't + + ;; --- Handle the keywords defined above --- + + (list (concat "\\<\\(" c-keywords "\\)\\>") + '(0 font-lock-keyword-face)) + + ;; --- Handle numbers too --- + ;; + ;; This looks strange, I know. It corresponds to the + ;; preprocessor's idea of what a number looks like, rather than + ;; anything sensible. + + (list (concat "\\(\\<[0-9]\\|\\.[0-9]\\)" + "\\([Ee][+-]\\|[0-9A-Za-z_.]\\)*") + '(0 mdw-number-face)) + + ;; --- And anything else is punctuation --- + + (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" + '(0 mdw-punct-face)))))) + +;;;----- Java programming configuration ------------------------------------- + +;; --- Make indentation nice --- + +(defun mdw-java-style () + (c-add-style "[mdw] Java style" + '((c-basic-offset . 2) + (c-tab-always-indent . nil) + (c-offsets-alist (substatement-open . 0) + (label . +) + (case-label . +) + (access-label . 0) + (inclass . +) + (statement-case-intro . +))) + t)) + +;; --- Declare Java fontification style --- + +(defun mdw-fontify-java () + + ;; --- Other stuff --- + + (mdw-java-style) + (modify-syntax-entry ?_ "w") + (setq c-hanging-comment-ender-p nil) + (setq c-backslash-column 72) + (setq comment-start "/* ") + (setq comment-end " */") + (setq mdw-fill-prefix + `((,(concat "\\([ \t]*/?\\)" + "\\([\*/][ \t]*\\)" + "\\([A-Za-z]+:[ \t]*\\)?" + mdw-hanging-indents) + (pad . 1) (match . 2) (pad . 3) (pad . 4)))) + + ;; --- Now define things to be fontified --- + + (make-local-variable 'font-lock-keywords) + (let ((java-keywords + (make-regexp '("abstract" "boolean" "break" "byte" "case" "catch" + "char" "class" "const" "continue" "default" "do" + "double" "else" "extends" "final" "finally" "float" + "for" "goto" "if" "implements" "import" "instanceof" + "int" "interface" "long" "native" "new" "package" + "private" "protected" "public" "return" "short" + "static" "super" "switch" "synchronized" "this" + "throw" "throws" "transient" "try" "void" "volatile" + "while" + + "false" "null" "true")))) + + (setq font-lock-keywords + (list + 't + + ;; --- Handle the keywords defined above --- + + (list (concat "\\<\\(" java-keywords "\\)\\>") + '(0 font-lock-keyword-face)) + + ;; --- Handle numbers too --- + ;; + ;; The following isn't quite right, but it's close enough. + + (list (concat "\\<\\(" + "0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|" + "[0-9]+\\(\\.[0-9]*\\|\\)" + "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)\\)" + "[lLfFdD]?") + '(0 mdw-number-face)) + + ;; --- And anything else is punctuation --- + + (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" + '(0 mdw-punct-face)))))) + +;;;----- Awk programming configuration -------------------------------------- + +;; --- Make Awk indentation nice --- + +(defun mdw-awk-style () + (c-add-style "[mdw] Awk style" + '((c-basic-offset . 2) + (c-tab-always-indent . nil) + (c-offsets-alist (substatement-open . 0) + (statement-cont . 0) + (statement-case-intro . +))) + t)) + +;; --- Declare Awk fontification style --- + +(defun mdw-fontify-awk () + + ;; --- Miscellaneous fiddling --- + + (modify-syntax-entry ?_ "w") + (mdw-awk-style) + (setq c-backslash-column 72) + (mdw-standard-fill-prefix "\\([ \t]*#+[ \t]*\\)") + + ;; --- Now define things to be fontified --- + + (make-local-variable 'font-lock-keywords) + (let ((c-keywords + (make-regexp '("BEGIN" "END" "ARGC" "ARGIND" "ARGV" "CONVFMT" + "ENVIRON" "ERRNO" "FIELDWIDTHS" "FILENAME" "FNR" + "FS" "IGNORECASE" "NF" "NR" "OFMT" "OFS" "ORS" "RS" + "RSTART" "RLENGTH" "RT" "SUBSEP" + "atan2" "break" "close" "continue" "cos" "delete" + "do" "else" "exit" "exp" "fflush" "file" "for" "func" + "function" "gensub" "getline" "gsub" "if" "in" + "index" "int" "length" "log" "match" "next" "rand" + "return" "print" "printf" "sin" "split" "sprintf" + "sqrt" "srand" "strftime" "sub" "substr" "system" + "systime" "tolower" "toupper" "while")))) + + (setq font-lock-keywords + (list + 't + + ;; --- Handle the keywords defined above --- + + (list (concat "\\<\\(" c-keywords "\\)\\>") + '(0 font-lock-keyword-face)) + + ;; --- Handle numbers too --- + ;; + ;; The following isn't quite right, but it's close enough. + + (list (concat "\\<\\(" + "0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|" + "[0-9]+\\(\\.[0-9]*\\|\\)" + "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)\\)" + "[uUlL]*") + '(0 mdw-number-face)) + + ;; --- And anything else is punctuation --- + + (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" + '(0 mdw-punct-face)))))) + +;;;----- Perl programming style --------------------------------------------- + +;; --- Perl indentation style --- + +(setq cperl-tab-always-indent nil) + +(setq cperl-indent-level 2) +(setq cperl-continued-statement-offset 2) +(setq cperl-continued-brace-offset 0) +(setq cperl-brace-offset -2) +(setq cperl-brace-imaginary-offset 0) +(setq cperl-label-offset 0) + +;; --- Define perl fontification style --- + +(defun mdw-fontify-perl () + + ;; --- Miscellaneous fiddling --- + + (modify-syntax-entry ?_ "w") + (modify-syntax-entry ?$ "\\") + (modify-syntax-entry ?$ "\\" font-lock-syntax-table) + (mdw-standard-fill-prefix "\\([ \t]*#+[ \t]*\\)") + + ;; --- Now define fontification things --- + + (make-local-variable 'font-lock-keywords) + (let ((perl-keywords + (make-regexp '("and" "cmp" "continue" "do" "else" "elsif" "eq" + "for" "foreach" "ge" "gt" "goto" "if" + "last" "le" "lt" "local" "my" "ne" "next" "or" + "package" "redo" "require" "return" "sub" + "undef" "unless" "until" "use" "while")))) + + (setq font-lock-keywords + (list + 't + + ;; --- Set up the keywords defined above --- + + (list (concat "\\<\\(" perl-keywords "\\)\\>") + '(0 font-lock-keyword-face)) + + ;; --- At least numbers are simpler than C --- + + (list (concat "\\<0\\([xX][0-9a-fA-F_]+\\|[0-7_]+\\)\\|" + "\\<[0-9][0-9_]*\\(\\.[0-9_]*\\|\\)" + "\\([eE]\\([-+]\\|\\)[0-9_]+\\|\\)") + '(0 mdw-number-face)) + + ;; --- And anything else is punctuation --- + + (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" + '(0 mdw-punct-face)))))) + +(defun perl-number-tests (&optional arg) + "Assign consecutive numbers to lines containing `#t'. With ARG, +strip numbers instead." + (interactive "P") + (save-excursion + (goto-char (point-min)) + (let ((i 0) (fmt (if arg "" " %4d"))) + (while (search-forward "#t" nil t) + (delete-region (point) (line-end-position)) + (setq i (1+ i)) + (insert (format fmt i))) + (goto-char (point-min)) + (if (re-search-forward "\\(tests\\s-*=>\\s-*\\)\\w*" nil t) + (replace-match (format "\\1%d" i)))))) + +;;;----- Python programming style ------------------------------------------- + +;; --- Define Python fontification style --- + +(trap (require 'pyrex-mode)) +(defun mdw-fontify-python () + + ;; --- Miscellaneous fiddling --- + + (modify-syntax-entry ?_ "w") + (mdw-standard-fill-prefix "\\([ \t]*#+[ \t]*\\)") + + ;; --- Now define fontification things --- + + (make-local-variable 'font-lock-keywords) + (let ((python-keywords + (make-regexp '("and" "as" "assert" "break" "class" "continue" "def" + "del" "elif" "else" "except" "exec" "finally" "for" + "from" "global" "if" "import" "in" "is" "lambda" + "not" "or" "pass" "print" "raise" "return" "try" + "while")))) + (setq font-lock-keywords + (list + 't + + ;; --- Set up the keywords defined above --- + + (list (concat "\\<\\(" python-keywords "\\)\\>") + '(0 font-lock-keyword-face)) + + ;; --- At least numbers are simpler than C --- + + (list (concat "\\<0\\([xX][0-9a-fA-F_]+\\|[0-7_]+\\)\\|" + "\\<[0-9][0-9_]*\\(\\.[0-9_]*\\|\\)" + "\\([eE]\\([-+]\\|\\)[0-9_]+\\|[lL]\\|\\)") + '(0 mdw-number-face)) + + ;; --- And anything else is punctuation --- + + (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" + '(0 mdw-punct-face)))))) + +;;;----- ARM assembler programming configuration ---------------------------- + +;; --- There doesn't appear to be an Emacs mode for this yet --- +;; +;; Better do something about that, I suppose. + +(defvar arm-assembler-mode-map nil) +(defvar arm-assembler-abbrev-table nil) +(defvar arm-assembler-mode-syntax-table (make-syntax-table)) + +(or arm-assembler-mode-map + (progn + (setq arm-assembler-mode-map (make-sparse-keymap)) + (define-key arm-assembler-mode-map "\C-m" 'arm-assembler-newline) + (define-key arm-assembler-mode-map [C-return] 'newline) + (define-key arm-assembler-mode-map "\t" 'tab-to-tab-stop))) + +(defun arm-assembler-mode () + "Major mode for ARM assembler programs" + (interactive) + + ;; --- Do standard major mode things --- + + (kill-all-local-variables) + (use-local-map arm-assembler-mode-map) + (setq local-abbrev-table arm-assembler-abbrev-table) + (setq major-mode 'arm-assembler-mode) + (setq mode-name "ARM assembler") + + ;; --- Set up syntax table --- + + (set-syntax-table arm-assembler-mode-syntax-table) + (modify-syntax-entry ?; ; Nasty hack + "<" arm-assembler-mode-syntax-table) + (modify-syntax-entry ?\n ">" arm-assembler-mode-syntax-table) + (modify-syntax-entry ?_ "_" arm-assembler-mode-syntax-table) + + (make-local-variable 'comment-start) + (setq comment-start ";") + (make-local-variable 'comment-end) + (setq comment-end "") + (make-local-variable 'comment-column) + (setq comment-column 48) + (make-local-variable 'comment-start-skip) + (setq comment-start-skip ";+[ \t]*") + + ;; --- Play with indentation --- + + (make-local-variable 'indent-line-function) + (setq indent-line-function 'indent-relative-maybe) + + ;; --- Set fill prefix --- + + (mdw-standard-fill-prefix "\\([ \t]*;+[ \t]*\\)") + + ;; --- Fiddle with fontification --- + + (make-local-variable 'font-lock-keywords) + (setq font-lock-keywords + (list + 't + + ;; --- Handle numbers too --- + ;; + ;; The following isn't quite right, but it's close enough. + + (list (concat "\\(" + "&[0-9a-fA-F]+\\|" + "\\<[0-9]+\\(\\.[0-9]*\\|_[0-9a-zA-Z]+\\|\\)" + "\\)") + '(0 mdw-number-face)) + + ;; --- Do something about operators --- + + (list "^[^ \t]*[ \t]+\\(GET\\|LNK\\)[ \t]+\\([^;\n]*\\)" + '(1 font-lock-keyword-face) + '(2 font-lock-string-face)) + (list ":[a-zA-Z]+:" + '(0 font-lock-keyword-face)) + + ;; --- Do menemonics and directives --- + + (list "^[^ \t]*[ \t]+\\([a-zA-Z]+\\)" + '(1 font-lock-keyword-face)) + + ;; --- And anything else is punctuation --- + + (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" + '(0 mdw-punct-face)))) + + (run-hooks 'arm-assembler-mode-hook)) + +;;;----- TCL configuration -------------------------------------------------- + +(defun mdw-fontify-tcl () + (mapcar #'(lambda (ch) (modify-syntax-entry ch ".")) '(?$)) + (mdw-standard-fill-prefix "\\([ \t]*#+[ \t]*\\)") + (make-local-variable 'font-lock-keywords) + (setq font-lock-keywords + (list + 't + (list (concat "\\<0\\([xX][0-9a-fA-F_]+\\|[0-7_]+\\)\\|" + "\\<[0-9][0-9_]*\\(\\.[0-9_]*\\|\\)" + "\\([eE]\\([-+]\\|\\)[0-9_]+\\|\\)") + '(0 mdw-number-face)) + (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" + '(0 mdw-punct-face))))) + +;;;----- REXX configuration ------------------------------------------------- + +(defun mdw-rexx-electric-* () + (interactive) + (insert ?*) + (rexx-indent-line)) + +(defun mdw-rexx-indent-newline-indent () + (interactive) + (rexx-indent-line) + (if abbrev-mode (expand-abbrev)) + (newline-and-indent)) + +(defun mdw-fontify-rexx () + + ;; --- Various bits of fiddling --- + + (setq mdw-auto-indent nil) + (local-set-key [?\C-m] 'mdw-rexx-indent-newline-indent) + (local-set-key [?*] 'mdw-rexx-electric-*) + (mapcar #'(lambda (ch) (modify-syntax-entry ch "w")) + '(?. ?! ?? ?_ ?# ?@ ?$)) + (mdw-standard-fill-prefix "\\([ \t]*/?\*[ \t]*\\)") + + ;; --- Set up keywords and things for fontification --- + + (make-local-variable 'font-lock-keywords-case-fold-search) + (setq font-lock-keywords-case-fold-search t) + + (setq rexx-indent 2) + (setq rexx-end-indent rexx-indent) + (setq rexx-tab-always-indent nil) + (setq rexx-cont-indent rexx-indent) + + (make-local-variable 'font-lock-keywords) + (let ((rexx-keywords + (make-regexp '("address" "arg" "by" "call" "digits" "do" "drop" + "else" "end" "engineering" "exit" "expose" "for" + "forever" "form" "fuzz" "if" "interpret" "iterate" + "leave" "linein" "name" "nop" "numeric" "off" "on" + "options" "otherwise" "parse" "procedure" "pull" + "push" "queue" "return" "say" "select" "signal" + "scientific" "source" "then" "trace" "to" "until" + "upper" "value" "var" "version" "when" "while" + "with" + + "abbrev" "abs" "bitand" "bitor" "bitxor" "b2x" + "center" "center" "charin" "charout" "chars" + "compare" "condition" "copies" "c2d" "c2x" + "datatype" "date" "delstr" "delword" "d2c" "d2x" + "errortext" "format" "fuzz" "insert" "lastpos" + "left" "length" "lineout" "lines" "max" "min" + "overlay" "pos" "queued" "random" "reverse" "right" + "sign" "sourceline" "space" "stream" "strip" + "substr" "subword" "symbol" "time" "translate" + "trunc" "value" "verify" "word" "wordindex" + "wordlength" "wordpos" "words" "xrange" "x2b" "x2c" + "x2d")))) + + (setq font-lock-keywords + (list + 't + + ;; --- Set up the keywords defined above --- + + (list (concat "\\<\\(" rexx-keywords "\\)\\>") + '(0 font-lock-keyword-face)) + + ;; --- Fontify all symbols the same way --- + + (list (concat "\\<\\([0-9.][A-Za-z0-9.!?_#@$]*[Ee][+-]?[0-9]+\\|" + "[A-Za-z0-9.!?_#@$]+\\)") + '(0 font-lock-variable-name-face)) + + ;; --- And everything else is punctuation --- + + (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" + '(0 mdw-punct-face)))))) + +;;;----- Standard ML programming style -------------------------------------- + +(defun mdw-fontify-sml () + + ;; --- Make underscore an honorary letter --- + + (modify-syntax-entry ?_ "w") + (modify-syntax-entry ?' "w") + + ;; --- Set fill prefix --- + + (mdw-standard-fill-prefix "\\([ \t]*(\*[ \t]*\\)") + + ;; --- Now define fontification things --- + + (make-local-variable 'font-lock-keywords) + (let ((sml-keywords + (make-regexp '("abstype" "and" "andalso" "as" + "case" + "datatype" "do" + "else" "end" "eqtype" "exception" + "fn" "fun" "functor" + "handle" + "if" "in" "include" "infix" "infixr" + "let" "local" + "nonfix" + "of" "op" "open" "orelse" + "raise" "rec" + "sharing" "sig" "signature" "struct" "structure" + "then" "type" + "val" + "where" "while" "with" "withtype")))) + + (setq font-lock-keywords + (list + 't + + ;; --- Set up the keywords defined above --- + + (list (concat "\\<\\(" sml-keywords "\\)\\>") + '(0 font-lock-keyword-face)) + + ;; --- At least numbers are simpler than C --- + + (list (concat "\\<\\(\\~\\|\\)" + "\\(0\\(\\([wW]\\|\\)[xX][0-9a-fA-F]+\\|" + "[wW][0-9]+\\)\\|" + "\\([0-9]+\\(\\.[0-9]+\\|\\)" + "\\([eE]\\(\\~\\|\\)" + "[0-9]+\\|\\)\\)\\)") + '(0 mdw-number-face)) + + ;; --- And anything else is punctuation --- + + (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" + '(0 mdw-punct-face)))))) + +;;;----- Haskell configuration ---------------------------------------------- + +(defun mdw-fontify-haskell () + + ;; --- Fiddle with syntax table to get comments right --- + + (modify-syntax-entry ?_ "w") + (modify-syntax-entry ?' "\"") + (modify-syntax-entry ?- ". 123") + (modify-syntax-entry ?{ ". 1b") + (modify-syntax-entry ?} ". 4b") + (modify-syntax-entry ?\n ">") + + ;; --- Set fill prefix --- + + (mdw-standard-fill-prefix "\\([ \t]*{?--?[ \t]*\\)") + + ;; --- Fiddle with fontification --- + + (make-local-variable 'font-lock-keywords) + (let ((haskell-keywords + (make-regexp '("as" "case" "ccall" "class" "data" "default" + "deriving" "do" "else" "foreign" "hiding" "if" + "import" "in" "infix" "infixl" "infixr" "instance" + "let" "module" "newtype" "of" "qualified" "safe" + "stdcall" "then" "type" "unsafe" "where")))) + + (setq font-lock-keywords + (list + 't + (list "--.*$" + '(0 font-lock-comment-face)) + (list (concat "\\<\\(" haskell-keywords "\\)\\>") + '(0 font-lock-keyword-face)) + (list (concat "\\<0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|" + "\\<[0-9][0-9_]*\\(\\.[0-9]*\\|\\)" + "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)") + '(0 mdw-number-face)) + (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" + '(0 mdw-punct-face)))))) + +;;;----- Texinfo configuration ---------------------------------------------- + +(defun mdw-fontify-texinfo () + + ;; --- Set fill prefix --- + + (mdw-standard-fill-prefix "\\([ \t]*@c[ \t]+\\)") + + ;; --- Real fontification things --- + + (make-local-variable 'font-lock-keywords) + (setq font-lock-keywords + (list + 't + + ;; --- Environment names are keywords --- + + (list "@\\(end\\) *\\([a-zA-Z]*\\)?" + '(2 font-lock-keyword-face)) + + ;; --- Unmark escaped magic characters --- + + (list "\\(@\\)\\([@{}]\\)" + '(1 font-lock-keyword-face) + '(2 font-lock-variable-name-face)) + + ;; --- Make sure we get comments properly --- + + (list "@c\\(\\|omment\\)\\( .*\\)?$" + '(0 font-lock-comment-face)) + + ;; --- Command names are keywords --- + + (list "@\\([^a-zA-Z@]\\|[a-zA-Z@]*\\)" + '(0 font-lock-keyword-face)) + + ;; --- Fontify TeX special characters as punctuation --- + + (list "[{}]+" + '(0 mdw-punct-face))))) + +;;;----- TeX and LaTeX configuration ---------------------------------------- + +(defun mdw-fontify-tex () + (setq ispell-parser 'tex) + + ;; --- Don't make maths into a string --- + + (modify-syntax-entry ?$ ".") + (modify-syntax-entry ?$ "." font-lock-syntax-table) + (local-set-key [?$] 'self-insert-command) + + ;; --- Set fill prefix --- + + (mdw-standard-fill-prefix "\\([ \t]*%+[ \t]*\\)") + + ;; --- Real fontification things --- + + (make-local-variable 'font-lock-keywords) + (setq font-lock-keywords + (list + 't + + ;; --- Environment names are keywords --- + + (list (concat "\\\\\\(begin\\|end\\|newenvironment\\)" + "{\\([^}\n]*\\)}") + '(2 font-lock-keyword-face)) + + ;; --- Suspended environment names are keywords too --- + + (list (concat "\\\\\\(suspend\\|resume\\)\\(\\[[^]]*\\]\\)?" + "{\\([^}\n]*\\)}") + '(3 font-lock-keyword-face)) + + ;; --- Command names are keywords --- + + (list "\\\\\\([^a-zA-Z@]\\|[a-zA-Z@]*\\)" + '(0 font-lock-keyword-face)) + + ;; --- Handle @/.../ for italics --- + + ;; (list "\\(@/\\)\\([^/]*\\)\\(/\\)" + ;; '(1 font-lock-keyword-face) + ;; '(3 font-lock-keyword-face)) + + ;; --- Handle @*...* for boldness --- + + ;; (list "\\(@\\*\\)\\([^*]*\\)\\(\\*\\)" + ;; '(1 font-lock-keyword-face) + ;; '(3 font-lock-keyword-face)) + + ;; --- Handle @`...' for literal syntax things --- + + ;; (list "\\(@`\\)\\([^']*\\)\\('\\)" + ;; '(1 font-lock-keyword-face) + ;; '(3 font-lock-keyword-face)) + + ;; --- Handle @<...> for nonterminals --- + + ;; (list "\\(@<\\)\\([^>]*\\)\\(>\\)" + ;; '(1 font-lock-keyword-face) + ;; '(3 font-lock-keyword-face)) + + ;; --- Handle other @-commands --- + + ;; (list "@\\([^a-zA-Z]\\|[a-zA-Z]*\\)" + ;; '(0 font-lock-keyword-face)) + + ;; --- Make sure we get comments properly --- + + (list "%.*" + '(0 font-lock-comment-face)) + + ;; --- Fontify TeX special characters as punctuation --- + + (list "[$^_{}#&]" + '(0 mdw-punct-face))))) + +;;;----- Shell scripts ------------------------------------------------------ + +(defun mdw-setup-sh-script-mode () + + ;; --- Fetch the shell interpreter's name --- + + (let ((shell-name sh-shell-file)) + + ;; --- Try reading the hash-bang line --- + + (save-excursion + (goto-char (point-min)) + (if (looking-at "#![ \t]*\\([^ \t\n]*\\)") + (setq shell-name (match-string 1)))) + + ;; --- Now try to set the shell --- + ;; + ;; Don't let `sh-set-shell' bugger up my script. + + (let ((executable-set-magic #'(lambda (s &rest r) s))) + (sh-set-shell shell-name))) + + ;; --- Now enable my keys and the fontification --- + + (mdw-misc-mode-config) + + ;; --- Set the indentation level correctly --- + + (setq sh-indentation 2) + (setq sh-basic-offset 2)) + +;;;----- Messages-file mode ------------------------------------------------- + +(defun message-mode-guts () + (setq messages-mode-syntax-table (make-syntax-table)) + (set-syntax-table messages-mode-syntax-table) + (modify-syntax-entry ?_ "w" messages-mode-syntax-table) + (modify-syntax-entry ?- "w" messages-mode-syntax-table) + (modify-syntax-entry ?0 "w" messages-mode-syntax-table) + (modify-syntax-entry ?1 "w" messages-mode-syntax-table) + (modify-syntax-entry ?2 "w" messages-mode-syntax-table) + (modify-syntax-entry ?3 "w" messages-mode-syntax-table) + (modify-syntax-entry ?4 "w" messages-mode-syntax-table) + (modify-syntax-entry ?5 "w" messages-mode-syntax-table) + (modify-syntax-entry ?6 "w" messages-mode-syntax-table) + (modify-syntax-entry ?7 "w" messages-mode-syntax-table) + (modify-syntax-entry ?8 "w" messages-mode-syntax-table) + (modify-syntax-entry ?9 "w" messages-mode-syntax-table) + (make-local-variable 'comment-start) + (make-local-variable 'comment-end) + (make-local-variable 'indent-line-function) + (setq indent-line-function 'indent-relative) + (mdw-standard-fill-prefix "\\([ \t]*\\(;\\|/?\\*\\)+[ \t]*\\)") + (make-local-variable 'font-lock-defaults) + (make-local-variable 'message-mode-keywords) + (let ((keywords + (make-regexp '("array" "bitmap" "callback" "docs[ \t]+enum" + "export" "enum" "fixed-octetstring" "flags" + "harmless" "map" "nested" "optional" + "optional-tagged" "package" "primitive" + "primitive-nullfree" "relaxed[ \t]+enum" + "set" "table" "tagged-optional" "union" + "variadic" "vector" "version" "version-tag")))) + (setq message-mode-keywords + (list + (list (concat "\\<\\(" keywords "\\)\\>:") + '(0 font-lock-keyword-face)) + '("\\([-a-zA-Z0-9]+:\\)" (0 font-lock-warning-face)) + '("\\(\\<[a-z][-_a-zA-Z0-9]*\\)" + (0 font-lock-variable-name-face)) + '("\\<\\([0-9]+\\)\\>" (0 mdw-number-face)) + '("\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" + (0 mdw-punct-face))))) + (setq font-lock-defaults + '(message-mode-keywords nil nil nil nil)) + (run-hooks 'messages-file-hook)) + +(defun messages-mode () + (interactive) + (fundamental-mode) + (setq major-mode 'messages-mode) + (setq mode-name "Messages") + (message-mode-guts) + (modify-syntax-entry ?# "<" messages-mode-syntax-table) + (modify-syntax-entry ?\n ">" messages-mode-syntax-table) + (setq comment-start "# ") + (setq comment-end "") + (turn-on-font-lock-if-enabled) + (run-hooks 'messages-mode-hook)) + +(defun cpp-messages-mode () + (interactive) + (fundamental-mode) + (setq major-mode 'cpp-messages-mode) + (setq mode-name "CPP Messages") + (message-mode-guts) + (modify-syntax-entry ?* ". 23" messages-mode-syntax-table) + (modify-syntax-entry ?/ ". 14" messages-mode-syntax-table) + (setq comment-start "/* ") + (setq comment-end " */") + (let ((preprocessor-keywords + (make-regexp '("assert" "define" "elif" "else" "endif" "error" + "ident" "if" "ifdef" "ifndef" "import" "include" + "line" "pragma" "unassert" "undef" "warning")))) + (setq message-mode-keywords + (append (list (list (concat "^[ \t]*\\#[ \t]*" + "\\(include\\|import\\)" + "[ \t]*\\(<[^>]+\\(>\\|\\)\\)") + '(2 font-lock-string-face)) + (list (concat "^\\([ \t]*#[ \t]*\\(\\(" + preprocessor-keywords + "\\)\\>\\|[0-9]+\\|$\\)\\)") + '(1 font-lock-keyword-face))) + message-mode-keywords))) + (setq font-lock-defaults + '(message-mode-keywords nil nil nil nil)) + (turn-on-font-lock-if-enabled) + (run-hooks 'messages-mode-hook)) + +(add-hook 'messages-file-hook 'mdw-misc-mode-config t) +; (add-hook 'messages-file-hook 'mdw-fontify-messages t) + +;;;----- Messages-file mode ------------------------------------------------- + +(defvar mallow-driver-substitution-face 'mallow-driver-substitution-face + "Face to use for subsittution directives.") +(make-face 'mallow-driver-substitution-face) +(defvar mallow-driver-text-face 'mallow-driver-text-face + "Face to use for body text.") +(make-face 'mallow-driver-text-face) + +(defun mallow-driver-mode () + (interactive) + (fundamental-mode) + (setq major-mode 'mallow-driver-mode) + (setq mode-name "Mallow driver") + (setq mallow-driver-mode-syntax-table (make-syntax-table)) + (set-syntax-table mallow-driver-mode-syntax-table) + (make-local-variable 'comment-start) + (make-local-variable 'comment-end) + (make-local-variable 'indent-line-function) + (setq indent-line-function 'indent-relative) + (mdw-standard-fill-prefix "\\([ \t]*\\(;\\|/?\\*\\)+[ \t]*\\)") + (make-local-variable 'font-lock-defaults) + (make-local-variable 'mallow-driver-mode-keywords) + (let ((keywords + (make-regexp '("each" "divert" "file" "if" + "perl" "set" "string" "type" "write")))) + (setq mallow-driver-mode-keywords + (list + (list (concat "^%\\s *\\(}\\|\\(" keywords "\\)\\>\\).*$") + '(0 font-lock-keyword-face)) + (list "^%\\s *\\(#.*\\|\\)$" + '(0 font-lock-comment-face)) + (list "^%" + '(0 font-lock-keyword-face)) + (list "^|?\\(.+\\)$" '(1 mallow-driver-text-face)) + (list "\\${[^}]*}" + '(0 mallow-driver-substitution-face t))))) + (setq font-lock-defaults + '(mallow-driver-mode-keywords nil nil nil nil)) + (modify-syntax-entry ?\" "_" mallow-driver-mode-syntax-table) + (modify-syntax-entry ?\n ">" mallow-driver-mode-syntax-table) + (setq comment-start "%# ") + (setq comment-end "") + (turn-on-font-lock-if-enabled) + (run-hooks 'mallow-driver-mode-hook)) + +(add-hook 'mallow-driver-hook 'mdw-misc-mode-config t) + +;;;----- NFast debugs ------------------------------------------------------- + +(defun nfast-debug-mode () + (interactive) + (fundamental-mode) + (setq major-mode 'nfast-debug-mode) + (setq mode-name "NFast debug") + (setq messages-mode-syntax-table (make-syntax-table)) + (set-syntax-table messages-mode-syntax-table) + (make-local-variable 'font-lock-defaults) + (make-local-variable 'nfast-debug-mode-keywords) + (setq truncate-lines t) + (setq nfast-debug-mode-keywords + (list + '("^\\(NFast_\\(Connect\\|Disconnect\\|Submit\\|Wait\\)\\)" + (0 font-lock-keyword-face)) + (list (concat "^[ \t]+\\(\\(" + "[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]" + "[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]" + "[ \t]+\\)*" + "[0-9a-fA-F]+\\)[ \t]*$") + '(0 mdw-number-face)) + '("^[ \t]+\.status=[ \t]+\\<\\(OK\\)\\>" + (1 font-lock-keyword-face)) + '("^[ \t]+\.status=[ \t]+\\<\\([a-zA-Z][0-9a-zA-Z]*\\)\\>" + (1 font-lock-warning-face)) + '("^[ \t]+\.status[ \t]+\\<\\(zero\\)\\>" + (1 nil)) + (list (concat "^[ \t]+\\.cmd=[ \t]+" + "\\<\\([a-zA-Z][0-9a-zA-Z]*\\)\\>") + '(1 font-lock-keyword-face)) + '("-?\\<\\([0-9]+\\|0x[0-9a-fA-F]+\\)\\>" (0 mdw-number-face)) + '("^\\([ \t]+[a-z0-9.]+\\)" (0 font-lock-variable-name-face)) + '("\\<\\([a-z][a-z0-9.]+\\)\\>=" (1 font-lock-variable-name-face)) + '("\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" (0 mdw-punct-face)))) + (setq font-lock-defaults + '(nfast-debug-mode-keywords nil nil nil nil)) + (turn-on-font-lock-if-enabled) + (run-hooks 'nfast-debug-mode-hook)) + +;;;----- Other languages ---------------------------------------------------- + +;; --- Smalltalk --- + +(defun mdw-setup-smalltalk () + (and mdw-auto-indent + (local-set-key "\C-m" 'smalltalk-newline-and-indent)) + (make-variable-buffer-local 'mdw-auto-indent) + (setq mdw-auto-indent nil) + (local-set-key "\C-i" 'smalltalk-reindent)) + +(defun mdw-fontify-smalltalk () + (make-local-variable 'font-lock-keywords) + (setq font-lock-keywords + (list + 't + (list "\\<[A-Z][a-zA-Z0-9]*\\>" + '(0 font-lock-keyword-face)) + (list (concat "\\<0\\([xX][0-9a-fA-F_]+\\|[0-7_]+\\)\\|" + "[0-9][0-9_]*\\(\\.[0-9_]*\\|\\)" + "\\([eE]\\([-+]\\|\\)[0-9_]+\\|\\)") + '(0 mdw-number-face)) + (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" + '(0 mdw-punct-face))))) + +;; --- Lispy languages --- + +(defun mdw-indent-newline-and-indent () + (interactive) + (indent-for-tab-command) + (newline-and-indent)) + +(eval-after-load "cl-indent" + '(progn + (mapc #'(lambda (pair) + (put (car pair) + 'common-lisp-indent-function + (cdr pair))) + '((destructuring-bind . ((&whole 4 &rest 1) 4 &body)) + (multiple-value-bind . ((&whole 4 &rest 1) 4 &body)))))) + +(defun mdw-common-lisp-indent () + (make-variable-buffer-local 'lisp-indent-function) + (setq lisp-indent-function 'common-lisp-indent-function)) + +(defun mdw-fontify-lispy () + + ;; --- Set fill prefix --- + + (mdw-standard-fill-prefix "\\([ \t]*;+[ \t]*\\)") + + ;; --- Not much fontification needed --- + + (make-local-variable 'font-lock-keywords) + (setq font-lock-keywords + (list + 't + (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" + '(0 mdw-punct-face))))) + +(defun comint-send-and-indent () + (interactive) + (comint-send-input) + (and mdw-auto-indent + (indent-for-tab-command))) + +;;;----- Text mode ---------------------------------------------------------- + +(defun mdw-text-mode () + (setq fill-column 72) + (flyspell-mode t) + (mdw-standard-fill-prefix + "\\([ \t]*\\([A-Za-z0-9]*[>#|:] ?\\)*[ \t]*\\)" 3) + (auto-fill-mode 1)) + +;;;----- Shell mode --------------------------------------------------------- + +(defun mdw-sh-mode-setup () + (local-set-key [?\C-a] 'comint-bol) + (add-hook 'comint-output-filter-functions + 'comint-watch-for-password-prompt)) + +(defun mdw-term-mode-setup () + (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)) + +;;;----- That's all, folks -------------------------------------------------- + +(provide 'dot-emacs) diff --git a/emacs b/emacs new file mode 100644 index 0000000..a9164a2 --- /dev/null +++ b/emacs @@ -0,0 +1,503 @@ +;;; -*-emacs-lisp-*- +;;; +;;; $Id: .emacs,v 1.11 1997/01/01 18:47:09 mdw Exp $ +;;; +;;; Emacs configuration file +;;; +;;; (c) 1996-1999 Mark Wooding +;;; + +;;;----- Licensing notice --------------------------------------------------- +;;; +;;; This program is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 2 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program; if not, write to the Free Software +;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +(setq load-path (nconc load-path (list "~/lib/emacs"))) +(require 'dot-emacs) + +;;;----- Some random initialisation ----------------------------------------- + +(setq mdw-init-window (selected-window)) + +;; --- Load some other bits of code --- + +(setq load-path (cons "~/lib/emacs" load-path)) + +(autoload 'cc-mode "cc-mode" nil t) +(autoload 'rexx-mode "rexx-mode" nil t) +(autoload 'cvs-update "pcl-cvs" nil t) +(autoload 'debian-changelog-mode "debian-changelog-mode" nil t) + +(trap + (or (fboundp 'make-regexp) + (load "make-regexp"))) + +(trap (require 'tex-site)) + +;; --- Skeleton stuff --- + +(trap (require 'skel-init)) + +;; --- Window system-dependent things --- + +(require 'paren) +(trap (show-paren-mode t)) +(or window-system (menu-bar-mode -1)) + +;; --- Temporary directory handling --- + +(defun mdw-check-dir-exists (dir) + (and dir + (file-directory-p dir) + dir)) +(setq tmpdir (or (mdw-check-dir-exists (getenv "TMPDIR")) + (mdw-check-dir-exists (format "/tmp/%s" (user-login-name))) + "/tmp")) + +;; --- Emacs server behaviour --- + +(and window-system + (trap (gnuserv-start) + (setq server-temp-file-regexp (concat "^" tmpdir "\\|/draft$")))) + +;; --- Control backup behaviour --- + +(setq backup-by-copying nil) +(setq backup-by-copying-when-linked t) +(setq backup-by-copying-when-mismatch t) + +;; --- Calculator fiddling --- + +(setq calc-settings-file "~/.emacs-calc") +(load calc-settings-file) + +;; ---- Some mail and news configuration --- + +(setq mail-from-style 'parens) +(setq mail-signature t) +(setq mail-yank-prefix "> ") +(setq mail-archive-file-name "~/Mail/sent") + +(setq rmail-display-summary t) +(setq rmail-file-name "~/Mail/rmail") + +;; --- GNUS configuration --- + +(setq gnus-select-method '(nntp "tux.nsict.org")) +(setq gnus-read-active-file 'some) +(setq gnus-inhibit-startup-message t) +(setq gnus-large-newsgroup 500) + +;; --- Internationalization twiddling --- + +(trap + (standard-display-european 1) + (let ((im (current-input-mode))) + (apply #'set-input-mode + (nconc (list (nth 0 im) (nth 1 im) 0) (nthcdr 3 im)))) + (set-language-environment "Latin-1")) + +;; --- Don't disable any commands --- + +(mapatoms #'(lambda (sym) (put sym 'disabled nil))) + +;; --- Split a wide window --- + +(mdw-divvy-window) + +;; --- Other goodies --- + +(resize-minibuffer-mode 1) ;Make minibuffer grow dynamically +(auto-compression-mode 1) ;Enable automatic compression +(setq dabbrev-case-replace nil) ;Retain case when completing +(setq next-line-add-newlines nil) ;Don't add weird newlines +(setq split-height-threshold 45) ;Reuse windows where sensible +(setq dired-deletion-confirmer ;Make deletion easier in dired + (symbol-function 'y-or-n-p)) +(setq dired-listing-switches "-alF") ;Do `ls -F' things in dired windows +(setq case-fold-file-names nil) ;Don't translate file names (grr...) +(setq scroll-step 5) ;Don't scroll too much at a time +(setq-default fill-column 77) ;I use rather narrow windows +(setq-default comment-column 40) ;Set a standard comment column +(setq-default truncate-partial-width-windows nil) +(setq diff-switches "-u" ;I like reading unified diffs + cvs-diff-flags (list diff-switches)) +(setq echo-keystrokes 10) ;Long delay before keystrokes echo +(setq ange-ftp-ftp-program-name "pftp") ;Use passive FTP +(setq find-ls-option ;Build file lists efficiently + '("-print0 | xargs -0r ls -ld" . "ld")) +(setq Info-fontify-maximum-menu-size 60000) +(setq ispell-dictionary "british" + flyspell-default-dictionary "british") +(setq browse-url-browser-function 'browse-url-mozilla + browse-url-mozilla-program "firefox") +(trap + (require 'uniquify) + (setq uniquify-buffer-name-style 'post-forward-angle-brackets) + (setq uniquify-after-kill-buffer-p t)) +(transient-mark-mode t) +(trap + (tooltip-mode 0) + (tool-bar-mode 0)) +(trap (global-auto-revert-mode t)) +(setq psgml-html-build-new-buffer nil) + +(setq cltl2-root-url + "http://metalzone.distorted.org.uk/doc/cltl/") +(setq common-lisp-hyperspec-root + "http://metalzone.distorted.org.uk/doc/hyperspec/") + +;;;----- Calendar configuration --------------------------------------------- + +;; --- Trivial stuff for the sunrise/sunset calculations --- + +(setq calendar-latitude 52.2) +(setq calendar-longitude 0.1) +(setq calendar-location-name "Cambridge, UK") + +;; --- Date format fiddling --- + +(setq european-calendar-style t) + +(setq diary-date-forms '((day "[-/]" month "[^-/0-9]") + (day " *" monthname "[ \t]*\\(\^M\\|\n\\)") + (backup day " *" monthname "\\W+\\<[^*0-9]") + (day "[-/]" month "[-/]" year "[^0-9]") + (day " *" monthname " *" year "[^0-9]") + (year "[-/]" month "[-/]" day "[^0-9]") + (dayname "\\W"))) + +;; --- Fancy diary handling --- + +(add-hook 'diary-display-hook 'fancy-diary-display) +(setq diary-list-include-blanks t) +(add-hook 'list-diary-entries-hook 'sort-diary-entries t) +(add-hook 'list-diary-entries-hook 'include-other-diary-files) +(add-hook 'mark-diary-entries-hook 'mark-included-diary-files) + +;; --- Appointment management --- + +(add-hook 'diary-hook 'appt-make-list) +(setq appt-issue-message t) +(setq appt-display-interval 3) +(setq appt-message-warning-time 10) + +;; --- Cosmetic stuff --- + +(setq display-time-24hr-format t) +(display-time) +(trap + (if window-system + (let ((view-diary-entries-initially t)) + (calendar)))) + +(defvar mdw-black-background t) + +;; --- Define more mode hooks for MailCrypt --- + +(setq mdw-mc-modes + '((mdwmail-mode (encrypt . mdwmail-mc-encrypt) + (sign . mdwmail-mc-sign)))) + +;; --- Load the MailCrypt support --- + +(trap + (and (string-match "linux" (symbol-name system-type)) + (progn (require 'mailcrypt-init) + (require 'mailcrypt) + (setq mc-default-scheme 'mc-scheme-gpg) + (setq mc-pgp-user-id "mdw-nsict-pgp") + (setq mc-gpg-user-id "mdw-nsict-gpg") + (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes)) + (setq mc-pgp-always-sign t) + (setq mc-gpg-always-sign t) + (setq mc-always-replace 'never) + (setq mc-passwd-timeout 3600) + (setq mc-temp-directory tmpdir) + (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes)) + (define-key mc-write-mode-map "\C-c/S" 'mc-sign-region) + (define-key mc-write-mode-map "\C-c/E" 'mc-encrypt-region) + (add-hook 'text-mode-hook 'mc-install-write-mode)))) + +;;;----- Other common declarations ------------------------------------------ + +;; --- Default frame size --- + +(setq default-frame-alist + (mdw-uniquify-alist + '((width . 78) + (height . 33) + (vertical-scroll-bars . right)) + (and window-system + '((cursor-type . bar) + (cursor-blink . t))) + '((cursor-color . "red")) + (if mdw-black-background + '((background-color . "black") + (foreground-color . "white") + (background-mode . dark)) + '((background-mode . light))) + (and (eq window-system 'pm) + '((font . "-os2-System VIO-medium-r-normal--*-40-*-*-m-*-cp850") + (menu-font . "8.Helv") + (background-color . "lightgrey"))) + '((transparency . t)) + default-frame-alist)) + +;; --- Other frame fiddling --- + +(setq frame-title-format '("" invocation-name "@" system-name ": %b")) + +;; --- Global keymap changes --- + +(trap + (windmove-default-keybindings) + (setq windmove-wrap-around t)) +(trap (iswitchb-mode)) +(global-set-key [f4] 'query-replace-regexp) +(global-set-key [f5] 'goto-line) +(global-set-key [f6] 'auto-fill-mode) +(global-set-key [f7] 'occur) +(global-set-key [f8] 'undo) +(global-set-key [f9] 'mdw-divvy-window) +(global-set-key [insertchar] 'overwrite-mode) +(global-set-key "\C-xm" 'vm-mail) +(global-set-key "\C-x\C-n" 'skel-create-file) +(global-set-key "\C-x4n" 'skel-create-file-other-window) +(global-set-key "\C-x5n" 'skel-create-file-other-frame) +(global-set-key [delete] 'delete-char) +(global-set-key "\C-[\C-m" 'call-last-kbd-macro) +(global-set-key "\M-q" 'mdw-fill-paragraph) +(global-set-key "\C-h\C-m" 'manual-entry) +(global-set-key [mode-line C-mouse-1] 'mouse-tear-off-window) +(global-set-key [vertical-scroll-bar C-down-mouse-1] + 'mouse-drag-vertical-line) +(global-set-key [vertical-scroll-bar C-mouse-1] + #'(lambda () (interactive))) +(global-set-key [mouse-4] 'mdw-wheel-up) +(global-set-key [mouse-5] 'mdw-wheel-down) + +;; --- Recognising types of files --- + +(setq auto-mode-alist + (append `(("\\.p[lm]$" . perl-mode) + ("\\.m$" . objc-mode) + ("\\.mxd$" . c-mode) + ;; ("/[ch]/" . c-mode) + (,(concat "/\\(" + "\\.stgit\\.msg" "\\|" + "\\.git/COMMIT_EDITMSG" "\\|" + "svn-commit\\.tmp" "\\|" + "svk-commit[^/.]*\\.tmp" + "\\)$") + . text-mode) + (,(concat "^" tmpdir "/\\(" + "svk-commit[^/.]*\\.tmp" "\\|" + "gitci\\.[^/.]*" "\\|" + "cvs[^/.]\\{6\\}" "\\|" + "\\)$") + . text-mode) + ("\\.calc?$" . apcalc-mode) + ("/src/linux/.*\\.\\(c\\|h\\|cc\\)$" . linux-c-mode) + ("/\\(s\\|sh\\)/" . arm-assembler-mode) + ("\\.\\(cmd\\|exec\\|rexx\\)$" . rexx-mode) + ("\\.st$" . smalltalk-mode) + ("\\.\\(tex\\|dtx\\)$" . latex-mode) + ("\\.gc$" . haskell.-mode) + (,(concat "^" (getenv "HOME") "/News/") . mdwmail-mode) + (,(concat "^" tmpdir "/\\(SLRN\\|snd\\|pico\\)") + . mdwmail-mode)) + auto-mode-alist)) + +(setq completion-ignored-extensions + (append `(".hc" ".hi") completion-ignored-extensions)) + +;; --- Some common local definitions --- + +(make-variable-buffer-local 'mdw-auto-indent) + +(mapcar (lambda (hook) (add-hook hook 'mdw-misc-mode-config)) + '(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook + perl-mode-hook cperl-mode-hook python-mode-hook awk-mode-hook + tcl-mode-hook + TeX-mode-hook LaTeX-mode-hook TeXinfo-mode-hook + tex-mode-hook latex-mode-hook texinfo-mode-hook + emacs-lisp-mode-hook scheme-mode-hook + lisp-mode-hook lisp-interaction-mode-hook inferior-lisp-mode-hook + slime-repl-mode-hook + sml-mode-hook haskell-mode-hook + smalltalk-mode-hook rexx-mode-hook + arm-assembler-mode-hook)) + +(global-font-lock-mode t) +(defalias 'perl-mode 'cperl-mode) + +;;;----- Rootly editingness ------------------------------------------------- + +(eval-after-load "tramp" + '(progn + (setq tramp-methods + (mdw-uniquify-alist + `(("become" + (tramp-connection-function tramp-open-connection-su) + (tramp-remote-sh "/bin/sh") + (tramp-login-program "become") + (tramp-copy-program nil) + (tramp-copy-args nil) + (tramp-copy-keep-date-arg nil) + (tramp-login-args ("TERM=dumb" "%u"))) + ("really" + (tramp-connection-function tramp-open-connection-su) + (tramp-login-program "really") + (tramp-login-args ("-u" "%u" "--" + "env" "TERM=dumb" "/bin/sh")) + (tramp-copy-program nil) + (tramp-copy-args nil) + (tramp-copy-keep-date-arg nil) + (tramp-remote-sh "/bin/sh")) + ,@tramp-methods))) + (setq tramp-multi-connection-function-alist + (mdw-uniquify-alist + '(("bc" tramp-multi-connect-su "become TERM=dumb %u%n")) + '(("r" tramp-multi-connect-su "really -u %u%n")) + tramp-multi-connection-function-alist)) + (setq tramp-default-method "ssh") + (setq tramp-default-method-alist + `(("\\`localhost\\'" "" + ,(cond ((executable-find "become") "become") + ((executable-find "really") "really") + (t "su"))))))) + +;;;----- General fontification ---------------------------------------------- + +;; --- Configure lazy fontification --- + +(setq font-lock-support-mode 'lazy-lock-mode) +; (setq lazy-lock-defer-contextually t) +(setq lazy-lock-defer-time nil) +(setq font-lock-maximum-decoration 3) +(setq lazy-lock-minimum-size 0) +(setq lazy-lock-stealth-time 5) +(setq lazy-lock-stealth-lines 100) +(setq lazy-lock-stealth-verbose t) + +(add-hook 'after-make-frame-functions 'mdw-do-set-font) +(add-hook 'term-setup-hook (lambda () (mdw-do-set-font (selected-frame)))) +(add-hook 'window-setup-hook (lambda () (mdw-do-set-font (selected-frame)))) + +(add-hook 'c-mode-hook 'mdw-fontify-c-and-c++ t) +(add-hook 'objc-mode-hook 'mdw-fontify-c-and-c++ t) +(add-hook 'c++-mode-hook 'mdw-fontify-c-and-c++ t) +(add-hook 'linux-c-mode-hook #'(lambda () (setq c-basic-offset 8))) + +(add-hook 'apcalc-mode-hook 'mdw-misc-mode-config t) +(add-hook 'apcalc-mode-hook 'mdw-fontify-apcalc t) + +(add-hook 'java-mode-hook 'mdw-fontify-java t) + +(add-hook 'awk-mode-hook 'mdw-fontify-awk t) + +(add-hook 'perl-mode-hook 'mdw-fontify-perl t) +(add-hook 'cperl-mode-hook 'mdw-fontify-perl t) + +(setq-default py-indent-offset 2) +(add-hook 'python-mode-hook 'mdw-fontify-python t) + +(setq-default tcl-indent-level 2) +(add-hook 'tcl-mode-hook 'mdw-fontify-tcl t) + +(add-hook 'rexx-mode-hook 'mdw-fontify-rexx t) + +(setq sml-nested-if-indent t) +(setq sml-case-indent nil) +(setq sml-indent-level 4) +(setq sml-type-of-indent nil) +(add-hook 'sml-mode-hook 'mdw-fontify-sml t) + +(add-hook 'haskell-mode-hook 'mdw-fontify-haskell t) +(setq-default haskell-indent-offset 2) + +(add-hook 'texinfo-mode-hook 'mdw-fontify-texinfo t) +(add-hook 'TeXinfo-mode-hook 'mdw-fontify-texinfo t) + +(setq LaTeX-table-label "tbl:") +(setq-default TeX-master nil) +;; (setq TeX-parse-self t) +;; (setq TeX-auto-save t) +(setq TeX-auto-untabify nil) +(add-hook 'TeX-mode-hook 'mdw-fontify-tex t) +(add-hook 'tex-mode-hook 'mdw-fontify-tex t) +(add-hook 'LaTeX-mode-hook 'mdw-fontify-tex t) +(add-hook 'latex-mode-hook 'mdw-fontify-tex t) + +(add-hook 'sh-mode-hook #'mdw-setup-sh-script-mode) + +(add-hook 'smalltalk-mode-hook 'mdw-fontify-smalltalk t) +(add-hook 'smalltalk-mode-hook 'mdw-setup-smalltalk t) + +(add-hook 'emacs-lisp-mode-hook 'mdw-fontify-lispy t) +(add-hook 'scheme-mode-hook 'mdw-fontify-lispy t) +(add-hook 'lisp-mode-hook 'mdw-fontify-lispy t) +(add-hook 'inferior-lisp-mode-hook 'mdw-fontify-lispy t) +(add-hook 'lisp-interaction-mode-hook 'mdw-fontify-lispy t) +(add-hook 'slime-repl-mode-hook 'mdw-fontify-lispy t) +(add-hook 'lisp-mode-hook 'mdw-common-lisp-indent t) +(require 'slime) +(slime-setup :autodoc t) +(trap (require 'xscheme)) +(setq-default xscheme-process-command-line "scheme -large -emacs") +(add-hook 'inferior-lisp-mode-hook + #'(lambda () + (local-set-key "\C-m" 'comint-send-and-indent)) t) + +(add-hook 'text-mode-hook 'mdw-text-mode t) + +;;;----- Shell mode --------------------------------------------------------- + +;; --- Make the shell mode aware of my prompt --- + +(setq shell-prompt-pattern "^[^]#$%>»\n]*[]#$%>»] *") +(setq comint-password-prompt-regexp + (concat "\\(\\([Oo]ld \\|[Nn]ew \\|[a-zA-Z0-9_]*'s \\|^\\)" + "[Pp]assword\\|pass phrase\\):\\s *\\'")) + +;; --- Notice passwords, and make C-a work right --- + +(add-hook 'shell-mode-hook #'mdw-sh-mode-setup) + +(add-hook 'term-mode-hook #'mdw-term-mode-setup) + +;;;----- Finishing touches -------------------------------------------------- + +(trap (select-window mdw-init-window)) +(provide 'emacs-init) + +;;;----- Emacs customization crud ------------------------------------------- + +(custom-set-variables + ;; custom-set-variables was added by Custom -- don't edit or cut/paste it! + ;; Your init file should contain only one such instance. + '(url-cookie-untrusted-urls (quote ("."))) + '(url-proxy-services (quote (("http" . "tux.nsict.org:3128") ("ftp" . "tux.nsict.org:3128") ("gopher" . "tux.nsict.org:3128")))) + '(w3-do-incremental-display t) + '(w3-honor-stylesheets nil) + '(w3-use-menus (quote (file edit view go bookmark options buffers style search emacs nil help))) + '(w3m-display-inline-image t) + '(w3m-key-binding (quote info))) +(custom-set-faces + ;; custom-set-faces was added by Custom -- don't edit or cut/paste it! + ;; Your init file should contain only one such instance. + ) + +;;;----- That's all, folks -------------------------------------------------- diff --git a/emacs-Makefile b/emacs-Makefile new file mode 100644 index 0000000..aa8da92 --- /dev/null +++ b/emacs-Makefile @@ -0,0 +1,7 @@ +### Emacs configuration Makefile + +all: dot-emacs.elc + +.SUFFIXES: .el .elc +.el.elc: + emacs --batch --eval '(byte-compile-file "$<")' diff --git a/emacs-calc b/emacs-calc new file mode 100644 index 0000000..ad95840 --- /dev/null +++ b/emacs-calc @@ -0,0 +1,111 @@ +;;; -*-emacs-lisp-*- + +;;; --- Homebrew functions --- + +(autoload 'calc-tabular-command "calc-alg-2") + +(defun calc-path-length (&optional var low high) + "Computes the path length of a parametric function. + +The stack should contain a vector containing the (rectangular only, I'm +afraid) components of a vector-valued function. The independent variable is +prompted for. If the Hyp flag is set, limits for the parameter are requested +and a definite path length is computed; otherwise an indefinite result is +computed. + +The path length of a function `r(t)' between limits `a' and `b' is computed +as + b + / + | |r(t)| dt + / + a + +If, as is likely, the result is unintegrable, a numeric result can be +obtained using `z n' (`calc-integrate-numerically')." + (interactive "sPath length variable: ") + (if (calc-is-hyperbolic) + (calc-tabular-command 'calcFunc-path-length "Path length" "path" + nil var low high) + (calc-slow-wrapper + (if (or (equal var "") (equal var "$")) + (calc-enter-result 2 "path" (list 'calcFunc-path-length + (calc-top-n 2) + (calc-top-n + 1))) + (let ((var (math-read-expr var))) + (if (eq (car-safe var) 'error) + (error "Bad format in expression: %s" + (nth 1 var))) + (calc-enter-result 1 "path" (list + 'calcFunc-path-length + (calc-top-n 1) + var))))))) + +(defun calcFunc-path-length (f x &optional a b) + (let ((d (math-simplify (list 'calcFunc-deriv f x)))) + (append (list 'calcFunc-integ + (list 'calcFunc-sqrt (list '* d d)) + x) + (and a b (list a b))))) + +(defvar var-IntegNumerRules 'calc-IntegNumerRules) +(defun calc-IntegNumerRules () + (math-read-plain-expr "[ +integ(f, x, a, b) := ninteg(f, x, a, b) :: constant(a) :: constant(b) +]")) + +(defun calc-integrate-numerically () + "Computes an approximate result for a symbolic definite integral with +constant bounds." + (interactive) + (calc-slow-wrapper + (calc-enter-result 1 "intn" + (math-rewrite (calc-top-n 1) var-IntegNumerRules 5)))) + +;;; Mode settings stored by Calc on Mon Mar 15 16:25:50 2004 +(setq calc-group-char " ") +(setq calc-frac-format '("/" nil)) +(setq calc-date-format '(Www " " D " " Mmmm " " YYYY (", " h ":" mm ":" ss))) +(setq calc-standard-date-formats '("N" "Www Mmm D, YYYY" "YYYY-MM-DD< hh:mm:ss>" "Www Mmm BD< hh:mm:ss> YYYY" "Www D Mmmm YYYY<, h:mm:ss>" "D.M.Y< h:mm:SS>" "M-D-Y< H:mm:SSpp>" "D-M-Y< h:mmCSS>" "j<, h:mm:SS>" "YYddd< hh:mm:ss>")) +(setq calc-complex-format 'i) +(setq calc-previous-modulo '(bigpos 296 967 294 4)) +(setq calc-angle-mode 'rad) +;;; End of mode settings + +;;; Variable "var-AlgSimpRules" stored by Calc on Thu Jan 6 21:04:23 2000 +(setq var-AlgSimpRules '(vec (calcFunc-assign (+ (^ (calcFunc-sin (var x var-x)) 2) (^ (calcFunc-cos (var x var-x)) 2)) 1) (calcFunc-assign (calcFunc-exp (var x var-x)) (^ (var e var-e) (var x var-x))))) + +;;; Custom units stored by Calc on Thu Mar 18 19:02:50 1999 +(setq math-additional-units '( + (TB "1024 * GB" "Terabyte") + (gig "GB" "Gigabyte") + (GB "1024 * MB" "Gigabyte") + (meg "MB" "Megabyte") + (MB "1024 * KB" "Megabyte") + (KB "1024 * byte" "Kilobyte") + (Tb "1024 * Gb" "Teraabit") + (Gb "1024 * Mb" "Gigabit") + (Mb "1024 * Kb" "Megabit") + (Kb "1024 * bit" "Kilobit") + (byte "octet" "Byte") + (octet "8 * bit" "Octet") + (bit nil "Bit") +)) +;;; End of custom units + +;;; Variable "var-DeMoivre" stored by Calc on Fri Mar 19 16:06:10 1999 +(setq var-DeMoivre '(vec (calcFunc-assign (^ (var e var-e) (var x var-x)) (calcFunc-exp (var x var-x))) (calcFunc-assign (calcFunc-exp (* (var i var-i) (var t var-t))) (calcFunc-evalsimp (+ (calcFunc-cos (var t var-t)) (* (var i var-i) (calcFunc-sin (var t var-t)))))))) + +;;; Variable "var-TrigDefRules" stored by Calc on Tue Jan 4 13:47:34 2000 +(setq var-TrigDefRules '(vec (calcFunc-phase 1) (calcFunc-assign (calcFunc-sin (var t var-t)) (/ (- (^ (var e var-e) (* (var i var-i) (var t var-t))) (^ (var e var-e) (neg (* (var i var-i) (var t var-t))))) (* 2 (var i var-i)))) (calcFunc-assign (calcFunc-cos (var t var-t)) (/ (+ (^ (var e var-e) (* (var i var-i) (var t var-t))) (^ (var e var-e) (neg (* (var i var-i) (var t var-t))))) 2)) (calcFunc-assign (calcFunc-arcsin (var x var-x)) (* (neg (var i var-i)) (calcFunc-ln (- (* (var i var-i) (var x var-x)) (calcFunc-sqrt (- 1 (^ (var x var-x) 2))))))) (calcFunc-assign (calcFunc-arccos (var x var-x)) (* (neg (var i var-i)) (calcFunc-ln (- (var x var-x) (calcFunc-sqrt (- (^ (var x var-x) 2) 1)))))) (calcFunc-assign (calcFunc-arctan (var x var-x)) (* (frac -1 2) (* (var i var-i) (calcFunc-ln (/ (+ 1 (* (var i var-i) (var x var-x))) (- 1 (* (var i var-i) (var x var-x)))))))) (calcFunc-assign (calcFunc-arctanh (var x var-x)) (* (frac 1 2) (calcFunc-ln (/ (+ 1 (var x var-x)) (- 1 (var x var-x)))))) (calcFunc-phase 2) (calcFunc-assign (calcFunc-tan (var t var-t)) (/ (calcFunc-sin (var t var-t)) (calcFunc-cos (var t var-t)))) (calcFunc-assign (calcFunc-sinh (var t var-t)) (* (neg (var i var-i)) (calcFunc-sin (* (var i var-i) (var t var-t))))) (calcFunc-assign (calcFunc-cosh (var t var-t)) (calcFunc-cos (* (var i var-i) (var t var-t)))) (calcFunc-assign (calcFunc-tanh (var t var-t)) (/ (calcFunc-sinh (var t var-t)) (calcFunc-cosh (var t var-t)))) (calcFunc-assign (calcFunc-arcsinh (var x var-x)) (* (neg (var i var-i)) (calcFunc-arcsin (* (var i var-i) (var x var-x))))) (calcFunc-assign (calcFunc-arccosh (var x var-x)) (* (neg (var i var-i)) (calcFunc-arccos (var x var-x)))))) + +;;; Definition stored by Calc on Tue Jan 4 22:44:33 2000 +(put 'calc-define 'calc-integrate-numerically '(progn + (define-key calc-mode-map "zn" 'calc-integrate-numerically) +)) + +;;; Definition stored by Calc on Tue Jan 4 22:44:37 2000 +(put 'calc-define 'calc-path-length '(progn + (define-key calc-mode-map "zp" 'calc-path-length) +)) diff --git a/lisp-init.lisp b/lisp-init.lisp new file mode 100644 index 0000000..c2a4fb5 --- /dev/null +++ b/lisp-init.lisp @@ -0,0 +1,7 @@ +;; Uppercase is bad on the eyes. +(setf *print-case* :downcase) +(setf *load-verbose* nil) +(setf *compile-verbose* nil) +#+cmu (setf *gc-verbose* nil) + + diff --git a/mailrc b/mailrc new file mode 100644 index 0000000..59fe250 --- /dev/null +++ b/mailrc @@ -0,0 +1,14 @@ +set MBOX=~/INBOX folder=Mail searchheaders dot ask indentprefix="> " +set append crt Replyall record=+sent +set EDITOR=ed +unset hold askcc askbcc autoprint save +retain From To Cc Bcc Subject Return-Path Delivered-To Date +# alias clive clive@dgw.co.uk +alias dad binswood@bigfoot.com +alias mum swbinswood@bigfoot.com +alias home mdw@distorted.org.uk +alias work mwooding@ncipher.com +alias spam spam@distorted.org.uk +alias ham ham@distorted.org.uk +alias band hibachi-dealers-members@chiark.greenend.org.uk +alias vicky vicky@harlequin.org.uk diff --git a/sbclrc b/sbclrc new file mode 120000 index 0000000..b812362 --- /dev/null +++ b/sbclrc @@ -0,0 +1 @@ +lisp-init.lisp \ No newline at end of file diff --git a/screenrc b/screenrc new file mode 100644 index 0000000..c291078 --- /dev/null +++ b/screenrc @@ -0,0 +1,3 @@ +escape ^zz +vbell off +defscrollback 1000 diff --git a/setup b/setup new file mode 100755 index 0000000..e262820 --- /dev/null +++ b/setup @@ -0,0 +1,184 @@ +#! /bin/sh + +set -e + +umask 002 + +sub= up=; +mkdir -p $HOME$sub + +: ${REPO=http://guvnor.distorted.org.uk/ftp/pub/mdw} + +export PATH=/usr/local/bin:$HOME$sub/bin:/usr/bin:/usr/ccs/bin:/bin + +### Sort out command line +xstuff= false= +while [ $# -gt 0 ]; do + case "$1" in + -x) xstuff=t;; + -n) false=false;; + --) shift; break;; + -*) echo >&2 "$0: bad option"; exit 1;; + *) break;; + esac + shift +done + +### Find out where I am +here=$(pwd) +case "$here" in + $HOME/*) ;; + *) echo >&2 "$0: must be below $HOME"; exit 1;; +esac +down=$(echo $here | sed "s#^$HOME/##") + +### Suss out how to print things +out=$(echo -n "foo"; echo "bar") +if [ "$out" = "foobar" ]; then + echon="echo -n" + echoc="" +else + echon="echo" + echoc='\c' +fi + +### Create the necessary directories +echo "Creating directories..." +for i in bin lib/emacs src; do + $echon " $i:$echoc" + if [ -d $HOME$sub/$i ]; then + echo " already exists." + else + mkdir -p $HOME$sub/$i + echo " done." + fi +done +echo " all done." + +### Find out how to fetch things over the net +$echon "Finding URL fetcher:$echoc" +if curl >/dev/null 2>&1 --version || [ $? -eq 2 ]; then + GETURL="curl -fs -o" + echo " curl." +elif wget >/dev/null 2>&1 --version; then + GETURL="wget -q -O" + echo " wget." +else + echo " failed!" + echo >&2 "$0: failed to find URL fetcher" + exit 1 +fi + +### Install necessary things +echo "Installing useful scripts..." + +for script in lesspipe.sh start-ssh-agent; do + $echon " $script:$echoc" + found= + for p in /bin /usr/bin /usr/local/bin $(echo $PATH | tr : ' '); do + if $false [ -x $p/$script ]; then + found=t + break + fi + done + if [ "$found" ]; then + echo " already installed." + else + $echon " downloading$echoc" + $GETURL $HOME$sub/bin/$script $REPO/$script + chmod +x $HOME$sub/bin/$script + echo " done." + fi +done + +echo " all done." + +### Install some more complicated programs +echo "Installing packages..." +systems=" + mLib:2.0.3:mLib-config + chkpath:1.1.0:tmpdir +" +[ "$xstuff" ] && systems="$systems + mgLib:1.1.0:mgLib-config + xtoys:1.3.0:xscsize +" +for system in $systems; do + set -- $(echo $system | tr : ' ') + sys=$1 ver=$2 prog=$3 + $echon " $sys:$echoc" + if $false $prog >/dev/null 2>&1 --version; then + echo " already installed." + else + ( set -e + $echon " downloading$echoc" + cd $HOME$sub/src + rm -rf $sys-$ver.tar.gz $sys-$ver + $GETURL $sys-$ver.tar.gz $REPO/$sys-$ver.tar.gz + $echon " unpacking$echoc" + gzip -cd $sys-$ver.tar.gz | tar xf - + $echon " configuring$echoc" + cd $sys-$ver + mkdir build + cd build + ../configure --prefix=$HOME$sub >>buildlog 2>&1 + $echon " building$echoc" + make >>buildlog 2>&1 + $echon " installing$echoc" + make install >>buildlog 2>&1 + echo " done." + ) + fi +done +echo " all done." + +### Symlink the various dotfiles into place +dotfiles=" + bash_profile bash_logout bashrc + emacs emacs-calc + vm mailrc + cmucl-init.lisp clisprc.lisp sbclrc + dircolors screenrc" +[ "$xstuff" ] && dotfiles="$dotfiles xinitrc xsession Xdefaults" +mkdir -p $HOME/test +echo "Installing dotfiles..." +for d in $dotfiles; do + [ -f $d ] + rm -f "$HOME$sub/.$d" + ln -s $up$down/$d $HOME$sub/.$d + echo " .$d" +done +echo " all done." + +### Set up the Emacs config +echo "Installing Emacs packages..." +for elib in make-regexp; do + $echon " $elib:$echoc" + if $false emacs >/dev/null 2>&1 --batch --eval ' + (kill-emacs (condition-case nil + (progn (load-library "make-regexp") 0) + (error 1)))'; then + echo " already installed." + else + $echon " downloading$echoc" + $GETURL $HOME$sub/lib/emacs/make-regexp.el $REPO/make-regexp.el + $echon " compiling$echoc" + (cd $HOME$sub/lib/emacs; + emacs >/dev/null 2>&1 --batch \ + --eval '(byte-compile-file "make-regexp.el")') + echo " done." + fi +done +echo " all done." + +$echon "Setting up Emacs configuration:$echoc" +$echon " linking$echoc" +for link in dot-emacs.el:dot-emacs.el emacs-Makefile:Makefile; do + set -- $(echo $link | tr : ' ') + from=$1 to=$2 + rm -f $HOME$sub/lib/emacs/$to + ln -s ../../$up$down/$from $HOME$sub/lib/emacs/$to +done +$echon " compiling$echoc" +make >/dev/null 2>&1 -C $HOME$sub/lib/emacs +echo " done." diff --git a/signature b/signature new file mode 100644 index 0000000..38bc198 --- /dev/null +++ b/signature @@ -0,0 +1 @@ +[mdw] diff --git a/vm b/vm new file mode 100644 index 0000000..4f23c6b --- /dev/null +++ b/vm @@ -0,0 +1,98 @@ +;;; -*-emacs-lisp-*- +;;; +;;; Configuration for VM + +(setq vm-reply-subject-prefix "Re: ") +(setq vm-included-text-prefix "> ") +(setq vm-included-text-attribution-format "%F <%f> wrote:\n\n") +;;(setq vm-spool-files '("/home/mdw/Mailbox" +;; "imap:tux.nsict.org:143:inbox:login:mdw:*")) +(setq vm-folder-directory "~/Mail/") +(setq vm-startup-with-summary t) +(setq vm-skip-deleted-messages nil) +(setq vm-circular-folders nil) +(setq vm-preview-lines nil) +(setq vm-highlighted-header-regexp "^From\\|^Subject") +(setq vm-delete-after-saving t) +(setq vm-move-after-deleting t) +(setq vm-delete-empty-folders) +(setq vm-mime-qp-encoder-program "mimencode") +(setq vm-mime-qp-encoder-switches '("-q")) +(setq vm-mime-qp-decoder-program "mimencode") +(setq vm-mime-qp-decoder-switches '("-q" "-u")) +(setq vm-mime-base64-encoder-program "mimencode") +(setq vm-mime-base64-encoder-switches '("-b")) +(setq vm-mime-base64-decoder-program "mimencode") +(setq vm-mime-base64-decoder-switches '("-b" "-u")) +(setq vm-visible-headers '("resent-from:" "from:" "reply-to:" "sender:" + "to:" "apparently-to:" "cc:" + "subject:" "date:" + "delivered-to:" "return-path:")) +(setq vm-reply-ignored-addresses '("mdw@excessus\\.demon\\.co\\.uk" + "mdw@nsict\\.org" "mdw@eh\\.org" + "mdw@ncipher\\.com" + "mdw@distorted\\.org\\.uk" + "mdw@metalzone\\.distorted\\.org\\.uk" + "mwooding@ncipher\\.com" + "tux@nsict\\.org")) + +(defvar mdw-mailing-lists + '("hibachi-dealers-members@chiark\\.greenend\\.org\\.uk")) + +(setq vm-mime-external-content-types-alist + '(("image/jpeg" "eog") + ("image/jpg" "eog") + ("image/gif" "eog") + ("image/tiff" "eog"))) + +(setq vm-url-browser "galeon") + +(setq vm-frame-parameter-alist + '((folder ((width . 80) (height . 33))) + (summary ((width . 80) (height . 33))) + (primary-summary ((width . 80) (height . 33))) + )) + +(setq vm-auto-folder-alist + '(("delivered-to" ("root@" . "admin")))) + + +(defun join-strings (del strings) + (with-output-to-string + (if (null strings) + nil + (princ (car strings)) + (setq strings (cdr strings)) + (while strings + (princ del) + (princ (car strings)) + (setq strings (cdr strings)))))) + +(defun mdw-vm-fix-mailing-lists () + (save-restriction + (save-excursion + (or (vm-mail-mode-get-header-contents "Resent-To:") + (vm-mail-mode-get-header-contents "Resent-Cc:") + (vm-mail-mode-get-header-contents "Resent-Bcc:") + (let ((mailing-list-regex (concat "\\<\\(" + (join-strings "\\|" + mdw-mailing-lists) + "\\)\\>")) + (to (vm-mail-mode-get-header-contents "To:")) + (cc (vm-mail-mode-get-header-contents "Cc:"))) + (if (or (and to (string-match mailing-list-regex to)) + (and cc (string-match mailing-list-regex cc))) + (let ((addrs (nconc (and to (vm-parse-addresses to)) + (and cc (vm-parse-addresses cc)))) + (new nil)) + (while addrs + (if (string-match mailing-list-regex (car addrs)) + (setq new (cons (car addrs) new))) + (setq addrs (cdr addrs))) + (vm-mail-mode-remove-header "Cc:") + (vm-mail-mode-remove-header "To:") + (widen) + (goto-char (point-min)) + (insert (format "To: %s\n" (join-strings ", " new)))))))))) + +(add-hook 'vm-reply-hook 'mdw-vm-fix-mailing-lists) diff --git a/xinitrc b/xinitrc new file mode 100755 index 0000000..17471fe --- /dev/null +++ b/xinitrc @@ -0,0 +1,113 @@ +#! /bin/bash + +xrdb -override $HOME/.Xdefaults +export __mdw_sechost="`hostname`" + +# --- Do some fiddling --- + +cleanup=":" +xset b 10 2000 50 +xset r rate 500 50 +xset m 1 1 +gnome-settings-daemon& +mail-notification& +gkrellm& +eval `xscsize -bx` + +# --- Crank up ESD --- + +if ! [ -r /tmp/.esd/socket ]; then + esd -nobeeps -as 10& + cleanup="$cleanup; kill $!" +fi + +# --- Start a nice window manager --- + +enlightenment $EOPTS& + +# --- Crank up a screenlock program --- + +if ${SCSAVE-true}; then + xscreensaver-command -exit + xscreensaver -no-splash& +fi +gnome-panel& +mail-notification& + +# --- Emacs window measurements --- +# +# Horizontal column pixel width = 492; window manager overhead = 34 +# Column character width = 82; Emacs magic overhead = -2 +# Vertical line pixel height = 13; misc overhead = 52 + +emacs="noip emacs" + +# --- Xterm window measurements --- +# +# Window width is 504 (fixed). +# Vertical line pixel height = 13; misc overhead = 23 + +xterm="Eterm" xgeom=-geometry + +# --- GNOME stuff measurements --- +# +# GNOME panel width = 113 + +declare -i xbound="XWIDTH - 113" + +# --- Choose a width for Emacs --- +# +# We'd like it to be as wide as possible, allowing for a column of xterms +# down the right hand side. However, I'd prefer a double-width Emacs to a +# single-width Emacs and xterms. If it's not going to work at all, a single +# Emacs column will have to do. Also, there's a strange thing with Emacs21 +# and the toolbar, so we add on some rows which are later mysteriously +# subtracted. + +declare -i ecols="(xbound - 504 - 34)/492" +if (( ecols < 2 && xbound > 492 * 2 + 34 )); then + ecols=2 +elif (( ecols < 1 )); then + ecols=1 +fi + +declare -i x="ecols * 492 + 34" +$emacs -geometry $((ecols * 82 - 2))x$(((XHEIGHT - 52)/13))+0+0& + +# --- Now place some xterms --- +# +# A few smaller xterms are in general better than one great big one. 35 +# lines is a good height for most terminals. 25 lines is a minimum. The +# strategy for doling out xterms into a column is to make as many 35-liners +# as we can, until the remaining space would be too small for a 25-liner. If +# we can get two 25s out of that then we do (largest first); otherwise just +# make one big one. We stop at the end of a page, once we've made three +# xterms. + +declare -i n=0 pgx=0 l h y ht +declare -i hstd="35 * 13 + 23" hmin="25 * 13 + 23" +while true; do + if ((x + 504 > xbound)); then + if ((n >= 3)); then break; fi + x="pgx + XWIDTH" pgx="pgx + XWIDTH" xbound="xbound + XWIDTH" + fi + y=0 ht=XHEIGHT + while ((ht - hstd >= hmin)); do + $xterm -$xgeom 80x35+$x+$y& + y="y + hstd" ht="ht - hstd" n="n + 1" + done + if ((ht >= 2 * hmin)); then h="ht - hmin"; else h=ht; fi + l="(h - 23)/13" h="l * 13 + 23" + $xterm -$xgeom 80x$l+$x+$y& + y="y + h" ht="ht - h" n="n + 1" + if ((ht >= hmin)); then + $xterm -$xgeom 80x25+$x+$y& + n="n + 1" + fi + x="x + 504" +done + +# --- Wait for the world to end --- + +xwait XWAIT_DIE:XWAIT_DIE_NOW +eval "$cleanup" diff --git a/xsession b/xsession new file mode 100755 index 0000000..4db274b --- /dev/null +++ b/xsession @@ -0,0 +1,8 @@ +#! /bin/bash + +# --- Lots of sensible initialisation --- + +__mdw_force_secure_session=yes +. $HOME/.bash_profile +. $HOME/.xinitrc +. $HOME/.bash_logout -- [mdw]