chiark / gitweb /
mdw.conf: Central configuration file for common differences.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 16 Mar 2006 20:26:33 +0000 (20:26 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 16 Mar 2006 20:40:13 +0000 (20:40 +0000)
Hopefully, isolating various simple differences in this file should make
branching and merging rarer.

bash_profile
bashrc
dot-emacs.el
emacs
mdw.conf [new file with mode: 0644]
setup

index 70d76068611e346a50bf43387cb33c9f955af7d0..198aeeb6ac7590789a25a05c5e7d4ecb21de9522 100644 (file)
@@ -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 16b7e8e327ce6cf966497995284d868452943d5c..4c5e02fca45e29dfaf187cd3ab83ac2a7465af29 100644 (file)
--- 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"
index 4f55e91714ee3499f711b88ba3b5a6892dbbf244..0ff6020570e308bac3b031b013d8a9369c36dce6 100644 (file)
@@ -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 7149f6f5928cbf88c6dbc5fdfb7b6aa2e780ad36..2b74aefc4b75447759ddd569c2672a413e9c505b 100644 (file)
--- a/emacs
+++ b/emacs
 (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 --------------------------------------------------
diff --git a/mdw.conf b/mdw.conf
new file mode 100644 (file)
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 78adb5daa73194a04dde522b07d5fcefeec2edef..1ebf7f1b82283a127d42beaecba39801bf1ed420 100755 (executable)
--- 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