.emacs-my
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 29 Jun 2009 17:57:11 +0300
changeset 147 91afa4a1017f
parent 146 506d2883199f
child 148 7df64d2c9f3d
permissions -rw-r--r--
Backups by coping.

;; -*- mode: lisp; coding: cp1251 -*-
;;
;; Copyright (C) 2008 by Oleksandr Gavenko <gavenkoa@gmail.com>
;;
;; This file formed from parts and ideas from many sites/docs and
;; placed in public domain.
;;
;; .emacs file for GNU Emacs.
;;
;; ~/.emacs load this file after ~/.emacs-pre, but before ~/.emacs-post.

;; ======================================================================
;; Debugging.

;; Shut off message buffer by setting nil. Note - if you need to debug emacs,
;; comment these out so you can see what's going on.
(setq message-log-max 100)

;;(add-hook 'after-init-hook
;;    '(lambda () (setq debug-on-error t)))
;;(debug-on-entry 'command-line-1)

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

;; ======================================================================
;; Настройка внешнего вида редактора.
;; View.

(menu-bar-mode -1)                     ; 1/-1
(tool-bar-mode -1)                     ; 1/-1
(tooltip-mode -1)                      ; 1/-1

(if window-system
    ;; Для X-window и Win
    (progn
      ;; size of emacs area and position
      (set-frame-height (selected-frame) 60)
      (set-frame-width (selected-frame) 120)
      ;; (set-frame-position (selected-frame) 10 25)

      ;;установка цветов экрана
      (set-background-color "white")
      (set-foreground-color "black")
      ;;установка режимов работы курсора
      (set-cursor-color "brown")
      ;;(setq blink-matching-delay 0.01)
      ;; курсор не мигает!
      ;; (blink-cursor-mode nil)
      ;; (set-face-font 'default "7x14")
      )
  ;; Для tty
  (progn
    )
)

;; ----------------------------------------------------------------------
;; Silent runing.

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

;; ======================================================================
;; GNU Serv.

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

(server-start)

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

;; ======================================================================
;; Standart settings

;прикрепляет к каждому окну полоску прокрутки t/nil
(scroll-bar-mode t)

;; удаляем строку целиком
(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")

;; ----------------------------------------------------------------------
;; 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)

(global-set-key "\C-x\C-b" 'buffer-menu)

;; ----------------------------------------------------------------------
;; Scrolling

(setq-default
 ;; 2 - default value
 next-screen-context-lines 2
 ;; The number of lines to try scrolling a window by when point moves out.
 scroll-step 1
 scroll-conservatively 100
 ;; при перемещении точка останавливается на расстоянии i строк к границе фрейма,
 scroll-margin 2
 scroll-preserve-screen-position t
 )

;; ----------------------------------------------------------------------
;; fringe-mode

;; ----------------------------------------------------------------------
;; *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 item is important.
(require 'pc-select)
;; To avoid some key bindings as F6, etc. Must set before 'pc-selection-mode' invoke.
(setq pc-select-selection-keys-only t)
(pc-selection-mode 1)

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

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

;; ----------------------------------------------------------------------
;; paren, brace

(show-paren-mode 1) ; Parenthesis matching via highlighting.
;; (setq show-paren-style 'expression) ; выделять все выражение в скобках
(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 t) ; 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)

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

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

(global-set-key (kbd "C-x C-d") 'dired)

(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.

; Подготовка к использованию соответствующих кодовых страниц.
(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   'cp1251)
    (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 'ctext-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

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

;; ======================================================================
;; Save
(setq auto-save-default nil)

;; ----------------------------------------------------------------------
;; *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
(global-set-key [f5]    'revert-buffer)
(setq revert-without-query (quote (".*")))
(setq auto-revert-interval 2)

;; ======================================================================
;; Convenient

;; ----------------------------------------------------------------------
;; Completion
(require 'icomplete) ; Interactive completion in minibuffer.
(icomplete-mode) ; Toggle incremental minibuffer completion for this Emacs session.
;; может дополнять несколько слов одновременно
(load "complete")
(setq completion-ignored-extensions (quote ("CVS/" ".o" "~" ".bin" ".bak" ".obj" ".map" ".a" ".ln" ".blg" ".bbl" ".elc"
                                            ".lof" ".glo" ".idx" ".lot" ".fmt" ".tfm" ".class" ".fas" ".lib" ".x86f" ".sparcf"
                                            ".lo" ".la" ".toc" ".log" ".aux" ".cp" ".fn" ".ky" ".pg" ".tp" ".vr" ".cps"
                                            ".fns" ".kys" ".pgs" ".tps" ".vrs")))


;; ----------------------------------------------------------------------
;; *grep*
(setq grep-command "find . -name '*' -exec grep -nH '' {} ;"
      grep-find-command "find . '(' -name .svn -o -name CVS -o -name .hg -o -name _darcs ')' -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-tree-command "find <D> <X> -type f <F> -print0 | xargs -0 -e grep <C> -nH  <R>"
      grep-use-null-device t)
(setq blink-matching-paren-on-screen t)

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

;; ----------------------------------------------------------------------
;; archive

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

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

;; ----------------------------------------------------------------------
;; 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 SETTING

;; ----------------------------------------------------------------------
;; 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)

;; ----------------------------------------------------------------------
;; 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)

(setq sentence-end-double-space nil)
(global-set-key (kbd "\e\ef") 'auto-fill-mode)

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

;; ----------------------------------------------------------------------
;; DESIRE

;; (require 'desire)

;; (add-to-list 'desire-load-path
;;       (expand-file-name "~/share/emacs/desire"))
;; (add-to-list 'auto-mode-alist
;;       (cons (concat (regexp-quote desire-extension) "\\'")
;;         'emacs-lisp-mode))

;; ----------------------------------------------------------------------

;; Pilot support
;; (desire 'pilot)

;; ----------------------------------------------------------------------

;; BBDB - Must be loaded before most other things, since other things
;;        may perform special configuration if BBDB is present.
;;
;; (desire 'bbdb "bbdb")

;; ----------------------------------------------------------------------

;; These provide options for the various message handling packages.
;; (desire 'browse-url)
;; (desire 'mailcrypt)

;; Message handing packages.
;; (desire 'gnus)
;; (desire 'message)
;; (desire 'sendmail)

;; ----------------------------------------------------------------------

;; Miscellaneous

;; (desire 'abbrev)
;; (desire 'bibtex)
;; (desire 'calc)
;; (desire 'cc-mode)
;; (desire 'ediff)
;; (desire 'eiffel-mode)
;; (desire 'emacs-w3m)
;; (desire 'eudc)
;; (desire 'filladapt)
;;;; (desire 'hugs-mode)
;; (desire 'haskell-mode)
;; (desire 'latex)
;; (desire 'lispdir)
;; (desire 'mpg123)
;; (desire 'php-mode)
;; (desire 'ps-print)
;; (desire 'sh-script)
;; (desire 'shell)
;; (desire 'tex)
;; (desire 'w3)

;; ======================================================================
;;
;; PERSONAL

;; (require 'chord-mode)  ; edit guitar music.
;; (require '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)

;; ======================================================================
;; TEX
(setq tex-run-command "initex")


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

;; (load "tex-site")

;(require 'tex-mik)
;(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)
;(load "tex-site")
;(load "tex-mik")

;;модифицируем меню
;;; 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

(require 'info)
(if (equal window-system 'w32)
    (progn
      ;; TODO Write which func to find runemacs.exe dir.
      ;; (setq Info-directory-list (list (expand-file-name "~/../bin/emacs/info")))
      ;; (add-to-list 'Info-directory-list (expand-file-name "~/../bin/MinGW/info") t) ; t - append to the end
      ))

;; ======================================================================
;;
;; SHELL

;; If you plan to use the bash shell, add the following lines to your .emacs file:
;; (setq binary-process-input t)
;; (setq w32-quote-process-args ?\")
;; (setq shell-file-name "bash") ;; or sh if you rename your bash executable to sh.
;; (setenv "SHELL" shell-file-name)
;; (setq explicit-shell-file-name shell-file-name)
;; (setq explicit-sh-args '("-login" "-i"))

;; Include the following only if you want to run
;; bash as your shell.

;; Setup Emacs to run bash as its primary shell.
;; (setq shell-file-name "bash")
;; (setq shell-command-switch "-c")
;; (setq explicit-shell-file-name shell-file-name)
;; (setenv "SHELL" shell-file-name)
;; (setq explicit-sh-args '("-login" "-i"))
;; (if (boundp 'w32-quote-process-args)
;;     (setq w32-quote-process-args ?\")) ;; Include only for MS Windows.

;; (setq sh-shell-file "D:\\home\\cygwin\\bin\\sh.exe")
;; (setq sh-shell-arg (quote ((bash) (csh . "-f") (pdksh) (ksh88) (rc . "-p") (wksh) (zsh . "-f") (sh . "-i"))))
(setq explicit-bash-args (quote ("-login" "-i")))

(when (provide 'bat-mode)
  (progn
    (add-to-list 'auto-mode-alist '("\\.[bB][aA][tT]$" . bat-mode))
    ;; For DOS init files
    (when (equal window-system 'w32)
      (add-to-list 'auto-mode-alist '("CONFIG\\." . bat-mode))
      (add-to-list 'auto-mode-alist '("AUTOEXEC\\." . bat-mode)))))

;; ======================================================================
;;
;; Spell

(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")) для org-version 4.67c
;; XXX (setq org-todo-keywords '("TODO" "START" "DONE")) для 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
       ) ))

;; ----------------------------------------------------------------------
;; 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-todo-face
  '((t :foreground "red" :weight bold))
  "Font for showing TODO words."
  :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 (or
         (member major-mode my-devel-mode-list)
         )
    (font-lock-add-keywords nil
     '(
       ("\t+" 0 'my-tab-face t)
       ("\\<\\(FIXME:?\\|XXX:?\\|TODO:?\\)\\>" 1 'my-todo-face t)
       ("\\(=\\{7,\\}\\|<\\{7,\\}\\|>\\{7,\\}\\)" 1 'my-conflict-face t)
       ))))))

;; ======================================================================
;; 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)
          )
  )


;; ----------------------------------------------------------------------
;; 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.")

;; ======================================================================
;; 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)

(setq my-svn-dir (concat my-el-dir "/svn"))
(if (file-exists-p my-svn-dir)
    (progn
      (add-to-list 'load-path my-svn-dir)
      (require 'vc-svn)
      )
  )

(if (file-exists-p (concat my-el-dir "/mercurial.el"))
    (require 'mercurial)
  )

(if window-system
    (setq-default vc-annotate-background "white")
  )

;; ----------------------------------------------------------------------
;; DVC

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

;; ======================================================================
;; Devel, prog

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

(setq comment-style (quote indent))

(setq-default show-trailing-whitespace t)

;; ----------------------------------------------------------------------
;; Diff, patch
(setq diff-switches "-u")

;; ----------------------------------------------------------------------
;; Indent

(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)     ; t - будут вставляться \t
(setq tab-always-indent t)
(setq c-tab-always-indent t)
(let ( (line-width 400) )
  (setq i (+ (/ line-width 4) 1))
  (setq tab-stop-list nil)
  (while (> (setq i (- i 1)) 0)
    (setq tab-stop-list (cons (* i 4) tab-stop-list))))

;; ----------------------------------------------------------------------
;; 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-mode-font-lock-keywords '("\\(/[Oo][Uu][Tt]:[^ 	]+\\)" . 1))
;; (add-to-list 'compilation-mode-font-lock-keywords '("[ 	]\\(/F[oe][^ 	]+\\)" . 1))

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

;; ----------------------------------------------------------------------
;; LISP
(setq list-command-history-max 256)

;; ----------------------------------------------------------------------
;; C, c-lang
(setq c-echo-syntactic-information-p t)

(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")

;; (objc-mode . "my-mode") (c++-mode . "cc-mode")
(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") (other . "my")))

;; Customizations for all modes in CC Mode.
;; (defun my-c-mode-common-hook ()
;;   ;; add my personal style and set it for the current buffer
;;   (c-add-style "PERSONAL" my-c-style t)
;;   ;; other customizations
;;   ;; we like auto-newline and hungry-delete
;;   (c-toggle-auto-hungry-state 1)
;;   ;; key bindings for all supported languages.  We can put these in
;;   ;; c-mode-base-map because c-mode-map, c++-mode-map, objc-mode-map,
;;   ;; java-mode-map, idl-mode-map, and pike-mode-map inherit from it.
;;   (define-key c-mode-base-map "\C-m" 'c-context-line-break))

;; (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

;; ----------------------------------------------------------------------
;; *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
;;
;;Печать в файл
;(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

;; (desire 'sql-mode)
(setq sql-password "")

;; ======================================================================
;;
;; Установка режима CUA - все как в Windows
;; поддержка Ctr-c,v,x,d как в windows через пакет CUA

;; версия 21.3

;(require 'cua)
;(CUA-mode t)
;;установка режимов работы курсора через CUA
;(setq CUA-mode-normal-cursor-color "black")
;(setq CUA-mode-overwrite-cursor-color "red")
;(setq CUA-mode-read-only-cursor-color "green")
;(CUA-keypad-mode 'numeric t); доп.клавиатура - цифры
;(CUA-keypad-mode 'prefix t); доп.клавиатура - префиксы регистров (М-2)

;; версия 21.3.50 и старше

;(require 'cua-base)
;(cua-mode t)
;;установка режимов работы курсора через CUA
;(setq cua-normal-cursor-color "black")
;(setq cua-overwrite-cursor-color "red")
;(setq cua-read-only-cursor-color "green")


;; ======================================================================
;; Backup

(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


;; ======================================================================
;; Setup 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  ">"))

(message ".emacs loaded OK.")

;;
;; End loading...