;; Default .emacs file for JDE

(setq inhibit-startup-message t)

;;; allow copy paste from firefox etc.
(setq x-select-enable-clipboard t)
(setq interprogram-paste-function 'x-cut-buffer-or-selection-value)

'(load-file "~fyj/pub/tools/emacs_jde-jpc")

'(setq user-init-file
      (expand-file-name "init.el"
                        (expand-file-name ".xemacs" "~")))
'(setq custom-file
      (expand-file-name "custom.el"
                        (expand-file-name ".xemacs" "~")))

'(load-file user-init-file)
'(load-file custom-file)
(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(buffers-menu-max-size 100)
 '(c-basic-offset 2)
 '(indent-tabs-mode nil)
 '(initial-scratch-message "")
 '(menu-bar-mode t)
 '(mouse-wheel-mode t nil (mwheel))
 '(mouse-wheel-progressive-speed nil)
 '(tex-fontify-script nil))
'(
''(set-background-color "black")
''(set-foreground-color "white")
''(set-cursor-color "red")
''(set-default-font "*-fixed-bold-r-*-13-*")
'(set-default-font "*-fixed-bold-r-*-15-*")
'(set-default-font "*-r-*-24-*")
)
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 )
'(set-default-font "-*-Courier-normal-r-*-*-13-*-*-*-c-*-*-iso8859-1")
(setq line-number-mode t)
(global-font-lock-mode 1)

(add-to-list 'default-frame-alist '(background-color . "black"))
(add-to-list 'default-frame-alist '(foreground-color . "white"))
(add-to-list 'default-frame-alist '(cursor-color . "red"))
'(add-to-list 'default-frame-alist '(font . "7x13"))
(add-to-list 'default-frame-alist '(font . "*-fixed-bold-r-*-13-*"))
'(add-to-list 'default-frame-alist '(menu-font . "*-fixed-bold-r-*-13-*"))

(global-set-key "\eo" 'fill-region)
(global-set-key "\ep" 'fill-region-as-paragraph)

(require 'easymenu)
(require 'cl)
(require 'cc-mode)

(defconst my-menu nil)

(defvar my-flag t) ;; just for testing

;;; These is example actions for menu
(defun my-1 () (interactive) (message "1") (setq my-flag t))
(defun my-2 () (interactive) (message "2") (setq my-flag nil))
(defun my-3 () (interactive) (message buffer-file-name))

(easy-menu-define
  my-menu
  java-mode-map ; the map
  "My test menu" ; documentation string
  (list
   "jde"
   ["Selection 1" my-1 t]
   ["Selection 2" my-2 t]
   ["Selection 3" my-3 my-flag ]))

(add-hook 'java-mode-hook
          (lambda ()
            (set (make-local-variable 'compile-command)
                 (concat "javac " buffer-file-name))))

'(defcustom compile-command "make -k "
  "*Last shell command used to do a compilation; default for next compilation.

Sometimes it is useful for files to supply local values for this variable.
You might also use mode hooks to specify it in certain modes, like this:

    (add-hook 'c-mode-hook
       (lambda ()
	 (unless (or (file-exists-p \"makefile\")
		     (file-exists-p \"Makefile\"))
	   (set (make-local-variable 'compile-command)
		(concat \"make -k \"
		        (file-name-sans-extension buffer-file-name))))))"
  :type 'string
  :group 'compilation)

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

;;       ;; test.el ? Just sample .el file

;;       (require 'easymenu)
;;       (require 'cl)


;;       (defconst my-map (make-sparse-keymap))
;;       (defconst my-menu nil)
;;       (defconst my-mode nil)
;;       (defvar   my-flag nil)

;;       (define-key my-map "\ez1" 'my-1)
;;       (define-key my-map "\ez2" 'my-2)
;;       (define-key my-map "\ez3" 'my-3)

;;       (easy-menu-define
;;          my-menu
;;          (if (boundp 'xemacs-logo) nil (list my-map))
;;          "My test menu"
;;          (list
;;           "jde" ;;; test duplicate menu name
;;           ["Selection 1" my-1 t]
;;           ;;
;;           ;;  X window note:
;;           ;;  Works in 19.14, but not in Emacs.
;;           ;;
;;           ;;  This is a bug in 19.34 but will be
;;           ;;  corrected to later release
;;           ;;
;;           ["Selection 2" my-2 nil]
;;           ;;
;;           ;;  let's try something more fancier here.
;;           ;;
;;           ["Selection 3" my-3 (get 'my-menu 'menu-flag) ]))


;;       ;;  Add mode to minor mode list
;;       ;;
;;       (unless my-flag                         ;Add only once
;;         (setq my-flag t)
;;         (push (cons 'my-mode my-map)  minor-mode-map-alist))

;;       (defun my-1 () (interactive) (message "1"))
;;       (defun my-2 () (interactive) (message "2"))
;;       (defun my-3 () (interactive) (message "3"))


;;       ;;   Toggle mode and add the menu, not the menu is available
;;       ;;
;;       (setq my-mode nil)
;;       (setq my-mode t)
;;       (easy-menu-add my-menu)

;;       ;; X window note:
;;       ;; Trying this does not enable choice "3" in XEmacs 19.14
;;       ;; In Emacs 19.30 it works ok.
;;       ;;
;;       ;; (progn (put 'my-menu 'menu-flag t) (force-mode-line-update))
;;       ;; (progn (put 'my-menu 'menu-flag nil) (force-mode-line-update))


;;       ;; Another Test, you need this in XEmacs, but not actually
;;       ;; in Emacs. --> Use it for portability.
;;       ;;
;;       ;; (easy-menu-remove my-menu)

;;       ;; end of code

(put 'downcase-region 'disabled nil)
