export __mdw_profile=done
+# --- 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
+
# --- Add elements to a path string ---
__mdw_addto () {
export $var=$val
}
-# --- What sort of machine am I running on? ---
-
-export arch=`echo $MACHTYPE | tr 'A-Z' 'a-z'`
+# --- Find a configuration item ---
+
+__mdw_conf () {
+ local var=$1
+ val=`sed -n "
+ /^[ ]*$var[ ]*=[ ]*\(\|.*[^ ]\)[ ]*$/ {
+ s//\1/; p; q
+ }
+ " ${MDWCONF-$HOME/.mdw.conf}`
+ case "$val" in "~"*) val=`eval "echo ${val%%/*}"`${val#\~};; esac
+ echo "$val"
+}
# --- Set the path variable ---
__mdw_addto PATH l \
+ $HOME/bin \
{,/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
+if [ -d /usr/local/plan9 ]; then
+ export PLAN9=/usr/local/plan9
+ __mdw_addto PATH r \
+ $PLAN9/bin
+fi
# --- And the same for manual pages ---
-case "$arch" in
+case "$MACHTIME" in
*linux*)
MANPATH=`manpath -q`
;;
{/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 MAIL=`__mdw_conf mailbox`
export NAME="Mark Wooding"
-export EMAIL="mdw@distorted.org.uk"
+export EMAIL=`__mdw_conf email`
export QMAILINJECT=c
# --- GIT environment things ---
__mdw_addto PERLLIB r $HOME/lib/perl
__mdw_addto PYTHONPATH r $HOME/lib/python
+export __MDW_ROOTLY=`__mdw_conf rootly`
+
[ -z "$LS_OPTIONS" ] && export LS_OPTIONS="-F"
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 CVSROOT=`__mdw_conf cvs-root`
+export SVNROOT=`__mdw_conf svn-root`
+
export BECOME="--preserve-environment"
export PAGER=`type -p less` METAMAIL_PAGER=`type -p less`
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 "$NNTPSERVER" ] && export NNTPSERVER=`__mdw_conf nntp-server`
+[ -z "$http_proxy" ] && export http_proxy=`__mdw_conf http-proxy`
[ -z "$ftp_proxy" ] && export ftp_proxy=$http_proxy
export XUSERFILESEARCHPATH="$HOME/.Xapps/%N:/usr/lib/X11/%T/%N%S"
alias cx='chmod a+x'
alias which="command -v"
alias ssync="rsync -e ssh"
-alias rootly="become -g0 root"
+alias rootly=$__MDW_ROOTLY
alias r=rootly
alias re="rootly sensible-editor"
alias pstree="pstree -Ghl"
,(if (cdr forms) (cons 'progn forms) (car forms))
(error (message "Error (trapped): %s" (error-message-string err)))))
+;; --- Configuration reading ---
+
+(defvar mdw-config nil)
+(defun mdw-config (sym)
+ "Read the configuration variable named SYM."
+ (unless mdw-config
+ (setq mdw-config (with-temp-buffer
+ (insert-file-contents "~/.mdw.conf")
+ (replace-regexp "^[ \t]*\\(#.*\\|\\)\n" ""
+ nil (point-min) (point-max))
+ (replace-regexp (concat "^[ \t]*"
+ "\\([-a-zA-Z0-9_.]*\\)"
+ "[ \t]*=[ \t]*"
+ "\\(.*[^ \t\n]\\|\\)"
+ "[ \t]**\\(\n\\|$\\)")
+ "(\\1 . \"\\2\") "
+ nil (point-min) (point-max))
+ (car (read-from-string
+ (concat "(" (buffer-string) ")"))))))
+ (cdr (assq sym mdw-config)))
+
;; --- Splitting windows ---
(defconst mdw-scrollbar-width (if window-system 6 1)
(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/")
+(setq cltl2-root-url (mdw-config 'cltl-url))
+(setq common-lisp-hyperspec-root (mdw-config 'hyperspec-url))
+
+;;;----- W3 and URL fetching stuff ------------------------------------------
+
+(let ((proxy (mdw-config 'proxy)))
+ (setq url-proxy-services
+ `(("http" . ,proxy)
+ ("ftp" . ,proxy)
+ ("gopher" . ,proxy))))
+(setq url-cookie-untrusted-urls '("."))
+
+(setq w3-do-incremental-display t
+ w3-use-menus '(file edit view go bookmark options
+ buffers style search emacs nil help)
+ w3-display-inline-image t
+ w3-keybinding 'info)
;;;----- Calendar configuration ---------------------------------------------
(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" . "metalzone.distorted.org.uk:3128") ("ftp" . "metalzone.distorted.org.uk:3128") ("gopher" . "metalzone.distorted.org.uk: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 --------------------------------------------------
--- /dev/null
+### System-specific differences for various dotfiles.
+
+email = mdw@distorted.org.uk
+mailbox = ~/Mailbox
+rootly = become -g0 root
+http-proxy = metalzone.distorted.org.uk:3128
+nntp-server = metalzone.distorted.org.uk
+cvs-root = metalzone.distorted.org.uk:/home/cvs/cvs
+svn-root = svn+ssh://metalzone.distorted.org.uk/home/cvs/svn
+cltl-url = http://metalzone.distorted.org.uk/doc/cltl/
+hyperspec-url = http://metalzone.distorted.org.uk/doc/hyperspec/
done
echo " all done."
+### Install global configuration
+echo -n "Installing dotfile configuration:"
+if [ -f $HOME$sub/.mdw.conf ]; then
+ echo " already installed."
+else
+ cp mdw.conf $HOME$sub/.mdw.conf
+ echo " done."
+fi
+
### Symlink the various dotfiles into place
dotfiles="
bash_profile bash_logout bashrc