;;    Artur Hefczyc sample, working .emacs file
;;    http://wttools.sf.net/
;;    (C) 2003, Artur Hefczyc
;;
;;    This library is free software; you can redistribute it and/or
;;    modify it under the terms of the GNU Lesser General Public
;;    License as published by the Free Software Foundation;
;;    version 2.1 of the License.
;;
;;    This library is distributed in the hope that it will be useful,
;;    but WITHOUT ANY WARRANTY; without even the implied warranty of
;;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;;    Lesser General Public License for more details.
;;
;; $Id: .emacs,v 1.16 2003/05/06 22:10:34 kobit Exp $

;;;; Macros ;;;;
;; Are we running XEmacs or Emacs?
(defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version))

;; Some simple macros to more easily tell if we're running GNUEmacs or XEmacs
;; taken from the .emacs of sukria@online.fr | http://sukria.online.fr
(defmacro GNUEmacs (&rest x)
  (list 'if (not running-xemacs) (cons 'progn x)))
(defmacro XEmacs (&rest x)
  (list 'if running-xemacs (cons 'progn x)))
(defmacro Xlaunch (&rest x)
  (list 'if (eq window-system 'x) (cons 'progn x)))
;;;; /Macros ;;;;

;;; My location for external packages.
(add-to-list 'load-path "~/.emacs.d/site-lisp")

;;; Setup initial emacs frames (windows) location and size
(setq default-frame-alist
      '((wait-for-wm . nil)
	(top . 0) (left . 0)
	(width . 85) (height . 40)
	(background-color . "gray15")
	(foreground-color . "limegreen")
	(cursor-color . "LightGoldenrod")
	(mouse-color . "yellow")
        ))
(setq initial-frame-alist 
      '((top . 45) (left . 300)
;;        (width . 105) (height . 40)
        )
      )

;;; If you have own color scheme and don't like to use emacs default
;;; I recommend to use this package:
;;; http://www.emacswiki.org/cgi-bin/wiki.pl?ColorTheme
(require 'color-theme)

;;; Excellent package for better scrolling in emacs
;;; should be default package. But now it can be downloaded
;;; from: http://user.it.uu.se/~mic/pager.el
(require 'pager)

;;;; Parens ;;;;
;;; mic-paren.el is available at:
;;; http://www.docs.uu.se/~mic/emacs.shtml
(Xlaunch (require 'mic-paren) (paren-activate))
;;; cparen.el is available at:
;;; http://www.hut.fi/u/rsaikkon/software/elisp/cparen.el
(require 'cparen)
(cparen-activate)
(show-paren-mode t)
;;;; /Parens ;;;;

;;; Last version of xml-lite.el should be evailable from:
;;; http://www.bigfoot.com/~mdub/software/xml-lite.el
;;; This is an option to use in place of psgml package.
;;; Much simpler and easier to use. Sufficient for
;;; simple 'taged' files editing.
;; (require 'xml-lite)

;;; Major mode for SGML and XML files
;;; It can be used inplace of built in SGML major mode with
;;; xml-lite minor mode. The last version of package can be found
;;; at address:
;;; http://sourceforge.net/projects/psgml
;;; Some tips and tricks can be found at address:
;;; http://www.snee.com/bob/sgmlfree/emcspsgm.html
(add-to-list 'load-path "~/.emacs.d/site-lisp/psgml")
(require 'psgml)
(autoload 'sgml-mode "psgml" "Major mode to edit SGML files." t)
(autoload 'xml-mode "psgml" "Major mode to edit XML files." t)
;;; Personal setting and functions for sgml mode
;;; stuff collected from internet and created on my own
;;; You can find this file if necessary at address:
;;; http://wttools.sourceforge.net/emacs-stuff/sgml-adds.html
;;; or download emacs lisp file from CVS repository:
;;; http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/wttools/wttools/emacs-stuff/sgml-adds.el?rev=HEAD&content-type=text/plain
(load-file "~/.emacs.d/site-lisp/sgml-adds.el")

;;; Load all JDEE related libraries
;;; JDEE, documentation and file are located at:
;;; http://jdee.sunsite.dk/
;;; To speed-up installation for JDEE beginners use:
;;; http://wttools.sourceforge.net/emacs-stuff/package.html#install-jdee
(add-to-list 'load-path "~/.emacs.d/site-lisp/elib")
(add-to-list 'load-path "~/.emacs.d/site-lisp/eieio")
(add-to-list 'load-path "~/.emacs.d/site-lisp/semantic")
(add-to-list 'load-path "~/.emacs.d/site-lisp/speedbar")
(add-to-list 'load-path "~/.emacs.d/site-lisp/jde")
(require 'jde)

;;; Source code browser for Emacs. Supports source-code 
;;; parsing for Java, C, C++, Elisp, Scheme etc.
;;; Project site with packages, docs and all other stuff:
;;; http://ecb.sourceforge.net/
(add-to-list 'load-path "~/.emacs.d/site-lisp/ecb")
(require 'ecb)

;;;; Libraries ;;;;
;;; Last found version of htmlize.el 
;;; http://fly.srk.fer.hr/~hniksic/emacs/htmlize.el
(require 'htmlize)

;;; IRC client for emacs available from:
;;; http://emacswiki.org/cgi-bin/wiki.pl?EmacsIRCClient
;;; Loading erc and additionall erc modules
(add-to-list 'load-path "~/.emacs.d/site-lisp/erc")
(require 'erc)
(require 'erc-stamp)
(require 'erc-match)

;;; First load personal-funcs.el with custum functions set
;;; and personal parameters.
;;; You can find this file if necessary at address:
;;; http://wttools.sourceforge.net/emacs-stuff/personal-funcs.html
;;; or download emacs lisp file from CVS repository:
;;; http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/wttools/wttools/emacs-stuff/personal-funcs.el?rev=HEAD&content-type=text/plain
(load-file "~/.emacs.d/site-lisp/personal-funcs.el")

;;; Execute some own custom functions stored in 
;;; personal-func.el
(my-color-theme)

;;; First configure PC like behaviour especially for those who started with
;;; Borland's editors. It also sets emacs default key map, so it is 
;;; important to do it before setting custom key bindings.
(pc-selection-mode)
(pc-bindings-mode)

;; Following bound functions are defined in
;; personal-funcs.el file
;; Stuff collected from internet and created on my own
;; Bind function to usual kill-line key
(global-set-key "\C-k" 'kill-whole-line)
(global-set-key "%" 'match-paren)

;;; Some basic keybindings
(global-set-key [delete] 'delete-char)
(global-set-key [backspace] 'delete-backward-char)
(global-set-key [(meta backspace)] 'undo)
(global-set-key [(control backspace)] 'backward-kill-word)
(global-set-key [(control delete)] 'kill-word)
(global-set-key [f1] 'man-follow)
(global-set-key [f4] 'speedbar-get-focus)
(global-set-key [f6] 'buffer-menu)
(global-set-key [M-return] 'expand-abbrev)
;; (global-set-key [end] 'end-of-line)
;; (global-set-key [home] 'beginning-of-line)
;;; Key binding for sqitching to next and previous buffer
(global-set-key '[C-tab] 'bs-cycle-next)
(global-set-key [S-tab] 'bs-cycle-previous) 

;;; Well, it is good to have the same keybinding for commenting out
;;; region in all modes.
(global-set-key [?\C-c ?c] 'comment-region)

;;; Bind scrolling functions from pager library.
(global-set-key [next] 	   'pager-page-down)
(global-set-key [prior]	   'pager-page-up)
(global-set-key '[M-up]    'pager-row-up)
(global-set-key '[M-down]  'pager-row-down)

;;; It works only if you manualy set CYGWIN_ROOT environment
;;; variable for your Windows system 
;;; (MyComputer->Properties->Advanced->Environment Varibles)
;;; Configures some parameters for CygWin specific environment
(if (not (null (getenv "CYGWIN_ROOT")))
    (progn
      (setq-default
       cygwin-root (getenv "CYGWIN_ROOT")
       exec-path (cons (concat cygwin-root "/bin") exec-path)
       process-coding-system-alist '(("bash" . undecided-unix))
       shell-file-name "bash"
       explicit-shell-file-name shell-file-name
       )
      (setenv "PATH" (concat cygwin-root "/bin;" 
			     cygwin-root "/usr/local/bin;" 
			     (getenv "PATH")))
      (setenv "SHELL" shell-file-name) 
      (add-hook 'comint-output-filter-functions
		'comint-strip-ctrl-m)
      )
  )

;;; I need support for my language "special" characters
(set-language-environment 'Polish)
(set-input-method 'latin-2-prefix)

;;; It is always better to know current line and column number
(column-number-mode t)
(line-number-mode t)

;;; Make all yes-or-no questions as y-or-n
(fset 'yes-or-no-p 'y-or-n-p)

;;; Some more customization for JDEE
(defun my-jde-mode-hook ()
  "Hook for running Java file..."
  (message "Loading my-java-hook...")
  (define-key c-mode-base-map "\C-ca" 'jde-javadoc-generate-javadoc-template)
  (define-key c-mode-base-map "\C-m" 'newline-and-indent)  
  (c-set-offset 'substatement-open 0)
  (c-set-offset 'statement-case-open 0)
  (c-set-offset 'case-label '+)
  (fset 'my-javadoc-code
	[?< ?c ?o ?d ?e ?>?< ?/ ?c ?o ?d ?e ?> left left left left left left left])
  (define-key c-mode-base-map "\C-cx" 'my-javadoc-code)
  (abbrev-mode t)
  (setq c-comment-continuation-stars "* "
	tab-width 4 
	indent-tabs-mode nil
	tempo-interactive t
	c-basic-offset 4)
  (message "my-jde-mode-hook function executed")
)
(add-hook 'jde-mode-hook 'my-jde-mode-hook)

;; Add current time to every new line
(erc-timestamp-mode t)
;; Notify me if someone calls me
(erc-match-mode t)
;; Some basic settings for erc package
(setq erc-server "irc.eu.freenode.net" 
      erc-port 6667 
      erc-nick "artur"
      erc-user-full-name user-full-name
      erc-email-userid "artur"
      erc-prompt-for-password nil
      erc-fill-prefix "      "
      erc-auto-query t
      erc-pals '("artur" "cameron" "james" "rob" "chris" "ian" "andrea"
		 "martin"
		 "CameronShorter" "jmacgill" "cholmes" "rob___" 
		 "MartinD" "IanS" "aaime" "ianT")
      erc-keywords '("vpf" "datasource" " core" " cts" "geoapi" " jts" 
		     "opengis" "shapefile" "gml" " wms" " wfs" " sld" 
		     "jdbc" "jalopy" " ogc" " rmi" " rpc" " xml" 
		     " bbox" "featurecollection" "featuretype"
		     " feature" "geometry" " cvs" " uml" "TileCache"
                     "abstract" "interface")
      erc-current-nick-highlight-type 'nick
      erc-timestamp-only-if-changed-flag nil
      erc-timestamp-format "%H:%M "
      erc-insert-timestamp-function 'erc-insert-timestamp-left
      erc-join-buffer (quote frame)
      erc-kill-buffer-on-part t
      erc-save-buffer-on-part t
      erc-log-channels t
      erc-log-channels-directory "~/.irclogs"
      erc-log-insert-log-on-open t
      erc-generate-log-file-name-function 'my-erc-generate-log-file-name-short
)

;;; Some basic and common parameters
(custom-set-variables
  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(auto-compression-mode t nil (jka-compr))
 '(bs-cycle-configuration-name "all")
 '(case-fold-search t)
 '(color-theme-is-global t)
 '(desktop-enable t nil (desktop))
 '(ecb-layout-name "top3")
 '(ecb-layout-window-sizes 
   (quote 
    (("top3" (0.4470588235294118 . 0.2) (0.5058823529411765 . 0.2)) 
     ("top1" (0.32941176470588235 . 0.2) (0.25882352941176473 . 0.2) 
      (0.3176470588235294 . 0.2)))))
 '(ecb-tip-of-the-day nil)
 '(ecb-tree-indent 1)
 '(fill-column 80)
 '(font-lock-mode-maximum-decoration t)
 '(global-font-lock-mode t nil (font-lock))
 '(indent-tabs-mode nil)
 '(jde-ant-enable-find t)
 '(jde-ant-home "$ANT_HOME")
 '(jde-auto-parse-max-buffer-size 0)
 '(jde-build-function (quote (jde-ant-build)))
 '(jde-complete-function (quote jde-complete-minibuf))
 '(kill-whole-line t)
 '(next-line-add-newlines nil)
 '(require-final-newline t)
 '(text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify)))
 '(transient-mark-mode t)
 '(uniquify-buffer-name-style nil nil (uniquify))
 '(user-full-name "Artur Hefczyc")
 '(user-mail-address "kobit@users.sourceforge.net")
 '(version-control t))

(desktop-load-default)
(desktop-read)
;; (load-file "d:/projects/wttools/dicts/kobit_dict.el")