;;;;;;;;;;;;; -*- Mode: Emacs-Lisp -*- ;;;;;;;;;;;;;;
;;; .emacs file for Emacs-AucTeX-MikTeX
;;; Compliler : Tatsuya YANAGIDA
;;; Created On : 4 Sep 2005
;;; Last Modifed By :
;;; Last Modified On:
;;; Updated Count :
;;; Status : Ok,
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; Put this file in your HOME directory (e.g. c:/home/yanagida/)

;;;;;;;;;; Colour settings for LaTeX mode ;;;;;;;;;;
;; Speeding up loading files which use font-lock mode
(setq font-lock-support-mode 'jit-lock-mode)

;;; The highlighting colours will be used in all modes with the following.
(global-font-lock-mode t)

;; my own colour settings for font-lock
;;; note: AucTeX do not differenciate LaTeX's prefixes such as \{document} with pakcages prefixes such as \glll of gb4e in colour settings and the following setting aims not to use too many colours and the settings for comment and keyword would be enoguth for the purpose.

(add-hook 'font-lock-mode-hook '(lambda ()
;; comment: commented out part will be maroon1
(set-face-foreground 'font-lock-comment-face "maroon1") ;firebrick1, orange red,indian red,maroon1,violetred3, maroon2, lightsalmon2
;; other candiates: darkred, firebrik1-4,violetred,
(set-face-background 'font-lock-comment-face nil)
(set-face-bold-p 'font-lock-comment-face nil)
(set-face-italic-p 'font-lock-comment-face nil)
(set-face-underline-p 'font-lock-comment-face nil)

;; keyword: LaTeX's prefixe such as \begin{document} and gb4e prefixes such as /glll will change.
(set-face-foreground 'font-lock-keyword-face "lemonchiffon4")
; other candidates: lemonchiffon4, spring green,green yellow, forest green, lawn green, light cyan, green4, darkgreen, cyan, turquoise, chartreuse,
(set-face-background 'font-lock-keyword-face nil)
(set-face-bold-p 'font-lock-keyword-face nil)
(set-face-italic-p 'font-lock-keyword-face nil)
(set-face-underline-p 'font-lock-keyword-face nil)
))
(provide 'faces-font-lock)

;;;; highlight marked regions ;;;;;;;
(setq transient-mark-mode t)
(set-face-foreground 'region "white") ;originally: white
(set-face-background 'region "dim gray") ;dim gray


;;; RefTeX: to turn on reftex Mode for all LaTeX files
;(add-hook 'LaTeX-mode-hook 'turn-on-reftex)

;;;; browse-kill-ring settings ;;;;
;;; source http://www.bookshelf.jp/soft/meadow_32.html#SEC444 ;;;;;

(require 'browse-kill-ring)
(global-set-key "\M-y" 'browse-kill-ring)

;; showing in one line.
;(setq browse-kill-ring-display-style 'one-line)

;; kill buffer when quit
;(setq browse-kill-ring-quit-action 'kill-and-delete-window)

;; highlight the current selection
(setq browse-kill-ring-highlight-current-entry t)


;;; cygwin settings ;;;;;
(setq explicit-shell-file-name "bash.exe")
(setq shell-file-name "sh.exe")
(setq shell-command-switch "-c")
;(modify-coding-system-alist 'process ".*sh\\.exe" '(undecided-dos . euc-japan))
;; argument-editing $B$N@_Dj(B
;(require 'mw32script)
;(mw32script-init)
;(setq exec-suffix-list '(".exe" ".sh" ".pl"))
;(setq shell-file-name-chars "~/A-Za-z0-9_^$!#%&{}@`'.:()-")


;;;----- no extra lines from the end of the file.----;;;;;;;;;
(setq next-line-add-newlines nil)

(add-hook 'text-mood-hook
'(lambda ()
(progn (set-fill-column 300)
(turn-on-auto-fill))))

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

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


;; font-latex.el settings
;(if window-system (require 'font-latex))

;;;-------------------------------------------------
;;;+++ yatex +++ ;;
;(setq auto-mode-alist
;(cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist))
;(autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)
;
;(setq load-path (cons (expand-file-name "c:/usr/local/emacs-21.3/site-lisp/yatex") load-path))
;;;; previously ---> c:/program files/emacs/site-lisp/yatex
;;;; note that if there are any spaces in the path YaTeX does not reach the destination.
;(load "yatex")
;
;;;; type-setter ;;;
;;;; YaTeX will find an exe file of latex to typeset.
;(setq tex-command "c:/localtexmf/miktex/bin/latex.exe")
;;;; previously ---> c:/texmf/miktex/bin/latex.exe
;;;; Note that if there are any spaces in the path YaTeX does not reach the destination.
;
;;;; previewer ;;;
;(setq dvi2-command "c:/localtexmf/miktex/bin/yap")
;(setq dvi2-command "c:/dviout/dviout.exe")
;;;; previously ---> c:/texmf/miktex/bin/yap.exe
;
;;;; I don't use Yahtml anymore and the following Yahtml part are uncommented;;;;;;
;; Yahtml
;; Yahtml will be autolatically loaded when opening *.html file.
;;(setq auto-mode-alist
;; (cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist))
;;(autoload 'yahtml-mode "yahtml" "Yet Another html-mode" t)
;;(setq yahtml-kanji-code 3)
;;;
;;; End of Yahtml settings ;;;;;;;;;;;;;;;;;;;;;

;;Setting for RefTeX
;; (add-hook 'yatex-mode-hook '(lambda () (reftex-mode t)))

;; html -------------------------------------------------------------------
;; html-helper-mode

(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
(setq auto-mode-alist (cons '("\\.html$" . html-helper-mode)
auto-mode-alist))
;(setq html-helper-mode-uses-JDE nil)
;(setq html-helper-mode-uses-visual-basic nil)

;; fonthtml
(setq load-path (cons "e:/home/tatsuya/emacs/site-lisp/html-helper-mode/" load-path))
(add-hook 'html-helper-load-hook
(function (lambda () (load "fonthtml.elc"))))

;;; bibtex ;;;
(setq bibtex-command "c:/texmf/miktex/bin/bibtex.exe")


;;;;; The following part is disabled in order to use CJK which is Japanese input method come with GNU Emacs.;;;;
;;;; y޲Á’»úyŽ£³’¡¼yޣɠ;;;
;;;; 1=Shift JIS >== Windows yŽ¢Éð¤é
;;;;; 2=JIS
;;; 3=EUC
;(setq YaTeX-kanji-code 1)
;
;;; LaTeX2e yŽ¢ñð»ÈyŽ¢¥þ;;;
;(setq YaTeX-use-LaTeX2e t)
;
;;;; y޽§’ÉÕyŽ¢± ;;;
;;;(setq Yatex-use-font-lock t)
;;;; originally (setq Yatex-use-font-lock t).
;;;; modified by Tatsuya to work on sytax-highlighting for Latex-mode 09/01/2004.
;
;;;; YaTeX help ;;;
;;;; The following line added by Tatsuya Yanagida on 09/01/2004.
;;;; This line is necessary to make yatex find its help file.
;(setq YaTeX-help-file
; (expand-file-name "YATEXHLP.jp" data-directory))
;
;; End of ;; +++ yatex +++ ;;

;;------------------------------------------------------------------
;; The following is another source for how to make my own
;; font-lock-keywords. The formulae works very nicely.
;;source: http://chaosweb.complex.eng.hokudai.ac.jp/~hagi/contents/memo-meadow-tex.html#yatex-fontlock
;;
;; Add font-lock keyword
(setq my-YaTeX-font-lock-keywords
'(("\\(\\\\\\(left\\|right\\)\\([][().|]\\|\\\\[{}]\\)\\)"
(0 font-lock-warning-face))
("\\(|\\|&\\|\\\\[{}]\\|\\\\\\\\\\)" (0 font-lock-warning-face))
("\\\\[a-zA-Z]*" (0 font-lock-builtin-face))
))
(add-hook 'yatex-mode-hook
'(lambda ()
(setq
YaTeX-font-lock-keywords
(append YaTeX-font-lock-keywords my-YaTeX-font-lock-keywords))))


;; ------------------------------------------------------------------
;; +++ display +++ ;;
;;; The following lines added by Tatsuya YANAGIDA 02/01/04.
;;; Need to work out how to fix problem in alignment of dates
;;; in Calendar mode when not using courier fonts.
(setq default-frame-alist
'((top . 8) (left . 2)
(width . 116) ; other fonts: Arial, 92; 14pt,100; @dotumche 16pt 94
(height . 40); Arial 24; when 14pt,43
(cursor-color . "yellow")
(cursor-type . box)
(scroll-bar-width . 12)
(mouse-color . "yellow")
(foreground-color . "wheat") ;; other candidate: white2
(background-color . "darkslategrey") ;; other candidates: gray70, dark slate gray,
))

;;----------------------------------------------------------------
;; +++ yŽ£¿’¥¤yŽ£Çð¥ëyŽ£Ïð¡¼yŽ¢Ë’º£yޱ«’¤¤yŽ¢Åð¤ëyŽ£Õ’¥¡yŽ££ð¥ëyŽ¢Íð¥ÕyŽ£ë’¥ÑyŽ£¹’¤«yŽ£Ïð¥ÃyŽ£Õ’¥¡yŽÊ½ð¤òyŽÇ½’¼¨yŽ¢¹’¤ë +++ ;;
;;; source: http://chaosweb.complex.eng.hokudai.ac.jp/~hagi/contents/files/meadow199.el
(defvar dired-mode-p nil)
(add-hook 'dired-mode-hook
(lambda ()
(make-local-variable 'dired-mode-p)
(setq dired-mode-p t)))
(setq frame-title-format-orig frame-title-format)
(setq frame-title-format
'((buffer-file-name "%f"
(dired-mode-p default-directory
mode-line-buffer-identification))))

;; coding-system yŽ¢ÍðɽyŽº§ë
(defun show-buffer-file-coding-system ()
(interactive)
(message "%s" buffer-file-coding-system)
)

;;------------------------------------------------------------------
;; +++ Window Size yŽ¢ÍðÊÑyŽ·¹ +++ ;;
;; source: http://chaosweb.complex.eng.hokudai.ac.jp/~hagi/contents/files/meadow199.el
(global-set-key [M-left] 'shrink-window-horizontally)
(global-set-key [M-right] 'enlarge-window-horizontally)
(global-set-key [M-down] 'shrink-window)
(global-set-key [M-up] 'enlarge-window)
;; Window yŽ¢Íð°ÜyŽÄ¯þ[S-[up,down,left,right]]
(windmove-default-keybindings)

;;--------------------------------------------------------------------
;; +++ Japanese fonts settings +++ ;;
;;; The following lines added by Tatsuya YANAGIDA 05/01/04:
;;; originally from: http://www.egroups.co.jp/message/emacs21-users-ja/262
;;; font size modified by Tatsuya YANAGIDA.
;;; This part is important to make Japanese fonts displayed properly.

(setq list-faces-sample-text "abcdefg ABCDEFG ¤¢¤¤¤¦¤¨¤ª¡¡ÆüËܸì")
(setq scalable-fonts-allowed t)
(let ((jfont "-*-MS ¥´¥·¥Ã¥¯-*-*-*-*-14-*-*-*-*-*-*-jisx0208-sjis") ;; 16- was added. previously no font size and slash after 16. 16pt works, but other size make Japanese fontsrotate 90 degrees.
(specs '(latin-jisx0201 katakana-jisx0201 japanese-jisx0208)))
(create-fontset-from-fontset-spec
(concat "-*-courier new-*-*-*-*-14-*-*-*-*-*-fontset-std," ;; (*) ;; the size was originally 14pt. Ok with calendar alignment: @dotumche, @gulimche, @gungsuhche
(mapconcat (lambda (x) (format "%s:%s" x jfont)) specs ",")))
(while specs
(set-fontset-font "fontset-std" (make-char (car specs))
'("MS ¥´¥·¥Ã¥¯" . "jisx0208-sjis"))
(setq specs (cdr specs))))

(setq default-frame-alist
(cons '(font . "fontset-std") default-frame-alist))
;; End of +++ Make Japanese fonts display possible +++ ;;

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

;; +++ time +++ ;;
(display-time)
(setq display-time-day-and-date t
display-time-24hr-format t
display-time-inverval 1
display-time-string-forms
'(day "/" month " "24-hours ":" minutes))



(set-language-environment "Japanese")
;(set-terminal-coding-system 'iso-2022-jp)

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


;; Reftex activation (Reftex is included with Emacs 21.1)
;;; This part is copied from Auc TeX .emacs files.
(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

;; ----------------------------------------------------------------------
;; Info for Ispell
(add-to-list 'Info-default-directory-list "c:/usr/local/info/")

(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.
'(global-font-lock-mode t nil (font-lock)))
(custom-set-faces
;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
'(YaTeX-font-lock-declaration-face ((((class color) (background dark)) (:foreground "steel blue"))))
'(vhdl-font-lock-attribute-face ((((class color) (background dark)) (:foreground "dim grey"))))
'(vhdl-font-lock-reserved-words-face ((t (:foreground "wheat" :weight bold)))))