dot/emacs: Don't do calendar/diary things if we're trying to start quickly.
[profile] / dot / bash_profile
index 7f372f2..2a47c68 100644 (file)
@@ -2,9 +2,8 @@
 ###
 ### Bash startup things
 
-## Only do any of this if we haven't done it before.  Otherwise we
-## can have loops and lots of wasted time.
-if [ -z "$__mdw_profile" ]; then
+## The `.bashrc' hook will run us if it thinks we haven't been run before.
+## We should therefore let it know.
 export __mdw_profile=done
 
 ###--------------------------------------------------------------------------
@@ -57,7 +56,7 @@ __mdw_programp () { type -t >/dev/null "$1"; }
 ## 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
+[ -n "$SCHROOT_SESSION_ID" ] || cd $HOME
 
 ## CDE's session structure is demented and doesn't leave us with a proper
 ## logout hook, so synthesize one here.
@@ -94,6 +93,12 @@ __mdw_addto PYTHONPATH r $HOME/lib/python
 ###--------------------------------------------------------------------------
 ### Various other kinds of configuration.
 
+__mdw_setconf () {
+  if val=$(mdw-conf 2>/dev/null "$2"); then
+    eval "export $1=\$val"
+  fi
+}
+
 ## Establish a temporary directory.
 [ "$TMPDIR" ] || eval `tmpdir -b`
 export TMP=$TMPDIR
@@ -102,9 +107,9 @@ export TMP=$TMPDIR
 umask 002
 
 ## Mail and general identification.
-export MAIL=`mdw-conf mailbox`
+__mdw_setconf MAIL mailbox
 export NAME="Mark Wooding"
-export EMAIL=`mdw-conf email`
+__mdw_setconf EMAIL email
 export QMAILINJECT=c
 
 ## Some programs want to know the hostname.
@@ -114,6 +119,8 @@ export QMAILINJECT=c
 export MDW_EDITOR=ed
 emacs_startup_args="--no-site-file --mdw-fast-startup -nw"
 for ed in \
+       "emacs23 $emacs_startup_args" \
+       "emacs24 $emacs_startup_args" \
        "emacs22 $emacs_startup_args" \
        "emacs21 $emacs_startup_args" \
        zile mg \
@@ -130,9 +137,9 @@ export EDITOR=mdw-editor VISUAL=mdw-editor
 ## Determine the locale settings.  Really don't set LC_COLLATE because it
 ## messes with the order of files in `ls' listings and similar.
 if [ "$DISPLAY" != "" ]; then
-  LANG=`mdw-conf x-ctype`
+  LANG=`mdw-conf x-ctype POSIX`
 else
-  : ${LANG=${LC_CTYPE-${LC_ALL-`mdw-conf console-ctype`}}}
+  : ${LANG=${LC_CTYPE-${LC_ALL-`mdw-conf console-ctype POSIX`}}}
   case "$TERM,`tty`" in
     linux,/dev/tty*)
       if { vt-is-UTF8 ||
@@ -150,7 +157,7 @@ export LC_COLLATE=POSIX LANG
 
 ## Pager configuration.
 export MDW_PAGER=`type -p less` PAGER=mdw-pager METAMAIL_PAGER=mdw-pager
-export LESS="-iqgRh1FSX"
+export LESS="-iqgRh1j.3FSX"
 export LESSOPEN="|lesspipe.sh %s"
 case "${LC_CTYPE-$LANG}" in
   *utf8 | *utf-8 | *UTF8 | *UTF-8) LESSCHARSET=utf-8 ;;
@@ -182,9 +189,23 @@ export PERL_READLINE_NOWARN=yes
 ## If we have `distcc' then tell `ccache' to use it.
 __mdw_programp distcc && export CCACHE_PREFIX=distcc
 
+## Choose a sensible web browser.  If we have a display, try to pick a
+## graphical one.
+browsers="elinks w3m lynx"
+case "${DISPLAY+t}" in
+  t) browsers="mdw-iceweasel mdw-chrome iceweasel firefox $browsers" ;;
+esac
+for i in $browsers; do
+  if __mdw_programp $i; then
+    export BROWSER=$i
+    break
+  fi
+done
+unset browsers
+
 ## Acquiring root privileges.  This is mainly the job of `bashrc', but we
 ## cache the mechanism here.
-export __MDW_ROOTLY=`mdw-conf rootly`
+__mdw_setconf __MDW_ROOTLY rootly
 export BECOME="--preserve-environment"
 
 ## It's useful to see the little sigils in `ls'.
@@ -195,12 +216,12 @@ export BASCAT="-l +n"
 
 ## Version control hacking.
 export CVS_RSH=ssh
-export CVSROOT=`mdw-conf cvs-root`
-export SVNROOT=`mdw-conf svn-root`
+__mdw_setconf CVSROOT cvs-root
+__mdw_setconf SVNROOT svn-root
 export P4CONFIG=.p4
 
 ## News server.
-[ -z "$NNTPSERVER" ] && export NNTPSERVER=`mdw-conf nntp-server`
+__mdw_setconf NNTPSERVER nntp-server
 
 ## Help X programs find their resources.
 export XUSERFILESEARCHPATH="$HOME/.Xapps/%N:/usr/lib/X11/%T/%N%S"
@@ -224,13 +245,11 @@ ulimit -S -c 0
 if { { [ "$GNOME_KEYRING_CONTROL" ] &&
        [ -s "$GNOME_KEYRING_CONTROL" ]; } ||
      { [ "$DBUS_SESSION_BUS_ADDRESS" ] &&
-       dbus-send --session --print-reply --dest=org.freedesktop.DBus \
-        / org.freedesktop.DBus.GetNameOwner string:org.gnome.keyring \
-        >/dev/null 2>/dev/null; }; } &&
-   stuff=$(gnome-keyring-daemon -s -c ssh 2>/dev/null)
+       __mdw_programp gnome-keyring-daemon; }; } &&
+   stuff=$(gnome-keyring-daemon -s -c ssh,gpg 2>/dev/null)
 then
   eval "$stuff"
-  export SSH_AUTH_SOCK
+  export SSH_AUTH_SOCK GPG_AGENT_INFO
 fi
 
 ## If we still don't have an agent then start one with a stable name.
@@ -272,9 +291,6 @@ fi
 ## If there's a local hook then run it.
 [ -f "$HOME/.profile-local" ] && . "$HOME/.profile-local"
 
-## End of the `__mdw_profile' guard.
-fi
-
 ## If we haven't run the `.bashrc' yet, and this shell is interactive, then
 ## run it now.
 [ -z "$__mdw_bashrc" ] && [ -t 0 ] && \