From: Mark Wooding Date: Thu, 16 Mar 2006 20:26:33 +0000 (+0000) Subject: mdw.conf: Central configuration file for common differences. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/profile/commitdiff_plain/f141fe0f7df0fbf62a6cf6fa5180c50c7c3d67e6 mdw.conf: Central configuration file for common differences. Hopefully, isolating various simple differences in this file should make branching and merging rarer. --- diff --git a/bash_profile b/bash_profile index 70d7606..198aeeb 100644 --- a/bash_profile +++ b/bash_profile @@ -8,6 +8,15 @@ if [ -z "$__mdw_profile" ]; then 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 () { @@ -44,24 +53,35 @@ __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` ;; @@ -70,20 +90,11 @@ __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 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 --- @@ -117,21 +128,16 @@ __mdw_addto INFOPATH r $HOME/info /usr/info /usr/share/info /usr/local/info __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` @@ -143,8 +149,8 @@ export LESSCHARSET=latin1 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" diff --git a/bashrc b/bashrc index 16b7e8e..4c5e02f 100644 --- a/bashrc +++ b/bashrc @@ -110,7 +110,7 @@ ls () { 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" diff --git a/dot-emacs.el b/dot-emacs.el index 4f55e91..0ff6020 100644 --- a/dot-emacs.el +++ b/dot-emacs.el @@ -36,6 +36,27 @@ (defmacro trap (&rest forms) ,(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) diff --git a/emacs b/emacs index 7149f6f..2b74aef 100644 --- a/emacs +++ b/emacs @@ -153,10 +153,23 @@ (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 --------------------------------------------- @@ -486,21 +499,4 @@ (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 -------------------------------------------------- diff --git a/mdw.conf b/mdw.conf new file mode 100644 index 0000000..f6c50a2 --- /dev/null +++ b/mdw.conf @@ -0,0 +1,11 @@ +### 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/ diff --git a/setup b/setup index 78adb5d..1ebf7f1 100755 --- a/setup +++ b/setup @@ -127,6 +127,15 @@ for system in $systems; do 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