yatex

annotate yatex19.el @ 70:44e3a5e1e883

Fix makefile for Windows Brush up label completion \cite completion Support much more about LaTeX2e --- [yahtml] English Info (By Jun Ohya) Automatic pixel size detection for <img src="..."> Aware global-class of css definition & for char-entity reference
author yuuji
date Sun, 09 Apr 2000 03:37:47 +0000
parents 807c1e7e68b7
children 0aaebd07dad0
rev   line source
yuuji@46 1 ;;; -*- Emacs-Lisp -*-
yuuji@46 2 ;;; YaTeX facilities for Emacs 19
yuuji@70 3 ;;; (c )1994-1999 by HIROSE Yuuji.[yuuji@yatex.org]
yuuji@70 4 ;;; Last modified Fri Nov 26 09:56:09 1999 on firestorm
yuuji@46 5 ;;; $Id$
yuuji@46 6
yuuji@49 7 ;;; とりあえず hilit19 を使っている時に色が付くようにして
yuuji@49 8 ;;; メニューバーでごにょごにょできるようにしただけ。
yuuji@49 9 ;;; いったい誰がメニューバー使ってLaTeXソース書くんだろうか?
yuuji@49 10 ;;; まあいいや練習練習。後ろの方にちょっとコメントあり。
yuuji@53 11 ;;; 真中辺にあるけど、hilit19.el 対応の方は結構本気。
yuuji@64 12 ;;; とかいってるうちに hilit19 って obsolete になってしまった…
yuuji@46 13
yuuji@64 14 ;(require 'yatex)
yuuji@47 15
yuuji@70 16 (defvar YaTeX-use-hilit19 (and (featurep 'hilit19) (fboundp 'x-color-values)
yuuji@70 17 (fboundp 'hilit-translate))
yuuji@70 18 "*Use hilit19 to fontify buffer or not.")
yuuji@70 19
yuuji@64 20 (defvar YaTeX-mode-menu-map (make-sparse-keymap "YaTeX"))
yuuji@64 21 (defvar YaTeX-mode-menu-map-process (make-sparse-keymap "Process"))
yuuji@64 22 (define-key YaTeX-mode-map [menu-bar yatex]
yuuji@64 23 (cons "YaTeX" YaTeX-mode-menu-map))
yuuji@64 24 (YaTeX-define-menu
yuuji@64 25 'YaTeX-mode-menu-map-process
yuuji@64 26 (nreverse
yuuji@64 27 '((buffer "LaTeX" . (lambda () (interactive) (YaTeX-typeset-menu nil ?j)))
yuuji@64 28 (kill "Kill LaTeX" . (lambda () (interactive) (YaTeX-typeset-menu nil ?k)))
yuuji@64 29 (bibtex "BibTeX" . (lambda () (interactive) (YaTeX-typeset-menu nil ?b)))
yuuji@64 30 (mindex "makeindex" . (lambda () (interactive) (YaTeX-typeset-menu nil ?i)))
yuuji@64 31 (preview "Preview" . (lambda () (interactive) (YaTeX-typeset-menu nil ?p)))
yuuji@64 32 (lpr "lpr" . (lambda () (interactive) (YaTeX-typeset-menu nil ?l)))
yuuji@64 33 (lpq "lpq" . (lambda () (interactive) (YaTeX-typeset-menu nil ?q))))))
yuuji@64 34 (defvar YaTeX-mode-menu-map-modes (make-sparse-keymap "Modes"))
yuuji@64 35 (YaTeX-define-menu
yuuji@64 36 'YaTeX-mode-menu-map-modes
yuuji@64 37 (delq nil
yuuji@64 38 (nreverse
yuuji@64 39 (list
yuuji@64 40 (if YaTeX-auto-math-mode nil
yuuji@64 41 (cons 'math (cons "Toggle math-mode"
yuuji@64 42 '(lambda () (interactive)
yuuji@64 43 (YaTeX-switch-mode-menu nil ?t)))))
yuuji@64 44 (cons 'mod (cons "Toggle Modify Mode"
yuuji@64 45 '(lambda () (interactive)
yuuji@64 46 (YaTeX-switch-mode-menu nil ?m))))))))
yuuji@64 47 (defvar YaTeX-mode-menu-map-percent (make-sparse-keymap "percent"))
yuuji@64 48 (YaTeX-define-menu
yuuji@64 49 'YaTeX-mode-menu-map-percent
yuuji@64 50 (nreverse
yuuji@64 51 '((! "Change LaTeX typesetter(%#!)"
yuuji@64 52 . (lambda () (interactive) (YaTeX-%-menu nil nil ?!)))
yuuji@64 53 (begend "Set %#BEGIN-%#END on region"
yuuji@64 54 . (lambda () (interactive) (YaTeX-%-menu nil nil ?b)))
yuuji@64 55 (lpr "Change LPR format"
yuuji@64 56 . (lambda () (interactive) (YaTeX-%-menu nil nil ?l))))))
yuuji@46 57
yuuji@64 58 (defvar YaTeX-mode-menu-map-jump (make-sparse-keymap "jump"))
yuuji@64 59 (YaTeX-define-menu
yuuji@64 60 'YaTeX-mode-menu-map-jump
yuuji@64 61 (nreverse
yuuji@64 62 '((corres "Goto corersponding position" . YaTeX-goto-corresponding-*)
yuuji@64 63 (main "Visit main source"
yuuji@64 64 . (lambda () (interactive) (YaTeX-visit-main)))
yuuji@64 65 (main-other "Visit main source other window"
yuuji@64 66 . YaTeX-visit-main-other-window))))
yuuji@46 67
yuuji@64 68 (defvar YaTeX-mode-menu-map-comment (make-sparse-keymap "comment"))
yuuji@64 69 (YaTeX-define-menu
yuuji@64 70 'YaTeX-mode-menu-map-comment
yuuji@64 71 (nreverse
yuuji@64 72 '((comment "Comment region or environment" . YaTeX-comment-region)
yuuji@64 73 (uncomment "Unomment region or environment" . YaTeX-uncomment-region)
yuuji@64 74 (commentp "Comment paragraph" . YaTeX-comment-paragraph)
yuuji@64 75 (uncommentp "Uncomment paragraph" . YaTeX-uncomment-paragraph))))
yuuji@46 76
yuuji@64 77 (YaTeX-define-menu
yuuji@64 78 'YaTeX-mode-menu-map
yuuji@64 79 (nreverse
yuuji@64 80 (list
yuuji@64 81 ;; Change/Kill/Fill -------------------------------------------------------
yuuji@64 82 (cons (list 'chg "Change") (cons "Change macros" 'YaTeX-change-*))
yuuji@64 83 (cons (list 'kill "Kill") (cons "Kill macros" 'YaTeX-kill-*))
yuuji@64 84 (cons (list 'fill "Fill") (cons "Fill \\item" 'YaTeX-fill-item))
yuuji@64 85 (cons (list 'nl "Newline") (cons "Newline" 'YaTeX-intelligent-newline))
yuuji@64 86 ;; ========================================================================
yuuji@64 87 (cons (list 'sep1 "---") (cons "---" nil))
yuuji@64 88 ;; Comment/Uncomment ------------------------------------------------------
yuuji@64 89 (cons (list 'comment "comment") (cons "Comment region or environment"
yuuji@64 90 'YaTeX-comment-region))
yuuji@64 91 (cons (list 'uncomment "uncomment") (cons "Uncomment region or environment"
yuuji@64 92 'YaTeX-uncomment-region))
yuuji@64 93 (cons (list 'commentp "commentp") (cons "Comment paragraph"
yuuji@64 94 'YaTeX-comment-paragraph))
yuuji@64 95 (cons (list 'uncommentp "uncommentp") (cons "Uncomment paragraph"
yuuji@64 96 'YaTeX-uncomment-paragraph))
yuuji@64 97 ;; ========================================================================
yuuji@64 98 (cons (list 'sep2 "---") (cons "---" nil))
yuuji@64 99 ;; Jump cursor ------------------------------------------------------------
yuuji@64 100 (cons (list 'jump "jump") (cons "Jump Cursor" YaTeX-mode-menu-map-jump))
yuuji@64 101 ;; Document hierarchy ---------------------------------------------------
yuuji@64 102 (cons (list 'hier "hier") (cons "Display Document hierarchy"
yuuji@64 103 'YaTeX-display-hierarchy))
yuuji@64 104 ;; What position ----------------------------------------------------------
yuuji@64 105 (cons (list 'col "column") (cons "What column in tabular"
yuuji@64 106 'YaTeX-what-column))
yuuji@64 107 ;; % menu -----------------------------------------------------------------
yuuji@64 108 (cons (list 'percent "percent") (cons "Edit %# notation"
yuuji@64 109 YaTeX-mode-menu-map-percent))
yuuji@64 110 ;; Switch modes -----------------------------------------------------------
yuuji@64 111 (cons (list 'mode "mode") (cons "Switching YaTeX's modes"
yuuji@64 112 YaTeX-mode-menu-map-modes))
yuuji@64 113 ;; ========================================================================
yuuji@64 114 (cons (list 'sep "---") (cons "---" nil))
yuuji@64 115 ;; Help for LaTeX ---------------------------------------------------------
yuuji@64 116 (cons (list 'ap "apr") (cons "Apropos on LaTeX commands" 'YaTeX-apropos))
yuuji@64 117 (cons (list 'help "help") (cons "Help on LaTeX commands" 'YaTeX-help))
yuuji@64 118 ;; Menu for Typeset relating processes ------------------------------------
yuuji@64 119 (cons (list 'process "Process menu")
yuuji@64 120 (cons "Process" YaTeX-mode-menu-map-process)))
yuuji@64 121 ))
yuuji@46 122
yuuji@64 123 ;; Make section-type commands menu -------------------------------------------
yuuji@64 124 (defvar YaTeX-mode-menu-map-sectionr
yuuji@64 125 (make-sparse-keymap "Enclose region with section-type macro"))
yuuji@64 126 (defvar YaTeX-mode-menu-map-section (make-sparse-keymap "Section-type macro"))
yuuji@46 127 (let ((sorted-section
yuuji@46 128 (sort
yuuji@46 129 (delq nil
yuuji@46 130 (mapcar (function (lambda (s)
yuuji@46 131 (if (> (length (car s)) 5)
yuuji@46 132 (car s))))
yuuji@46 133 (append section-table user-section-table)))
yuuji@46 134 'string<)))
yuuji@64 135 (YaTeX-define-menu
yuuji@64 136 'YaTeX-mode-menu-map-section
yuuji@64 137 (mapcar
yuuji@64 138 (function (lambda (secname)
yuuji@64 139 (cons (intern secname)
yuuji@64 140 (cons secname
yuuji@64 141 (list 'lambda ()
yuuji@64 142 (list 'interactive)
yuuji@64 143 (list 'YaTeX-make-section
yuuji@64 144 nil nil nil
yuuji@64 145 secname))))))
yuuji@64 146 sorted-section))
yuuji@64 147 (YaTeX-define-menu
yuuji@64 148 'YaTeX-mode-menu-map-sectionr
yuuji@64 149 (mapcar
yuuji@64 150 (function (lambda (secname)
yuuji@64 151 (cons (intern secname)
yuuji@64 152 (cons secname
yuuji@64 153 (list 'lambda ()
yuuji@64 154 (list 'interactive)
yuuji@64 155 (list 'YaTeX-make-section
yuuji@64 156 nil
yuuji@64 157 (list 'region-beginning)
yuuji@64 158 (list 'region-end)
yuuji@64 159 secname))))))
yuuji@64 160 sorted-section)))
yuuji@46 161
yuuji@64 162 (YaTeX-define-menu
yuuji@64 163 'YaTeX-mode-menu-map
yuuji@64 164 (nreverse
yuuji@64 165 (list
yuuji@64 166 (cons '(sectionr "Section-type (long name)")
yuuji@64 167 (cons "Section type" YaTeX-mode-menu-map-section))
yuuji@64 168 (cons '(section "Section-type region (long name)")
yuuji@64 169 (cons "Section type region (long name)"
yuuji@64 170 YaTeX-mode-menu-map-sectionr)))))
yuuji@64 171
yuuji@64 172 ;; Make large-type commands menu ---------------------------------------------
yuuji@64 173 (defvar YaTeX-mode-menu-map-envr (make-sparse-keymap "Environment region"))
yuuji@64 174 (defvar YaTeX-mode-menu-map-env (make-sparse-keymap "Environment"))
yuuji@64 175
yuuji@64 176 (let ((sorted-env
yuuji@64 177 (sort
yuuji@64 178 (mapcar (function (lambda (s) (car s)))
yuuji@64 179 (append env-table user-env-table))
yuuji@64 180 'string<)))
yuuji@64 181 (YaTeX-define-menu
yuuji@64 182 'YaTeX-mode-menu-map-env
yuuji@64 183 (mapcar
yuuji@64 184 (function (lambda (envname)
yuuji@64 185 (cons (intern envname)
yuuji@64 186 (cons envname
yuuji@64 187 (list 'lambda ()
yuuji@64 188 (list 'interactive)
yuuji@64 189 (list 'YaTeX-insert-begin-end
yuuji@64 190 envname nil))))))
yuuji@64 191 sorted-env))
yuuji@64 192 (YaTeX-define-menu
yuuji@64 193 'YaTeX-mode-menu-map-envr
yuuji@64 194 (mapcar
yuuji@64 195 (function (lambda (envname)
yuuji@64 196 (cons (intern envname)
yuuji@64 197 (cons envname
yuuji@64 198 (list 'lambda ()
yuuji@64 199 (list 'interactive)
yuuji@64 200 (list 'YaTeX-insert-begin-end
yuuji@64 201 envname t))))))
yuuji@64 202 sorted-env)))
yuuji@64 203 (YaTeX-define-menu
yuuji@64 204 'YaTeX-mode-menu-map
yuuji@64 205 (nreverse
yuuji@64 206 (list
yuuji@64 207 (cons '(envr "Environment")
yuuji@64 208 (cons "Environment" YaTeX-mode-menu-map-env))
yuuji@64 209 (cons '(env "Environment region")
yuuji@64 210 (cons "Environment region"
yuuji@64 211 YaTeX-mode-menu-map-envr)))))
yuuji@64 212
yuuji@64 213 (and (featurep 'xemacs)
yuuji@64 214 (add-hook 'yatex-mode-hook
yuuji@64 215 '(lambda ()
yuuji@64 216 (or (assoc "YaTeX" current-menubar)
yuuji@64 217 (progn
yuuji@64 218 (set-buffer-menubar (copy-sequence current-menubar))
yuuji@64 219 (add-submenu nil YaTeX-mode-menu-map))))))
yuuji@46 220
yuuji@53 221 ;; Other key bindings for window-system
yuuji@53 222 ;(YaTeX-define-key [?\C- ] 'YaTeX-do-completion)
yuuji@53 223 (define-key YaTeX-mode-map [?\M-\C- ] 'YaTeX-mark-environment)
yuuji@53 224
yuuji@46 225 ;; Highlightening
yuuji@53 226 ;; メニューに比べてこっちは結構本気でやってます。
yuuji@53 227 ;; だって文書構造がとっても分かり易いんだもん。
yuuji@53 228 ;; みんなも hilit19.el を使おう!
yuuji@53 229 ;;
yuuji@53 230 ;; さて、まずは対応する {} をピカピカ範囲とするような関数を作る。
yuuji@53 231 ;; これは hilit-LaTeX.el を参考にした。でも、ちゃんと section 型コマンドの
yuuji@53 232 ;; 引数を数えて正しい位置までピカピカさせるよ〜ん!
yuuji@53 233
yuuji@53 234 (defun YaTeX-19-region-section-type (pattern)
yuuji@53 235 "Return list of starting and end point of section-type commands of PATTERN."
yuuji@53 236 (if (re-search-forward pattern nil t)
yuuji@69 237 (let ((m0 (match-beginning 0)) (e0 (match-end 0)) cmd (argc 1))
yuuji@64 238 (setq cmd (substring (YaTeX-match-string 0) 1)
yuuji@53 239 argc (or (car (cdr (YaTeX-lookup-table cmd 'section))) argc))
yuuji@69 240 (if (= argc 0) (cons m0 (point)) ;引数個数0ならマッチした領域
yuuji@69 241 (skip-chars-forward " \n\t*")
yuuji@69 242 (while (looking-at "\\[") (forward-list 1)) ;optionならスキップ
yuuji@69 243 (skip-chars-forward " \n\t")
yuuji@69 244 (if (looking-at "{") ;{}が始まるならちゃんとしたsection型
yuuji@69 245 (cons m0
yuuji@69 246 (progn ;(skip-chars-backward "^{") (forward-char -2)
yuuji@69 247 (while (> argc 0)
yuuji@69 248 (skip-chars-forward "^{")
yuuji@69 249 (forward-list 1)
yuuji@69 250 (setq argc (1- argc)))
yuuji@69 251 (point)))
yuuji@69 252 ;{}でないならたぶん \verb 環境などにあるダミー
yuuji@69 253 (cons m0 e0))))))
yuuji@53 254
yuuji@53 255 (defun YaTeX-19-region-large-type (pattern)
yuuji@53 256 "Return list of large-type contents.
yuuji@53 257 Assumes PATTERN begins with `{'."
yuuji@53 258 (if (re-search-forward pattern nil t)
yuuji@53 259 (let ((m0 (match-beginning 0)))
yuuji@53 260 (goto-char m0)
yuuji@53 261 (skip-chars-forward "^ \t\n")
yuuji@53 262 (skip-chars-forward " \t\n")
yuuji@53 263 (cons (point)
yuuji@53 264 (progn (goto-char m0) (forward-list 1)
yuuji@53 265 (1- (point)))))))
yuuji@53 266
yuuji@53 267 ;; 些細なことだが % の前の文字もピカリとさせてしまうようで… >hilit19
yuuji@53 268 ;; ↓この関数は下の hilit-set-mode-patterns の "[^\\]\\(%\\).*$" に
yuuji@53 269 ;; 依存している
yuuji@53 270 (defun YaTeX-19-region-comment (pattern)
yuuji@53 271 "Return list of comment start and end point."
yuuji@53 272 (if (re-search-forward pattern nil t)
yuuji@56 273 (cons (match-beginning 2) (match-end 0))))
yuuji@56 274
yuuji@56 275 ;;(make-face 'tt)
yuuji@56 276 ;;(set-face-font 'tt "-schumacher-clean-medium-r-normal--*-*-*-*-*-*-*-*")
yuuji@56 277 ;;(hilit-translate 'tt "white")
yuuji@53 278
yuuji@53 279 (defvar YaTeX-hilit-patterns-alist
yuuji@53 280 '(
yuuji@53 281 ;; comments
yuuji@56 282 (YaTeX-19-region-comment "\\([^\\]\\|^\\)\\(%\\).*$" comment)
yuuji@58 283
yuuji@64 284 (YaTeX-19-region-section-type "\\\\footnote\\(mark\\|text\\)?\\>" keyword)
yuuji@53 285 ("\\\\[a-z]+box" 0 keyword)
yuuji@64 286 (YaTeX-19-region-section-type "\\\\\\(v\\|h\\)space\\>" keyword)
yuuji@58 287
yuuji@53 288 ;; (re-)define new commands/environments/counters
yuuji@53 289 (YaTeX-19-region-section-type
yuuji@64 290 "\\\\\\(re\\)?new\\(environment\\|command\\|theorem\\|length\\|counter\\)\\>"
yuuji@60 291 defun)
yuuji@53 292 (YaTeX-19-region-section-type
yuuji@64 293 "\\\\textbf\\>" bold)
yuuji@53 294
yuuji@53 295 ;; various declarations/definitions
yuuji@53 296 (YaTeX-19-region-section-type
yuuji@64 297 "\\\\\\(set\\|setto\\|addto\\)\\(length\\|width\\|counter\\)\\>"
yuuji@53 298 define)
yuuji@53 299 (YaTeX-19-region-section-type
yuuji@64 300 "\\\\\\(title\\|author\\|date\\|thanks\\)\\>" define)
yuuji@53 301
yuuji@59 302 ("\\\\document\\(style\\|class\\)\\(\\[.*\\]\\)?{" "}" decl)
yuuji@53 303 ("\\\\\\(begin\\|end\\|nofiles\\|includeonly\\){" "}" decl)
yuuji@53 304 ("\\\\\\(raggedright\\|makeindex\\|makeglossary\\|maketitle\\)\\b" 0 decl)
yuuji@53 305 ("\\\\\\(pagestyle\\|thispagestyle\\|pagenumbering\\){" "}" decl)
yuuji@53 306 ("\\\\\\(normalsize\\|small\\|footnotesize\\|scriptsize\\|tiny\\|large\\|Large\\|LARGE\\|huge\\|Huge\\)\\b" 0 decl)
yuuji@53 307 ("\\\\\\(appendix\\|tableofcontents\\|listoffigures\\|listoftables\\)\\b"
yuuji@53 308 0 decl)
yuuji@53 309 ("\\\\\\(bf\\|em\\|it\\|rm\\|sf\\|sl\\|ss\\|tt\\)\\b" 0 decl)
yuuji@53 310
yuuji@53 311 ;; label-like things
yuuji@53 312 ;;this should be customized by YaTeX-item-regexp
yuuji@53 313 ("\\\\\\(sub\\)*item\\b\\(\\[[^]]*\\]\\)?" 0 label)
yuuji@53 314 (YaTeX-19-region-section-type
yuuji@64 315 "\\\\caption\\(\\[[^]]*\\]\\)?\\>" label)
yuuji@53 316
yuuji@61 317 ;; things that do some sort of cross-reference
yuuji@61 318 (YaTeX-19-region-section-type
yuuji@64 319 "\\\\\\(\\(no\\)?cite\\|\\(page\\)?ref\\|label\\|index\\|glossary\\)\\>"
yuuji@61 320 crossref)
yuuji@61 321
yuuji@61 322 ;; things that bring in external files
yuuji@61 323 ("\\\\\\(include\\|input\\|bibliography\\){" "}" include)
yuuji@61 324
yuuji@53 325 ;; formulas
yuuji@53 326 ("[^\\]\\\\(" "\\\\)" formula) ; \( \)
yuuji@53 327 ("[^\\]\\\\\\[" "\\\\\\]" formula) ; \[ \]
yuuji@68 328 ("\\\\begin{\\(eqn\\|equation\\|x?x?align\\|split\\|multline\\|gather\\)"
yuuji@68 329 "\\\\end{\\(eqn\\|equation\\|x?x?align\\|split\\|multline\\|gather\\).*}"
yuuji@58 330 formula)
yuuji@58 331 ("[^\\$]\\($\\($[^$]*\\$\\|[^$]*\\)\\$\\)" 1 formula); '$...$' or '$$...$$'
yuuji@53 332
yuuji@61 333 ;; "wysiwyg" emphasis -- these don't work on nested expressions
yuuji@56 334 (YaTeX-19-region-large-type "{\\\\\\(em\\|it\\|sl\\)" italic)
yuuji@53 335 (YaTeX-19-region-large-type "{\\\\bf" bold)
yuuji@56 336 ;;;(YaTeX-19-region-large-type "{\\\\tt" tt)
yuuji@56 337 ;;;("\\\\begin{verbatim" "\\\\end{verbatim" tt)
yuuji@53 338
yuuji@61 339 ("``" "''" string))
yuuji@58 340 "*Hiliting pattern alist for LaTeX text.")
yuuji@53 341
yuuji@53 342 ;;(defvar YaTeX-hilit-pattern-adjustment-default nil)
yuuji@53 343 ;; ↑いらなくなった。
yuuji@51 344 (defvar YaTeX-hilit-pattern-adjustment-private nil
yuuji@53 345 "*Adjustment hilit-pattern-alist for default yatex-mode's pattern.")
yuuji@46 346 (defvar YaTeX-hilit-sectioning-face
yuuji@57 347 '(yellow/dodgerblue yellow/slateblue)
yuuji@51 348 "*Hilightening face for sectioning unit. '(FaceForLight FaceForDark)")
yuuji@57 349 (defvar YaTeX-hilit-sectioning-attenuation-rate
yuuji@57 350 '(15 40)
yuuji@57 351 "*Maximum attenuation rate of sectioning face. '(ForeRate BackRate)
yuuji@57 352 Each rate specifies how much portion of RGB value should be attenuated
yuuji@57 353 towards to lowest sectioning unit. Numbers should be written in percentage.")
yuuji@52 354 (defvar YaTeX-sectioning-patterns-alist nil
yuuji@52 355 "Hilightening patterns for sectioning units.")
yuuji@47 356 (defvar YaTeX-hilit-singlecmd-face
yuuji@51 357 '(slateblue2 aquamarine)
yuuji@51 358 "*Hilightening face for maketitle type. '(FaceForLight FaceForDark)")
yuuji@52 359
yuuji@52 360 ;;; セクションコマンドを、構造レベルの高さに応じて色の濃度を変える
yuuji@52 361 ;;; 背景が黒でないと何が嬉しいのか分からないに違いない.
yuuji@53 362 ;;; もしかして白地の時は構造レベルに応じて色を明るくしたほうが良いのか?
yuuji@60 363 ;(if (fboundp 'win32-color-values)
yuuji@60 364 ; (fset 'x-color-values 'win32-color-values))
yuuji@60 365
yuuji@53 366 (cond
yuuji@70 367 (YaTeX-use-hilit19
yuuji@53 368 (let*((sectface
yuuji@53 369 (car (if (eq hilit-background-mode 'dark)
yuuji@53 370 (cdr YaTeX-hilit-sectioning-face)
yuuji@53 371 YaTeX-hilit-sectioning-face)))
yuuji@53 372 (sectcol (symbol-name sectface))
yuuji@53 373 sect-pat-alist)
yuuji@53 374 (if (string-match "/" sectcol)
yuuji@57 375 (let ((fmin (nth 0 YaTeX-hilit-sectioning-attenuation-rate))
yuuji@57 376 (bmin (nth 1 YaTeX-hilit-sectioning-attenuation-rate))
yuuji@57 377 colorvalue fR fG fB bR bG bB pat fg bg level from face list lm)
yuuji@53 378 (require 'yatexsec)
yuuji@53 379 (setq fg (substring sectcol 0 (string-match "/" sectcol))
yuuji@53 380 bg (substring sectcol (1+ (string-match "/" sectcol)))
yuuji@53 381 colorvalue (x-color-values fg)
yuuji@53 382 fR (/ (nth 0 colorvalue) 256)
yuuji@53 383 fG (/ (nth 1 colorvalue) 256)
yuuji@53 384 fB (/ (nth 2 colorvalue) 256)
yuuji@53 385 colorvalue (x-color-values bg)
yuuji@53 386 bR (/ (nth 0 colorvalue) 256)
yuuji@53 387 bG (/ (nth 1 colorvalue) 256)
yuuji@53 388 bB (/ (nth 2 colorvalue) 256)
yuuji@57 389 lm YaTeX-sectioning-max-level
yuuji@53 390 list YaTeX-sectioning-level)
yuuji@53 391 (while list
yuuji@59 392 (setq pat (concat YaTeX-ec-regexp (car (car list))
yuuji@69 393 ;"\\*?\\(\\[[^]]*\\]\\)?\\>" ;改行はさむと駄目
yuuji@64 394 "\\>"
yuuji@64 395 )
yuuji@53 396 level (cdr (car list))
yuuji@53 397 fg (format "hex-%02x%02x%02x"
yuuji@57 398 (- fR (/ (* level fR fmin) lm 100))
yuuji@57 399 (- fG (/ (* level fG fmin) lm 100))
yuuji@57 400 (- fB (/ (* level fB fmin) lm 100)))
yuuji@53 401 bg (format "hex-%02x%02x%02x"
yuuji@57 402 (- bR (/ (* level bR bmin) lm 100))
yuuji@57 403 (- bG (/ (* level bG bmin) lm 100))
yuuji@57 404 (- bB (/ (* level bB bmin) lm 100)))
yuuji@53 405 from (intern (format "sectioning-%d" level))
yuuji@53 406 face (intern (concat fg "/" bg)))
yuuji@53 407 (hilit-translate from face)
yuuji@53 408 (setq sect-pat-alist
yuuji@53 409 (cons;;(list pat "}" face)
yuuji@53 410 (list 'YaTeX-19-region-section-type pat face)
yuuji@53 411 sect-pat-alist))
yuuji@53 412 (setq list (cdr list)))
yuuji@53 413 (setq YaTeX-sectioning-patterns-alist sect-pat-alist))))))
yuuji@52 414
yuuji@53 415 ;; ローカルなマクロを読み込んだ後 redraw すると
yuuji@53 416 ;; ローカルマクロを keyword として光らせる(keywordじゃまずいかな…)。
yuuji@53 417 (defun YaTeX-19-collect-macros ()
yuuji@46 418 (cond
yuuji@70 419 (YaTeX-use-hilit19
yuuji@47 420 (let ((get-face
yuuji@47 421 (function
yuuji@47 422 (lambda (table)
yuuji@47 423 (cond
yuuji@47 424 ((eq hilit-background-mode 'light) (car table))
yuuji@47 425 ((eq hilit-background-mode 'dark) (car (cdr table)))
yuuji@57 426 (t nil)))))
yuuji@57 427 sect single)
yuuji@47 428 (hilit-translate
yuuji@52 429 ;;sectioning (funcall get-face YaTeX-hilit-sectioning-face)
yuuji@57 430 macro (funcall get-face YaTeX-hilit-singlecmd-face))
yuuji@57 431 (if (setq sect (append user-section-table tmp-section-table))
yuuji@57 432 (setq sect (concat "\\\\\\("
yuuji@57 433 (mapconcat
yuuji@57 434 (function
yuuji@57 435 (lambda (s) (regexp-quote (car s))))
yuuji@57 436 sect
yuuji@57 437 "\\|")
yuuji@64 438 "\\)\\>")))
yuuji@57 439 (if (setq single (append user-singlecmd-table tmp-singlecmd-table))
yuuji@57 440 (setq single (concat "\\\\\\("
yuuji@57 441 (mapconcat
yuuji@57 442 (function (lambda (s) (regexp-quote (car s))))
yuuji@57 443 single
yuuji@57 444 "\\|")
yuuji@57 445 "\\)\\b")))
yuuji@57 446 (setq hilit-patterns-alist ;Remove at first.
yuuji@57 447 (delq (assq 'yatex-mode hilit-patterns-alist) hilit-patterns-alist)
yuuji@57 448 hilit-patterns-alist
yuuji@57 449 (cons
yuuji@57 450 (cons 'yatex-mode
yuuji@57 451 (append
yuuji@57 452 (list nil)
yuuji@57 453 YaTeX-sectioning-patterns-alist
yuuji@57 454 YaTeX-hilit-pattern-adjustment-private
yuuji@57 455 ;;YaTeX-hilit-pattern-adjustment-default
yuuji@57 456 YaTeX-hilit-patterns-alist
yuuji@57 457 (delq nil
yuuji@57 458 (list
yuuji@57 459 (if sect (list
yuuji@57 460 'YaTeX-19-region-section-type
yuuji@57 461 sect
yuuji@57 462 'keyword))
yuuji@57 463 (if single (list single 0 'macro))))))
yuuji@57 464 hilit-patterns-alist))))))
yuuji@53 465 ;;(YaTeX-19-collect-macros) ;causes an error
yuuji@46 466 (defun YaTeX-hilit-recenter (arg)
yuuji@46 467 "Collect current local macro and hilit-recenter."
yuuji@46 468 (interactive "P")
yuuji@53 469 (YaTeX-19-collect-macros)
yuuji@46 470 (hilit-recenter arg))
yuuji@46 471 (if (fboundp 'hilit-recenter) ;Replace hilit-recenter with
yuuji@46 472 (mapcar (function (lambda (key) ;YaTeX-hilit-recenter in yatex-mode
yuuji@46 473 (define-key YaTeX-mode-map key 'YaTeX-hilit-recenter)))
yuuji@46 474 (where-is-internal 'hilit-recenter)))
yuuji@46 475
yuuji@53 476 (defun YaTeX-switch-to-new-window ()
yuuji@53 477 (let ((c 0) (i 1) (free (make-string win:max-configs ? )))
yuuji@53 478 (while (< i win:max-configs)
yuuji@53 479 (or (aref win:configs i) (aset free i (+ i win:base-key)))
yuuji@53 480 (setq i (1+ i)))
yuuji@53 481 (while (not (string-match (char-to-string c) free))
yuuji@53 482 (message "Which window to create? [%s]: " free)
yuuji@53 483 (setq c (read-char)))
yuuji@53 484 (message "Creating window [%c]" c)
yuuji@53 485 (set-buffer (get-buffer-create "*scratch*"))
yuuji@53 486 (win:switch-window (- c win:base-key))))
yuuji@53 487
yuuji@53 488 (defun YaTeX-visit-main-other-frame ()
yuuji@53 489 "Visit main file in other frame.
yuuji@53 490 WARNING, This code is not perfect."
yuuji@53 491 (interactive)
yuuji@53 492 (if (YaTeX-main-file-p) (message "I think this is main LaTeX source.")
yuuji@53 493 (let (parent)
yuuji@53 494 (save-excursion (YaTeX-visit-main t) (setq parent (current-buffer)))
yuuji@53 495 (cond
yuuji@53 496 ((get-buffer-window parent t)
yuuji@53 497 (goto-buffer-window parent))
yuuji@53 498 ((and (featurep 'windows) win:use-frame)
yuuji@53 499 (YaTeX-switch-to-new-window)
yuuji@53 500 (switch-to-buffer parent))
yuuji@53 501 (t (switch-to-buffer-other-frame (buffer-name parent)))))))
yuuji@53 502
yuuji@53 503 (defun YaTeX-goto-corresponding-*-other-frame (arg)
yuuji@53 504 "Go to corresponding object in other frame."
yuuji@53 505 (interactive "P")
yuuji@53 506 (let (b p)
yuuji@53 507 (save-window-excursion
yuuji@53 508 (save-excursion
yuuji@53 509 (YaTeX-goto-corresponding-* arg)
yuuji@53 510 (setq b (current-buffer) p (point))))
yuuji@53 511 (cond
yuuji@53 512 ((get-buffer-window b t)
yuuji@53 513 (goto-buffer-window b)
yuuji@53 514 (goto-char p))
yuuji@53 515 ((and (featurep 'windows) win:use-frame)
yuuji@53 516 (YaTeX-switch-to-new-window)
yuuji@53 517 (switch-to-buffer b)
yuuji@53 518 (goto-char p))
yuuji@53 519 (t (switch-to-buffer-other-frame (buffer-name b))
yuuji@53 520 (goto-char p))))
yuuji@53 521 )
yuuji@53 522
yuuji@49 523 ;;; reverseVideo にして hilit-background-mode を 'dark
yuuji@49 524 ;;; にしている人は数式などが暗くなりすぎて見づらいかもしれない。
yuuji@49 525 ;;; 次のコードを hilit19 をロードしている場所の直後に置くとちょっ
yuuji@49 526 ;;; とはまし。
yuuji@46 527 ;;; (if (eq hilit-background-mode 'dark)
yuuji@46 528 ;;; (hilit-translate
yuuji@46 529 ;;; string 'mediumspringgreen
yuuji@46 530 ;;; formula 'khaki
yuuji@46 531 ;;; label 'yellow-underlined))
yuuji@57 532 (and YaTeX-emacs-19
yuuji@64 533 (not (featurep 'xemacs))
yuuji@58 534 (boundp 'byte-compile-current-file)
yuuji@58 535 (if (and (boundp 'window-system) window-system)
yuuji@58 536 (require 'hilit19)
yuuji@58 537 (error "Byte compile this file on window system! Not `-nw'!")))
yuuji@46 538
yuuji@46 539 (provide 'yatex19)