.emacs-autogen.sh
changeset 579 b71e74cfe817
parent 575 d2730823e23f
child 604 9084d12d924d
equal deleted inserted replaced
578:66918a26149f 579:b71e74cfe817
     5   exit 1
     5   exit 1
     6 fi
     6 fi
     7 
     7 
     8 cfg=$1
     8 cfg=$1
     9 
     9 
    10 if command -v ispell; then
    10 # Set host_os:
    11   echo >>$cfg
    11 #   windows, linux, unknown
    12   echo "(setq-default ispell-program-name \"ispell\")" >>$cfg
    12 # host_distro:
    13   if [ -e /etc/debian_version ]; then
    13 #   cygwin, debian, unknown
    14     echo "(setq-default ispell-local-dictionary \"british\")" >>$cfg
    14 check_platform() {
    15   else
    15   case `uname -s` in
    16     echo "(setq-default ispell-local-dictionary \"default\")" >>$cfg
    16     CYGWIN_NT-*)
    17   fi
    17       host_os=windows
    18 elif command -v aspell; then
    18       host_distro=cygwin
    19   echo >>$cfg
    19       ;;
    20   echo "(setq-default ispell-program-name \"aspell\")" >>$cfg
    20     Linux)
    21   echo "(setq-default ispell-local-dictionary \"english\")" >>$cfg
    21       host_os=linux
    22 fi
    22       if [ -e /etc/debian_version ]; then
       
    23         host_distro=debian
       
    24       else
       
    25         host_distro=unknown
       
    26       fi
       
    27       ;;
       
    28     *)
       
    29       host_os=unknown
       
    30       ;;
       
    31   esac
       
    32 }
       
    33 
       
    34 check_ispell() {
       
    35   command -v ispell >/dev/null && return 0 || return 1
       
    36 }
       
    37 
       
    38 check_aspell() {
       
    39   command -v aspell >/dev/null && return 0 || return 1
       
    40 }
       
    41 
       
    42 print_ispell() {
       
    43   echo '(setq-default ispell-program-name "ispell")'
       
    44   case $host_distro in
       
    45     debian)
       
    46       echo '(setq-default ispell-local-dictionary "british")'
       
    47       ;;
       
    48     unknown)
       
    49       echo '(setq-default ispell-local-dictionary "default")'
       
    50       ;;
       
    51   esac
       
    52 }
       
    53 
       
    54 print_aspell() {
       
    55   echo '(setq-default ispell-program-name "aspell")'
       
    56   echo '(setq-default ispell-local-dictionary "en")'
       
    57 }
       
    58 
       
    59 check_speller() {
       
    60   echo
       
    61   echo ';; ================================================================'
       
    62   echo ';; Speller settings (check_speller).'
       
    63   echo
       
    64   check_ispell
       
    65   ispell_present=$?
       
    66   check_aspell
       
    67   aspell_present=$?
       
    68   case $host_os in
       
    69     windows)
       
    70       case $host_distro in
       
    71         cygwin)
       
    72           if [ $aspell_present = 0 ]; then
       
    73             print_aspell
       
    74           elif [ $ispell_present = 0 ]; then
       
    75             print_ispell
       
    76           fi
       
    77           ;;
       
    78       esac
       
    79       ;;
       
    80     linux)
       
    81       case $host_distro in
       
    82         debian)
       
    83           if [ $ispell_present = 0 ]; then
       
    84             print_ispell
       
    85           elif [ $aspell_present = 0 ]; then
       
    86             print_aspell
       
    87           fi
       
    88           ;;
       
    89       esac
       
    90       ;;
       
    91     *)
       
    92       :
       
    93       ;;
       
    94   esac
       
    95 }
       
    96 
       
    97 # Remove old auto-generated config and fill it by standard header.
       
    98 echo ";; -*- mode: lisp; coding: utf-8; fill-column: 78 -*-
       
    99 ;;
       
   100 ;; For load order see README.
       
   101 " >$cfg
       
   102 
       
   103 check_platform
       
   104 check_speller >>$cfg