yatex

annotate yatex19.el @ 283:95e8bb2a5c5f

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