diff -r 66918a26149f -r b71e74cfe817 .emacs-autogen.sh --- a/.emacs-autogen.sh Mon Feb 21 21:09:27 2011 +0200 +++ b/.emacs-autogen.sh Mon Feb 21 23:38:34 2011 +0200 @@ -7,16 +7,98 @@ cfg=$1 -if command -v ispell; then - echo >>$cfg - echo "(setq-default ispell-program-name \"ispell\")" >>$cfg - if [ -e /etc/debian_version ]; then - echo "(setq-default ispell-local-dictionary \"british\")" >>$cfg - else - echo "(setq-default ispell-local-dictionary \"default\")" >>$cfg - fi -elif command -v aspell; then - echo >>$cfg - echo "(setq-default ispell-program-name \"aspell\")" >>$cfg - echo "(setq-default ispell-local-dictionary \"english\")" >>$cfg -fi +# Set host_os: +# windows, linux, unknown +# host_distro: +# cygwin, debian, unknown +check_platform() { + case `uname -s` in + CYGWIN_NT-*) + host_os=windows + host_distro=cygwin + ;; + Linux) + host_os=linux + if [ -e /etc/debian_version ]; then + host_distro=debian + else + host_distro=unknown + fi + ;; + *) + host_os=unknown + ;; + esac +} + +check_ispell() { + command -v ispell >/dev/null && return 0 || return 1 +} + +check_aspell() { + command -v aspell >/dev/null && return 0 || return 1 +} + +print_ispell() { + echo '(setq-default ispell-program-name "ispell")' + case $host_distro in + debian) + echo '(setq-default ispell-local-dictionary "british")' + ;; + unknown) + echo '(setq-default ispell-local-dictionary "default")' + ;; + esac +} + +print_aspell() { + echo '(setq-default ispell-program-name "aspell")' + echo '(setq-default ispell-local-dictionary "en")' +} + +check_speller() { + echo + echo ';; ================================================================' + echo ';; Speller settings (check_speller).' + echo + check_ispell + ispell_present=$? + check_aspell + aspell_present=$? + case $host_os in + windows) + case $host_distro in + cygwin) + if [ $aspell_present = 0 ]; then + print_aspell + elif [ $ispell_present = 0 ]; then + print_ispell + fi + ;; + esac + ;; + linux) + case $host_distro in + debian) + if [ $ispell_present = 0 ]; then + print_ispell + elif [ $aspell_present = 0 ]; then + print_aspell + fi + ;; + esac + ;; + *) + : + ;; + esac +} + +# Remove old auto-generated config and fill it by standard header. +echo ";; -*- mode: lisp; coding: utf-8; fill-column: 78 -*- +;; +;; For load order see README. +" >$cfg + +check_platform +check_speller >>$cfg