.emacs-my
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sun, 07 Mar 2010 10:58:13 +0200
changeset 323 7a7dc2befa99
parent 322 b1bd2648b826
child 324 a32e3536d337
permissions -rw-r--r--
Because of Debian policy documentation covered by FDL license with invariant sections not allowed in packet repository tree. So it must be installed manually. My usually configuration install user local software into ~/usr DISTDIR.

;; -*- mode: lisp; coding: utf-8 -*-
;;
;; Written by Oleksandr Gavenko <gavenkoa@gmail.com>, 2008-2010.
;;
;; This file formed from parts and ideas from many sites/docs and
;; placed in public domain.
;;
;; Config file for GNU Emacs.
;;
;; For loading order see README.

;; ======================================================================
;; debugging.

;; Shut off message buffer by setting nil.
(setq message-log-max 512)

;; Set the debug option to enable a backtrace when a problem occurs.
(setq debug-on-error nil)               ; t/nil

;; ======================================================================
;; appearance.

(menu-bar-mode -1)
(tool-bar-mode -1)
(tooltip-mode -1)
(scroll-bar-mode 1)

(if window-system
    ;; For graphical environment.
    (progn
      (set-background-color "white")
      (set-foreground-color "black")
      (set-cursor-color "brown")
      (setq cursor-type 'box)           ; box, hollow, bar, hbar
      ;;(setq blink-matching-delay 0.01)
      (blink-cursor-mode 1)
      ;; (set-face-font 'default "7x14")
      (fringe-mode 'default)
      )
  ;; For tty.
  (progn
    )
)

;; See what I am typing immediately (for keystroke in minibuffer).
(setq echo-keystrokes 0.2)

;; ----------------------------------------------------------------------
;; silent runing.

;; (setq inhibit-splash-screen t) ; nonexist on 21.4.1
(setq inhibit-startup-message t)

;; ======================================================================
;; gnu serv, server.

;; (load "~/emacs/bin/gnuserv/gnuserv.el")
;; (require 'gnuserv)
;; (setq gnuserv-frame (selected-frame))

(require 'server)
(when (and (= emacs-major-version 23) (equal window-system 'w32))
  (defun server-ensure-safe-dir (dir) "Noop" t)) ; Suppress error directory ~/.emacs.d/server is unsafe on windows.

(server-start)

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

;; ======================================================================
;; standart/general settings.

(setq kill-whole-line t)

;; show column & line numbers in status bar
(setq column-number-mode t)
(setq line-number-mode t)

(setq view-read-only t)

(setq frame-title-format "Emacs - %b")

(setq read-quoted-char-radix 16)

;; ----------------------------------------------------------------------
;; switching, creating, selecting buffers.

(iswitchb-mode 1)
(setq iswitchb-buffer-ignore nil)
(mapc (lambda (arg) (add-to-list 'iswitchb-buffer-ignore arg))
        '("^ "
          "^\*Buffer"
          "^\*Completions\*"
          "^\*tramp"
          "^\*Dired log\*"
          "^\*Help\*"
          "^\*Quail Completions\*"
          "^\*Disabled Command\*"
          "^\*vc\*"
          ))

(require 'uniquify)
(setq uniquify-buffer-name-style 'post-forward)

;; buffer-menu better then buffer-list, but ibuffer much better.
(global-set-key "\C-x\C-b" 'ibuffer)

;; ----------------------------------------------------------------------
;; scrolling.

(setq-default
 scroll-step 1
 scroll-conservatively 100
 ;; При перемещении точка останавливается на расстоянии i строк к границе фрейма.
 scroll-margin 2
 scroll-preserve-screen-position t
 )

;; ----------------------------------------------------------------------
;; searching.

(setq case-fold-search t)

(setq query-replace-highlight t)        ; highlight during query
(setq search-highlight t)               ; highlight incremental search

;; ----------------------------------------------------------------------
;; *Occur*
(global-set-key [f7] 'occur)            ; Key binding as in mc

;; ----------------------------------------------------------------------
;; *Text*
(setq default-major-mode 'text-mode)

;; ----------------------------------------------------------------------
;; syntax highlighting.

(setq font-lock-maximum-decoration t)
(global-font-lock-mode 1 t)

;; ----------------------------------------------------------------------
;; highlight selected text.

;; 1/-1, when the mark is active, the region is highlighted.
(transient-mark-mode 1)
(delete-selection-mode 1)               ; 1/-1

;; Order of next items is important, (assignment must done before pc-selection-mode enabled).
(require 'pc-select)
(setq pc-select-selection-keys-only t)  ; To avoid some key bindings as F6, etc.
(setq pc-select-meta-moves-sexps t)
(pc-selection-mode 1)

(when (eq window-system 'x)
  (setq x-select-enable-clipboard t)    ; for Emacs 21.2.1 and newer
  )

;; ----------------------------------------------------------------------
;; highlighting current line.

(when window-system
  (custom-set-faces '(hl-line ((t (:inherit highlight :background "light yellow")))))
  (global-hl-line-mode 1)
  )

;; ----------------------------------------------------------------------
;; paren, braces.

(show-paren-mode 1) ; Parenthesis matching via highlighting.
(setq show-paren-style (quote parenthesis))

;; ======================================================================
;; keyboard, mouse.

;; cyrillic-jcuken  for 567 is :,.
;; russian-computer for 567 is %^&
(setq default-input-method 'cyrillic-jcuken)

;; (pc-bindings-mode) ; Myself define keybinding, see

;; ----------------------------------------------------------------------
;; completition.

;; partial-completion-mode cause bug in read-file-name with Emacs v22.3.1 (but not with v23.1).
;; read-file-name used in rgrep, so I disable partial-completion-mode.
(partial-completion-mode -1) ; For example, M-x p-c-m expands to M-x partial-completion-mode

;; ----------------------------------------------------------------------
;; mouse.

;; Scroll Bar gets dragged by mouse butn 1
(global-set-key [vertical-scroll-bar down-mouse-1] 'scroll-bar-drag)
;; Paste at point NOT at cursor
(setq mouse-yank-at-point t)
(mouse-wheel-mode 1)

;; ----------------------------------------------------------------------
;; key binding, short-keys.

(global-set-key [home]    'beginning-of-line)
(global-set-key [end]     'end-of-line)
(global-set-key [C-home] 'beginning-of-buffer)
(global-set-key [C-end]  'end-of-buffer)
(global-set-key [C-delete]  'kill-word)
(global-set-key [delete]     'delete-char)
;; (global-set-key [backspace]  'backward-delete-char-untabify) ; not work properly in *info* mode

;; setting some f[1-12] keys
(global-set-key [f1]    'help)
(global-set-key [f2]    'save-buffer)
;; (global-set-key [xxx]    'ediff-buffers)
(global-set-key [f4]    'ispell-buffer)
(global-set-key [S-f6]  'rename-buffer)
(global-set-key [f8]    'kill-this-buffer)
(global-set-key [M-f4]  'save-buffers-kill-emacs)
(global-set-key [f6]    'toggle-truncate-lines)

;; frames, windows manipulation, switch buffers
(global-set-key [?\C-x right] 'next-buffer)
(global-set-key [?\C-x left]  'previous-buffer)

;; I usually mistype "C-x C-f" to "C-x d" or "C-x C-d", so always use find-file,
;; because when file if directory find-file load dired, if regular file open it.
(global-set-key (kbd "C-x C-f") 'find-file)
(global-set-key (kbd "C-x C-d") 'find-file)
(global-set-key (kbd "C-x d") 'find-file)

(global-set-key (kbd "\e\eg") 'goto-line)
(global-set-key (kbd "\e\er") 'query-replace-regexp)

;; Disable C-z, it ugly.
(if window-system (global-set-key (kbd "C-z") 'nil))

;; (global-set-key [language-change] 'ignore)

;; ======================================================================
;; coding system, charset, locale, lang.

;; Emacs 23.1 no longer need codepage-setup.
(when (<= emacs-major-version 22)
  (codepage-setup 866)
  (codepage-setup 1251)
  )

;; Comment because prefer-coding-system will be ignored.
;; (setq-default coding-system-for-read  'cp1251-dos)
;; (setq-default coding-system-for-write 'cp1251-dos)

;; (setq locale-coding-system  'cp1251-dos)
;; (set-terminal-coding-system 'cp1251)
;; (set-keyboard-coding-system 'cp1251)

(prefer-coding-system 'koi8-r-dos)
(prefer-coding-system 'utf-16-le)
(prefer-coding-system 'cp866-dos)

(modify-coding-system-alist 'file "\\.el" 'iso-2022-7bit)
(cond
 ((equal window-system 'w32)          ; also (string-equal system-type "windows-nt")
  (progn
    (set-selection-coding-system 'utf-16le-dos)
    (prefer-coding-system 'utf-8-unix)
    (prefer-coding-system 'cp1251-dos)
    ))
 ((equal window-system 'x)
  (progn
    (prefer-coding-system 'cp1251-dos)
    (prefer-coding-system 'utf-8-unix)
    (setq selection-coding-system 'compound-text-with-extensions)
    (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
    (modify-coding-system-alist 'process ".*" 'utf-8-unix)
    ))
 (t
  (progn
    ;; (set-selection-coding-system   'utf-8-unix)
    (prefer-coding-system 'cp1251-dos)
    (prefer-coding-system 'utf-8-unix)
    (modify-coding-system-alist 'process ".*" 'utf-8-unix)
    ))
  )

;; XXXXXXXXXXXXXXXXXXXXXXXX

;; To open from command line file, which names has extended opcode
;; (set-file-name-coding-system 'cp1251)

;; (set-language-environment "Russian") ; XXX not used as set default coding system to koi8-r.

;; ======================================================================
;;
;; NON-STANDARD VARIABLES

;; ======================================================================
;;
;; STANDARD VARIABLES

(if (boundp 'confirm-kill-emacs)
    (setq confirm-kill-emacs 'yes-or-no-p))

;; Try to speed things up, especially in VM.
(setq gc-cons-threshold 2000000)

;; Don't beep in my headphones!
(setq ring-bell-function '(lambda () "Empty ring-bell-function." nil))
(setq visible-bell t) ; With default ring-bell-function in text terminal
                      ; revert screen if press [end] or [home]

;; Prompt before evaluating local bits of lisp.  This stops people
;; putting things at the end of files which delete all your files!
(setq enable-local-variables t
      enable-local-eval      1)

;; ======================================================================
;; STANDARD LIBRARIES

;; ----------------------------------------------------------------------
;; dired.

(setq dired-dwim-target t)
;; dangerous
;; (setq
;;  dired-recursive-copies 'top
;;  dired-recursive-deletes 'top)

;; ----------------------------------------------------------------------
;; compression, archive.

(require 'jka-compr) ; Automatic decompression, hooks for tar-mode.
(if (fboundp 'auto-compression-mode)
    (auto-compression-mode 1))

(modify-coding-system-alist 'file "\\.\\(war\\|ear\\|sar\\|egg\\)\\'" 'no-conversion)

(add-to-list 'auto-mode-alist '("\\.\\(war\\|ear\\|sar\\|egg\\)\\'" . archive-mode))

;; ----------------------------------------------------------------------
;; image.

(when (fboundp 'auto-image-file-mode)
  (auto-image-file-mode 1))

;; ----------------------------------------------------------------------
;; *Recentf*

(require 'recentf)
;; Prevent TRAMP to login on remote host when loading.
;; Its take time and ask passwords!
(setq recentf-auto-cleanup 'never)
(recentf-mode t)
(setq recentf-max-saved-items 200)
(global-set-key (kbd "\e\eq")  'recentf-open-files)

;; ----------------------------------------------------------------------
;; revert buffer.

(global-set-key [f5]    'revert-buffer)
(setq revert-without-query (quote (".*")))
(setq auto-revert-interval 2)

;; ======================================================================
;; convenient.

(defun reglen()
  "Show region length."
  (interactive)
  (message "%s" (- (region-end) (region-beginning))))

;; ----------------------------------------------------------------------
;; minibuffer.

(require 'icomplete) ; Interactive completion in minibuffer.
(icomplete-mode 1)

(mapc (lambda (ext) (add-to-list 'completion-ignored-extensions ext))
      '(
        ".class" "~" ".aux"
        ".o" ".obj" ".map" ".lib" ".lo" ".la" ".a" ".bin" ".exe"
        ;; Place dir at end to appear at the start of completion-ignored-extensions.
        "CVS/" ".hg/" ".svn/" ".git/" ".bzr/"
        ) )

;; ----------------------------------------------------------------------
;; *grep*
(setq grep-command "find . -name '*' -exec grep -nH '' {} ;"
      grep-find-command "find . '(' -name .svn -o -name CVS -o -name .hg -o -name _darcs -o -name .git ')' -prune -o -type f -name '*' -print0 | xargs -0 -e grep -nH "
      grep-highlight-matches nil ; do not set t because some grep do not has --color options
      grep-use-null-device t)

;; ----------------------------------------------------------------------
;; music.
(setq gnus-audio-au-player "winamp.exe"
      gnus-audio-directory "D:\\music"
      gnus-audio-wav-player "winamp.exe")

;; ----------------------------------------------------------------------
;; browser.

(cond
 ((equal window-system 'w32)
  (setq browse-url-browser-function 'browse-url-default-windows-browser))
 (t
  (setq browse-url-browser-function 'browse-url-mozilla)))

;; ----------------------------------------------------------------------
;; time.

;; Also useful such format:
;; (setq display-time-format " %H:%M %d-%m-%y ")
(setq display-time-24hr-format t)
(setq display-time-default-load-average nil)
(display-time)                          ; display-time-mode

;; ----------------------------------------------------------------------
;; calendar.

;; (setq mark-holidays-in-calendar t)
;; (setq all-christian-calendar-holidays t)
;; (setq calendar-date-display-form (quote ((format "%04s-%02d-%02d" year (string-to-int month) (string-to-int day)))))
;; (setq calendar-time-display-form (quote (24-hours ":" minutes (if time-zone " (") time-zone (if time-zone ")"))))
(setq calendar-week-start-day 1)
(setq european-calendar-style t)

;; ======================================================================
;;
;; STANDARD HOOKS

(add-hook 'write-file-hooks 'time-stamp)

;; ======================================================================
;; *auto-fill*

(setq-default fill-column 78)

;; By default used American convention - sentence and with two spaces. Change
;; it to one space. Has affect on filling and M-a, M-e commands.
(setq sentence-end-double-space nil)

;; Turn on auto-fill mode
(add-hook 'html-mode-hook 'turn-on-auto-fill)
(add-hook 'text-mode-hook 'turn-on-auto-fill)

;; ----------------------------------------------------------------------
;; unknown.

;; browse-url mailcrypt gnus message sendmail bbdb pilot bibtex eiffel-mode emacs-w3m
;; eudc filladapt hugs-mode mpg123 php-mode ps-print
;; chord-mode - edit guitar music
;; discography - variant of BibTeX mode for discographies

;; ======================================================================
;; unNOVICEd commands...
;;
;; The following commands are usually disabled by default. Enable them...

(put 'eval-expression  'disabled nil)
(put 'downcase-region  'disabled nil)
(put 'upcase-region    'disabled nil)
(put 'narrow-to-page   'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'scroll-left      'disabled nil)

;; ======================================================================
;; TEX.

(setq tex-run-command "initex")

;; ======================================================================
;; AUC TeX.

;(add-hook 'LaTeX-mode-hook 'LaTeX-install-toolbar)
;; (setq TeX-parse-self t)             ; Enable parse on load.
;; (setq TeX-auto-save t)              ; Enable parse on save.
;; (setq-default TeX-master nil)       ; Query for master file. Finally, if you often use \include or \input, you should make AUCTEX aware of the multi-file document structure

;(setq TeX-PDF-mode t)
;(setq TeX-interactive-mode t)
;(setq TeX-source-specials-mode 1)

;;; some more menu entries in the command list:
;;; see tex-mik.el from package auctex: %v is defined in tex-mik.el
;;; other variables are defined in tex.el from auctex
;;; the meaning of some auctex-varibles:
        ;symbols defined in tex.el and tex-mik.el:
        ;%b name slave tex-file  %t name master tex-file
        ;%d dvi-file  %f ps-file
        ;%l "latex --src-specials"
        ;%n line number  %p printcommand  %q "lpq"
        ;%r (TeX-style-check TeX-print-style)
        ;%s master-file-name without extention
        ;%v yap command view line
;(eval-after-load "tex"
;  '(progn
;     (add-to-list 'TeX-command-list
;         (list "->PS landscape for pdf"
;           "dvips %d -N0 -Ppdf -G0 -T 297mm,210mm -o %f "
;           'TeX-run-command nil t))
;     (add-to-list 'TeX-command-list
;         (list "All Texify run-viewer"
;           "texify --tex-opt=--src --run-viewer --clean %s.tex"
;           'TeX-run-command nil t))))

;; ======================================================================
;; Reftex activation (Reftex is included with Emacs 21.1).

;; (autoload 'reftex-mode     "reftex" "RefTeX Minor Mode" t)
;; (autoload 'turn-on-reftex  "reftex" "RefTeX Minor Mode" nil)
;; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
;; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
;; (add-hook 'LaTeX-mode-hook 'turn-on-reftex)   ; with AUCTeX LaTeX mode
;; (add-hook 'latex-mode-hook 'turn-on-reftex)   ; with Emacs latex mode

;; ======================================================================
;; PreviewLatex.

;(load "preview-latex.el" nil t t)

;(add-hook 'LaTeX-mode-hook #'LaTeX-preview-setup)
;(autoload 'LaTeX-preview-setup "preview")

;; ======================================================================
;; Info.

;; Because of Debian policy documentation covered by FDL license with invariant sections not allowed in packet
;; repository tree. So it must be installed manually. My usually configuration install user local software
;; into ~/usr DISTDIR.
(unless (getenv "INFOPATH")
  (setenv "INFOPATH" "~/usr/share/info:"))

;; ======================================================================
;; man, woman.

(setq woman-use-own-frame nil)
(setq woman-fill-frame t)

;; ======================================================================
;; shell, sh, bash.

;; Setup Emacs to run bash as its primary shell.
;; (setq binary-process-input t)
;; (setq shell-file-name "bash")
;; (setq shell-command-switch "-c")
;; (setenv "SHELL" shell-file-name)

(when (eq window-system 'w32)           ; may require Cygwin or MSYS
  (setenv "ESHELL" "bash")
  ;; (setq explicit-shell-file-name "bash")
  ;; (setq shell-file-name "bash")
  (setq explicit-bash-args '("-i"))
  (setq explicit-sh-args '("-i"))
  ;; Here is workaround: when explicit-shell-file-name is "bash" and shell-file-name is "cmdproxy.exe"
  ;; find-dired incorrect quote args (in shell-quote-argument (w32-shell-name) return "bash", but
  ;; shell-command used shell-file-name which value "cmdproxy.exe"). So I put additional space in pattern to
  ;; prevent quoting.
  (setq find-ls-option '("-exec ls -ld {}  ;" . "-ld"))
  )

;; ======================================================================
;; spell, ispall, aspell.

(setq ispell-program-name "ispell")
;(setq ispell-dictionary "russianw"); default dictionary
;(setq ispell-local-dictionary "russianw"); default dictionary
;(add-hook 'text-mode-hook 'flyspell-mode)
;(setq flyspell-default-dictionary "russianw")
;(setq flyspell-delay '1)
;; (setq ispell-local-dictionary-alist
;;   '((nil             ; default (english.aff)
;;      "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil iso-8859-1)
;;     ("UK-xlg"                ; english large version
;;      "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B" "-d" "UK-xlg") nil iso-8859-1)
;;     ("US-xlg"                ; american large version
;;      "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B" "-d" "US-xlg") nil iso-8859-1)
;;    )
;; )

;; ======================================================================
;; GTD, PIM, organize, todo mode.

;; ----------------------------------------------------------------------
;; org-mode.

(if (>= emacs-major-version 22)
(progn
  (require 'org)
  ))

;; XXX org-todo-keywords '((sequence "TODO" "START" "|" "DONE")) for org-version 4.67c
;; XXX (setq org-todo-keywords '("TODO" "START" "DONE")) for org-version 6.05b
(if (or (featurep 'org) (featurep 'org-install))
    (progn
      (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
      (setq org-directory (expand-file-name "~/.gtd"))
      (setq org-default-notes-file (expand-file-name "~/.gtd/notes"))
      (setq org-agenda-ndays 14
            org-deadline-warning-days 7
            org-agenda-show-all-dates t
            org-agenda-skip-deadline-if-done t
            org-agenda-skip-scheduled-if-done t
            org-agenda-start-on-weekday nil
            org-reverse-note-order t
            org-hide-leading-stars t
            org-tags-column 64
            )
      (define-key global-map "\C-ca" 'org-agenda)
      (setq org-agenda-files '("~/.gtd/todo.org")) ))

;; ----------------------------------------------------------------------
;; remember-mode.

(if (featurep 'remember)
    (progn
      (setq remember-annotation-functions '(org-remember-annotation))
      (setq remember-handler-functions '(org-remember-handler))
      (add-hook 'remember-mode-hook 'org-remember-apply-template)
      (define-key global-map "\C-cr" 'org-remember)
      (setq org-remember-templates
            ;; With one item emacs do not prompt choose template.
            '((?t "* TODO %?" "~/.gtd/todo.org")
              ;; (?j "* %^{topic}\n  %T\n" "~/.gtd/journal.org")
              ))
      (setq
       org-remember-store-without-prompt t
       ) ))

;; ======================================================================
;; whitespaces.

(setq-default show-trailing-whitespace t)
(setq-default indicate-empty-lines t)
(setq next-line-add-newlines nil)

;; See also 'mode-require-final-newline'.
(add-hook 'text-mode-hook (lambda () (setq require-final-newline nil)))

;; ----------------------------------------------------------------------
;; TODO, XXX, FIXME highlight.
;; Show blanks and FIXME
;; http://www.emacswiki.org/cgi-bin/wiki/EightyColumnRule

(defface my-tab-face
  '((t :background "gray"))
  "Face for showing TABs."
  :group 'basic-faces)

(defface my-conflict-face
  '((t :background "pink" :foreground "red" :weight bold))
  "Font for showing conflicts."
  :group 'basic-faces)

(defvar my-devel-mode-list
  '(sh-mode script-mode java-mode c-mode outline-mode text-mode
            lisp-mode makefile-mode makefile-gmake-mode python-mode)
  "List of development modes." )

(add-hook 'font-lock-mode-hook (function (lambda ()
  (when (member major-mode my-devel-mode-list)
    (font-lock-add-keywords nil
     '(
       ("\t+" 0 'my-tab-face t)
       ("\\<\\(FIXME:?\\|XXX:?\\|TODO:?\\)\\>" 1 'font-lock-warning-face t)
       ("\\(=\\{7,\\}\\|<\\{7,\\}\\|>\\{7,\\}\\)" 1 'my-conflict-face t)
       ))))))

;; (dolist (mode '(c-mode
;;                 java-mode
;;                 cperl-mode
;;                 html-mode-hook
;;                 css-mode-hook
;;                 emacs-lisp-mode))
;;   (font-lock-add-keywords mode
;;                           '(("\\(XXX\\|FIXME\\|TODO\\)"
;;                              1 font-lock-warning-face prepend))))

;; ======================================================================
;; communication

;; ----------------------------------------------------------------------
;; jabber.

(when (featurep 'jabber)
  (setq
   jabber-history-enabled t
   jabber-use-global-history nil
   jabber-backlog-number 15
   jabber-backlog-days 30
   jabber-alert-presence-message-function (lambda (who oldstatus newstatus statustext) nil)
   )
  )

(setq my-chat-prompt "[%t] %n>\n")
(when (featurep 'jabber)
  (setq
   jabber-chat-foreign-prompt-format my-chat-prompt
   jabber-chat-local-prompt-format my-chat-prompt
   jabber-groupchat-prompt-format my-chat-prompt
   jabber-muc-private-foreign-prompt-format "[%t] %g/%n>\n"
   )
  )

;; fsm used in emacs jabber
(when (featurep 'fsm)
  (setq fsm-debug nil)                  ; Disable *fsm-debug* buffer.
  )

;; ----------------------------------------------------------------------
;; rcirc.

;; Turn on logging everything to a special buffer, for debugging.
;; (setq rcirc-debug-flag t)

(add-hook 'rcirc-mode-hook (lambda () (rcirc-track-minor-mode 1)))
(setq rcirc-time-format "%H:%M ")
(defun rcirc-handler-301 (process cmd sender args)
  "/away message handler.")

;; ----------------------------------------------------------------------
;; erc.

(setq erc-server-coding-system 'utf-8)

;; ======================================================================
;; VCS, version control, cvs, svn.

(if (equal window-system 'w32)
    (progn
      (modify-coding-system-alist 'process "cvs" '(cp1251-dos . cp1251-dos))
      (modify-coding-system-alist 'process "svn" '(cp866-dos . cp1251-dos))
      ))

;; (setq-default vc-svn-register-switches "--encoding cp1251")
(setq-default vc-svn-register-switches nil)

(if window-system
    (progn
     (custom-set-variables
      '(vc-annotate-very-old-color "#0b5b20")
      '(vc-annotate-background "white")
      '(vc-annotate-color-map
        (quote (
                (20 .  "#EE0000")
                (40 .  "#E0800D")
                (60 .  "#D3001A")
                (80 .  "#C68027")
                (100 . "#B90034")
                (120 . "#AB8042")
                (140 . "#9E004F")
                (160 . "#91805C")
                (180 . "#840069")
                (200 . "#778077")
                (220 . "#690084")
                (240 . "#5C8091")
                (260 . "#4F009E")
                (280 . "#4280AB")
                (300 . "#3400B9")
                (320 . "#2780C6")
                (340 . "#1A00D3")
                (360 . "#0D80E0"))))
      )
     )
  )

;; ----------------------------------------------------------------------
;; psvn.

(setq svn-status-verbose t)
(setq svn-status-hide-unmodified t)

;; ----------------------------------------------------------------------
;; DVC.

(when (featurep 'dvc-emacs)
  (setq dvc-tips-enabled nil)
  )

;; ======================================================================
;; devel, prog, programming.

(add-to-list 'auto-mode-alist '("\\.cu$" . c-mode))

(setq-default comment-style (quote indent))
(setq-default comment-column 44)
(setq-default comment-fill-column 100)

(mapc (lambda (mode)
        (add-hook mode
                  (lambda ()
                    (setq fill-column 110) )
                  ))
      '(c-mode-hook lisp-mode-hook))

;; ----------------------------------------------------------------------
;; diff, patch.

(setq diff-switches "-u")

;; ----------------------------------------------------------------------
;; indenting.

(setq standard-indent 4)
(setq c-basic-offset 4)
(setq sh-basic-offset 2)
(setq sgml-basic-offset 4)

;; TAB (tab settings)
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil)     ; spaces instead of tabs by default
(setq tab-always-indent t)
(setq c-tab-always-indent t)
(let ( (line-width 400) i )
  (setq i (* (ceiling line-width 4) 4))
  (setq tab-stop-list nil)
  (while (>= i 0)
    (setq tab-stop-list (cons i tab-stop-list))
    (setq i (- i 4))))

;; ----------------------------------------------------------------------
;; diff.

(setq ediff-diff-options "")

;; ----------------------------------------------------------------------
;; *Compile*

(setq compile-auto-highlight t
      compile-command "make ")
;; compilation window shall scroll down if not 0
(setq compilation-scroll-output 1)

;; My funny error messages.
;; XXX нужно реализовать через hook.
(require 'compile)
(add-to-list 'compilation-error-regexp-alist '("^\\( +\\[csc\\] \\|\\)\\(.*\\)(\\([0-9]*\\),\\([0-9]*\\)):" 2 3 4))
(add-to-list 'compilation-error-regexp-alist '("^ *\\(.*\\)(\\([0-9]*\\)) +:" 1 2))
(add-to-list 'compilation-error-regexp-alist '("^\"?\\([^\"]*\\)\"?,\\([0-9]*\\) .*\\[.*\\]: " 1 2)) ; KEIL compiler
;; (add-to-list 'compilation-mode-font-lock-keywords '("\\(/[Oo][Uu][Tt]:[^ 	]+\\)" . 1))
;; (add-to-list 'compilation-mode-font-lock-keywords '("[ 	]\\(/F[oe][^ 	]+\\)" . 1))

;; ----------------------------------------------------------------------
;; windows inf files for driver installing

(add-to-list 'auto-mode-alist '("\\.inf\\'" . conf-mode))

;; ----------------------------------------------------------------------
;; makefile, make.

(add-to-list 'auto-mode-alist '("\\(Makefile\\|Makefile\\..+\\)\\'" . makefile-gmake-mode))

;; ----------------------------------------------------------------------
;; asm, assembler.

;; (setq-default asm-comment-char 59)
(add-hook 'asm-mode-hook '(lambda () (setq comment-start "/*") (setq comment-end "*/")) t)

(add-to-list 'auto-mode-alist '("\\.\\([sS]79\\|[sS]\\)\\'" . asm-mode))

;; (add-hook 'asm-mode-hook '(lambda () (local-unset-key ":")))
;; (add-hook 'asm-mode-hook '(lambda () (local-set-key ":" ":")))

;; ----------------------------------------------------------------------
;; linker.

(when (fboundp 'iar-linker-config-mode)
  (add-to-list 'auto-mode-alist '("\\.icf\\'" . iar-linker-config-mode))
  )
(when (fboundp 'iar4-linker-config-mode)
  (add-to-list 'auto-mode-alist '("\\.xcl\\'" . iar4-linker-config-mode))
  )

;; ----------------------------------------------------------------------
;; lisp.

(setq list-command-history-max 256)

;; ----------------------------------------------------------------------
;; C, c-mode, C++, c++-mode.

(setq c-echo-syntactic-information-p t)
(add-hook 'c-mode-common-hook
 (lambda ()
   ;; Automatically inserte newlines after special characters such as brace, comma, semi-colon, and colon.
   (c-toggle-auto-newline -1)
   ;; Delete all preceding whitespace by DEL.
   (c-toggle-hungry-state -1)
   ))

(defconst my-c-style
  '((c-tab-always-indent . t)
    (c-comment-only-line-offset . 4)
    (c-hanging-braces-alist
     . (
        (brace-list-open)
        (substatement-open after)
        ))
    (c-hanging-colons-alist
     . (
        (access-label after)
        (case-label after)
        (inher-intro)
        (label after)
        (member-init-intro before)
        ))
    (c-cleanup-list
     . (
        defun-close-semi
        empty-defun-braces
        scope-operator
        ))
    (c-offsets-alist
     . (
        (arglist-close . c-lineup-arglist)
        (arglist-cont-nonempty . ++)
        (arglist-intro . ++)
        (block-open . 0)
        (case-label . 0)
        (comment-intro . 0)
        (func-decl-cont . ++)
        (inexpr-class . 0)
        (inline-open . 0)
        (knr-argdecl-intro . -)
        (label . 0)
        (statement-block-intro . +)
        (statement-cont . ++)
        (substatement-open . 0)
        ))
    (c-echo-syntactic-information-p . t))
  "My C Programming Style")

(add-hook 'c-mode-common-hook
          (lambda () (c-add-style "my" my-c-style t)))
(setq c-default-style '((java-mode . "my") (c-mode . "my") (csharp-mode . "my") (c++-mode . "my") (objc-mode . "my") (other . "my")))

;; ----------------------------------------------------------------------
;; bat file, batch.

(when (fboundp 'bat-file-mode)
  (add-to-list 'auto-mode-alist '("\\.[bB][aA][tT]\\'" . bat-file-mode))
  (add-to-list 'auto-mode-alist '("\\.[cC][mM][dD]\\'" . bat-file-mode))
  )

;; ----------------------------------------------------------------------
;; nsis-mode.

(when (fboundp 'nsis-mode)
  (add-to-list 'auto-mode-alist '("\\.\\(nsi\\|nsh\\)\\'" . nsis-mode))
  )

;; ----------------------------------------------------------------------
;; *csharp*, c-sharp.

(autoload 'csharp-mode "csharp-mode" "Major mode for editing C# code." t)
(add-to-list 'auto-mode-alist '("\\.cs$" . csharp-mode))

;; ----------------------------------------------------------------------
;; java.

;; Update the Emacs load-path to include the path to
;; the JDE and its require packages. This code assumes
;; that you have installed the packages in the emacs/site
;; subdirectory of your home directory.
;; (add-to-list 'load-path (expand-file-name "~/emacs/site/semantic"))
;; (add-to-list 'load-path (expand-file-name "~/emacs/site/speedbar"))
;; (add-to-list 'load-path (expand-file-name "~/emacs/site/elib-1.0"))
;; (add-to-list 'load-path (expand-file-name "~/emacs/site/eieio"))
;; (add-to-list 'load-path (expand-file-name "~/emacs/site/jde-2.3.5.1/lisp"))

;; Load CEDET
;; (load-file "~/emacs/site/common/cedet.el")
;; Enabling SEMANTIC minor modes.  See semantic/INSTALL for more ideas.
;; (semantic-load-enable-code-helpers)

;; If you want Emacs to defer loading the JDE until you open a
;; Java file, edit the following line
;; (setq defer-loading-jde nil)
;; to read:
;;
;;  (setq defer-loading-jde t)
;;

;; (if defer-loading-jde
;;     (progn
;;       (autoload 'jde-mode "jde" "JDE mode." t)
;;       (add-to-list 'auto-mode-alist '("\\.java\\'" . jde-mode))
;;       (require 'jde)))


;; Sets the basic indentation for Java source files
;; to two spaces.
;; (defun my-jde-mode-hook ()
;;   (setq c-basic-offset 2))

;; (add-hook 'jde-mode-hook 'my-jde-mode-hook)

;; (require 'jde)

;; ----------------------------------------------------------------------
;; ECB.

(setq ecb-tip-of-the-day nil)
;; (add-to-list 'load-path  "~/emacs/site/ecb-2.32")
;; (require 'ecb)

;; (global-set-key (kbd "\e\eE") 'ecb-activate)

;; ----------------------------------------------------------------------
;; html.

;; ----------------------------------------------------------------------
;; xml.

;; ----------------------------------------------------------------------
;; psgml.

(setq sgml-set-face t)                  ; for highlighting in sgml

;; ======================================================================
;; printing.

;; Use Notepad to print plain text files to the default Windows printer
;(setq lpr-command "notepad")
;(setq lpr-headers-switches '("/p"))    ; \ mis-use these
;(setq lpr-switches nil)                ; / two variables
;(setq printer-name nil)        ; notepad takes the default
;(setq lpr-printer-switch "/P") ;; run notepad as batch printer
;;

;; ----------------------------------------------------------------------
;; printing to file.

;(setq printer-name "~/myprint.txt")
;(setq ps-printer-name nil)
;(setq ps-print-header nil)
;;; some more menu entries in the command list:
;;; see tex-mik.el from package auctex: %v is defined in tex-mik.el
;;; other variables are defined in tex.el from auctex
;;; the meaning of some auctex-varibles:
        ;symbols defined in tex.el and tex-mik.el:
        ;%b name slave tex-file  %t name master tex-file
        ;%d dvi-file  %f ps-file
        ;%l "latex --src-specials"
        ;%n line number  %p printcommand  %q "lpq"
        ;%r (TeX-style-check TeX-print-style)
        ;%s master-file-name without extention
        ;%v yap command view line
;(eval-after-load "tex"
;  '(progn
;     (add-to-list 'TeX-command-list
;         (list "->PS landscape for pdf"
;           "dvips %d -N0 -Ppdf -G0 -T 297mm,210mm -o %f "
;           'TeX-run-command nil t))
;     (add-to-list 'TeX-command-list
;         (list "All Texify run-viewer"
;           "texify --tex-opt=--src --run-viewer --clean %s.tex"
;           'TeX-run-command nil t))))

;; ----------------------------------------------------------------
;; SQL.

(setq sql-password "")

;; ======================================================================
;; backuping.

(setq
 backup-by-copying t                           ; don't clobber symlinks
 backup-directory-alist '(("." . "~/.backup")) ; don't litter my fs tree
 delete-old-versions t                         ; delete excess backup versions silently
 kept-old-versions 1                           ; store first original version
 kept-new-versions 3                           ; store last 3 version
 version-control t)                            ; use versioned backups

;; ======================================================================
;; auto save.

(setq auto-save-default t)
;; If nil autosave to different than original to buffer file.
(setq auto-save-visited-file-name nil)
;; Note: if you kill unsaved file auto save file not deleted.
(setq delete-auto-save-files t)

;; ======================================================================
;; user info.

(cd "~/")
(setq user-full-name "Oleksandr Gavenko")
(setq user-mail-address "gavenkoa@gmail.com")
(setenv "ORGANIZATION" (concat user-full-name " <" user-mail-address  ">"))

(add-hook 'emacs-startup-hook
          (lambda ()
            (let ( (mgs-list '("Welcome to emacs, the thermonuclear editor."
                               "You enter to Out Space. Emacs on."
                               "Nice day for Emacsing!")) )
              (message (nth (random (length mgs-list)) mgs-list)))))

;; Size of emacs area and its position.
(when window-system
  (run-at-time (format "%d sec" 1) nil '(lambda () (set-frame-position (selected-frame) 1 1)))
  (when (boundp 'my-frame-width)
    (run-at-time (format "%d sec" 2) nil '(lambda () (set-frame-width (selected-frame) my-frame-width t))) )
  (when (boundp 'my-frame-height)
    (run-at-time (format "%d sec" 3) nil '(lambda () (set-frame-height (selected-frame) my-frame-height t))) )
  )

;; End loading...