yatex
diff yatex19.el @ 73:f41b01fef5d6
Stable version(hope to be)
author | yuuji |
---|---|
date | Wed, 22 May 2002 04:57:42 +0000 |
parents | 0aaebd07dad0 |
children | 1b172d26b55e |
line diff
1.1 --- a/yatex19.el Mon Dec 25 10:19:28 2000 +0000 1.2 +++ b/yatex19.el Wed May 22 04:57:42 2002 +0000 1.3 @@ -1,14 +1,14 @@ 1.4 ;;; -*- Emacs-Lisp -*- 1.5 ;;; YaTeX facilities for Emacs 19 1.6 -;;; (c )1994-2000 by HIROSE Yuuji.[yuuji@yatex.org] 1.7 -;;; Last modified Mon Dec 25 19:16:04 2000 on firestorm 1.8 +;;; (c )1994-2002 by HIROSE Yuuji.[yuuji@yatex.org] 1.9 +;;; Last modified Wed May 22 13:55:20 2002 on firestorm 1.10 ;;; $Id$ 1.11 1.12 ;(require 'yatex) 1.13 1.14 -(cond 1.15 - (YaTeX-use-hilit19 (require 'hilit19)) 1.16 - (YaTeX-use-font-lock (require 'font-lock))) 1.17 +(and (boundp 'YaTeX-use-hilit19) 1.18 + YaTeX-use-hilit19 1.19 + (require 'hilit19)) 1.20 1.21 (defvar YaTeX-use-highlighting (or YaTeX-use-font-lock YaTeX-use-hilit19) 1.22 "*Use highlighting buffer or not.") 1.23 @@ -18,6 +18,15 @@ 1.24 ((boundp 'frame-background-mode) frame-background-mode) 1.25 ((fboundp 'get-frame-background-mode) 1.26 (get-frame-background-mode (selected-frame))) 1.27 + (if (face-background 'default) 1.28 + (if (> (+ 32768 32768 32768) 1.29 + (apply '+ 1.30 + (funcall (if (fboundp 'color-rgb-components) 1.31 + 'color-rgb-components 1.32 + 'x-color-values) 1.33 + (face-background 'default)))) 1.34 + 'dark 1.35 + 'light)) 1.36 (t nil))) 1.37 1.38 (defvar YaTeX-mode-menu-map (make-sparse-keymap "YaTeX")) 1.39 @@ -319,7 +328,8 @@ 1.40 "\\\\\\(title\\|author\\|date\\|thanks\\)\\>" define) 1.41 1.42 ("\\\\document\\(style\\|class\\)\\(\\[.*\\]\\)?{" "}" decl) 1.43 - ("\\\\\\(begin\\|end\\|nofiles\\|includeonly\\){" "}" decl) 1.44 + 1.45 + ("\\\\\\(begin\\|end\\|nofiles\\|includeonly\\|usepackage\\(\\[.*\\]\\)?\\){" "}" decl) 1.46 ("\\\\\\(raggedright\\|makeindex\\|makeglossary\\|maketitle\\)\\b" 0 decl) 1.47 ("\\\\\\(pagestyle\\|thispagestyle\\|pagenumbering\\){" "}" decl) 1.48 ("\\\\\\(normalsize\\|small\\|footnotesize\\|scriptsize\\|tiny\\|large\\|Large\\|LARGE\\|huge\\|Huge\\)\\b" 0 decl) 1.49 @@ -488,8 +498,9 @@ 1.50 (cond 1.51 ((eq YaTeX-background-mode 'light) (car table)) 1.52 ((eq YaTeX-background-mode 'dark) (cdr table)) 1.53 - (t nil))))) 1.54 - sect single) 1.55 + ;; Default case equals to 'light mode...is it OK? 1.56 + (t (car table)))))) 1.57 + sect single pattern-alist) 1.58 (YaTeX-19-create-face ;;hilit-translate 1.59 ;;sectioning (funcall get-face YaTeX-hilit-sectioning-face) 1.60 'macro (funcall get-face YaTeX-hilit-singlecmd-face)) 1.61 @@ -508,53 +519,68 @@ 1.62 single 1.63 "\\|") 1.64 "\\)\\b"))) 1.65 - (setq hilit-patterns-alist ;Remove at first. 1.66 - (delq (assq 'yatex-mode hilit-patterns-alist) hilit-patterns-alist) 1.67 - hilit-patterns-alist 1.68 - (cons 1.69 - (cons 'yatex-mode 1.70 - (append 1.71 - (list nil) 1.72 - YaTeX-sectioning-patterns-alist 1.73 - YaTeX-hilit-pattern-adjustment-private 1.74 - ;;YaTeX-hilit-pattern-adjustment-default 1.75 - YaTeX-hilit-patterns-alist 1.76 - (delq nil 1.77 - (list 1.78 - (if sect (list 1.79 - 'YaTeX-19-region-section-type 1.80 - sect 1.81 - 'keyword)) 1.82 - (if single (list single 0 'macro)))))) 1.83 - hilit-patterns-alist)))))) 1.84 + (cons 'yatex-mode 1.85 + (append 1.86 + (list nil) 1.87 + YaTeX-sectioning-patterns-alist 1.88 + YaTeX-hilit-pattern-adjustment-private 1.89 + ;;YaTeX-hilit-pattern-adjustment-default 1.90 + YaTeX-hilit-patterns-alist 1.91 + (delq nil 1.92 + (list 1.93 + (if sect (list 1.94 + 'YaTeX-19-region-section-type 1.95 + sect 1.96 + 'keyword)) 1.97 + (if single (list single 0 'macro)))))))))) 1.98 ;;(YaTeX-19-collect-macros) ;causes an error 1.99 +(defun YaTeX-hilit-setup-alist () 1.100 + (cond 1.101 + ((boundp 'hilit-patterns-alist) 1.102 + (setq hilit-patterns-alist 1.103 + (delq (assq 'yatex-mode hilit-patterns-alist) hilit-patterns-alist)) 1.104 + (if YaTeX-use-hilit19 1.105 + (setq hilit-patterns-alist 1.106 + (cons (YaTeX-19-collect-macros) hilit-patterns-alist)))))) 1.107 + 1.108 (defun YaTeX-hilit-recenter (arg) 1.109 "Collect current local macro and hilit-recenter." 1.110 (interactive "P") 1.111 - (YaTeX-19-collect-macros) 1.112 + (YaTeX-hilit-setup-alist) 1.113 + (if (fboundp 'font-lock-mode) (font-lock-mode -1)) 1.114 (hilit-recenter arg)) 1.115 -(defvar YaTeX-19-recenter-function 1.116 - (cond 1.117 - (YaTeX-use-hilit19 (cons 'YaTeX-hilit-recenter 'hilit-recenter)) 1.118 - (YaTeX-use-font-lock (cons 'YaTeX-font-lock-recenter 'recenter)) 1.119 - (t nil))) 1.120 1.121 -(if YaTeX-19-recenter-function 1.122 - (let ((k (where-is-internal (cdr YaTeX-19-recenter-function)))) 1.123 - (while k 1.124 - (define-key YaTeX-mode-map (car k) (car YaTeX-19-recenter-function)) 1.125 - (setq k (cdr k))))) 1.126 +(let ((k (append (where-is-internal 'hilit-recenter) 1.127 + (where-is-internal 'recenter)))) 1.128 + (while k 1.129 + (define-key YaTeX-mode-map (car k) 'YaTeX-19-recenter) 1.130 + (setq k (cdr k)))) 1.131 + 1.132 +(defun YaTeX-19-recenter (&optional arg) 1.133 + (interactive "P") 1.134 + (if YaTeX-use-hilit19 1.135 + (YaTeX-hilit-recenter arg) 1.136 + (YaTeX-font-lock-recenter arg))) 1.137 1.138 (defun YaTeX-font-lock-recenter (&optional arg) 1.139 (interactive "P") 1.140 + (cond 1.141 + ((and (boundp 'hilit-patterns-alist) 1.142 + (assq 'yatex-mode hilit-patterns-alist)) 1.143 + (if (fboundp 'hilit-unhighlight-region) 1.144 + (hilit-unhighlight-region (point-min) (point-max))) 1.145 + (setq hilit-patterns-alist ;ensure to remove 1.146 + (delq (assq 'yatex-mode hilit-patterns-alist) 1.147 + hilit-patterns-alist)))) 1.148 (setq YaTeX-font-lock-keywords 1.149 (YaTeX-convert-pattern-hilit2fontlock 1.150 - (cdr (assq 'yatex-mode (YaTeX-19-collect-macros)))) 1.151 + (cdr (YaTeX-19-collect-macros))) 1.152 font-lock-keywords nil) 1.153 ;(save-excursion 1.154 ; (font-lock-fontify-region (window-start) (window-end))) 1.155 (font-lock-mode -1) ;is stupid, but sure. 1.156 - (font-lock-mode 1)) 1.157 + (font-lock-mode 1) 1.158 + (recenter arg)) 1.159 1.160 (defvar YaTeX-font-lock-keywords nil 1.161 "Pattern-face alist of yahtml-mode for font-lock")