(set-input-mode nil nil 'We-will-use-eighth-bit-of-input-byte)

(setenv "LC_TIME" "C")

;;
;; Key bindings
;;
(global-set-key [help] 'info)
(global-set-key [f1] 'manual-entry)
(global-set-key [f3] 'find-file)
(global-set-key [(shift f3)] 'find-file-at-point)
(global-set-key [f2] 'save-buffer)
(global-set-key [f5] 'delete-other-windows)
(global-set-key [f6] 'other-window)
(global-set-key [f7] 'replace-string)
(global-set-key [f8] 'next-error)
(global-set-key [f9] 'My-Compile)
(global-set-key [f10] 'delete-frame)
(global-set-key "\M-0" 'buffer-menu)
(global-set-key "\C-y" 'Kill-Line)
(global-set-key [(control Icircumflex)] 'Kill-Line) ; C-y
(global-set-key [(control Iacute)] 'scroll-up) ; C-v
(global-set-key [(control Ugrave)] 'isearch-forward) ; C-s
(global-set-key [(control menu)] 'popup-mode-menu)
(global-set-key [(shift insert)] 'yank)
(global-set-key [(shift delete)] 'copy-region-as-kill)
(global-set-key [(control x) m] 'mh-smail)
(global-set-key [(control x) r j] 'bookmark-jump)
(global-set-key [(meta THORN)] 'execute-extended-command)
(global-set-key [(alt meta !)] 'shell-filter-region)

(defun shell-filter-region ( command )
  (interactive (list (read-shell-command "Filter to apply: ")))
  (shell-command-on-region (region-beginning) (region-end) command (current-buffer) t))

(autoload 'find-file-at-point "ffap")

(defun My-Kill-Buffer ()
  (interactive)
  (kill-buffer (current-buffer)))


(require 'iso-control-hack)

;(require 'flyspell)
;(add-hook 'text-mode-hook 'flyspell-mode)

(if (device-on-window-system-p)
    (progn
      (setq delete-key-deletes-forward t)
      (global-set-key [(kp-7)] 'beginning-of-line)
      (global-set-key [(kp-8)] 'previous-line)
      (global-set-key [(kp-9)] 'scroll-down)
      (global-set-key [(kp-4)] 'backward-char)
      (global-set-key [(kp-6)] 'forward-char)
      (global-set-key [(kp-1)] 'end-of-line)
      (global-set-key [(kp-2)] 'next-line)
      (global-set-key [(kp-3)] 'scroll-up)
      (global-set-key [(kp-5)] 'next-line)
      (global-set-key [(kp-0)] 'overwrite-mode)
      (global-set-key [(kp-decimal)] 'backward-or-forward-delete-char)
      (global-set-key [(shift kp-0)] 'yank)
      (global-set-key [(shift kp-decimal)] 'copy-region-as-kill)
      )
  (setq delete-key-deletes-forward nil))

(global-set-key [(alt i)]
  '(lambda ()
     (interactive)
     (shell-command (read-string "Shell command to insert: ") t)))

(quietly-read-abbrev-file)

(defun Kill-Line ()
  (interactive)
  (beginning-of-line)
  (kill-line))


(defun Kill-Buffer ()
  (interactive)
  (kill-buffer (current-buffer)))

;; To be called from gnudoit
(defun MyGNUS ()
  (deiconify-frame)
  (gnus))

(defun toolbar-news ()
  "Run Gnus in the frame it was started from."
  (interactive)
  (gnus))

;;;
;;; -------- Global options
;;;

(setq kill-whole-line t
      default-major-mode 'text-mode
      gnus-read-active-file nil
      gnus-check-new-newsgroups 'ask-server
      delete-key-deletes-forward t
      options-save-faces t
      next-line-add-newlines nil
      passwd-invert-frame-when-keyboard-grabbed nil
      scroll-step 1
      european-calendar-style t)

;(autoload 'maniac-fill-mode "maniac" nil t)

(add-hook 'lisp-interaction-mode-hook 
          '(lambda ()
             (local-set-key [(return)] 'eval-print-last-sexp)))

(add-hook 'find-file-not-found-hooks 'MyAutoInsert)
(add-hook 'text-mode-hook 'turn-on-auto-fill)
(require 'cc-mode)
(add-hook 'c-mode-common-hook 
          '(lambda ()
             (c-set-style "cc-mode")
             (line-number-mode 1)
             (column-number-mode 1)
             (abbrev-mode 1)
             (auto-fill-mode 1)
             (setq tab-width 4)
             (local-set-key [return] 'reindent-then-newline-and-indent)
             )
          )

(defun MyAutoInsert ()
  (let ((f-name (buffer-file-name)))
    (if (or (string-match "\\.C$" f-name) (string-match "\\.h$" f-name))
        (insert "// -*- C++ -*-\n"
                "// File: " (file-name-nondirectory f-name) "\n"
                "//\n"
                "// Created: " (current-time-string) "\n"
                "//\n"
                "// $Id$\n"
                "//\n"))))

(defun My-Compile ()
  "Saves all unsaved buffers, and runs 'compile'."
  (interactive)
  (save-some-buffers t)
  (compile compile-command)
  )

(gnuserv-start)

(setq auto-mode-alist
      (append   
       '(
         ( "\\.html.ru$"        . html-mode )
         ( "\\.html.en$"        . html-mode )
         ( "\\.tei$"            . tei-mode )
         ( "\\.docbook$"        . sgml-mode )
         ( "\\.sgml$"           . sgml-mode )
         ( "\\.dsl$"            . scheme-mode )
         ( "\\.gwm$"            . lisp-mode )
         ( "\\.py$"             . python-mode )
        ) auto-mode-alist))

;;
;; Supercite
;;


(load-library "supercite")
(setq sc-preferred-header-style 0
      sc-rewrite-header-list '((my-header-line-generator))
      sc-citation-leader " "
      sc-confirm-always-p nil
      sc-preferred-attribution-list 
      '( "x-attribution" "firstname" "initials" "sc-lastchoice" )
      )

(defun my-header-line-generator ()
  (let ((sc-mumble "")
        (whofrom (sc-whofrom)))
    (if whofrom
        (insert sc-reference-tag-string
                (sc-hdr "\"" (sc-mail-field "sc-attribution") "\" == ")
                (sc-hdr ""   (sc-mail-field "sc-author") " ")
                "writes:\n")
      )
    )
  )

(setq gnus-use-sc t
      gnus-asynchronous nil
      nnspool-active-file "/var/lib/news/active"
      nnspool-active-times-file "/var/lib/news/active.times"
      default-mime-charset 'koi8-r
      mime-setup-use-sc t
      mime-charset-type-list  
      '((koi8-r         8 nil)
        (us-ascii       7 nil)
        (iso-8859-1     8 "quoted-printable")
        (iso-8859-2     8 "quoted-printable")
        (iso-8859-3     8 "quoted-printable")
        (iso-8859-4     8 "quoted-printable")
        (iso-8859-5     8 "quoted-printable")
        (iso-8859-7     8 "quoted-printable")
        (iso-8859-8     8 "quoted-printable")
        (iso-8859-9     8 "quoted-printable")
        (iso-2022-jp    7 "base64")
        (iso-2022-kr    7 "base64")
        (euc-kr         8 "base64")
        (gb2312         8 "quoted-printable")
        (big5           8 "base64")
        (iso-2022-jp-2  7 "base64")
        (iso-2022-int-1 7 "base64")
        )
      mime/field-encoding-method-alist
      '(
        ("Subject" . nil)
        )
      mime-eword/charset-encoding-alist
      '((koi8-r         . nil)
        (us-ascii       . nil)
        )
      )

(require 'gnus-setup)
(require 'gnus-charset)

(setq message-signature 'My-Signature)

(gnus-set-newsgroup-default-charset ".*" "koi8-r")

(add-hook 'gnus-article-display-hook
          '(lambda ()
             (gnus-article-highlight)
             (gnus-article-hide-headers-if-wanted)
             (setq gnus-visible-headers 
                   '("^From:" "^X-Comment-To:" "^Comment-To:" "^Subject:" "^Date:" 
                     "^Followup-To:" "^Reply-To:" "^Organization:" "^Summary:" 
                     "^Keywords:" "^To:" "^Cc:" "^Posted-To:" "^Mail-Copies-To:" 
                     "^Apparently-To:" "^Gnus-Warning:" "^Resent-From"
                     )
                   )
             (article-emphasize)))

(add-hook 'gnus-summary-mode-hook
          '(lambda ()
             (local-set-key [tab] 'gnus-summary-next-unread-article)))

(add-hook 'gnus-summary-exit-hook 'gnus-summary-bubble-group)

(add-hook 'message-mode-hook
          '(lambda ()
             (auto-fill-mode 1)
             (font-lock-mode 1)
             (setq fill-column 75)))

(add-hook 'message-setup-hook
          '(lambda ()
             (setq message-signature 'My-Signature)
             ;; Add X-Comment-To: field. We need From: field from original
             ;; letter. How to get right? 
             (if message-reply-buffer
                 (let ((cur-buffer (current-buffer)) from-field)
                   (save-excursion
                     (set-buffer message-reply-buffer)
                     (if (string-match "^From: " (buffer-string))
                         (progn
                           (setq from-start (+ (match-end 0) 1))
                           (goto-char from-start)
                           (end-of-line)
                           (setq from-field (buffer-substring from-start (point))))))
                   (if from-field
                       (save-excursion
                         (goto-char (point-min))
                         (insert "X-Comment-To: " (Make-Comment-To from-field) "\n")))))))

;(add-hook 'message-send-hook 'ispell-buffer)

(defun My-Signature ()
  (save-excursion
    (set-buffer (get-buffer-create "*fortune*"))
    (delete-region (point-min) (point-max))
    (call-process "fortune" nil t nil (concat (getenv "HOME") "/.fortunes"))
    (concat "\tBest regards, -- Boris.\n\n" (buffer-string))))

(defun Make-Comment-To (from)
  (if (string-match " *<.*> *" from)
      (concat (substring from 0 (match-beginning 0)) (substring from
                                                                (match-end 0)))
    (if (string-match "\(.*\)" from)
        (substring from (+ (match-beginning 0) 1) (- (match-end 0) 1))
      from)))

(add-hook 'sc-load-hook 'sc-setup-filladapt)

(require 'bbdb)
(bbdb-initialize 'message 'sc 'w3)

;---

(setq nnmail-split-methods '(("inbox" "")))

(setq mc-pgp-user-id "0xFC7D5E25")

;;
;; Outline
;;
(add-hook 'outline-mode-hook 
          '(lambda () 
             (line-number-mode 1)
             (column-number-mode 1)))
 
;;
;; Tcl
;;

(add-hook 'tcl-mode-hook
          (lambda ()
            (local-set-key [return] 'reindent-then-newline-and-indent)))
;;
;; SGML
;;

(setq sgml-catalog-files 
      (list "catalog"
            "CATALOG"
            "/usr/lib/TEItools/site/dtd/catalog"
            "/usr/lib/TEItools/dtd/catalog"
            "/usr/local/lib/xemacs-20/etc/sgml/CATALOG")
      sgml-custom-dtd 
      '(("TEI Lite" "<!doctype tei.2 public '-//TEI//DTD TEI Lite 1.6//EN'>"
         "/tmp/teilite.ced")
        ("TEI Tools" "<!doctype tei.2 public '-////DTD TEI Tools 0.1//EN'>"
         "/tmp/teitools.ced")
        ("TZ" "<!doctype tz system>" "/tmp/tz.ced")
        ("CALS" "<!doctype table PUBLIC '-//USA-DOD//DTD Table Model 951010//EN'>"
         "/tmp/cals.ced")
        ("DocBook (book)" 
         "<!doctype book public '-//Davenport//DTD DocBook V3.0//EN'>"
         "/tmp/docbook.ced")
        ("DocBook (part)" 
         "<!doctype part public '-//Davenport//DTD DocBook V3.0//EN'>"
         "/tmp/docpart.ced")
        ("DocBook (chapter)" 
         "<!doctype chapter public '-//Davenport//DTD DocBook V3.0//EN'>"
         "/tmp/docchap.ced")
        ("DocBook (article)" 
         "<!doctype Article public '-//Davenport//DTD DocBook V3.0//EN'>"
         "/tmp/docart.ced")
        ("HTML with frames"
         "<!doctype html public '+//Silmaril//DTD HTML Pro v0r11 19970101//EN'>")
        )
      )

(defun My-SGML-keymap ()
  (local-set-key [(alt i)] 
                 '(lambda ()
                    (interactive)
                    (sgml-indent-line)
                    (sgml-insert-element 'item)
                    (sgml-indent-line)))
  (local-set-key [(alt l)] 
                 '(lambda ()
                    (interactive)
                    (sgml-insert-element 'list)
                    (sgml-insert-element 'item)
                    (sgml-indent-line)))
  (local-set-key [(alt p)]
                 '(lambda ()
                    (interactive)
                    (sgml-indent-line)
                    (sgml-insert-element 'p)
                    (sgml-indent-line)))
  (local-set-key [(alt -)]
                 '(lambda ()
                    (interactive)
                    (insert "&mdash;")))
  
  )

(add-hook 'sgml-mode-hook 
          '(lambda ()
             (make-local-variable 'compile-command)
             (line-number-mode 1)
             (column-number-mode 1)
             (setq write-file-hooks (delete 'fix-iso2sgml write-file-hooks)
                   find-file-hooks (delete 'fix-iso2sgml find-file-hooks)
                   sgml-set-face t
                   sgml-insert-missing-element-comment nil
;                  compile-command 
;                  (concat "tei2dvi " (file-name-nondirectory (buffer-file-name)))
                   sgml-live-element-indicator t)
                   
             (let ((ced-file-name 
                    (concat (file-name-sans-extension (buffer-file-name)) ".ced"))
                   )
               (if (file-readable-p ced-file-name)
                   (sgml-load-dtd ced-file-name)))))

(add-hook 'sgml-mode-hook 'My-SGML-keymap)

;;
;; SGML markup faces.
;;
(make-face 'sgml-comment-face)
(make-face 'sgml-doctype-face)
(make-face 'sgml-end-tag-face)
(make-face 'sgml-entity-face)
(make-face 'sgml-ignored-face)
(make-face 'sgml-ms-end-face)
(make-face 'sgml-ms-start-face)
(make-face 'sgml-pi-face)
(make-face 'sgml-sgml-face)
(make-face 'sgml-short-ref-face)
(make-face 'sgml-start-tag-face)

(set-face-foreground 'sgml-comment-face "dark green")
(set-face-foreground 'sgml-doctype-face "maroon")
(set-face-foreground 'sgml-end-tag-face "blue2")
(set-face-foreground 'sgml-entity-face "red2")
(set-face-foreground 'sgml-ignored-face "maroon")
(set-face-background 'sgml-ignored-face "gray90")
(set-face-foreground 'sgml-ms-end-face "maroon")
(set-face-foreground 'sgml-ms-start-face "maroon")
(set-face-foreground 'sgml-pi-face "maroon")
(set-face-foreground 'sgml-sgml-face "maroon")
(set-face-foreground 'sgml-short-ref-face "goldenrod")
(set-face-foreground 'sgml-start-tag-face "blue2")

(setq-default sgml-markup-faces
              '((comment . sgml-comment-face)
                (doctype . sgml-doctype-face)
                (end-tag . sgml-end-tag-face)
                (entity . sgml-entity-face)
                (ignored . sgml-ignored-face)
                (ms-end . sgml-ms-end-face)
                (ms-start . sgml-ms-start-face)
                (pi . sgml-pi-face)
                (sgml . sgml-sgml-face)
                (short-ref . sgml-short-ref-face)
                (start-tag . sgml-start-tag-face)))

(make-face 'tei-head-1-face)
(set-face-foreground 'tei-head-1-face "dark green")
(set-face-font 'tei-head-1-face  "-*-courier-bold-r-*-*-*-180-*-*-*-*-koi8-*")
(make-face 'tei-head-2-face)
(set-face-foreground 'tei-head-2-face "dark blue")
(set-face-font 'tei-head-2-face  "-*-courier-bold-r-*-*-*-180-*-*-*-*-koi8-*")
(make-face 'tei-head-3-face)
(set-face-foreground 'tei-head-3-face "dark green")
(set-face-font 'tei-head-3-face  "-*-courier-normal-r-*-*-*-180-*-*-*-*-koi8-*")
(make-face 'tei-head-4-face)
(set-face-foreground 'tei-head-4-face "dark blue")
(set-face-font 'tei-head-4-face  "-*-courier-normal-r-*-*-*-180-*-*-*-*-koi8-*")
(make-face 'tei-head-5-face)
(set-face-foreground 'tei-head-5-face "brown")
(set-face-font 'tei-head-5-face  "-*-courier-bold-r-*-*-*-180-*-*-*-*-koi8-*")
(make-face 'tei-emph-face)
(set-face-font 'tei-emph-face  "-adobe-helvetica-medium-o-*-*-*-180-*-*-*-*-koi8-*")
(make-face 'tei-title-face)
(set-face-font 'tei-title-face  "-adobe-helvetica-bold-r-*-*-*-180-*-*-*-*-koi8-*")
(make-face 'tei-eg-face)
(set-face-font 'tei-eg-face  "-adobe-helvetica-medium-r-*-*-*-180-*-*-*-*-koi8-*")
(set-face-foreground 'tei-eg-face "dark blue")
(make-face 'tei-label-face)
(set-face-foreground 'tei-label-face "dark cyan")
(set-face-font 'tei-label-face  "-adobe-courier-medium-o-*-*-*-180-*-*-*-*-koi8-*")
(make-face 'tei-item-face)
(set-face-foreground 'tei-item-face "dark cyan")
(set-face-font 'tei-item-face  "-adobe-courier-bold-r-*-*-*-180-*-*-*-*-koi8-*")
(make-face 'tei-note-face)
(set-face-font 'tei-note-face  "-adobe-courier-medium-r-*-*-*-140-*-*-*-*-koi8-*")
(make-face 'tei-quote-face)
(set-face-font 'tei-quote-face "-adobe-courier-medium-o-*-*-*-180-*-*-*-*-koi8-*")

(add-hook 'tei-mode-hook 'TEI-fontify)

(defun TEI-fontify ()
  (setq 
   font-lock-keywords
   '(
     ("<div1[^>]*><head/[^/]*/" . tei-head-1-face)
     ("<div1[^>]*><head[^>]*>[^<]*</>"  . tei-head-1-face)
     ("<div1[^>]*><head[^>]*>[^<]*</head>"      . tei-head-1-face)
     ("<div2[^>]*><head/[^/]*/" . tei-head-2-face)
     ("<div2[^>]*><head[^>]*>[^<]*</>"  . tei-head-2-face)
     ("<div2[^>]*><head[^>]*>[^<]*</head>"      . tei-head-2-face)
     ("<div3[^>]*><head/[^/]*/" . tei-head-3-face)
     ("<div3[^>]*><head[^>]*>[^<]*</>"  . tei-head-3-face)
     ("<div3[^>]*><head[^>]*>[^<]*</head>"      . tei-head-3-face)
     ("<div4[^>]*><head/[^/]*/" . tei-head-4-face)
     ("<div4[^>]*><head[^>]*>[^<]*</>"  . tei-head-4-face)
     ("<div4[^>]*><head[^>]*>[^<]*</head>"      . tei-head-4-face)
     ("<div5[^>]*><head/[^/]*/" . tei-head-5-face)
     ("<div5[^>]*><head[^>]*>[^<]*</>"  . tei-head-5-face)
     ("<div5[^>]*><head[^>]*>[^<]*</head>"      . tei-head-5-face)
     ("<emph/[^/]*/" . tei-emph-face)
     ("<emph[^>]*>[^<]*</emph>" . tei-emph-face)
     ("<emph[^>]*>[^<]*</>" . tei-emph-face)
     ("<hi/[^/]*/" . tei-emph-face)
     ("<hi[^>]*>[^<]*</title>" . tei-emph-face)
     ("<hi[^>]*>[^<]*</>" . tei-emph-face)
     ("<title/[^/]*/" . tei-title-face)
     ("<title[^>]*>[^<]*</title>" . tei-title-face)
     ("<title[^>]*>[^<]*</>" . tei-title-face)
     ("<eg/[^/]*/" . tei-eg-face)
     ("<eg[^>]*>.*</>" . tei-eg-face)
     ("<eg[^>]*>.*</eg>" . tei-eg-face)
     ("<code/[^/]*/" . tei-eg-face)
     ("<code[^>]*>[^<]*</>" . tei-eg-face)
     ("<code[^>]*>[^<]*</code>" . tei-eg-face)
     ("<kw/[^/]*/" . tei-eg-face)
     ("<kw[^>]*>[^<]*</>" . tei-eg-face)
     ("<kw[^>]*>[^<]*</kw>" . tei-eg-face)
     ("<label/[^/]*/" . tei-label-face)
     ("<label[^>]*>[^<]*</>" . tei-label-face)
     ("<label[^>]*>[^<]*</label>" . tei-label-face)
     ("<note/[^/]*/" . tei-note-face)
     ("<note[^>]*>[^<]*</>" . tei-note-face)
     ("<note[^>]*>[^<]*</note>" . tei-note-face)
     ("<item/" . tei-item-face)
     ("<item[^>]*>" . tei-item-face)
     ("<q/[^/]*/" . tei-quote-face)
     ("<q>[^<]*</>" . tei-quote-face)
     ("<q>[^<]*</q>" . tei-quote-face)
     ("<socalled/[^/]*/" . tei-quote-face)
     ("<socalled>[^<]*</>" . tei-quote-face)
     ("<socalled[^>]*>[^<]*</socalled>" . tei-quote-face)
     ("<term/[^/]*/" . tei-eg-face)
     ("<term[^>]*>[^<]*</>" . tei-eg-face)
     ("<term[^>]*>[^<]*</term>" . tei-eg-face)
     )
   )
  )
                       
(defun tei-mode ()
  (interactive)
  (sgml-mode)
  (run-hooks 'tei-mode-hook))

(defun docbook-mode ()
  (sgml-mode)
  )

;; DTD mode
;(autoload 'dtd-mode "tdtd" "Major mode for SGML and XML DTDs.")

;; Turn on font lock when in DTD mode
;(add-hook 'dtd-mode-hooks
;          'turn-on-font-lock)

;(setq auto-mode-alist
;      (append
;       (list
;        '("\\.dcl$" . dtd-mode)
;        '("\\.dec$" . dtd-mode)
;        '("\\.dtd$" . dtd-mode)
;        '("\\.ent$" . dtd-mode)
;        '("\\.mod$" . dtd-mode))
;       auto-mode-alist))

;;
;; TeX
;;
(require 'tex-site)

(add-hook 'TeX-mode-hook
          '(lambda ()
             (local-set-key "\\" 'TeX-electric-macro)
             )
          )

(setq TeX-open-quote "<<"
      TeX-close-quote ">>"
      )

;;
;; Calc
;;
;(autoload 'calc-dispatch          "calc" "Calculator Options" t)
;(autoload 'full-calc              "calc" "Full-screen Calculator" t)
;(autoload 'full-calc-keypad       "calc" "Full-screen X Calculator" t)
;(autoload 'calc-eval              "calc" "Use Calculator from Lisp")
;(autoload 'defmath                "calc" nil t t)
;(autoload 'calc                   "calc" "Calculator Mode" t)
;(autoload 'quick-calc             "calc" "Quick Calculator" t)
;(autoload 'calc-keypad            "calc" "X windows Calculator" t)
;(autoload 'calc-embedded          "calc" "Use Calc from any buffer" t)
;(autoload 'calc-embedded-activate "calc" "Activate =>'s in buffer" t)
;(autoload 'calc-grab-region       "calc" "Grab region of Calc data" t)
;(autoload 'calc-grab-rectangle    "calc" "Grab rectangle of data" t)

;;
;; Scheme
;;
(add-hook 'scheme-mode-hook
          '(lambda ()
             (local-set-key "\C-c\C-c" 'comment-region)))

(autoload 'run-scheme "cmuscheme" "Run an inferior Scheme" t)
(setq scheme-program-name "mzscheme")
(add-hook 'inferior-scheme-mode-hook
          '(lambda ()
             (split-window)))



;; 
;; Allegro CL
;
(setq load-path
      (cons "/usr/local/lib/acl4.3/home/emacs/fi"
            load-path))
;(load "fi-site-init")

;;
;; W3
;; 
(setq url-be-asynchronous t)

;;
;; Misc
;;

(defun DefineKeyPadKeys ()
  (global-set-key 'kp-1 "1")
  (global-set-key 'kp-2 "2")
  (global-set-key 'kp-3 "3")
  (global-set-key 'kp-4 "4")
  (global-set-key 'kp-5 "5")
  (global-set-key 'kp-6 "6")
  (global-set-key 'kp-7 "7")
  (global-set-key 'kp-8 "8")
  (global-set-key 'kp-9 "9")
  (global-set-key 'kp-0 "0")
  (global-set-key 'kp-decimal ".")
  (global-set-key 'kp-enter "\C-m")
  (global-set-key 'kp-add "+")
  (global-set-key 'kp-subtract "-")
  (global-set-key 'kp-multiply "*")
  (global-set-key 'kp-divide "/")
  )

(if (device-on-window-system-p)
    (progn
      (require 'strokes)
      (add-hook 'fundamental-mode-hook 'strokes-mode)
      (add-hook 'text-mode-hook 'strokes-mode)
;      (load-library "delbackspace")
      (add-hook 'calc-mode-hook '(lambda () (local-set-key 'kp-5 'calc-five)))
      (add-hook 'gnus-article-display-hook 'smiley-buffer)
      (add-hook 'gnus-summary-mode-hook 'smiley-buffer)
      (set-frame-width (selected-frame) 88)
      (set-frame-height (selected-frame) 35)
;      (set-frame-position (selected-frame) 10 30)
      (setq strokes-use-strokes-buffer nil
            mouse-yank-at-point t)
      (require 'big-menubar)
      (load "recent-files")
      (recent-files-initialize)
      (load-library "time")
      (setq display-time-24hr-format t
            display-tme-mail-file t
            display-time-form-list (list 'time 'load)
            display-time-day-and-date t)
      (display-time)
      (blink-cursor-mode t)))

(require 'crypt)             
(require 'filladapt)
(add-hook 'text-mode-hook 'turn-on-filladapt-mode)

;; Options Menu Settings
;; =====================
(cond
 ((and (string-match "XEmacs" emacs-version)
       (boundp 'emacs-major-version)
       (or (and
            (= emacs-major-version 19)
            (>= emacs-minor-version 14))
           (= emacs-major-version 20))
       (fboundp 'load-options-file))
  (load-options-file "/home/boris/.xemacs-options")))
;; ============================
;; End of Options Menu Settings

;;
;; I HATE it
;;
(add-spec-list-to-specifier 
 (face-property 'default 'font) 
 '((global (nil . "-adobe-courier-medium-r-*-*-*-180-*-*-*-*-koi8-*"))))

(add-hook 'shell-mode-hook 'install-shell-fonts)


;; bugfix for 20.3b94
(or (boundp 'custom-put)
    (defun custom-put (symbol ignored list)
      (custom-add-loads symbol list)))

(fset 'yes-or-no-p 'y-or-n-p)

(random t)

(require 'koi8-syntax)

(load "rus-convert")
(load "rus-display")
(load "rus-syntax")


;;
;; Ispell
;;
(setq ispell-dictionary-alist
      (append ispell-dictionary-alist
              (list
               (list
                "russian"
                "[бвчздецъйклмнопртуфхжигюыэящшьасБВЧЗДЕЦЪЙКЛМНОПРТУФХЖИГЮЫЭЯЩШЬАС]"
                "[^бвчздецъйклмнопртуфхжигюыэящшьасБВЧЗДЕЦЪЙКЛМНОПРТУФХЖИГЮЫЭЯЩШЬАС]"
                "[\0]"
                nil
                nil
                nil)))
      ispell-dictionary "russian")


(require 'htmlize)

;(require 'desktop)
;(desktop-load-default)
;(desktop-read)