yatex

annotate yatex19.el @ 582:f4c2dca86202

Add "mcfamily" and "gtfamily"
author HIROSE Yuuji <yuuji@gentei.org>
date Sat, 08 Feb 2020 18:31:52 +0900
parents 723f136edde5
children
rev   line source
yuuji@395 1 ;;; yatex19.el -- YaTeX facilities for Emacs 19 or later -*- coding: sjis -*-
yuuji@443 2 ;;; (c)1994-2017 by HIROSE Yuuji.[yuuji@yatex.org]
yuuji@497 3 ;;; Last modified Sun Sep 17 10:22:54 2017 on firestorm
yuuji@366 4 ;;; $Id$
yuuji@46 5
yuuji@287 6 ;;; Code:
yuuji@64 7 ;(require 'yatex)
yuuji@47 8
yuuji@73 9 (and (boundp 'YaTeX-use-hilit19)
yuuji@73 10 YaTeX-use-hilit19
yuuji@73 11 (require 'hilit19))
yuuji@72 12
yuuji@72 13 (defvar YaTeX-use-highlighting (or YaTeX-use-font-lock YaTeX-use-hilit19)
yuuji@72 14 "*Use highlighting buffer or not.")
yuuji@72 15 (defvar YaTeX-background-mode
yuuji@80 16 (or (if (fboundp 'get-frame-background-mode)
yuuji@80 17 (get-frame-background-mode (selected-frame)))
yuuji@398 18 (if (boundp 'frame-background-mode)
yuuji@398 19 frame-background-mode)
yuuji@80 20 (if (fboundp 'frame-parameters)
yuuji@80 21 (cdr (assq 'background-mode (frame-parameters))))
yuuji@80 22 (if (boundp 'hilit-background-mode)
yuuji@80 23 hilit-background-mode)
yuuji@80 24 (if (face-background 'default)
yuuji@80 25 (if (> (+ 32768 32768 32768)
yuuji@80 26 (apply '+
yuuji@80 27 (funcall (if (fboundp 'color-rgb-components)
yuuji@80 28 'color-rgb-components
yuuji@80 29 'x-color-values)
yuuji@80 30 (face-background 'default))))
yuuji@80 31 'dark
yuuji@80 32 'light))))
yuuji@70 33
yuuji@64 34 (defvar YaTeX-mode-menu-map (make-sparse-keymap "YaTeX"))
yuuji@64 35 (defvar YaTeX-mode-menu-map-process (make-sparse-keymap "Process"))
yuuji@64 36 (define-key YaTeX-mode-map [menu-bar yatex]
yuuji@64 37 (cons "YaTeX" YaTeX-mode-menu-map))
yuuji@64 38 (YaTeX-define-menu
yuuji@64 39 'YaTeX-mode-menu-map-process
yuuji@64 40 (nreverse
yuuji@64 41 '((buffer "LaTeX" . (lambda () (interactive) (YaTeX-typeset-menu nil ?j)))
yuuji@214 42 (pdf "LaTeX+PDF" . (lambda () (interactive) (YaTeX-typeset-menu nil ?d)))
yuuji@64 43 (kill "Kill LaTeX" . (lambda () (interactive) (YaTeX-typeset-menu nil ?k)))
yuuji@64 44 (bibtex "BibTeX" . (lambda () (interactive) (YaTeX-typeset-menu nil ?b)))
yuuji@64 45 (mindex "makeindex" . (lambda () (interactive) (YaTeX-typeset-menu nil ?i)))
yuuji@64 46 (preview "Preview" . (lambda () (interactive) (YaTeX-typeset-menu nil ?p)))
yuuji@64 47 (lpr "lpr" . (lambda () (interactive) (YaTeX-typeset-menu nil ?l)))
yuuji@64 48 (lpq "lpq" . (lambda () (interactive) (YaTeX-typeset-menu nil ?q))))))
yuuji@64 49 (defvar YaTeX-mode-menu-map-modes (make-sparse-keymap "Modes"))
yuuji@64 50 (YaTeX-define-menu
yuuji@64 51 'YaTeX-mode-menu-map-modes
yuuji@64 52 (delq nil
yuuji@64 53 (nreverse
yuuji@64 54 (list
yuuji@64 55 (if YaTeX-auto-math-mode nil
yuuji@64 56 (cons 'math (cons "Toggle math-mode"
yuuji@353 57 (function(lambda () (interactive)
yuuji@353 58 (YaTeX-switch-mode-menu nil ?t))))))
yuuji@64 59 (cons 'mod (cons "Toggle Modify Mode"
yuuji@353 60 (function(lambda () (interactive)
yuuji@353 61 (YaTeX-switch-mode-menu nil ?m)))))))))
yuuji@64 62 (defvar YaTeX-mode-menu-map-percent (make-sparse-keymap "percent"))
yuuji@64 63 (YaTeX-define-menu
yuuji@64 64 'YaTeX-mode-menu-map-percent
yuuji@64 65 (nreverse
yuuji@64 66 '((! "Change LaTeX typesetter(%#!)"
yuuji@64 67 . (lambda () (interactive) (YaTeX-%-menu nil nil ?!)))
yuuji@64 68 (begend "Set %#BEGIN-%#END on region"
yuuji@64 69 . (lambda () (interactive) (YaTeX-%-menu nil nil ?b)))
yuuji@64 70 (lpr "Change LPR format"
yuuji@64 71 . (lambda () (interactive) (YaTeX-%-menu nil nil ?l))))))
yuuji@46 72
yuuji@64 73 (defvar YaTeX-mode-menu-map-jump (make-sparse-keymap "jump"))
yuuji@64 74 (YaTeX-define-menu
yuuji@64 75 'YaTeX-mode-menu-map-jump
yuuji@64 76 (nreverse
yuuji@64 77 '((corres "Goto corersponding position" . YaTeX-goto-corresponding-*)
yuuji@64 78 (main "Visit main source"
yuuji@64 79 . (lambda () (interactive) (YaTeX-visit-main)))
yuuji@64 80 (main-other "Visit main source other window"
yuuji@64 81 . YaTeX-visit-main-other-window))))
yuuji@46 82
yuuji@64 83 (defvar YaTeX-mode-menu-map-comment (make-sparse-keymap "comment"))
yuuji@64 84 (YaTeX-define-menu
yuuji@64 85 'YaTeX-mode-menu-map-comment
yuuji@64 86 (nreverse
yuuji@64 87 '((comment "Comment region or environment" . YaTeX-comment-region)
yuuji@64 88 (uncomment "Unomment region or environment" . YaTeX-uncomment-region)
yuuji@64 89 (commentp "Comment paragraph" . YaTeX-comment-paragraph)
yuuji@64 90 (uncommentp "Uncomment paragraph" . YaTeX-uncomment-paragraph))))
yuuji@46 91
yuuji@64 92 (YaTeX-define-menu
yuuji@64 93 'YaTeX-mode-menu-map
yuuji@64 94 (nreverse
yuuji@64 95 (list
yuuji@64 96 ;; Change/Kill/Fill -------------------------------------------------------
yuuji@64 97 (cons (list 'chg "Change") (cons "Change macros" 'YaTeX-change-*))
yuuji@64 98 (cons (list 'kill "Kill") (cons "Kill macros" 'YaTeX-kill-*))
yuuji@64 99 (cons (list 'fill "Fill") (cons "Fill \\item" 'YaTeX-fill-item))
yuuji@64 100 (cons (list 'nl "Newline") (cons "Newline" 'YaTeX-intelligent-newline))
yuuji@64 101 ;; ========================================================================
yuuji@64 102 (cons (list 'sep1 "---") (cons "---" nil))
yuuji@64 103 ;; Comment/Uncomment ------------------------------------------------------
yuuji@64 104 (cons (list 'comment "comment") (cons "Comment region or environment"
yuuji@64 105 'YaTeX-comment-region))
yuuji@64 106 (cons (list 'uncomment "uncomment") (cons "Uncomment region or environment"
yuuji@64 107 'YaTeX-uncomment-region))
yuuji@64 108 (cons (list 'commentp "commentp") (cons "Comment paragraph"
yuuji@64 109 'YaTeX-comment-paragraph))
yuuji@64 110 (cons (list 'uncommentp "uncommentp") (cons "Uncomment paragraph"
yuuji@64 111 'YaTeX-uncomment-paragraph))
yuuji@64 112 ;; ========================================================================
yuuji@64 113 (cons (list 'sep2 "---") (cons "---" nil))
yuuji@64 114 ;; Jump cursor ------------------------------------------------------------
yuuji@64 115 (cons (list 'jump "jump") (cons "Jump Cursor" YaTeX-mode-menu-map-jump))
yuuji@64 116 ;; Document hierarchy ---------------------------------------------------
yuuji@64 117 (cons (list 'hier "hier") (cons "Display Document hierarchy"
yuuji@64 118 'YaTeX-display-hierarchy))
yuuji@64 119 ;; What position ----------------------------------------------------------
yuuji@64 120 (cons (list 'col "column") (cons "What column in tabular"
yuuji@64 121 'YaTeX-what-column))
yuuji@64 122 ;; % menu -----------------------------------------------------------------
yuuji@64 123 (cons (list 'percent "percent") (cons "Edit %# notation"
yuuji@64 124 YaTeX-mode-menu-map-percent))
yuuji@64 125 ;; Switch modes -----------------------------------------------------------
yuuji@64 126 (cons (list 'mode "mode") (cons "Switching YaTeX's modes"
yuuji@64 127 YaTeX-mode-menu-map-modes))
yuuji@64 128 ;; ========================================================================
yuuji@64 129 (cons (list 'sep "---") (cons "---" nil))
yuuji@64 130 ;; Help for LaTeX ---------------------------------------------------------
yuuji@64 131 (cons (list 'ap "apr") (cons "Apropos on LaTeX commands" 'YaTeX-apropos))
yuuji@64 132 (cons (list 'help "help") (cons "Help on LaTeX commands" 'YaTeX-help))
yuuji@64 133 ;; Menu for Typeset relating processes ------------------------------------
yuuji@64 134 (cons (list 'process "Process menu")
yuuji@64 135 (cons "Process" YaTeX-mode-menu-map-process)))
yuuji@64 136 ))
yuuji@46 137
yuuji@64 138 ;; Make section-type commands menu -------------------------------------------
yuuji@64 139 (defvar YaTeX-mode-menu-map-sectionr
yuuji@64 140 (make-sparse-keymap "Enclose region with section-type macro"))
yuuji@64 141 (defvar YaTeX-mode-menu-map-section (make-sparse-keymap "Section-type macro"))
yuuji@46 142 (let ((sorted-section
yuuji@46 143 (sort
yuuji@46 144 (delq nil
yuuji@46 145 (mapcar (function (lambda (s)
yuuji@46 146 (if (> (length (car s)) 5)
yuuji@46 147 (car s))))
yuuji@46 148 (append section-table user-section-table)))
yuuji@46 149 'string<)))
yuuji@64 150 (YaTeX-define-menu
yuuji@64 151 'YaTeX-mode-menu-map-section
yuuji@64 152 (mapcar
yuuji@64 153 (function (lambda (secname)
yuuji@64 154 (cons (intern secname)
yuuji@64 155 (cons secname
yuuji@64 156 (list 'lambda ()
yuuji@64 157 (list 'interactive)
yuuji@64 158 (list 'YaTeX-make-section
yuuji@64 159 nil nil nil
yuuji@64 160 secname))))))
yuuji@64 161 sorted-section))
yuuji@64 162 (YaTeX-define-menu
yuuji@64 163 'YaTeX-mode-menu-map-sectionr
yuuji@64 164 (mapcar
yuuji@64 165 (function (lambda (secname)
yuuji@64 166 (cons (intern secname)
yuuji@64 167 (cons secname
yuuji@64 168 (list 'lambda ()
yuuji@64 169 (list 'interactive)
yuuji@64 170 (list 'YaTeX-make-section
yuuji@64 171 nil
yuuji@64 172 (list 'region-beginning)
yuuji@64 173 (list 'region-end)
yuuji@64 174 secname))))))
yuuji@64 175 sorted-section)))
yuuji@46 176
yuuji@64 177 (YaTeX-define-menu
yuuji@64 178 'YaTeX-mode-menu-map
yuuji@64 179 (nreverse
yuuji@64 180 (list
yuuji@64 181 (cons '(sectionr "Section-type (long name)")
yuuji@64 182 (cons "Section type" YaTeX-mode-menu-map-section))
yuuji@64 183 (cons '(section "Section-type region (long name)")
yuuji@64 184 (cons "Section type region (long name)"
yuuji@64 185 YaTeX-mode-menu-map-sectionr)))))
yuuji@64 186
yuuji@64 187 ;; Make large-type commands menu ---------------------------------------------
yuuji@64 188 (defvar YaTeX-mode-menu-map-envr (make-sparse-keymap "Environment region"))
yuuji@64 189 (defvar YaTeX-mode-menu-map-env (make-sparse-keymap "Environment"))
yuuji@64 190
yuuji@64 191 (let ((sorted-env
yuuji@64 192 (sort
yuuji@64 193 (mapcar (function (lambda (s) (car s)))
yuuji@64 194 (append env-table user-env-table))
yuuji@64 195 'string<)))
yuuji@64 196 (YaTeX-define-menu
yuuji@64 197 'YaTeX-mode-menu-map-env
yuuji@64 198 (mapcar
yuuji@64 199 (function (lambda (envname)
yuuji@64 200 (cons (intern envname)
yuuji@64 201 (cons envname
yuuji@64 202 (list 'lambda ()
yuuji@64 203 (list 'interactive)
yuuji@64 204 (list 'YaTeX-insert-begin-end
yuuji@64 205 envname nil))))))
yuuji@64 206 sorted-env))
yuuji@64 207 (YaTeX-define-menu
yuuji@64 208 'YaTeX-mode-menu-map-envr
yuuji@64 209 (mapcar
yuuji@64 210 (function (lambda (envname)
yuuji@64 211 (cons (intern envname)
yuuji@64 212 (cons envname
yuuji@64 213 (list 'lambda ()
yuuji@64 214 (list 'interactive)
yuuji@64 215 (list 'YaTeX-insert-begin-end
yuuji@64 216 envname t))))))
yuuji@64 217 sorted-env)))
yuuji@64 218 (YaTeX-define-menu
yuuji@64 219 'YaTeX-mode-menu-map
yuuji@64 220 (nreverse
yuuji@64 221 (list
yuuji@64 222 (cons '(envr "Environment")
yuuji@64 223 (cons "Environment" YaTeX-mode-menu-map-env))
yuuji@64 224 (cons '(env "Environment region")
yuuji@64 225 (cons "Environment region"
yuuji@64 226 YaTeX-mode-menu-map-envr)))))
yuuji@64 227
yuuji@64 228 (and (featurep 'xemacs)
yuuji@64 229 (add-hook 'yatex-mode-hook
yuuji@353 230 (function
yuuji@353 231 (lambda ()
yuuji@64 232 (or (assoc "YaTeX" current-menubar)
yuuji@64 233 (progn
yuuji@64 234 (set-buffer-menubar (copy-sequence current-menubar))
yuuji@353 235 (add-submenu nil YaTeX-mode-menu-map)))))))
yuuji@46 236
yuuji@53 237 ;; Other key bindings for window-system
yuuji@53 238 ;(YaTeX-define-key [?\C- ] 'YaTeX-do-completion)
yuuji@53 239 (define-key YaTeX-mode-map [?\M-\C- ] 'YaTeX-mark-environment)
yuuji@53 240
yuuji@46 241 ;; Highlightening
yuuji@53 242 ;; メニューに比べてこっちは結構本気でやってます。
yuuji@53 243 ;; だって文書構造がとっても分かり易いんだもん。
yuuji@53 244 ;; みんなも hilit19.el を使おう!
yuuji@72 245 ;; とかいってるうちに hilit19 って obsolete になってしまった…
yuuji@72 246 ;; …ということで、hilit19 用のパターンを font-lock に変換する関数を
yuuji@72 247 ;; 作成してなんとか font-lock にも対応(2000年12月)。
yuuji@72 248 ;; しかし、font-lock は仕様が変わりやすい雰囲気でずっと動き続けるか
yuuji@72 249 ;; どうかは不明。むしろ進化の止まったhilit19を使い続ける方が安心と
yuuji@72 250 ;; 言えないこともないが世の流れは読めず……。
yuuji@53 251 ;;
yuuji@53 252 ;; さて、まずは対応する {} をピカピカ範囲とするような関数を作る。
yuuji@53 253 ;; これは hilit-LaTeX.el を参考にした。でも、ちゃんと section 型コマンドの
yuuji@53 254 ;; 引数を数えて正しい位置までピカピカさせるよ〜ん!
yuuji@53 255
yuuji@53 256 (defun YaTeX-19-region-section-type (pattern)
yuuji@80 257 "Return cons of starting and end point of section-type commands of PATTERN."
yuuji@53 258 (if (re-search-forward pattern nil t)
yuuji@69 259 (let ((m0 (match-beginning 0)) (e0 (match-end 0)) cmd (argc 1))
yuuji@64 260 (setq cmd (substring (YaTeX-match-string 0) 1)
yuuji@53 261 argc (or (car (cdr (YaTeX-lookup-table cmd 'section))) argc))
yuuji@69 262 (if (= argc 0) (cons m0 (point)) ;引数個数0ならマッチした領域
yuuji@69 263 (skip-chars-forward " \n\t*")
yuuji@69 264 (while (looking-at "\\[") (forward-list 1)) ;optionならスキップ
yuuji@69 265 (skip-chars-forward " \n\t")
yuuji@72 266 (prog1
yuuji@72 267 (if (looking-at "{") ;{}が始まるならちゃんとしたsection型
yuuji@72 268 (cons m0
yuuji@72 269 (condition-case err
yuuji@72 270 (progn
yuuji@72 271 ;;(skip-chars-backward "^{") (forward-char -2)
yuuji@72 272 (while (> argc 0)
yuuji@72 273 (skip-chars-forward "^{")
yuuji@72 274 (forward-list 1)
yuuji@72 275 (setq argc (1- argc)))
yuuji@72 276 (point))
yuuji@72 277 (error m0)))
yuuji@72 278 ;{}でないならたぶん \verb 環境などにあるダミー
yuuji@72 279 (cons m0 e0))
yuuji@72 280 ;;move to re-search end not to make font-lock confused
yuuji@72 281 (goto-char e0))))))
yuuji@53 282
yuuji@53 283 (defun YaTeX-19-region-large-type (pattern)
yuuji@80 284 "Return cons of large-type contents.
yuuji@53 285 Assumes PATTERN begins with `{'."
yuuji@53 286 (if (re-search-forward pattern nil t)
yuuji@72 287 (let ((m0 (match-beginning 0)) (e0 (match-end 0))p)
yuuji@53 288 (goto-char m0)
yuuji@53 289 (skip-chars-forward "^ \t\n")
yuuji@53 290 (skip-chars-forward " \t\n")
yuuji@72 291 (prog1
yuuji@72 292 (cons (setq p (point))
yuuji@72 293 (condition-case err
yuuji@72 294 (progn (goto-char m0) (forward-list 1) (1- (point)))
yuuji@72 295 (error (1+ p))))
yuuji@72 296 ;;move to re-search end not to make font-lock confused
yuuji@72 297 (goto-char e0)))))
yuuji@53 298
yuuji@80 299 (defun YaTeX-19-region-env-type (envptn)
yuuji@80 300 "Return cons of environment contents specified by ENVPTN as regexp."
yuuji@80 301 (if (and (looking-at envptn) ;;re-search-forward envptn nil t)
yuuji@80 302 (save-excursion
yuuji@80 303 (not(search-backward YaTeX-comment-prefix
yuuji@80 304 (point-beginning-of-line) t))))
yuuji@80 305 (let ((m0 (match-beginning 0)) (e0 (match-end 0))
yuuji@80 306 (env (YaTeX-match-string 1))
yuuji@80 307 (nextline (progn (forward-line 1) (point))))
yuuji@80 308 (goto-char m0)
yuuji@80 309 ;(message "max=%d" (point-max))(sit-for 2)
yuuji@80 310 (condition-case err
yuuji@80 311 (if (YaTeX-goto-corresponding-environment)
yuuji@80 312 (prog1
yuuji@80 313 (cons nextline (match-beginning 0))
yuuji@80 314 (goto-char e0)))
yuuji@80 315 (error nil)))))
yuuji@80 316
yuuji@80 317 (defun YaTeX-19-region-paren-math (ptn)
yuuji@80 318 "Return cons of \(...\) or \[...\] type math environment."
yuuji@80 319 (if (looking-at "\\\\\\([\[(]\\)")
yuuji@80 320 (let*((ptype (cdr (assoc (YaTeX-match-string 1)
yuuji@80 321 '(("(" . ")") ("[" "]")))))
yuuji@80 322 (b (match-beginning 0))
yuuji@80 323 (e (match-end 0)))
yuuji@80 324 (condition-case err
yuuji@80 325 (if (re-search-forward
yuuji@80 326 (concat "[^\\]\\\\" (regexp-quote ptype))
yuuji@80 327 nil t)
yuuji@80 328 (prog1 (cons b (match-beginning 0))
yuuji@80 329 (goto-char e)))
yuuji@80 330 (error nil)))))
yuuji@80 331
yuuji@80 332 (defun YaTeX-19-region-math-sub (ptn)
yuuji@80 333 "Return cons of _{...}"
yuuji@80 334 (if (and (looking-at ptn)
yuuji@80 335 (eq YaTeX-font-lock-formula-face
yuuji@80 336 (get-text-property (point) 'face)))
yuuji@80 337 (let ((e (match-end 0)) (p (point)))
yuuji@80 338 (goto-char e)
yuuji@80 339 (prog1
yuuji@80 340 (condition-case ()
yuuji@80 341 (if (looking-at "{")
yuuji@80 342 (cons (1+ (point))
yuuji@80 343 (progn (forward-list 1) (1- (point))))
yuuji@80 344 (cons e
yuuji@80 345 (cond
yuuji@80 346 ((looking-at (concat YaTeX-ec-regexp
yuuji@80 347 YaTeX-TeX-token-regexp))
yuuji@80 348 (match-end 0))
yuuji@80 349 ;; other case??
yuuji@80 350 (t (1+ (point)))))))
yuuji@80 351 (goto-char e)))))
yuuji@80 352
yuuji@53 353 ;; 些細なことだが % の前の文字もピカリとさせてしまうようで… >hilit19
yuuji@53 354 ;; ↓この関数は下の hilit-set-mode-patterns の "[^\\]\\(%\\).*$" に
yuuji@53 355 ;; 依存している
yuuji@53 356 (defun YaTeX-19-region-comment (pattern)
yuuji@53 357 "Return list of comment start and end point."
yuuji@53 358 (if (re-search-forward pattern nil t)
yuuji@56 359 (cons (match-beginning 2) (match-end 0))))
yuuji@56 360
yuuji@80 361 ;; 2006/6/23 match only if it's in specified envrironment.
yuuji@80 362 (defun YaTeX-19-re-search-in-env (ptn_env)
yuuji@80 363 (catch 'done
yuuji@80 364 ;; For font-lock, this function should find it.
yuuji@80 365 (let (md r)
yuuji@80 366 (while (YaTeX-re-search-active-forward
yuuji@80 367 (car ptn_env) YaTeX-comment-prefix nil t)
yuuji@80 368 (setq md (match-data)
yuuji@80 369 r (string-match (cdr ptn_env)
yuuji@80 370 (or (YaTeX-inner-environment 'quick) "")))
yuuji@80 371 (store-match-data md)
yuuji@80 372 (if r (setq r (cons (match-beginning 0) (match-end 0))))
yuuji@80 373 (if (or YaTeX-use-hilit19 r) (throw 'done r))
yuuji@80 374 (goto-char (match-end 0)))
yuuji@80 375 (throw 'done r))))
yuuji@80 376
yuuji@56 377 ;;(make-face 'tt)
yuuji@56 378 ;;(set-face-font 'tt "-schumacher-clean-medium-r-normal--*-*-*-*-*-*-*-*")
yuuji@56 379 ;;(hilit-translate 'tt "white")
yuuji@53 380
yuuji@80 381 ;; font-lockの関数呼びパターンの場合は正規表現が行末までマッチすると
yuuji@80 382 ;; hilit候補対象外にされてしまうので1字手前で正規表現を止める
yuuji@53 383 (defvar YaTeX-hilit-patterns-alist
yuuji@53 384 '(
yuuji@80 385 ;; formulas
yuuji@80 386 (YaTeX-19-region-math-sub "[^\\]^" YaTeX-font-lock-math-sup-face overwrite)
yuuji@80 387 (YaTeX-19-region-math-sub "[^\\]_" YaTeX-font-lock-math-sub-face overwrite)
yuuji@80 388 (YaTeX-19-region-env-type
yuuji@80 389 "\\\\begin{\\(equation\\|eqnarray\\|displaymath\\|\\(x?x?\\|fl\\)align\\|multline\\|gather\\)" formula)
yuuji@80 390 ;(YaTeX-19-region-paren-math "\\\\" formula)
yuuji@80 391 ;;("[^\\]\\\\(" "\\\\)" formula) ; \( \)
yuuji@80 392 ;;("[^\\]\\\\\\[" "\\\\\\]" formula) ; \[ \]
yuuji@53 393 ;; comments
yuuji@56 394 (YaTeX-19-region-comment "\\([^\\]\\|^\\)\\(%\\).*$" comment)
yuuji@58 395
yuuji@64 396 (YaTeX-19-region-section-type "\\\\footnote\\(mark\\|text\\)?\\>" keyword)
yuuji@53 397 ("\\\\[a-z]+box" 0 keyword)
yuuji@64 398 (YaTeX-19-region-section-type "\\\\\\(v\\|h\\)space\\>" keyword)
yuuji@58 399
yuuji@53 400 ;; (re-)define new commands/environments/counters
yuuji@53 401 (YaTeX-19-region-section-type
yuuji@64 402 "\\\\\\(re\\)?new\\(environment\\|command\\|theorem\\|length\\|counter\\)\\>"
yuuji@60 403 defun)
yuuji@53 404 (YaTeX-19-region-section-type
yuuji@64 405 "\\\\textbf\\>" bold)
yuuji@53 406
yuuji@53 407 ;; various declarations/definitions
yuuji@53 408 (YaTeX-19-region-section-type
yuuji@64 409 "\\\\\\(set\\|setto\\|addto\\)\\(length\\|width\\|counter\\)\\>"
yuuji@53 410 define)
yuuji@53 411 (YaTeX-19-region-section-type
yuuji@64 412 "\\\\\\(title\\|author\\|date\\|thanks\\)\\>" define)
yuuji@53 413
yuuji@59 414 ("\\\\document\\(style\\|class\\)\\(\\[.*\\]\\)?{" "}" decl)
yuuji@73 415
yuuji@73 416 ("\\\\\\(begin\\|end\\|nofiles\\|includeonly\\|usepackage\\(\\[.*\\]\\)?\\){" "}" decl)
yuuji@53 417 ("\\\\\\(raggedright\\|makeindex\\|makeglossary\\|maketitle\\)\\b" 0 decl)
yuuji@53 418 ("\\\\\\(pagestyle\\|thispagestyle\\|pagenumbering\\){" "}" decl)
yuuji@53 419 ("\\\\\\(normalsize\\|small\\|footnotesize\\|scriptsize\\|tiny\\|large\\|Large\\|LARGE\\|huge\\|Huge\\)\\b" 0 decl)
yuuji@53 420 ("\\\\\\(appendix\\|tableofcontents\\|listoffigures\\|listoftables\\)\\b"
yuuji@53 421 0 decl)
yuuji@53 422 ("\\\\\\(bf\\|em\\|it\\|rm\\|sf\\|sl\\|ss\\|tt\\)\\b" 0 decl)
yuuji@53 423
yuuji@53 424 ;; label-like things
yuuji@53 425 ;;this should be customized by YaTeX-item-regexp
yuuji@53 426 ("\\\\\\(sub\\)*item\\b\\(\\[[^]]*\\]\\)?" 0 label)
yuuji@53 427 (YaTeX-19-region-section-type
yuuji@80 428 "\\\\\\(caption\\|bibitem\\)\\(\\[[^]]*\\]\\)?\\>" label)
yuuji@53 429
yuuji@61 430 ;; things that do some sort of cross-reference
yuuji@61 431 (YaTeX-19-region-section-type
yuuji@80 432 "\\\\\\(\\(no\\|possessive\\)?cite[a-z]*\\|[a-z]*ref\\|label\\|index\\|glossary\\)\\>"
yuuji@61 433 crossref)
yuuji@61 434
yuuji@61 435 ;; things that bring in external files
yuuji@80 436 ("\\\\\\(include\\|input\\|bibliography\\(style\\)?\\){" "}" include)
yuuji@61 437
yuuji@80 438 ;; ("\\\\begin{\\(eqn\\|equation\\|x?x?align\\|split\\|multline\\|gather\\)"
yuuji@80 439 ;; "\\\\end{\\(eqn\\|equation\\|x?x?align\\|split\\|multline\\|gather\\).*}"
yuuji@80 440 ;; formula)
yuuji@72 441 ("\\([^\\$]\\|^\\)\\($\\($[^$]*\\$\\|[^$]*\\)\\$\\)" 2 formula); '$...$' or '$$...$$'
yuuji@53 442
yuuji@61 443 ;; "wysiwyg" emphasis -- these don't work on nested expressions
yuuji@56 444 (YaTeX-19-region-large-type "{\\\\\\(em\\|it\\|sl\\)" italic)
yuuji@53 445 (YaTeX-19-region-large-type "{\\\\bf" bold)
yuuji@56 446 ;;;(YaTeX-19-region-large-type "{\\\\tt" tt)
yuuji@56 447 ;;;("\\\\begin{verbatim" "\\\\end{verbatim" tt)
yuuji@53 448
yuuji@80 449 ("``" "''" string)
yuuji@80 450 ("\\\\\\(new\\|clear\\(double\\)?\\)page\\>\\|\\\\\\(\\\\\\|cr\\)\\>"
yuuji@80 451 0 delimiter)
yuuji@86 452 ;; re-search-in-env seems to make it slow down. 2007/2/11
yuuji@86 453 ;;(YaTeX-19-re-search-in-env
yuuji@86 454 ;; ("&\\|\\\\hline" . "tabular\\|equation\\|eqn\\|array\\|align") delimiter)
yuuji@86 455 ;;(YaTeX-19-re-search-in-env ("\\\\[+-=><'`]" . "tabbing") delimiter)
yuuji@86 456 ("&\\|\\\\hline\\|\\\\[+-=><'`]" 0 delimiter)
yuuji@80 457 )
yuuji@72 458 "*Hiliting pattern alist for LaTeX text.")
yuuji@53 459
yuuji@53 460 ;;(defvar YaTeX-hilit-pattern-adjustment-default nil)
yuuji@53 461 ;; ↑いらなくなった。
yuuji@51 462 (defvar YaTeX-hilit-pattern-adjustment-private nil
yuuji@53 463 "*Adjustment hilit-pattern-alist for default yatex-mode's pattern.")
yuuji@46 464 (defvar YaTeX-hilit-sectioning-face
yuuji@57 465 '(yellow/dodgerblue yellow/slateblue)
yuuji@51 466 "*Hilightening face for sectioning unit. '(FaceForLight FaceForDark)")
yuuji@57 467 (defvar YaTeX-hilit-sectioning-attenuation-rate
yuuji@57 468 '(15 40)
yuuji@57 469 "*Maximum attenuation rate of sectioning face. '(ForeRate BackRate)
yuuji@57 470 Each rate specifies how much portion of RGB value should be attenuated
yuuji@57 471 towards to lowest sectioning unit. Numbers should be written in percentage.")
yuuji@52 472 (defvar YaTeX-sectioning-patterns-alist nil
yuuji@52 473 "Hilightening patterns for sectioning units.")
yuuji@47 474 (defvar YaTeX-hilit-singlecmd-face
yuuji@72 475 '("slateblue2" . "aquamarine")
yuuji@51 476 "*Hilightening face for maketitle type. '(FaceForLight FaceForDark)")
yuuji@52 477
yuuji@52 478 ;;; セクションコマンドを、構造レベルの高さに応じて色の濃度を変える
yuuji@52 479 ;;; 背景が黒でないと何が嬉しいのか分からないに違いない.
yuuji@53 480 ;;; もしかして白地の時は構造レベルに応じて色を明るくしたほうが良いのか?
yuuji@72 481 ;;; ...どうやらそうでもないらしい。これでいいみたい(2000/12)。
yuuji@60 482 ;(if (fboundp 'win32-color-values)
yuuji@60 483 ; (fset 'x-color-values 'win32-color-values))
yuuji@60 484
yuuji@72 485 (defun YaTeX-19-create-face (sym fgcolor &optional bgcolor)
yuuji@72 486 "Create face named SYM with face of FGCOLOR/BGCOLOR."
yuuji@376 487 (if (consp fgcolor)
yuuji@376 488 (setq fgcolor (if (eq YaTeX-background-mode 'light)
yuuji@376 489 (car fgcolor)
yuuji@376 490 (cdr fgcolor))))
yuuji@376 491 (if (consp bgcolor)
yuuji@376 492 (setq bgcolor (if (eq YaTeX-background-mode 'light)
yuuji@376 493 (car bgcolor)
yuuji@376 494 (cdr bgcolor))))
yuuji@72 495 (cond
yuuji@72 496 ((and YaTeX-use-font-lock (fboundp 'defface))
yuuji@72 497 (custom-declare-face
yuuji@72 498 sym
yuuji@72 499 (list
yuuji@72 500 (list (list
yuuji@72 501 '(class color)
yuuji@72 502 ;(list 'background YaTeX-background-mode)
yuuji@72 503 )
yuuji@72 504 (delq nil
yuuji@72 505 (append
yuuji@72 506 (list ':foreground fgcolor)
yuuji@72 507 (if bgcolor
yuuji@72 508 (list ':background bgcolor))
yuuji@72 509 ))
yuuji@72 510 )
yuuji@72 511 (list t (list ':bold t ':underline t))
yuuji@72 512 )
yuuji@72 513 (format "Font lock face for %s" sym)
yuuji@72 514 ':group 'font-lock-faces)
yuuji@72 515 (set sym sym)
yuuji@72 516 sym)
yuuji@72 517 ((and YaTeX-use-hilit19 (and (fboundp 'hilit-translate)))
yuuji@72 518 (let ((face (intern (concat fgcolor "/" bgcolor))))
yuuji@80 519 (if (facep sym)
yuuji@80 520 (hilit-translate sym face)
yuuji@80 521 (make-face sym)
yuuji@80 522 (or (memq sym hilit-predefined-face-list)
yuuji@80 523 (progn
yuuji@80 524 (set-face-foreground sym fgcolor)
yuuji@80 525 (set-face-background sym bgcolor)
yuuji@80 526 (setq hilit-predefined-face-list
yuuji@80 527 (cons sym hilit-predefined-face-list)))))
yuuji@72 528 face))))
yuuji@72 529
yuuji@53 530 (cond
yuuji@72 531 (YaTeX-use-highlighting
yuuji@72 532 (cond
yuuji@72 533 (window-system
yuuji@72 534 (let*((sectface
yuuji@72 535 (car (if (eq YaTeX-background-mode 'dark)
yuuji@72 536 (cdr YaTeX-hilit-sectioning-face)
yuuji@72 537 YaTeX-hilit-sectioning-face)))
yuuji@72 538 (sectcol (symbol-name sectface))
yuuji@72 539 (fl YaTeX-use-font-lock)
yuuji@72 540 (form (if fl "#%02x%02x%02x" "hex-%02x%02x%02x"))
yuuji@72 541 sect-pat-alist)
yuuji@72 542 (if (string-match "/" sectcol)
yuuji@72 543 (let ((fmin (nth 0 YaTeX-hilit-sectioning-attenuation-rate))
yuuji@72 544 (bmin (nth 1 YaTeX-hilit-sectioning-attenuation-rate))
yuuji@72 545 colorvalue fR fG fB bR bG bB pat fg bg level from face list lm)
yuuji@72 546 (require 'yatexsec)
yuuji@72 547 (setq fg (substring sectcol 0 (string-match "/" sectcol))
yuuji@72 548 bg (substring sectcol (1+ (string-match "/" sectcol)))
yuuji@72 549 colorvalue (x-color-values fg)
yuuji@72 550 fR (/ (nth 0 colorvalue) 256)
yuuji@72 551 fG (/ (nth 1 colorvalue) 256)
yuuji@72 552 fB (/ (nth 2 colorvalue) 256)
yuuji@72 553 colorvalue (x-color-values bg)
yuuji@72 554 bR (/ (nth 0 colorvalue) 256)
yuuji@72 555 bG (/ (nth 1 colorvalue) 256)
yuuji@72 556 bB (/ (nth 2 colorvalue) 256)
yuuji@72 557 lm YaTeX-sectioning-max-level
yuuji@72 558 list YaTeX-sectioning-level)
yuuji@72 559 (while list
yuuji@72 560 (setq pat (concat YaTeX-ec-regexp (car (car list))
yuuji@72 561 ;;"\\*?\\(\\[[^]]*\\]\\)?\\>" ;改行はさむと駄目
yuuji@72 562 "\\>"
yuuji@72 563 )
yuuji@72 564 level (cdr (car list))
yuuji@72 565 fg (format form
yuuji@72 566 (- fR (/ (* level fR fmin) lm 100))
yuuji@72 567 (- fG (/ (* level fG fmin) lm 100))
yuuji@72 568 (- fB (/ (* level fB fmin) lm 100)))
yuuji@72 569 bg (format form
yuuji@72 570 (- bR (/ (* level bR bmin) lm 100))
yuuji@72 571 (- bG (/ (* level bG bmin) lm 100))
yuuji@72 572 (- bB (/ (* level bB bmin) lm 100)))
yuuji@72 573 from (intern (format "YaTeX-sectioning-%d" level))
yuuji@72 574 ;;face (intern (concat fg "/" bg))
yuuji@72 575 )
yuuji@72 576 (setq face (YaTeX-19-create-face from fg bg))
yuuji@72 577 (setq sect-pat-alist
yuuji@72 578 (cons;;(list pat "}" face)
yuuji@72 579 (list 'YaTeX-19-region-section-type pat face)
yuuji@72 580 sect-pat-alist))
yuuji@72 581 (setq list (cdr list)))
yuuji@72 582 (setq YaTeX-sectioning-patterns-alist sect-pat-alist)))))
yuuji@72 583 (t ;not window-system
yuuji@72 584 (setq YaTeX-sectioning-patterns-alist
yuuji@72 585 (list
yuuji@72 586 (list
yuuji@72 587 (concat YaTeX-ec-regexp
yuuji@72 588 "\\(\\(sub\\)*\\(section\\|paragraph\\)\\|chapter"
yuuji@72 589 "\\|part\\){[^}]*}")
yuuji@72 590 0
yuuji@72 591 'define)))))))
yuuji@52 592
yuuji@53 593 ;; ローカルなマクロを読み込んだ後 redraw すると
yuuji@53 594 ;; ローカルマクロを keyword として光らせる(keywordじゃまずいかな…)。
yuuji@72 595 (defvar hilit-patterns-alist nil) ;for absence of hilit19
yuuji@72 596
yuuji@53 597 (defun YaTeX-19-collect-macros ()
yuuji@46 598 (cond
yuuji@72 599 (YaTeX-use-highlighting
yuuji@47 600 (let ((get-face
yuuji@47 601 (function
yuuji@47 602 (lambda (table)
yuuji@47 603 (cond
yuuji@72 604 ((eq YaTeX-background-mode 'light) (car table))
yuuji@72 605 ((eq YaTeX-background-mode 'dark) (cdr table))
yuuji@73 606 ;; Default case equals to 'light mode...is it OK?
yuuji@73 607 (t (car table))))))
yuuji@73 608 sect single pattern-alist)
yuuji@72 609 (YaTeX-19-create-face ;;hilit-translate
yuuji@52 610 ;;sectioning (funcall get-face YaTeX-hilit-sectioning-face)
yuuji@72 611 'macro (funcall get-face YaTeX-hilit-singlecmd-face))
yuuji@57 612 (if (setq sect (append user-section-table tmp-section-table))
yuuji@57 613 (setq sect (concat "\\\\\\("
yuuji@57 614 (mapconcat
yuuji@57 615 (function
yuuji@57 616 (lambda (s) (regexp-quote (car s))))
yuuji@57 617 sect
yuuji@57 618 "\\|")
yuuji@64 619 "\\)\\>")))
yuuji@57 620 (if (setq single (append user-singlecmd-table tmp-singlecmd-table))
yuuji@57 621 (setq single (concat "\\\\\\("
yuuji@57 622 (mapconcat
yuuji@57 623 (function (lambda (s) (regexp-quote (car s))))
yuuji@57 624 single
yuuji@57 625 "\\|")
yuuji@57 626 "\\)\\b")))
yuuji@73 627 (cons 'yatex-mode
yuuji@73 628 (append
yuuji@73 629 (list nil)
yuuji@73 630 YaTeX-sectioning-patterns-alist
yuuji@73 631 YaTeX-hilit-pattern-adjustment-private
yuuji@73 632 ;;YaTeX-hilit-pattern-adjustment-default
yuuji@73 633 YaTeX-hilit-patterns-alist
yuuji@73 634 (delq nil
yuuji@73 635 (list
yuuji@73 636 (if sect (list
yuuji@73 637 'YaTeX-19-region-section-type
yuuji@73 638 sect
yuuji@73 639 'keyword))
yuuji@73 640 (if single (list single 0 'macro))))))))))
yuuji@80 641
yuuji@80 642 ;;2006/6/23 new face, `delimiter' introduced
yuuji@376 643 (YaTeX-19-create-face
yuuji@376 644 'delimiter '("saddlebrown" . "lightyellow") '("ivory". "navy"))
yuuji@80 645
yuuji@53 646 ;;(YaTeX-19-collect-macros) ;causes an error
yuuji@73 647 (defun YaTeX-hilit-setup-alist ()
yuuji@73 648 (cond
yuuji@73 649 ((boundp 'hilit-patterns-alist)
yuuji@73 650 (setq hilit-patterns-alist
yuuji@73 651 (delq (assq 'yatex-mode hilit-patterns-alist) hilit-patterns-alist))
yuuji@73 652 (if YaTeX-use-hilit19
yuuji@73 653 (setq hilit-patterns-alist
yuuji@73 654 (cons (YaTeX-19-collect-macros) hilit-patterns-alist))))))
yuuji@73 655
yuuji@46 656 (defun YaTeX-hilit-recenter (arg)
yuuji@46 657 "Collect current local macro and hilit-recenter."
yuuji@46 658 (interactive "P")
yuuji@73 659 (YaTeX-hilit-setup-alist)
yuuji@73 660 (if (fboundp 'font-lock-mode) (font-lock-mode -1))
yuuji@46 661 (hilit-recenter arg))
yuuji@72 662
yuuji@73 663 (let ((k (append (where-is-internal 'hilit-recenter)
yuuji@73 664 (where-is-internal 'recenter))))
yuuji@73 665 (while k
yuuji@73 666 (define-key YaTeX-mode-map (car k) 'YaTeX-19-recenter)
yuuji@73 667 (setq k (cdr k))))
yuuji@73 668
yuuji@73 669 (defun YaTeX-19-recenter (&optional arg)
yuuji@73 670 (interactive "P")
yuuji@73 671 (if YaTeX-use-hilit19
yuuji@73 672 (YaTeX-hilit-recenter arg)
yuuji@73 673 (YaTeX-font-lock-recenter arg)))
yuuji@72 674
yuuji@72 675 (defun YaTeX-font-lock-recenter (&optional arg)
yuuji@72 676 (interactive "P")
yuuji@73 677 (cond
yuuji@73 678 ((and (boundp 'hilit-patterns-alist)
yuuji@73 679 (assq 'yatex-mode hilit-patterns-alist))
yuuji@73 680 (if (fboundp 'hilit-unhighlight-region)
yuuji@73 681 (hilit-unhighlight-region (point-min) (point-max)))
yuuji@73 682 (setq hilit-patterns-alist ;ensure to remove
yuuji@73 683 (delq (assq 'yatex-mode hilit-patterns-alist)
yuuji@73 684 hilit-patterns-alist))))
yuuji@72 685 (setq YaTeX-font-lock-keywords
yuuji@72 686 (YaTeX-convert-pattern-hilit2fontlock
yuuji@73 687 (cdr (YaTeX-19-collect-macros)))
yuuji@80 688 ;;; Keep this section for debugging.
yuuji@80 689 ;; YaTeX-font-lock-keywords
yuuji@80 690 ;; (append (YaTeX-convert-pattern-hilit2fontlock
yuuji@80 691 ;; (cdr (YaTeX-19-collect-macros)))
yuuji@80 692 ;; '(((lambda (lim)
yuuji@80 693 ;; (YaTeX-19-re-search-in-env '("foo" . "tabular"))
yuuji@80 694 ;; ;(search-forward "foo" nil t)
yuuji@80 695 ;; )
yuuji@80 696 ;; (0 YaTeX-font-lock-delimiter-face))))
yuuji@80 697 ;;font-lock-keywords nil
yuuji@80 698 font-lock-set-defaults nil)
yuuji@80 699 ;;(save-excursion
yuuji@80 700 ;; (font-lock-fontify-region (window-start) (window-end))
yuuji@72 701 (font-lock-mode -1) ;is stupid, but sure.
yuuji@73 702 (font-lock-mode 1)
yuuji@73 703 (recenter arg))
yuuji@72 704
yuuji@80 705 (defun YaTeX-font-lock-fontify-region (beg end)
yuuji@80 706 (interactive "r")
yuuji@80 707 (save-excursion (font-lock-fontify-region beg end)))
yuuji@80 708
yuuji@80 709 (defun YaTeX-font-lock-fontify-environment ()
yuuji@80 710 (interactive)
yuuji@80 711 (save-excursion
yuuji@80 712 (save-match-data ;is safe after emacs-19
yuuji@80 713 (YaTeX-mark-environment)
yuuji@80 714 (message "")
yuuji@80 715 (YaTeX-font-lock-fontify-region (region-beginning) (region-end)))))
yuuji@80 716
yuuji@80 717 (defun YaTeX-font-lock-highlight-menu ()
yuuji@80 718 (interactive)
yuuji@80 719 (message "Force Highlight: R)egion E)nvironment")
yuuji@80 720 (let ((c (read-char)))
yuuji@80 721 (cond
yuuji@80 722 ((memq c '(?R ?r))
yuuji@80 723 (YaTeX-font-lock-fontify-region (region-beginning) (region-end)))
yuuji@80 724 ((memq c '(?e ?e))
yuuji@80 725 (YaTeX-font-lock-fontify-environment)))))
yuuji@80 726
yuuji@80 727 (if YaTeX-use-font-lock
yuuji@80 728 (YaTeX-define-key "u" 'YaTeX-font-lock-highlight-menu))
yuuji@80 729
yuuji@72 730 (defvar YaTeX-font-lock-keywords nil
yuuji@72 731 "Pattern-face alist of yahtml-mode for font-lock")
yuuji@72 732
yuuji@72 733 (defun YaTeX-font-lock-set-default-keywords ()
yuuji@72 734 (put 'yatex-mode 'font-lock-defaults
yuuji@72 735 (list 'YaTeX-font-lock-keywords nil nil))
yuuji@72 736 (setq YaTeX-font-lock-keywords
yuuji@72 737 (YaTeX-convert-pattern-hilit2fontlock
yuuji@72 738 (cons nil
yuuji@72 739 (append YaTeX-sectioning-patterns-alist
yuuji@72 740 YaTeX-hilit-pattern-adjustment-private
yuuji@72 741 YaTeX-hilit-patterns-alist)))))
yuuji@72 742
yuuji@72 743 (if YaTeX-use-font-lock
yuuji@72 744 (progn
yuuji@72 745 (if (and (boundp 'hilit-mode-enable-list) hilit-mode-enable-list)
yuuji@72 746 ;;for those who use both hilit19 and font-lock
yuuji@72 747 (if (eq (car hilit-mode-enable-list) 'not)
yuuji@72 748 (or (member 'yatex-mode hilit-mode-enable-list)
yuuji@72 749 (nconc hilit-mode-enable-list (list 'yatex-mode)))
yuuji@72 750 (setq hilit-mode-enable-list
yuuji@72 751 (delq 'yatex-mode hilit-mode-enable-list))))
yuuji@72 752 (YaTeX-font-lock-set-default-keywords)))
yuuji@46 753
yuuji@53 754 (defun YaTeX-switch-to-new-window ()
yuuji@53 755 (let ((c 0) (i 1) (free (make-string win:max-configs ? )))
yuuji@53 756 (while (< i win:max-configs)
yuuji@53 757 (or (aref win:configs i) (aset free i (+ i win:base-key)))
yuuji@53 758 (setq i (1+ i)))
yuuji@53 759 (while (not (string-match (char-to-string c) free))
yuuji@53 760 (message "Which window to create? [%s]: " free)
yuuji@53 761 (setq c (read-char)))
yuuji@53 762 (message "Creating window [%c]" c)
yuuji@53 763 (set-buffer (get-buffer-create "*scratch*"))
yuuji@53 764 (win:switch-window (- c win:base-key))))
yuuji@53 765
yuuji@53 766 (defun YaTeX-visit-main-other-frame ()
yuuji@53 767 "Visit main file in other frame.
yuuji@53 768 WARNING, This code is not perfect."
yuuji@53 769 (interactive)
yuuji@53 770 (if (YaTeX-main-file-p) (message "I think this is main LaTeX source.")
yuuji@53 771 (let (parent)
yuuji@53 772 (save-excursion (YaTeX-visit-main t) (setq parent (current-buffer)))
yuuji@53 773 (cond
yuuji@53 774 ((get-buffer-window parent t)
yuuji@53 775 (goto-buffer-window parent))
yuuji@53 776 ((and (featurep 'windows) win:use-frame)
yuuji@53 777 (YaTeX-switch-to-new-window)
yuuji@53 778 (switch-to-buffer parent))
yuuji@53 779 (t (switch-to-buffer-other-frame (buffer-name parent)))))))
yuuji@53 780
yuuji@53 781 (defun YaTeX-goto-corresponding-*-other-frame (arg)
yuuji@53 782 "Go to corresponding object in other frame."
yuuji@53 783 (interactive "P")
yuuji@53 784 (let (b p)
yuuji@53 785 (save-window-excursion
yuuji@53 786 (save-excursion
yuuji@53 787 (YaTeX-goto-corresponding-* arg)
yuuji@53 788 (setq b (current-buffer) p (point))))
yuuji@53 789 (cond
yuuji@53 790 ((get-buffer-window b t)
yuuji@53 791 (goto-buffer-window b)
yuuji@53 792 (goto-char p))
yuuji@53 793 ((and (featurep 'windows) win:use-frame)
yuuji@53 794 (YaTeX-switch-to-new-window)
yuuji@53 795 (switch-to-buffer b)
yuuji@53 796 (goto-char p))
yuuji@53 797 (t (switch-to-buffer-other-frame (buffer-name b))
yuuji@72 798 (goto-char p)))))
yuuji@53 799
yuuji@49 800 ;;; reverseVideo にして hilit-background-mode を 'dark
yuuji@49 801 ;;; にしている人は数式などが暗くなりすぎて見づらいかもしれない。
yuuji@49 802 ;;; 次のコードを hilit19 をロードしている場所の直後に置くとちょっ
yuuji@49 803 ;;; とはまし。
yuuji@46 804 ;;; (if (eq hilit-background-mode 'dark)
yuuji@46 805 ;;; (hilit-translate
yuuji@46 806 ;;; string 'mediumspringgreen
yuuji@46 807 ;;; formula 'khaki
yuuji@46 808 ;;; label 'yellow-underlined))
yuuji@57 809 (and YaTeX-emacs-19
yuuji@64 810 (not (featurep 'xemacs))
yuuji@58 811 (boundp 'byte-compile-current-file)
yuuji@72 812 byte-compile-current-file
yuuji@72 813 (progn
yuuji@72 814 (if YaTeX-emacs-20 (require 'font-lock))
yuuji@72 815 (if (and (boundp 'window-system) window-system)
yuuji@72 816 (require 'hilit19)
yuuji@72 817 (error "Byte compile this file on window system! Not `-nw'!"))))
yuuji@46 818
yuuji@46 819 (provide 'yatex19)
yuuji@72 820
yuuji@72 821
yuuji@72 822 ; Local variables:
yuuji@72 823 ; fill-prefix: ";;; "
yuuji@72 824 ; paragraph-start: "^$\\| \\|;;;$"
yuuji@72 825 ; paragraph-separate: "^$\\| \\|;;;$"
yuuji@72 826 ; End: