yuuji@46: ;;; -*- Emacs-Lisp -*- yuuji@46: ;;; YaTeX facilities for Emacs 19 yuuji@52: ;;; (c )1994-1995 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] yuuji@57: ;;; Last modified Sun Dec 3 03:29:56 1995 on inspire yuuji@46: ;;; $Id$ yuuji@46: yuuji@49: ;;; とりあえず hilit19 を使っている時に色が付くようにして yuuji@49: ;;; メニューバーでごにょごにょできるようにしただけ。 yuuji@49: ;;; いったい誰がメニューバー使ってLaTeXソース書くんだろうか? yuuji@49: ;;; まあいいや練習練習。後ろの方にちょっとコメントあり。 yuuji@53: ;;; 真中辺にあるけど、hilit19.el 対応の方は結構本気。 yuuji@46: yuuji@47: (require 'yatex) yuuji@47: yuuji@46: (defun YaTeX-19-define-sub-menu (map vec &rest bindings) yuuji@46: "Define sub-menu-item in MAP at vector VEC as BINDINGS. yuuji@46: BINDINGS is a form with optional length: (symbol title binding). yuuji@46: When you defined menu-bar keymap such like: yuuji@46: (define-key foo-map [menu-bar foo] (make-sparse-keymap \"foo menu\")) yuuji@46: and you want to define sub menu for `foo menu' as followings. yuuji@46: foo -> menu1 (calling function `func1') yuuji@46: menu2 (doing interactive call `(func2 ...)' yuuji@46: Call this function like this: yuuji@46: (YaTeX-19-define-sub-menu foo-map [menu-bar foo] yuuji@46: '(m1 \"Function 1\" func1) yuuji@46: '(m2 \"Function 2\" (lambda () (interactive) (func2 ...)))) yuuji@46: where yuuji@46: `m1' and `m2' are the keymap symbol for sub-menu of `[menu-bar foo]. yuuji@46: `Funtion 1' and `Function 2' are the title strings for sub-menu. yuuji@46: " yuuji@46: (let ((i 0) (vec2 (make-vector (1+ (length vec)) nil))) yuuji@46: (while (< i (length vec)) yuuji@46: (aset vec2 i (aref vec i)) yuuji@46: (setq i (1+ i))) yuuji@46: (setq bindings (reverse bindings)) yuuji@46: (mapcar yuuji@46: (function yuuji@46: (lambda (bind) yuuji@46: (aset vec2 (1- (length vec2)) (car bind)) ;set menu-symbol yuuji@46: (define-key map vec2 yuuji@46: (cons (car (cdr bind)) yuuji@46: (car (cdr (cdr bind))))))) yuuji@46: bindings))) yuuji@46: yuuji@46: ;; Menu for Typeset relating processes ---------------------------------------- yuuji@46: (define-key YaTeX-mode-map [menu-bar yatex] yuuji@46: (cons "YaTeX" (make-sparse-keymap "YaTeX"))) yuuji@46: (define-key YaTeX-mode-map [menu-bar yatex process] yuuji@46: (cons "Process" (make-sparse-keymap "Process"))) yuuji@46: (YaTeX-19-define-sub-menu yuuji@46: YaTeX-mode-map [menu-bar yatex process] yuuji@46: '(buffer "LaTeX" (lambda () (interactive) (YaTeX-typeset-menu nil ?j))) yuuji@46: '(kill "Kill LaTeX" (lambda () (interactive) (YaTeX-typeset-menu nil ?k))) yuuji@46: '(bibtex "BibTeX" (lambda () (interactive) (YaTeX-typeset-menu nil ?b))) yuuji@46: '(makeindex "makeindex" (lambda () (interactive) (YaTeX-typeset-menu nil ?i))) yuuji@46: '(preview "Preview" (lambda () (interactive) (YaTeX-typeset-menu nil ?p))) yuuji@46: '(lpr "lpr" (lambda () (interactive) (YaTeX-typeset-menu nil ?l))) yuuji@46: '(lpq "lpq" (lambda () (interactive) (YaTeX-typeset-menu nil ?q))) yuuji@46: ) yuuji@46: yuuji@46: ;; Help for LaTeX ------------------------------------------------------------ yuuji@46: (YaTeX-19-define-sub-menu yuuji@46: YaTeX-mode-map [menu-bar yatex] yuuji@46: '(sephelp "--") yuuji@46: '(help "Help on LaTeX commands" YaTeX-help) yuuji@46: '(apropos "Apropos on LaTeX commands" YaTeX-apropos)) yuuji@46: yuuji@46: ;; Switch modes -------------------------------------------------------------- yuuji@46: (define-key YaTeX-mode-map [menu-bar yatex switch] yuuji@46: (cons "Switching YaTeX's modes" (make-sparse-keymap "modes"))) yuuji@46: (or YaTeX-auto-math-mode yuuji@46: (define-key YaTeX-mode-map [menu-bar yatex switch math] yuuji@46: '("Toggle math mode" . (lambda () (interactive) yuuji@46: (YaTeX-switch-mode-menu nil ?t))))) yuuji@46: (define-key YaTeX-mode-map [menu-bar yatex switch mod] yuuji@46: '("Toggle modify mode" . (lambda () (interactive) yuuji@46: (YaTeX-switch-mode-menu nil ?m)))) yuuji@46: yuuji@46: ;; % menu -------------------------------------------------------------------- yuuji@46: (define-key YaTeX-mode-map [menu-bar yatex percent] yuuji@46: (cons "Edit %# notation" (make-sparse-keymap "Edit %# notation"))) yuuji@46: (YaTeX-19-define-sub-menu yuuji@46: YaTeX-mode-map [menu-bar yatex percent] yuuji@46: '(! "Change LaTeX typesetter(%#!)" yuuji@46: (lambda () (interactive) (YaTeX-%-menu nil nil ?!))) yuuji@46: '(begend "Set %#BEGIN-%#END on region" yuuji@46: (lambda () (interactive) (YaTeX-%-menu nil nil ?b))) yuuji@46: '(lpr "Change LPR format" yuuji@46: (lambda () (interactive) (YaTeX-%-menu nil nil ?l)))) yuuji@46: yuuji@46: ;; What position ------------------------------------------------------------- yuuji@46: (YaTeX-19-define-sub-menu yuuji@46: YaTeX-mode-map [menu-bar yatex] yuuji@46: '(what "What column in tabular" YaTeX-what-column)) yuuji@46: yuuji@52: ;; Document hierarchy ------------------------------------------------------ yuuji@52: (YaTeX-19-define-sub-menu yuuji@52: YaTeX-mode-map [menu-bar yatex] yuuji@52: '(hier "Display document hierarchy" YaTeX-display-hierarchy-directly)) yuuji@52: yuuji@46: ;; Jump cursor --------------------------------------------------------------- yuuji@46: (define-key YaTeX-mode-map [menu-bar yatex jump] yuuji@46: (cons "Jump cursor" yuuji@46: (make-sparse-keymap "Jump cursor"))) yuuji@46: (YaTeX-19-define-sub-menu yuuji@46: YaTeX-mode-map [menu-bar yatex jump] yuuji@46: '(corres "Goto corersponding position" YaTeX-goto-corresponding-*) yuuji@46: '(main "Visit main source" (lambda () (interactive) (YaTeX-visit-main))) yuuji@46: '(main-other "Visit main source other window" YaTeX-visit-main-other-window) yuuji@46: ) yuuji@46: yuuji@46: ;; =========================================================================== yuuji@46: (define-key YaTeX-mode-map [menu-bar yatex sepcom] yuuji@46: '("---" . nil)) yuuji@46: yuuji@46: ;; Comment/Uncomment --------------------------------------------------------- yuuji@46: (YaTeX-19-define-sub-menu yuuji@46: YaTeX-mode-map [menu-bar yatex] yuuji@46: '(comment "Comment region or environment" YaTeX-comment-region) yuuji@46: '(uncomment "Unomment region or environment" YaTeX-uncomment-region) yuuji@46: '(commentp "Comment paragraph" YaTeX-comment-paragraph) yuuji@47: '(uncommentp "Uncomment paragraph" YaTeX-uncomment-paragraph) yuuji@46: '(sepcom "--" nil) yuuji@46: ) yuuji@46: yuuji@46: yuuji@46: ;; =========================================================================== yuuji@46: ;; Change/Kill/Fill yuuji@46: (YaTeX-19-define-sub-menu yuuji@46: YaTeX-mode-map [menu-bar yatex] yuuji@46: '(change "Change macros" YaTeX-change-*) yuuji@46: '(kill "Kill macros" YaTeX-kill-*) yuuji@46: '(fillitem "Fill \\item" YaTeX-fill-item) yuuji@46: '(newline "Newline" YaTeX-intelligent-newline) yuuji@46: '(sepchg "--" nil) yuuji@46: ) yuuji@46: yuuji@46: ;; Menu for completions ------------------------------------------------------ yuuji@46: yuuji@46: yuuji@46: ;;;(YaTeX-19-define-sub-menu yuuji@46: ;;; YaTeX-mode-map [menu-bar yatex] yuuji@46: ;;; '(secr "Section-type command on region" YaTeX-make-section-region) yuuji@46: ;;; '(sec "Section-type command" YaTeX-make-section)) yuuji@46: yuuji@46: (define-key YaTeX-mode-map [menu-bar yatex sectionr] yuuji@46: (cons "Section-type region(long name)" yuuji@46: (make-sparse-keymap "Enclose region with section-type macro"))) yuuji@46: (define-key YaTeX-mode-map [menu-bar yatex section] yuuji@47: (cons "Section-type(long name)" yuuji@46: (make-sparse-keymap "Section-type macro"))) yuuji@46: (let ((sorted-section yuuji@46: (sort yuuji@46: (delq nil yuuji@46: (mapcar (function (lambda (s) yuuji@46: (if (> (length (car s)) 5) yuuji@46: (car s)))) yuuji@46: (append section-table user-section-table))) yuuji@46: 'string<))) yuuji@46: (apply 'YaTeX-19-define-sub-menu yuuji@46: YaTeX-mode-map [menu-bar yatex section] yuuji@46: (mapcar (function (lambda (secname) yuuji@46: (list (intern secname) secname yuuji@46: (list 'lambda () yuuji@46: (list 'interactive) yuuji@46: (list 'YaTeX-make-section yuuji@46: nil nil nil secname))))) yuuji@46: sorted-section)) yuuji@46: (apply 'YaTeX-19-define-sub-menu yuuji@46: YaTeX-mode-map [menu-bar yatex sectionr] yuuji@46: (mapcar (function (lambda (secname) yuuji@46: (list (intern secname) secname yuuji@46: (list 'lambda () yuuji@46: (list 'interactive) yuuji@46: (list 'YaTeX-make-section yuuji@46: nil yuuji@46: (list 'region-beginning) yuuji@46: (list 'region-end) yuuji@46: secname))))) yuuji@46: sorted-section))) yuuji@46: yuuji@46: (define-key YaTeX-mode-map [menu-bar yatex envr] yuuji@46: (cons "Environment region" (make-sparse-keymap "Environment region"))) yuuji@46: (define-key YaTeX-mode-map [menu-bar yatex env] yuuji@46: (cons "Environment" (make-sparse-keymap "Environment"))) yuuji@46: (let (prev envname) yuuji@46: (mapcar yuuji@46: (function yuuji@46: (lambda (envalist) yuuji@46: (setq envname (car envalist)) yuuji@46: (define-key-after yuuji@46: (lookup-key YaTeX-mode-map [menu-bar yatex env]) yuuji@46: (vector (intern envname)) yuuji@46: (cons envname yuuji@46: (list 'lambda () (list 'interactive) yuuji@46: (list 'YaTeX-insert-begin-end yuuji@46: envname nil))) yuuji@46: prev) yuuji@46: (define-key-after yuuji@46: (lookup-key YaTeX-mode-map [menu-bar yatex envr]) yuuji@46: (vector (intern envname)) yuuji@46: (cons envname yuuji@46: (list 'lambda () (list 'interactive) yuuji@46: (list 'YaTeX-insert-begin-end yuuji@46: envname t))) yuuji@46: prev) yuuji@46: (setq prev (intern envname)))) yuuji@46: (sort (append env-table user-env-table) yuuji@46: '(lambda (x y) (string< (car x) (car y)))))) yuuji@46: yuuji@53: ;; Other key bindings for window-system yuuji@53: ;(YaTeX-define-key [?\C- ] 'YaTeX-do-completion) yuuji@53: (define-key YaTeX-mode-map [?\M-\C- ] 'YaTeX-mark-environment) yuuji@53: yuuji@46: ;; Highlightening yuuji@53: ;; メニューに比べてこっちは結構本気でやってます。 yuuji@53: ;; だって文書構造がとっても分かり易いんだもん。 yuuji@53: ;; みんなも hilit19.el を使おう! yuuji@53: ;; yuuji@53: ;; さて、まずは対応する {} をピカピカ範囲とするような関数を作る。 yuuji@53: ;; これは hilit-LaTeX.el を参考にした。でも、ちゃんと section 型コマンドの yuuji@53: ;; 引数を数えて正しい位置までピカピカさせるよ〜ん! yuuji@53: yuuji@53: (defun YaTeX-19-region-section-type (pattern) yuuji@53: "Return list of starting and end point of section-type commands of PATTERN." yuuji@53: (if (re-search-forward pattern nil t) yuuji@53: (let ((m0 (match-beginning 0)) cmd (argc 1)) yuuji@53: (setq cmd (substring (YaTeX-match-string 0) 1 -1) yuuji@53: argc (or (car (cdr (YaTeX-lookup-table cmd 'section))) argc)) yuuji@53: (cons m0 yuuji@53: (progn (skip-chars-backward "^{") (forward-char -2) yuuji@53: (while (> argc 0) yuuji@53: (skip-chars-forward "^{") yuuji@53: (forward-list 1) yuuji@53: (setq argc (1- argc))) yuuji@53: (point)))))) yuuji@53: yuuji@53: (defun YaTeX-19-region-large-type (pattern) yuuji@53: "Return list of large-type contents. yuuji@53: Assumes PATTERN begins with `{'." yuuji@53: (if (re-search-forward pattern nil t) yuuji@53: (let ((m0 (match-beginning 0))) yuuji@53: (goto-char m0) yuuji@53: (skip-chars-forward "^ \t\n") yuuji@53: (skip-chars-forward " \t\n") yuuji@53: (cons (point) yuuji@53: (progn (goto-char m0) (forward-list 1) yuuji@53: (1- (point))))))) yuuji@53: yuuji@53: ;; 些細なことだが % の前の文字もピカリとさせてしまうようで… >hilit19 yuuji@53: ;; ↓この関数は下の hilit-set-mode-patterns の "[^\\]\\(%\\).*$" に yuuji@53: ;; 依存している yuuji@53: (defun YaTeX-19-region-comment (pattern) yuuji@53: "Return list of comment start and end point." yuuji@53: (if (re-search-forward pattern nil t) yuuji@56: (cons (match-beginning 2) (match-end 0)))) yuuji@56: yuuji@56: ;;(make-face 'tt) yuuji@56: ;;(set-face-font 'tt "-schumacher-clean-medium-r-normal--*-*-*-*-*-*-*-*") yuuji@56: ;;(hilit-translate 'tt "white") yuuji@53: yuuji@53: (defvar YaTeX-hilit-patterns-alist yuuji@53: '( yuuji@53: ;; comments yuuji@56: (YaTeX-19-region-comment "\\([^\\]\\|^\\)\\(%\\).*$" comment) yuuji@53: yuuji@53: (YaTeX-19-region-section-type "\\\\footnote\\(mark\\|text\\)?{" keyword) yuuji@53: ("\\\\[a-z]+box" 0 keyword) yuuji@53: (YaTeX-19-region-section-type "\\\\\\(v\\|h\\)space\\(\*\\)?{" keyword) yuuji@53: yuuji@53: ;; (re-)define new commands/environments/counters yuuji@53: (YaTeX-19-region-section-type yuuji@53: "\\\\\\(re\\)?new\\(environment\\|command\\|theorem\\){" defun) yuuji@53: (YaTeX-19-region-section-type yuuji@53: "\\\\\\(re\\)?new\\(length\\|counter\\){" define) yuuji@53: yuuji@53: ;; various declarations/definitions yuuji@53: (YaTeX-19-region-section-type yuuji@53: "\\\\\\(set\\|setto\\|addto\\)\\(length\\|width\\|counter\\){" yuuji@53: define) yuuji@53: (YaTeX-19-region-section-type yuuji@53: "\\\\\\(title\\|author\\|date\\|thanks\\){" define) yuuji@53: yuuji@53: ("\\\\documentstyle\\(\\[.*\\]\\)?{" "}" decl) yuuji@53: ("\\\\\\(begin\\|end\\|nofiles\\|includeonly\\){" "}" decl) yuuji@53: ("\\\\\\(raggedright\\|makeindex\\|makeglossary\\|maketitle\\)\\b" 0 decl) yuuji@53: ("\\\\\\(pagestyle\\|thispagestyle\\|pagenumbering\\){" "}" decl) yuuji@53: ("\\\\\\(normalsize\\|small\\|footnotesize\\|scriptsize\\|tiny\\|large\\|Large\\|LARGE\\|huge\\|Huge\\)\\b" 0 decl) yuuji@53: ("\\\\\\(appendix\\|tableofcontents\\|listoffigures\\|listoftables\\)\\b" yuuji@53: 0 decl) yuuji@53: ("\\\\\\(bf\\|em\\|it\\|rm\\|sf\\|sl\\|ss\\|tt\\)\\b" 0 decl) yuuji@53: yuuji@53: ;; label-like things yuuji@53: ;;this should be customized by YaTeX-item-regexp yuuji@53: ("\\\\\\(sub\\)*item\\b\\(\\[[^]]*\\]\\)?" 0 label) yuuji@53: (YaTeX-19-region-section-type yuuji@53: "\\\\caption\\(\\[[^]]*\\]\\)?{" label) yuuji@53: yuuji@53: ;; formulas yuuji@53: ("[^\\]\\\\(" "\\\\)" formula) ; \( \) yuuji@53: ("[^\\]\\\\\\[" "\\\\\\]" formula) ; \[ \] yuuji@53: ("\\\\begin{\\(eqn\\|equation\\)" "\\\\end{\\(eqn\\|equation\\)" formula) yuuji@53: ("[^\\$]\\($\\($[^$]*\\$\\|[^$]*\\)\\$\\)" 1 formula) ; '$...$' or '$$...$$' yuuji@53: yuuji@53: ;; things that bring in external files yuuji@53: ("\\\\\\(include\\|input\\|bibliography\\){" "}" include) yuuji@53: yuuji@53: ;; "wysiwyg" emphasis -- these don't work with nested expressions yuuji@56: (YaTeX-19-region-large-type "{\\\\\\(em\\|it\\|sl\\)" italic) yuuji@53: (YaTeX-19-region-large-type "{\\\\bf" bold) yuuji@56: ;;;(YaTeX-19-region-large-type "{\\\\tt" tt) yuuji@56: ;;;("\\\\begin{verbatim" "\\\\end{verbatim" tt) yuuji@53: yuuji@53: ("``" "''" string) yuuji@53: yuuji@53: ;; things that do some sort of cross-reference yuuji@53: (YaTeX-19-region-section-type yuuji@53: "\\\\\\(\\(no\\)?cite\\|\\(page\\)?ref\\|label\\|index\\|glossary\\){" yuuji@53: crossref) yuuji@53: ) yuuji@53: "*Hiliting pattern alist for LaTeX text.") yuuji@53: yuuji@53: ;;(defvar YaTeX-hilit-pattern-adjustment-default nil) yuuji@53: ;; ↑いらなくなった。 yuuji@51: (defvar YaTeX-hilit-pattern-adjustment-private nil yuuji@53: "*Adjustment hilit-pattern-alist for default yatex-mode's pattern.") yuuji@46: (defvar YaTeX-hilit-sectioning-face yuuji@57: '(yellow/dodgerblue yellow/slateblue) yuuji@51: "*Hilightening face for sectioning unit. '(FaceForLight FaceForDark)") yuuji@57: (defvar YaTeX-hilit-sectioning-attenuation-rate yuuji@57: '(15 40) yuuji@57: "*Maximum attenuation rate of sectioning face. '(ForeRate BackRate) yuuji@57: Each rate specifies how much portion of RGB value should be attenuated yuuji@57: towards to lowest sectioning unit. Numbers should be written in percentage.") yuuji@52: (defvar YaTeX-sectioning-patterns-alist nil yuuji@52: "Hilightening patterns for sectioning units.") yuuji@47: (defvar YaTeX-hilit-singlecmd-face yuuji@51: '(slateblue2 aquamarine) yuuji@51: "*Hilightening face for maketitle type. '(FaceForLight FaceForDark)") yuuji@52: yuuji@52: ;;; セクションコマンドを、構造レベルの高さに応じて色の濃度を変える yuuji@52: ;;; 背景が黒でないと何が嬉しいのか分からないに違いない. yuuji@53: ;;; もしかして白地の時は構造レベルに応じて色を明るくしたほうが良いのか? yuuji@53: (cond yuuji@53: ((and (featurep 'hilit19) (fboundp 'x-color-values)) yuuji@53: (let*((sectface yuuji@53: (car (if (eq hilit-background-mode 'dark) yuuji@53: (cdr YaTeX-hilit-sectioning-face) yuuji@53: YaTeX-hilit-sectioning-face))) yuuji@53: (sectcol (symbol-name sectface)) yuuji@53: sect-pat-alist) yuuji@53: (if (string-match "/" sectcol) yuuji@57: (let ((fmin (nth 0 YaTeX-hilit-sectioning-attenuation-rate)) yuuji@57: (bmin (nth 1 YaTeX-hilit-sectioning-attenuation-rate)) yuuji@57: colorvalue fR fG fB bR bG bB pat fg bg level from face list lm) yuuji@53: (require 'yatexsec) yuuji@53: (setq fg (substring sectcol 0 (string-match "/" sectcol)) yuuji@53: bg (substring sectcol (1+ (string-match "/" sectcol))) yuuji@53: colorvalue (x-color-values fg) yuuji@53: fR (/ (nth 0 colorvalue) 256) yuuji@53: fG (/ (nth 1 colorvalue) 256) yuuji@53: fB (/ (nth 2 colorvalue) 256) yuuji@53: colorvalue (x-color-values bg) yuuji@53: bR (/ (nth 0 colorvalue) 256) yuuji@53: bG (/ (nth 1 colorvalue) 256) yuuji@53: bB (/ (nth 2 colorvalue) 256) yuuji@57: lm YaTeX-sectioning-max-level yuuji@53: list YaTeX-sectioning-level) yuuji@53: (while list yuuji@53: (setq pat (concat YaTeX-ec-regexp (car (car list)) "\\*?{") yuuji@53: level (cdr (car list)) yuuji@53: fg (format "hex-%02x%02x%02x" yuuji@57: (- fR (/ (* level fR fmin) lm 100)) yuuji@57: (- fG (/ (* level fG fmin) lm 100)) yuuji@57: (- fB (/ (* level fB fmin) lm 100))) yuuji@53: bg (format "hex-%02x%02x%02x" yuuji@57: (- bR (/ (* level bR bmin) lm 100)) yuuji@57: (- bG (/ (* level bG bmin) lm 100)) yuuji@57: (- bB (/ (* level bB bmin) lm 100))) yuuji@53: from (intern (format "sectioning-%d" level)) yuuji@53: face (intern (concat fg "/" bg))) yuuji@53: (hilit-translate from face) yuuji@53: (setq sect-pat-alist yuuji@53: (cons;;(list pat "}" face) yuuji@53: (list 'YaTeX-19-region-section-type pat face) yuuji@53: sect-pat-alist)) yuuji@53: (setq list (cdr list))) yuuji@53: (setq YaTeX-sectioning-patterns-alist sect-pat-alist)))))) yuuji@52: yuuji@53: ;; ローカルなマクロを読み込んだ後 redraw すると yuuji@53: ;; ローカルマクロを keyword として光らせる(keywordじゃまずいかな…)。 yuuji@53: (defun YaTeX-19-collect-macros () yuuji@46: (cond yuuji@46: ((and (featurep 'hilit19) (fboundp 'hilit-translate)) yuuji@47: (let ((get-face yuuji@47: (function yuuji@47: (lambda (table) yuuji@47: (cond yuuji@47: ((eq hilit-background-mode 'light) (car table)) yuuji@47: ((eq hilit-background-mode 'dark) (car (cdr table))) yuuji@57: (t nil))))) yuuji@57: sect single) yuuji@47: (hilit-translate yuuji@52: ;;sectioning (funcall get-face YaTeX-hilit-sectioning-face) yuuji@57: macro (funcall get-face YaTeX-hilit-singlecmd-face)) yuuji@57: (if (setq sect (append user-section-table tmp-section-table)) yuuji@57: (setq sect (concat "\\\\\\(" yuuji@57: (mapconcat yuuji@57: (function yuuji@57: (lambda (s) (regexp-quote (car s)))) yuuji@57: sect yuuji@57: "\\|") yuuji@57: "\\){"))) yuuji@57: (if (setq single (append user-singlecmd-table tmp-singlecmd-table)) yuuji@57: (setq single (concat "\\\\\\(" yuuji@57: (mapconcat yuuji@57: (function (lambda (s) (regexp-quote (car s)))) yuuji@57: single yuuji@57: "\\|") yuuji@57: "\\)\\b"))) yuuji@57: (setq hilit-patterns-alist ;Remove at first. yuuji@57: (delq (assq 'yatex-mode hilit-patterns-alist) hilit-patterns-alist) yuuji@57: hilit-patterns-alist yuuji@57: (cons yuuji@57: (cons 'yatex-mode yuuji@57: (append yuuji@57: (list nil) yuuji@57: YaTeX-sectioning-patterns-alist yuuji@57: YaTeX-hilit-pattern-adjustment-private yuuji@57: ;;YaTeX-hilit-pattern-adjustment-default yuuji@57: YaTeX-hilit-patterns-alist yuuji@57: (delq nil yuuji@57: (list yuuji@57: (if sect (list yuuji@57: 'YaTeX-19-region-section-type yuuji@57: sect yuuji@57: 'keyword)) yuuji@57: (if single (list single 0 'macro)))))) yuuji@57: hilit-patterns-alist)))))) yuuji@53: ;;(YaTeX-19-collect-macros) ;causes an error yuuji@46: (defun YaTeX-hilit-recenter (arg) yuuji@46: "Collect current local macro and hilit-recenter." yuuji@46: (interactive "P") yuuji@53: (YaTeX-19-collect-macros) yuuji@46: (hilit-recenter arg)) yuuji@46: (if (fboundp 'hilit-recenter) ;Replace hilit-recenter with yuuji@46: (mapcar (function (lambda (key) ;YaTeX-hilit-recenter in yatex-mode yuuji@46: (define-key YaTeX-mode-map key 'YaTeX-hilit-recenter))) yuuji@46: (where-is-internal 'hilit-recenter))) yuuji@46: yuuji@53: (defun YaTeX-switch-to-new-window () yuuji@53: (let ((c 0) (i 1) (free (make-string win:max-configs ? ))) yuuji@53: (while (< i win:max-configs) yuuji@53: (or (aref win:configs i) (aset free i (+ i win:base-key))) yuuji@53: (setq i (1+ i))) yuuji@53: (while (not (string-match (char-to-string c) free)) yuuji@53: (message "Which window to create? [%s]: " free) yuuji@53: (setq c (read-char))) yuuji@53: (message "Creating window [%c]" c) yuuji@53: (set-buffer (get-buffer-create "*scratch*")) yuuji@53: (win:switch-window (- c win:base-key)))) yuuji@53: yuuji@53: (defun YaTeX-visit-main-other-frame () yuuji@53: "Visit main file in other frame. yuuji@53: WARNING, This code is not perfect." yuuji@53: (interactive) yuuji@53: (if (YaTeX-main-file-p) (message "I think this is main LaTeX source.") yuuji@53: (let (parent) yuuji@53: (save-excursion (YaTeX-visit-main t) (setq parent (current-buffer))) yuuji@53: (cond yuuji@53: ((get-buffer-window parent t) yuuji@53: (goto-buffer-window parent)) yuuji@53: ((and (featurep 'windows) win:use-frame) yuuji@53: (YaTeX-switch-to-new-window) yuuji@53: (switch-to-buffer parent)) yuuji@53: (t (switch-to-buffer-other-frame (buffer-name parent))))))) yuuji@53: yuuji@53: (defun YaTeX-goto-corresponding-*-other-frame (arg) yuuji@53: "Go to corresponding object in other frame." yuuji@53: (interactive "P") yuuji@53: (let (b p) yuuji@53: (save-window-excursion yuuji@53: (save-excursion yuuji@53: (YaTeX-goto-corresponding-* arg) yuuji@53: (setq b (current-buffer) p (point)))) yuuji@53: (cond yuuji@53: ((get-buffer-window b t) yuuji@53: (goto-buffer-window b) yuuji@53: (goto-char p)) yuuji@53: ((and (featurep 'windows) win:use-frame) yuuji@53: (YaTeX-switch-to-new-window) yuuji@53: (switch-to-buffer b) yuuji@53: (goto-char p)) yuuji@53: (t (switch-to-buffer-other-frame (buffer-name b)) yuuji@53: (goto-char p)))) yuuji@53: ) yuuji@53: yuuji@49: ;;; reverseVideo にして hilit-background-mode を 'dark yuuji@49: ;;; にしている人は数式などが暗くなりすぎて見づらいかもしれない。 yuuji@49: ;;; 次のコードを hilit19 をロードしている場所の直後に置くとちょっ yuuji@49: ;;; とはまし。 yuuji@46: ;;; (if (eq hilit-background-mode 'dark) yuuji@46: ;;; (hilit-translate yuuji@46: ;;; string 'mediumspringgreen yuuji@46: ;;; formula 'khaki yuuji@46: ;;; label 'yellow-underlined)) yuuji@57: (and YaTeX-emacs-19 yuuji@57: (eval-when-compile yuuji@57: (if (and (boundp 'window-system) window-system) yuuji@57: (require 'hilit19) yuuji@57: (error "Byte compile this file on window system! Not `-nw'!")))) yuuji@46: yuuji@46: (provide 'yatex19)