dot/emacs: Set up autoloads for mail-sending functions.
[profile] / dot / xinitrc
index 81a7aaf..0871b35 100755 (executable)
@@ -116,7 +116,7 @@ case ",$XWIDTH,$XHEIGHT," in
 esac
 case ",$XNSCR," in
   ,,)
-    XNSCR=1 XSCR0_X=0 XSCR0_Y=0 XSCR0_WIDTH=$XWIDTH XSCR0_HEIGHT=XHEIGHT
+    XNSCR=1 XSCR0_X=0 XSCR0_Y=0 XSCR0_WIDTH=$XWIDTH XSCR0_HEIGHT=$XHEIGHT
     ;;
 esac
 i=0; while (( i < XNSCR )); do
@@ -216,7 +216,8 @@ start-clients () {
 ### Main screen layout.
 
 ## Choose appropriate clients.
-emacs=$(pick_program emacs emacs23 emacs24 emacs22 emacs21 emacs)
+emacs=$(pick_program emacs \
+  emacs23-lucid emacs24-lucid emacs23 emacs24 emacs22 emacs21 emacs)
 term=$(pick_program terminal pterm Eterm xterm)
 
 ## Emacs window measurements.
@@ -248,6 +249,16 @@ case "$emacs" in
     e_colchars=82 e_cextra=-6
     e_lineht=13 e_vextra=42
     ;;
+  emacs23-lucid)
+    e_colwd=492 e_hextra=7
+    e_colchars=82 e_cextra=-6
+    e_lineht=13 e_vextra=48
+    ;;
+  emacs24-lucid)
+    e_colwd=492 e_hextra=7
+    e_colchars=82 e_cextra=-5
+    e_lineht=13 e_vextra=48
+    ;;
 esac
 
 ## Terminal window measurements.
@@ -266,27 +277,34 @@ declare -i panelwd=64 xbound=$(( XWIDTH - panelwd ))
 
 ## 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.
-
+## We're going to make a single frame of Emacs, which will be automatically
+## divvied into columns; the rest of the space will be tiled with xterms.  If
+## we have multiple screens, then Emacs can have the first screen and we'll
+## fill the rest with terminals.  Otherwise, we'll try to have N columns of
+## Emacs, and N - 1 columns of xterms; if that doesn't work, we'll make do
+## with N - 2 columns of xterms.
+##
+## So, let W be the available width; let E and T be the widths of an Emacs
+## column (e_colwd) and terminal (t_wd), respectively, and let E0 be the
+## additive width of Emacs's existence (e_hextra).  If we have more than one
+## screen, then instead, let T be zero.  To start out, then, we let N = 1 +
+## floor((W - E - E0)/(E + T)).  If W - E0 - (N + 1) E - (N - 1)*T >= 0, then
+## we increase N by one.
 declare -i lim=XSCR0_WIDTH
 if (( lim > xbound )); then lim=xbound; fi
-declare -i ecols="(lim - t_wd - e_hextra)/e_colwd"
-if (( ecols < 2 && lim > 2*e_colwd + e_hextra )); then ecols=2
-elif (( ecols < 1 )); then ecols=1
+declare -i twd=t_wd; if (( XNSCR > 1 )); then twd=0; fi
+declare -i ecols=$(( (lim - e_colwd - e_hextra)/(e_colwd + twd) + 1 ))
+if (( lim - e_hextra - (ecols + 1)*e_colwd - (ecols - 1)*twd >= 0 )); then
+  ecols=$(( ecols + 1 ))
 fi
 
 declare -i \
-  emacsx="ecols*e_colchars + e_cextra" \
-  emacsy="(XHEIGHT - e_vextra)/e_lineht"
+  emacsx=$(( ecols*e_colchars + e_cextra )) \
+  emacsy=$(( (XHEIGHT - e_vextra)/e_lineht ))
 
 start-emacs () {
   GDK_NATIVE_WINDOWS=1 run bgclients noip \
-    $emacs -bg black -geometry ${emacsx}x${emacsy}+0+0
+    $emacs -bg black -geometry ${emacsx}x${emacsy}+${XSCR0_X}+${XSCR0_Y}
 }
 
 ## Now place some xterms.
@@ -302,9 +320,10 @@ start-emacs () {
 start-xterms () {
 
   ## Initialize some parameters.
-  declare -i x="ecols*e_colwd + e_hextra" xb=xbound
+  declare -i x=$(( ecols*e_colwd + e_hextra + XSCR0_X )) xb=xbound
   declare -i n=0 pgx=0 l h y ht scr=0 ll=lim
-  declare -i hstd="35*t_lineht + t_vextra" hmin="25*t_lineht + t_vextra"
+  declare -i hstd=$(( 35*t_lineht + t_vextra ))
+  declare -i hmin=$(( 25*t_lineht + t_vextra ))
   declare -i scrx scry scrwd scrht
 
   eval "scrx=\$XSCR${scr}_X scry=\$XSCR${scr}_Y
@@ -314,7 +333,7 @@ start-xterms () {
   while :; do
 
     ## Start a new iteration.
-    if ((x + t_wd > ll)); then
+    if (( x + t_wd > ll )); then
       scr=$(( scr + 1 ))
       if (( scr >= XNSCR )); then
        if (( n >= 3 )); then break; fi
@@ -330,21 +349,21 @@ start-xterms () {
 
     ## Make large xterms.
     y=scry ht=scrht
-    while ((ht - hstd >= hmin)); do
+    while (( ht - hstd >= hmin )); do
       run bgclients $term $geom 80x35+$x+$y
-      y="y + hstd" ht="ht - hstd" n="n + 1"
+      y=$(( y + hstd )) ht=$(( ht - hstd )) n=$(( n + 1 ))
     done
 
     ## Fill the remaining space.
-    if ((ht >= 2 * hmin)); then h="ht - hmin"; else h=ht; fi
-    l="(h - t_vextra)/t_lineht" h="l * t_lineht + t_vextra"
+    if (( ht >= 2*hmin )); then h=$(( ht - hmin )); else h=ht; fi
+    l=$(( (h - t_vextra)/t_lineht )) h=$(( l*t_lineht + t_vextra ))
     run bgclients $term $geom 80x$l+$x+$y
-    y="y + h" ht="ht - h" n="n + 1"
+    y=$(( y + h )) ht=$(( ht - h )) n=$(( n + 1 ))
     if ((ht >= hmin)); then
       run bgclients $term $geom 80x25+$x+$y
-      n="n + 1"
+      n=$(( n + 1 ))
     fi
-    x="x + t_wd"
+    x=$(( x + t_wd ))
   done
 }