;;;;;;;;;;;;; -*- Mode: Emacs-Lisp -*- ;;;;;;;;;;;;;;
;;; .emacs file for emacs-yatex-miktex on Windows XP
;;; Compliler :
;;; Created On : 30 Dec 2003
;;; Last Modifed By :
;;; Last Modified On : 23/02/2004
;;; Updated Count : many times
;;; Status : Ok,
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; Put this file in your HOME directory.
;;------------------------------------------------------------
;;

(setq inhibit-startup-message nil) ;; skip the opening message.
(setq initial-scratch-message nil) ;; without scratchmessage.

(setq next-line-add-newlines nil)

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

;; Viewing URL from Mew by Mozzila
;(setq
owse-url-browser-function 'browse-url-netscape)
;(autoload 'browse-url-at-mouse "browse-url"
; "Ask a WWW
owser to load a URL clicked with the mouse." t)
;(add-hook 'mew-message-mode-hook
; (function
; (lambda()
; (local-set-key [mouse-2] 'browse-url-at-mouse))))
;
;(setq
owse-url-netscape-program "IE")

(setq scroll-bar-mode-explicit t)
(setq scroll-bar-mode 'left)

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


;;; 自動改行の設定
;(setq text-mode-hook ' turn-on-auto-fill)

(add-hook 'text-mode-hook
'(lambda ()
(progn (set-fill-column 60)
(turn-on-auto-fill))))

;--Replace yes/no+enter prompts with y/n prompts
(fset 'yes-or-no-p 'y-or-n-p)


;;--------------------------------------------------------------------
;; +++ font-lock +++ ;;
;;; comment in general:
;;; Difinitions for font-lock and syntax high-lighting colours should
;;; be placed at the begining of .emacs file. If these are placed
;;; at the end of the file, syntax-highliting does not work.
;;; I have not find out the cause.

;; Speeding up loading files which use font-lock mode ;;;;;
;;; If using emacs 21 the following will speed up loading files
;;; which used font-lock mode.
;;; The following line added by 01/01/2004.
;;; originally from: http://homepage1.nifty.com/blankspace/emacs/color.html
(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)

;;; font-lock for specific mode ;;;
;;; The following line is disabled since I set font-lock for all modes.
;(add-hook 'latex-mode-hook 'turn-on-font-lock)
;(add-hook 'Emacs-lisp 'turn-on-font-lock)
;; +++ End of font-lock matters+++ ;;

;;-------------------------------------------------------------------
;; +++ font-lock +++ ;;
;;; quote--- source: http://www-2.cs.cmu.edu/cgi-bin/info2www?(emacs)Font%2520Lock
;;; Font Lock highlighting patterns already exist for many modes, but you
;;; may want to fontify additional patterns. You can use the function
;;;`font-lock-add-keywords', to add your own highlighting patterns for a
;;; particular mode. For example, to highlight `FIXME:' words in C
;;; comments, use this:
;;;
;;; (font-lock-add-keywords
;;; 'latex-mode
;;; '(("\\<\\(FIXME\\):" 1 font-lock-warning-face t)))
;;;
;;; To remove keywords from the font-lock highlighting patterns, use the
;;; function `font-lock-remove-keywords'. --- end of quote.

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

;; +++ Syntax-highlighting for LaTeX mode +++ ;;
;;; The followings are my own colour for syntax-highlighting.
;;; The lines added by 03/01/04
(add-hook 'font-lock-mode-hook '(lambda ()
;; comment
(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)

;;string
(set-face-foreground 'font-lock-string-face "green") ; cyan3, dark cyan
(set-face-background 'font-lock-string-face nil)
(set-face-bold-p 'font-lock-string-face nil)
(set-face-italic-p 'font-lock-string-face nil)
(set-face-underline-p 'font-lock-string-face nil)

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

;; builtin -> \XXX for LaTeX
(set-face-foreground 'font-lock-builtin-face "deepskyblue");; mediumspringgreen, magenta4
;; other candiates: mediumseagreen, aquamarine, olivedrab, deeppink, magenta, darkorange
(set-face-background 'font-lock-builtin-face nil)
(set-face-bold-p 'font-lock-builtin-face nil)
(set-face-italic-p 'font-lock-builtin-face nil)
(set-face-underline-p 'font-lock-builtin-face nil)

;; function-name
(set-face-foreground 'font-lock-function-name-face "sandybrown")
; other candidates: blueviolet,
(set-face-background 'font-lock-function-name-face nil)
(set-face-bold-p 'font-lock-function-name-face nil)
(set-face-italic-p 'font-lock-function-name-face nil)
(set-face-underline-p 'font-lock-function-name-face nil)

;; variable-name
(set-face-foreground 'font-lock-variable-name-face "deepskyblue") ;green,BlueViolet
(set-face-background 'font-lock-variable-name-face nil)
(set-face-bold-p 'font-lock-variable-name-face nil)
(set-face-italic-p 'font-lock-variable-name-face nil)
(set-face-underline-p 'font-lock-variable-name-face nil)

;;type
(set-face-foreground 'font-lock-type-face "lemonchiffon4") ; mediumspringgreen
(set-face-background 'font-lock-type-face nil)
(set-face-bold-p 'font-lock-type-face nil)
(set-face-italic-p 'font-lock-type-face nil)
(set-face-underline-p 'font-lock-type-face nil)

;; constant
(set-face-foreground 'font-lock-constant-face "indianred") ;; indianRed
(set-face-background 'font-lock-constant-face nil)
(set-face-bold-p 'font-lock-constant-face t)
(set-face-italic-p 'font-lock-constant-face nil)
(set-face-underline-p 'font-lock-constant-face nil)

;; warning
(set-face-foreground 'font-lock-warning-face "Red3")
(set-face-background 'font-lock-warning-face nil)
(set-face-bold-p 'font-lock-warning-face nil)
(set-face-italic-p 'font-lock-warning-face nil)
(set-face-underline-p 'font-lock-warning-face nil)
))
(provide 'faces-font-lock)


;;----------------------------------------------------------
;; +++ 領域指定 +++
;;; source: http://sakito.s2.xrea.com/detail/emacs/emacs21.el.txt
;;; マークしたときに領域を強調表示するかしないかを管理 ;;
(setq transient-mark-mode t)
;;; マーク領域を色付け
;(set-face-foreground 'region "white") ;originally: white
;(set-face-background 'region "dim gray") ;dim gray


;;; 対応する括弧のハイライト表示
;;; http://chaosweb.complex.eng.hokudai.ac.jp/~hagi/contents/files/meadow199.el
(show-paren-mode t)
;;; If 1 is used for t, it does not work.
;(setq show-paren-style 'mixed) ;; 画面外の括弧のときのみ背景色を変更
;(setq show-paren-style 'expression) ;; 常に括弧内の背景色を変更
;(set-face-background 'show-paren-match-face "#006A6A") ;#006A6A
;(set-face-foreground 'show-paren-match-face nil)
;(set-face-bold-p 'show-paren-match-face t)

;; The following lines added by 09/01/04.
;;(setq show-brace-style 'expression) ;; 常に括弧内の背景色を変更
;;(set-face-background 'show-brace-match-face "#006A6A")
;;(set-face-foreground 'show-brace-match-face nil)
;;(set-face-bold-p 'show-brace-match-face t)

;;(setq show-bracket-style 'expression) ;; 常に括弧内の背景色を変更
;;(set-face-background 'show-bracket-match-face "#006A6A")
;;(set-face-foreground 'show-bracket-match-face nil)
;;(set-face-bold-p 'show-bracket-match-face t)

;; 括弧の色を薄くしよう
;; Meadow Memo Wiki http://www.bookshelf.jp/pukiwiki/pukiwiki.php
;(defvar paren-face 'paren-face)
;(make-face 'paren-face)
;(set-face-foreground 'paren-face "#88aaff")

;(defvar
ace-face 'brace-face)
;(make-face 'brace-face)
;(set-face-foreground 'brace-face "medium orchid")

;(defvar
acket-face 'bracket-face)
;(make-face 'bracket-face)
;(set-face-foreground 'bracket-face "#aaaa00")

;(setq lisp-font-lock-keywords-2
; (append '(("(\\|)" . paren-face))
; lisp-font-lock-keywords-2))

;(setq lisp-font-lock-keywords-2
; (append '(("(\\|)" . paren-face))
; lisp-font-lock-keywords-2))

;; (add-hook 'scheme-mode-hook
;; '(lambda ()
;; (setq scheme-font-lock-keywords-2
;; (append '(("(\\|)" . paren-face))
;; scheme-font-lock-keywords-2))))

;(setq c-font-lock-keywords-3
; (append '(("(\\|)" . paren-face))
; '(("{\\|}" .
ace-face))
; '(("\\[\\|\\]" .
acket-face))
; c-font-lock-keywords-3))
;(setq c++-font-lock-keywords-3
; (append '(("(\\|)" . paren-face))
; '(("{\\|}" .
ace-face))
; '(("\\[\\|\\]" .
acket-face))
; c-font-lock-keywords-3))

;;------------------------------------------------------------
;; +++ モードライン +++ ;;
;;; モードライン(下にあるやつ)の色設定
;;; source: http://sakito.s2.xrea.com/detail/emacs/emacs21.el.txt

(set-face-foreground 'modeline "grey50") ;slate grey, lightskyblue4, dark goldenrod, oritinally: snow
(set-face-background 'modeline "darkslategrey") ;originally: black, grey6

;;; 行番号・桁番号をモードラインに表示する
;;; source: http://chaosweb.complex.eng.hokudai.ac.jp/~hagi/contents/files/meadow199.el

(line-number-mode t) ; 行番号
(column-number-mode t) ; 桁番号

;;-------------------------------------------------
;;+++ 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/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")
;;; previously ---> c:/texmf/miktex/bin/yap.exe

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

;;; 漢字コード ;;;
;;; 1=Shift JIS >== Windows なら
;;; 2=JIS
;;; 3=EUC
(setq YaTeX-kanji-code 1)

;;; LaTeX2e を使う ;;;
(setq YaTeX-use-LaTeX2e t)

;;; 色付け ;;;
;;(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 +++ ;;


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




;;------------------------------------------------------------------
;; 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
;; YaTeX の font-lock keywords の追加.\foo 型キーワード(数式環境中のものか
;; YaTeX が触らないもの)と,括弧関係と改行(\\).
;; 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 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 . 2) (left . 80) ; courier new 16pt, left 20
(width . 89) ; other fonts: Arial, 92; 14pt,100; @dotumche 16pt 94; courier new 14pt, 95; courier new 16pt, 80
(height . 39); Arial 24; when 14pt,43; courier new 14pt, 41; courier new 16pt,39
(cursor-color . "yellow")
(cursor-type . box)
(scroll-bar-width . 12)
(mouse-color . "yellow")
(foreground-color . "grey85") ;; other candidate: wheat, white2
(background-color . "darkslategrey") ;; other candidates: gray70, dark slate gray,
))


;;----------------------------------------------------------------
;; +++ タイトルバーに今開いてるファイルのフルパスかバッファ名を表示する +++ ;;
;;; 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 の表示
(defun show-buffer-file-coding-system ()
(interactive)
(message "%s" buffer-file-coding-system)
)

;;------------------------------------------------------------------
;; +++ Window Size の変更 +++ ;;
;; 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-up] 'shrink-window)
(global-set-key [M-down] 'enlarge-window)
;; Window の移動 [S-[up,down,left,right]]
(windmove-default-keybindings)

;;--------------------------------------------------------------------
;; +++ 常にホームディレクトリから +++ ;;
;; http://chaosweb.complex.eng.hokudai.ac.jp/~hagi/contents/files/meadow199.el

(cd "e:/tty")
;;;; currently disabled.

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

(setq list-faces-sample-text "abcdefg
CDEFG あいうえお 日本語")
(setq scalable-fonts-allowed t)
(let ((jfont "-*-MS ゴシック-*-*-*-*-16-*-*-*-*-*-*-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-*-*-*-*-16-*-*-*-*-*-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))

;; +++ calendar & Diary +++ ;;
(setq european-calendar-style t)
;(calendar)
(diary)
(setq mark-diary-entries-in-calendar t)
(setq view-calendar-holidays-initially t)
(setq all-general-holidays t)
(setq all-christian-calendar-holidays t)
(setq all-other-holidays t)

;;; I tried the following in vain. I disabled all the lines. 09/01/2004
;;; originally from: http://www.ai.cs.scitec.kobe-u.ac.jp/~masanori/emacs/dotemacs.html
;; The disabled lines begin here.
;:(setq mark-holidays-in-calendar t ; 休日に印を付ける
;; local-holidays nil ; general-holidays 以外は無視
;; christian-holidays nil
;; hebrew-holidays nil
;; islamic-holidays nil
;; oriental-holidays nil
;; other-holidays nil
;; general-holidays '((holiday-fixed 1 1 "元日")
;; (holiday-float 1 1 2 "成人の日")
;; (holiday-fixed 2 11 "建国記念の日")
;; (holiday-fixed 3 20 "春分の日")
;; (holiday-fixed 4 29 "みどりの日")
;; (holiday-fixed 5 3 "憲法記念日")
;; (holiday-fixed 5 4 "国民の休日")
;; (holiday-fixed 5 5 "こどもの日")
;; (holiday-float 7 1 3 "海の日")
;; (holiday-float 9 1 3 "敬老の日")
;; (holiday-fixed 9 23 "秋分の日")
;; (holiday-float 10 1 2 "体育の日")
;; (holiday-fixed 11 3 "文化の日")
;; (holiday-fixed 11 23 "勤労感謝の日")
;; (holiday-fixed 12 23 "天皇誕生日")))
;; The disabled lines end here.


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