Mercurial > hgrepos > hgweb.cgi > yatex
comparison yatex19.el @ 73:f41b01fef5d6
Stable version(hope to be)
author | yuuji |
---|---|
date | Wed, 22 May 2002 04:57:42 +0000 |
parents | 0aaebd07dad0 |
children | 1b172d26b55e |
comparison
equal
deleted
inserted
replaced
72:0aaebd07dad0 | 73:f41b01fef5d6 |
---|---|
1 ;;; -*- Emacs-Lisp -*- | 1 ;;; -*- Emacs-Lisp -*- |
2 ;;; YaTeX facilities for Emacs 19 | 2 ;;; YaTeX facilities for Emacs 19 |
3 ;;; (c )1994-2000 by HIROSE Yuuji.[yuuji@yatex.org] | 3 ;;; (c )1994-2002 by HIROSE Yuuji.[yuuji@yatex.org] |
4 ;;; Last modified Mon Dec 25 19:16:04 2000 on firestorm | 4 ;;; Last modified Wed May 22 13:55:20 2002 on firestorm |
5 ;;; $Id$ | 5 ;;; $Id$ |
6 | 6 |
7 ;(require 'yatex) | 7 ;(require 'yatex) |
8 | 8 |
9 (cond | 9 (and (boundp 'YaTeX-use-hilit19) |
10 (YaTeX-use-hilit19 (require 'hilit19)) | 10 YaTeX-use-hilit19 |
11 (YaTeX-use-font-lock (require 'font-lock))) | 11 (require 'hilit19)) |
12 | 12 |
13 (defvar YaTeX-use-highlighting (or YaTeX-use-font-lock YaTeX-use-hilit19) | 13 (defvar YaTeX-use-highlighting (or YaTeX-use-font-lock YaTeX-use-hilit19) |
14 "*Use highlighting buffer or not.") | 14 "*Use highlighting buffer or not.") |
15 (defvar YaTeX-background-mode | 15 (defvar YaTeX-background-mode |
16 (cond | 16 (cond |
17 ((boundp 'hilit-background-mode) hilit-background-mode) | 17 ((boundp 'hilit-background-mode) hilit-background-mode) |
18 ((boundp 'frame-background-mode) frame-background-mode) | 18 ((boundp 'frame-background-mode) frame-background-mode) |
19 ((fboundp 'get-frame-background-mode) | 19 ((fboundp 'get-frame-background-mode) |
20 (get-frame-background-mode (selected-frame))) | 20 (get-frame-background-mode (selected-frame))) |
21 (if (face-background 'default) | |
22 (if (> (+ 32768 32768 32768) | |
23 (apply '+ | |
24 (funcall (if (fboundp 'color-rgb-components) | |
25 'color-rgb-components | |
26 'x-color-values) | |
27 (face-background 'default)))) | |
28 'dark | |
29 'light)) | |
21 (t nil))) | 30 (t nil))) |
22 | 31 |
23 (defvar YaTeX-mode-menu-map (make-sparse-keymap "YaTeX")) | 32 (defvar YaTeX-mode-menu-map (make-sparse-keymap "YaTeX")) |
24 (defvar YaTeX-mode-menu-map-process (make-sparse-keymap "Process")) | 33 (defvar YaTeX-mode-menu-map-process (make-sparse-keymap "Process")) |
25 (define-key YaTeX-mode-map [menu-bar yatex] | 34 (define-key YaTeX-mode-map [menu-bar yatex] |
317 define) | 326 define) |
318 (YaTeX-19-region-section-type | 327 (YaTeX-19-region-section-type |
319 "\\\\\\(title\\|author\\|date\\|thanks\\)\\>" define) | 328 "\\\\\\(title\\|author\\|date\\|thanks\\)\\>" define) |
320 | 329 |
321 ("\\\\document\\(style\\|class\\)\\(\\[.*\\]\\)?{" "}" decl) | 330 ("\\\\document\\(style\\|class\\)\\(\\[.*\\]\\)?{" "}" decl) |
322 ("\\\\\\(begin\\|end\\|nofiles\\|includeonly\\){" "}" decl) | 331 |
332 ("\\\\\\(begin\\|end\\|nofiles\\|includeonly\\|usepackage\\(\\[.*\\]\\)?\\){" "}" decl) | |
323 ("\\\\\\(raggedright\\|makeindex\\|makeglossary\\|maketitle\\)\\b" 0 decl) | 333 ("\\\\\\(raggedright\\|makeindex\\|makeglossary\\|maketitle\\)\\b" 0 decl) |
324 ("\\\\\\(pagestyle\\|thispagestyle\\|pagenumbering\\){" "}" decl) | 334 ("\\\\\\(pagestyle\\|thispagestyle\\|pagenumbering\\){" "}" decl) |
325 ("\\\\\\(normalsize\\|small\\|footnotesize\\|scriptsize\\|tiny\\|large\\|Large\\|LARGE\\|huge\\|Huge\\)\\b" 0 decl) | 335 ("\\\\\\(normalsize\\|small\\|footnotesize\\|scriptsize\\|tiny\\|large\\|Large\\|LARGE\\|huge\\|Huge\\)\\b" 0 decl) |
326 ("\\\\\\(appendix\\|tableofcontents\\|listoffigures\\|listoftables\\)\\b" | 336 ("\\\\\\(appendix\\|tableofcontents\\|listoffigures\\|listoftables\\)\\b" |
327 0 decl) | 337 0 decl) |
486 (function | 496 (function |
487 (lambda (table) | 497 (lambda (table) |
488 (cond | 498 (cond |
489 ((eq YaTeX-background-mode 'light) (car table)) | 499 ((eq YaTeX-background-mode 'light) (car table)) |
490 ((eq YaTeX-background-mode 'dark) (cdr table)) | 500 ((eq YaTeX-background-mode 'dark) (cdr table)) |
491 (t nil))))) | 501 ;; Default case equals to 'light mode...is it OK? |
492 sect single) | 502 (t (car table)))))) |
503 sect single pattern-alist) | |
493 (YaTeX-19-create-face ;;hilit-translate | 504 (YaTeX-19-create-face ;;hilit-translate |
494 ;;sectioning (funcall get-face YaTeX-hilit-sectioning-face) | 505 ;;sectioning (funcall get-face YaTeX-hilit-sectioning-face) |
495 'macro (funcall get-face YaTeX-hilit-singlecmd-face)) | 506 'macro (funcall get-face YaTeX-hilit-singlecmd-face)) |
496 (if (setq sect (append user-section-table tmp-section-table)) | 507 (if (setq sect (append user-section-table tmp-section-table)) |
497 (setq sect (concat "\\\\\\(" | 508 (setq sect (concat "\\\\\\(" |
506 (mapconcat | 517 (mapconcat |
507 (function (lambda (s) (regexp-quote (car s)))) | 518 (function (lambda (s) (regexp-quote (car s)))) |
508 single | 519 single |
509 "\\|") | 520 "\\|") |
510 "\\)\\b"))) | 521 "\\)\\b"))) |
511 (setq hilit-patterns-alist ;Remove at first. | 522 (cons 'yatex-mode |
512 (delq (assq 'yatex-mode hilit-patterns-alist) hilit-patterns-alist) | 523 (append |
513 hilit-patterns-alist | 524 (list nil) |
514 (cons | 525 YaTeX-sectioning-patterns-alist |
515 (cons 'yatex-mode | 526 YaTeX-hilit-pattern-adjustment-private |
516 (append | 527 ;;YaTeX-hilit-pattern-adjustment-default |
517 (list nil) | 528 YaTeX-hilit-patterns-alist |
518 YaTeX-sectioning-patterns-alist | 529 (delq nil |
519 YaTeX-hilit-pattern-adjustment-private | 530 (list |
520 ;;YaTeX-hilit-pattern-adjustment-default | 531 (if sect (list |
521 YaTeX-hilit-patterns-alist | 532 'YaTeX-19-region-section-type |
522 (delq nil | 533 sect |
523 (list | 534 'keyword)) |
524 (if sect (list | 535 (if single (list single 0 'macro)))))))))) |
525 'YaTeX-19-region-section-type | |
526 sect | |
527 'keyword)) | |
528 (if single (list single 0 'macro)))))) | |
529 hilit-patterns-alist)))))) | |
530 ;;(YaTeX-19-collect-macros) ;causes an error | 536 ;;(YaTeX-19-collect-macros) ;causes an error |
537 (defun YaTeX-hilit-setup-alist () | |
538 (cond | |
539 ((boundp 'hilit-patterns-alist) | |
540 (setq hilit-patterns-alist | |
541 (delq (assq 'yatex-mode hilit-patterns-alist) hilit-patterns-alist)) | |
542 (if YaTeX-use-hilit19 | |
543 (setq hilit-patterns-alist | |
544 (cons (YaTeX-19-collect-macros) hilit-patterns-alist)))))) | |
545 | |
531 (defun YaTeX-hilit-recenter (arg) | 546 (defun YaTeX-hilit-recenter (arg) |
532 "Collect current local macro and hilit-recenter." | 547 "Collect current local macro and hilit-recenter." |
533 (interactive "P") | 548 (interactive "P") |
534 (YaTeX-19-collect-macros) | 549 (YaTeX-hilit-setup-alist) |
550 (if (fboundp 'font-lock-mode) (font-lock-mode -1)) | |
535 (hilit-recenter arg)) | 551 (hilit-recenter arg)) |
536 (defvar YaTeX-19-recenter-function | 552 |
537 (cond | 553 (let ((k (append (where-is-internal 'hilit-recenter) |
538 (YaTeX-use-hilit19 (cons 'YaTeX-hilit-recenter 'hilit-recenter)) | 554 (where-is-internal 'recenter)))) |
539 (YaTeX-use-font-lock (cons 'YaTeX-font-lock-recenter 'recenter)) | 555 (while k |
540 (t nil))) | 556 (define-key YaTeX-mode-map (car k) 'YaTeX-19-recenter) |
541 | 557 (setq k (cdr k)))) |
542 (if YaTeX-19-recenter-function | 558 |
543 (let ((k (where-is-internal (cdr YaTeX-19-recenter-function)))) | 559 (defun YaTeX-19-recenter (&optional arg) |
544 (while k | 560 (interactive "P") |
545 (define-key YaTeX-mode-map (car k) (car YaTeX-19-recenter-function)) | 561 (if YaTeX-use-hilit19 |
546 (setq k (cdr k))))) | 562 (YaTeX-hilit-recenter arg) |
563 (YaTeX-font-lock-recenter arg))) | |
547 | 564 |
548 (defun YaTeX-font-lock-recenter (&optional arg) | 565 (defun YaTeX-font-lock-recenter (&optional arg) |
549 (interactive "P") | 566 (interactive "P") |
567 (cond | |
568 ((and (boundp 'hilit-patterns-alist) | |
569 (assq 'yatex-mode hilit-patterns-alist)) | |
570 (if (fboundp 'hilit-unhighlight-region) | |
571 (hilit-unhighlight-region (point-min) (point-max))) | |
572 (setq hilit-patterns-alist ;ensure to remove | |
573 (delq (assq 'yatex-mode hilit-patterns-alist) | |
574 hilit-patterns-alist)))) | |
550 (setq YaTeX-font-lock-keywords | 575 (setq YaTeX-font-lock-keywords |
551 (YaTeX-convert-pattern-hilit2fontlock | 576 (YaTeX-convert-pattern-hilit2fontlock |
552 (cdr (assq 'yatex-mode (YaTeX-19-collect-macros)))) | 577 (cdr (YaTeX-19-collect-macros))) |
553 font-lock-keywords nil) | 578 font-lock-keywords nil) |
554 ;(save-excursion | 579 ;(save-excursion |
555 ; (font-lock-fontify-region (window-start) (window-end))) | 580 ; (font-lock-fontify-region (window-start) (window-end))) |
556 (font-lock-mode -1) ;is stupid, but sure. | 581 (font-lock-mode -1) ;is stupid, but sure. |
557 (font-lock-mode 1)) | 582 (font-lock-mode 1) |
583 (recenter arg)) | |
558 | 584 |
559 (defvar YaTeX-font-lock-keywords nil | 585 (defvar YaTeX-font-lock-keywords nil |
560 "Pattern-face alist of yahtml-mode for font-lock") | 586 "Pattern-face alist of yahtml-mode for font-lock") |
561 | 587 |
562 (defun YaTeX-font-lock-set-default-keywords () | 588 (defun YaTeX-font-lock-set-default-keywords () |