annotate yatexlib.el @ 493:a9f39600366a

Added tag yatex-1.80 for changeset a2bb2426a154
author HIROSE Yuuji <yuuji@gentei.org>
date Sun, 10 Sep 2017 21:47:29 +0859
parents 6dcd746db62e
children c0827f80b18e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
395
5aa8208fbef0 Change header lines.
HIROSE Yuuji <yuuji@gentei.org>
parents: 393
diff changeset
1 ;;; yatexlib.el --- YaTeX and yahtml common libraries -*- coding: sjis -*-
287
5921f28ef77c Change the first lines.
HIROSE Yuuji <yuuji@gentei.org>
parents: 266
diff changeset
2 ;;;
443
7a9d30752353 Release preparation
HIROSE Yuuji <yuuji@gentei.org>
parents: 395
diff changeset
3 ;;; (c)1994-2017 by HIROSE Yuuji.[yuuji@yatex.org]
483
6dcd746db62e DOC string fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 482
diff changeset
4 ;;; Last modified Sun Sep 10 21:16:11 2017 on firestorm
368
8ee8514e06ed Start for 1.79
HIROSE Yuuji <yuuji@gentei.org>
parents: 364
diff changeset
5 ;;; $Id$
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
6
287
5921f28ef77c Change the first lines.
HIROSE Yuuji <yuuji@gentei.org>
parents: 266
diff changeset
7 ;;; Code:
451
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
8
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
9 ;; High-precedence compatible function
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
10 (fset 'YaTeX-str2int
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
11 (if (fboundp 'string-to-number)
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
12 (function
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
13 (lambda (string &optional base)
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
14 (ceiling (string-to-number string base))))
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
15 'string-to-int))
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
16
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
17 ;; General variables
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
18 (defvar YaTeX-dos (memq system-type '(ms-dos windows-nt OS/2)))
79
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
19 (defvar YaTeX-macos (memq system-type '(darwin)))
451
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
20 (defvar YaTeX-emacs-19 (>= (YaTeX-str2int emacs-version) 19))
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
21 (defvar YaTeX-emacs-20 (>= (YaTeX-str2int emacs-version) 20))
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
22 (defvar YaTeX-emacs-21 (>= (YaTeX-str2int emacs-version) 21))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
23 (defvar YaTeX-user-completion-table
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
24 (if YaTeX-dos "~/_yatexrc" "~/.yatexrc")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
25 "*Default filename in which user completion table is saved.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
26
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
27 (defvar YaTeX-display-color-p
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
28 (or (and (fboundp 'display-color-p) (display-color-p))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
29 (and (fboundp 'device-class)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
30 (eq 'color (device-class (selected-device))))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
31 window-system) ; falls down lazy check..
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
32 "Current display's capability of expressing colors.")
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
33
79
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
34 (defvar YaTeX-japan
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
35 (or (boundp 'NEMACS)
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
36 (boundp 'MULE)
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
37 (and (boundp 'current-language-environment)
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
38 (string-match "[Jj]apanese" current-language-environment)))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
39 "Whether yatex mode is running on Japanese environment or not.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
40
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
41 ;; autoload from yahtml.el
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
42 (autoload 'yahtml-inner-environment-but "yahtml" "yahtml internal func." t)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
43
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
44 (defvar latex-message-kanji-code 2
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
45 "*Kanji coding system latex command types out.
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
46 1 = Shift JIS, 2 = JIS, 3 = EUC. 4 = UTF-8")
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
47
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
48 (defvar YaTeX-kanji-code-alist
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
49 (cond
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
50 ((boundp '*junet*)
77
1b172d26b55e Fix auto-fill movement on Emacs21.
yuuji
parents: 73
diff changeset
51 (list '(0 . *noconv*)
1b172d26b55e Fix auto-fill movement on Emacs21.
yuuji
parents: 73
diff changeset
52 (cons
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
53 1
79
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
54 (cond
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
55 (YaTeX-dos (if (boundp '*sjis-dos*) *sjis-dos* *sjis*dos))
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
56 (YaTeX-macos (if (boundp '*sjis-mac*) *sjis-mac* *sjis*mac))
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
57 (t *sjis*)))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
58 '(2 . *junet*) '(3 . *euc-japan*)))
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
59 ((and YaTeX-emacs-20 (featurep 'mule))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
60 ;;(cdr-safe(assq 'coding-system (assoc "Japanese" language-info-alist)))
77
1b172d26b55e Fix auto-fill movement on Emacs21.
yuuji
parents: 73
diff changeset
61 (list '(0 . no-conversion)
1b172d26b55e Fix auto-fill movement on Emacs21.
yuuji
parents: 73
diff changeset
62 (cons
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
63 1 (cond (YaTeX-dos 'shift_jis-dos)
79
0734be649cb8 Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents: 77
diff changeset
64 (YaTeX-macos 'shift_jis-mac)
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
65 ((member 'shift_jis (coding-system-list)) 'shift_jis-unix)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
66 (t 'sjis)))
68
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
67 '(2 . iso-2022-jp-unix)
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
68 '(3 . euc-jp-unix)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
69 '(4 . utf-8))))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
70 "Kanji-code expression translation table.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
71 (defvar YaTeX-inhibit-prefix-letter nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
72 "*T for changing key definitions from [prefix] Letter to [prefix] C-Letter.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
73
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
74 (defvar YaTeX-no-begend-shortcut nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
75 "*T for disabling shortcut of begin-type completion, [prefix] b d, etc.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
76
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
77 (defvar YaTeX-default-pop-window-height 10
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
78 "Default typesetting buffer height.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
79 If integer, sets the window-height of typesetting buffer.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
80 If string, sets the percentage of it.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
81 If nil, use default pop-to-buffer.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
82
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
83 (defvar YaTeX-create-file-prefix-g nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
84 "*Non-nil creates new file when [prefix] g on \\include{foo}.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
85
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
86 (defvar YaTeX-nervous t
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
87 "*If you are nervous about maintenance of yatexrc, set this value to T.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
88 And you will have the local dictionary.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
89
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
90 (defvar YaTeX-use-italic-bold (string< "20" emacs-version)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
91 "*Non-nil tries to find italic/bold fontset.
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
92 This variable is effective when font-lock is used.
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
93 \it, \bf 内部での日本語が□になってしまう場合はこれをnilにして下さい。")
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
94
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
95 ;----------- work variables ----------------------------------------
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
96 (defvar YaTeX-minibuffer-completion-map nil
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
97 "Minibuffer completion key map that allows comma completion.")
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
98 (if YaTeX-minibuffer-completion-map nil
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
99 (setq YaTeX-minibuffer-completion-map
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
100 (copy-keymap minibuffer-local-completion-map))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
101 (define-key YaTeX-minibuffer-completion-map " "
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
102 'YaTeX-minibuffer-complete)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
103 (define-key YaTeX-minibuffer-completion-map "\t"
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
104 'YaTeX-minibuffer-complete))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
105
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
106 (defvar YaTeX-typesetting-mode-map nil
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
107 "Keymap used in YaTeX typesetting buffer")
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
108
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
109 (if YaTeX-typesetting-mode-map nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
110 (setq YaTeX-typesetting-mode-map (make-keymap))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
111 ;(suppress-keymap YaTeX-typesetting-mode-map t)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
112 (define-key YaTeX-typesetting-mode-map " " 'YaTeX-jump-error-line)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
113 (define-key YaTeX-typesetting-mode-map "\C-m" 'YaTeX-send-string)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
114 (define-key YaTeX-typesetting-mode-map "1" 'delete-other-windows)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
115 (define-key YaTeX-typesetting-mode-map "0" 'delete-window)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
116 (define-key YaTeX-typesetting-mode-map "q" 'delete-window))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
117
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
118 (defvar YaTeX-parent-file nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
119 "*Main LaTeX source file name used when %#! expression doesn't exist.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
120 (make-variable-buffer-local 'YaTeX-parent-file)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
121
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
122 ;---------- Define default key bindings on YaTeX mode map ----------
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
123 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
124 (defun YaTeX-define-key (key binding &optional map)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
125 "Define key on YaTeX-prefix-map."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
126 (if YaTeX-inhibit-prefix-letter
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
127 (let ((c (aref key 0)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
128 (cond
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
129 ((and (>= c ?a) (<= c ?z)) (aset key 0 (1+ (- c ?a))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
130 ((and (>= c ?A) (<= c ?Z) (numberp YaTeX-inhibit-prefix-letter))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
131 (aset key 0 (1+ (- c ?A))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
132 (t nil))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
133 (define-key (or map YaTeX-prefix-map) key binding))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
134
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
135 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
136 (defun YaTeX-local-table-symbol (symbol)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
137 "Return the lisp symbol which keeps local completion table of SYMBOL."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
138 (intern (concat "YaTeX$"
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
139 default-directory
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
140 (symbol-name symbol))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
141
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
142 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
143 (defun YaTeX-sync-local-table (symbol)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
144 "Synchronize local variable SYMBOL.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
145 Copy its corresponding directory dependent completion table to SYMBOL."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
146 (if (boundp (YaTeX-local-table-symbol symbol))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
147 (set symbol (symbol-value (YaTeX-local-table-symbol symbol)))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
148
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
149 (defvar YaTeX-user-table-is-read nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
150 "Flag that means whether user completion table has been read or not.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
151 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
152 (defun YaTeX-read-user-completion-table (&optional forcetoread)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
153 "Append user completion table of LaTeX macros"
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
154 (interactive)
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
155 (let*((user-table (expand-file-name YaTeX-user-completion-table))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
156 (local-table (expand-file-name (file-name-nondirectory user-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
157 var localvar localbuf (curbuf (current-buffer)) sexp)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
158 (if YaTeX-user-table-is-read nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
159 (message "Loading user completion table")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
160 (if (file-exists-p user-table) (load-file user-table)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
161 (message "Welcome to the field of YaTeX. I'm glad to see you!")))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
162 (setq YaTeX-user-table-is-read t)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
163 (cond
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
164 ((file-exists-p local-table)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
165 (set-buffer (setq localbuf (find-file-noselect local-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
166 (widen)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
167 (goto-char (point-min))
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
168 (while (re-search-forward "(setq \\([^ \t\n]+\\)" nil t)
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
169 (setq var (intern (buffer-substring
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
170 (match-beginning 1) (match-end 1)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
171 localvar (YaTeX-local-table-symbol var))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
172 (goto-char (match-beginning 0))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
173 (setq sexp (buffer-substring (point)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
174 (progn (forward-sexp) (point))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
175 (set-buffer curbuf)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
176 (or (assq var (buffer-local-variables)) (make-local-variable var))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
177 (eval (read sexp))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
178 (or (and (boundp localvar)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
179 (symbol-value localvar)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
180 (not forcetoread))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
181 (set localvar (symbol-value var)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
182 (set-buffer localbuf))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
183 (kill-buffer localbuf)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
184 (set-buffer curbuf)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
185
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
186 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
187 (defun YaTeX-reload-dictionary ()
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
188 "Reload local dictionary.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
189 Use this function after editing ./.yatexrc."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
190 (interactive)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
191 (let ((YaTeX-user-table-is-read nil))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
192 (YaTeX-read-user-completion-table t)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
193
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
194 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
195 (defun YaTeX-lookup-table (word type)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
196 "Lookup WORD in completion table whose type is TYPE.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
197 This function refers the symbol tmp-TYPE-table, user-TYPE-table, TYPE-table.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
198 Typically, TYPE is one of 'env, 'section, 'fontsize, 'singlecmd."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
199 (if (symbolp type) (setq type (symbol-name type)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
200 (or (assoc word (symbol-value (intern (concat "tmp-" type "-table"))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
201 (assoc word (symbol-value (intern (concat "user-" type "-table"))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
202 (assoc word (symbol-value (intern (concat type "-table"))))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
203
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
204 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
205 (defun YaTeX-update-table (vallist default-table user-table local-table)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
206 "Update completion table if the car of VALLIST is not in current tables.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
207 Second argument DEFAULT-TABLE is the quoted symbol of default completion
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
208 table, third argument USER-TABLE is user table which will be saved in
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
209 YaTeX-user-completion-table, fourth argument LOCAL-TABLE should have the
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
210 completion which is valid during current Emacs's session. If you
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
211 want to make LOCAL-TABLE valid longer span (but restrict in this directory)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
212 create the file in current directory which has the same name with
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
213 YaTeX-user-completion-table."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
214 (let ((car-v (car vallist)) key answer
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
215 (file (file-name-nondirectory YaTeX-user-completion-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
216 (cond
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
217 ((assoc car-v (symbol-value default-table))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
218 nil) ;Nothing to do
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
219 ((setq key (assoc car-v (symbol-value user-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
220 (if (equal (cdr vallist) (cdr key)) nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
221 ;; if association hits, but contents differ.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
222 (message
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
223 "%s's attributes turned into %s" (car vallist) (cdr vallist))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
224 (set user-table (delq key (symbol-value user-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
225 (set user-table (cons vallist (symbol-value user-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
226 (YaTeX-update-dictionary
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
227 YaTeX-user-completion-table user-table "user")))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
228 ((setq key (assoc car-v (symbol-value local-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
229 (if (equal (cdr vallist) (cdr key)) nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
230 (message
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
231 "%s's attributes turned into %s" (car vallist) (cdr vallist))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
232 (set local-table (delq key (symbol-value local-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
233 (set local-table (cons vallist (symbol-value local-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
234 (set (YaTeX-local-table-symbol local-table) (symbol-value local-table))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
235 (YaTeX-update-dictionary file local-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
236 ;; All of above cases, there are some completion in tables.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
237 ;; Then update tables.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
238 (t
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
239 (if (not YaTeX-nervous)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
240 (setq answer "u")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
241 (message
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
242 (cond
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
243 (YaTeX-japan
68
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
244 "`%s'の登録先: U)ユーザ辞書 L)ローカル辞書 N)メモリ D)しない")
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
245 (t
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
246 "Register `%s' into: U)serDic L)ocalDic N)one D)iscard"))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
247 (if (> (length car-v) 23)
68
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
248 (concat (substring car-v 0 10) "..." (substring car-v -9))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
249 car-v))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
250 (setq answer (char-to-string (read-char))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
251 (cond
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
252 ((string-match answer "uy")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
253 (set user-table (cons vallist (symbol-value user-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
254 (YaTeX-update-dictionary YaTeX-user-completion-table user-table "user")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
255 )
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
256 ((string-match answer "tl")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
257 (set local-table (cons vallist (symbol-value local-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
258 (set (YaTeX-local-table-symbol local-table) (symbol-value local-table))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
259 (YaTeX-update-dictionary file local-table))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
260 ((string-match answer "d") nil) ;discard it
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
261 (t (set default-table
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
262 (cons vallist (symbol-value default-table)))))))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
263
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
264 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
265 (defun YaTeX-cplread-with-learning
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
266 (prom default-table user-table local-table
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
267 &optional pred reqmatch init hsym)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
268 "Completing read with learning.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
269 Do a completing read with prompt PROM. Completion table is what
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
270 DEFAULT-TABLE, USER-TABLE, LOCAL table are appended in reverse order.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
271 Note that these tables are passed by the symbol.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
272 Optional arguments PRED, REQMATH and INIT are passed to completing-read
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
273 as its arguments PREDICATE, REQUIRE-MATCH and INITIAL-INPUT respectively.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
274 If optional 8th argument HSYM, history symbol, is passed, use it as
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
275 history list variable."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
276 (YaTeX-sync-local-table local-table)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
277 (let*((table (append (symbol-value local-table)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
278 (symbol-value user-table)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
279 (symbol-value default-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
280 (word (completing-read-with-history
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
281 prom table pred reqmatch init hsym)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
282 (if (and (string< "" word) (not (assoc word table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
283 (YaTeX-update-table (list word) default-table user-table local-table))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
284 word))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
285
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
286 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
287 (defun YaTeX-update-dictionary (file symbol &optional type)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
288 (let ((local-table-buf (find-file-noselect file))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
289 (name (symbol-name symbol))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
290 (value (symbol-value symbol)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
291 (save-excursion
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
292 (message "Updating %s dictionary..." (or type "local"))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
293 (set-buffer local-table-buf)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
294 (goto-char (point-max))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
295 (search-backward (concat "(setq " name) nil t)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
296 (delete-region (point) (progn (forward-sexp) (point)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
297 (delete-blank-lines)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
298 (insert "(setq " name " '(\n")
353
2a72779d9c50 Rewrite lambda notations to suppress annoying warnings from emacs24
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
299 (mapcar (function (lambda (s)
2a72779d9c50 Rewrite lambda notations to suppress annoying warnings from emacs24
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
300 (insert (format "%s\n" (prin1-to-string s)))))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
301 value)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
302 (insert "))\n\n")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
303 (delete-blank-lines)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
304 (basic-save-buffer)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
305 (kill-buffer local-table-buf)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
306 (message "Updating %s dictionary...Done" (or type "local")))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
307
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
308 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
309 (defun YaTeX-define-begend-key-normal (key env &optional map)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
310 "Define short cut YaTeX-make-begin-end key."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
311 (YaTeX-define-key
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
312 key
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
313 (list 'lambda '(arg) '(interactive "P")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
314 (list 'YaTeX-insert-begin-end env 'arg))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
315 map))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
316
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
317 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
318 (defun YaTeX-define-begend-region-key (key env &optional map)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
319 "Define short cut YaTeX-make-begin-end-region key."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
320 (YaTeX-define-key key (list 'lambda nil '(interactive)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
321 (list 'YaTeX-insert-begin-end env t)) map))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
322
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
323 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
324 (defun YaTeX-define-begend-key (key env &optional map)
86
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
325 "Define short cut key for begin type completion.
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
326 Define both strokes for normal and region mode.
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
327 To customize YaTeX, user should use this function."
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
328 (YaTeX-define-begend-key-normal key env map)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
329 (if YaTeX-inhibit-prefix-letter nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
330 (YaTeX-define-begend-region-key
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
331 (concat (upcase (substring key 0 1)) (substring key 1)) env)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
332
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
333 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
334 (defun YaTeX-search-active-forward (string cmntrx &optional bound err cnt func)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
335 "Search STRING which is not commented out by CMNTRX.
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
336 Optional arguments after BOUND, ERR, CNT are passed literally to search-forward
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
337 or search-backward.
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
338 Optional sixth argument FUNC changes search-function."
49
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 47
diff changeset
339 (let ((sfunc (or func 'search-forward)) found md)
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
340 (while (and (prog1
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
341 (setq found (funcall sfunc string bound err cnt))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
342 (setq md (match-data)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
343 (or
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
344 (and (eq major-mode 'yatex-mode)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
345 (YaTeX-in-verb-p (match-beginning 0)))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
346 (save-excursion
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
347 (goto-char (match-beginning 0))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
348 (beginning-of-line)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
349 (re-search-forward cmntrx (match-beginning 0) t)))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
350 (store-match-data md)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
351 found))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
352
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
353 (defun YaTeX-re-search-active-forward (regexp cmntrx &optional bound err cnt)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
354 "Search REGEXP backward which is not commented out by regexp CMNTRX.
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
355 See also YaTeX-search-active-forward."
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
356 (YaTeX-search-active-forward regexp cmntrx bound err cnt 're-search-forward))
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
357
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
358 (defun YaTeX-search-active-backward (string cmntrx &optional bound err cnt)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
359 "Search STRING backward which is not commented out by regexp CMNTRX.
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
360 See also YaTeX-search-active-forward."
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
361 (YaTeX-search-active-forward string cmntrx bound err cnt 'search-backward))
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
362
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
363 (defun YaTeX-re-search-active-backward (regexp cmntrx &optional bound err cnt)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
364 "Search REGEXP backward which is not commented out by regexp CMNTRX.
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
365 See also YaTeX-search-active-forward."
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
366 (YaTeX-search-active-forward
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
367 regexp cmntrx bound err cnt 're-search-backward))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
368
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
369 (defun YaTeX-relative-path-p (path)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
370 "Return non-nil if PATH is not absolute one."
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
371 (let ((md (match-data)))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
372 (unwind-protect
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
373 (not (string-match "^\\(/\\|[a-z]:\\|\\\\\\).*/" file))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
374 (store-match-data md))))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
375
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
376 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
377 (defun YaTeX-switch-to-buffer (file &optional setbuf)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
378 "Switch to buffer if buffer exists, find file if not.
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
379 Optional second arg SETBUF t make use set-buffer instead of switch-to-buffer."
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
380 (interactive "Fswitch to file: ")
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
381 (if (bufferp file)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
382 (setq file (buffer-file-name file))
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
383 (and (YaTeX-relative-path-p file)
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
384 (eq major-mode 'yatex-mode)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
385 YaTeX-search-file-from-top-directory
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
386 (save-excursion
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
387 (YaTeX-visit-main t)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
388 (setq file (expand-file-name file)))))
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
389 (let (buf (hilit-auto-highlight (not setbuf)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
390 (cond
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
391 ((setq buf (get-file-buffer file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
392 (funcall (if setbuf 'set-buffer 'switch-to-buffer)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
393 (get-file-buffer file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
394 buf)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
395 ((or YaTeX-create-file-prefix-g (file-exists-p file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
396 (or ;find-file returns nil but set current-buffer...
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
397 (if setbuf (set-buffer (find-file-noselect file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
398 (find-file file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
399 (current-buffer)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
400 (t (message "%s was not found in this directory." file)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
401 nil))))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
402
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
403 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
404 (defun YaTeX-switch-to-buffer-other-window (file)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
405 "Switch to buffer if buffer exists, find file if not."
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
406 (interactive "Fswitch to file: ")
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
407 (and (eq major-mode 'yatex-mode)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
408 (stringp file)
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
409 (YaTeX-relative-path-p file)
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
410 YaTeX-search-file-from-top-directory
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
411 (save-excursion
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
412 (YaTeX-visit-main t)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
413 (setq file (expand-file-name file))))
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
414 (if (bufferp file) (setq file (buffer-file-name file)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
415 (cond
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
416 ((get-file-buffer file)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
417 (switch-to-buffer-other-window (get-file-buffer file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
418 t)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
419 ((or YaTeX-create-file-prefix-g (file-exists-p file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
420 (find-file-other-window file) t)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
421 (t (message "%s was not found in this directory." file)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
422 nil)))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
423
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
424 (defun YaTeX-get-file-buffer (file)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
425 "Return the FILE's buffer.
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
426 Base directory is that of main file or current directory."
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
427 (let (dir main (cdir default-directory))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
428 (or (and (eq major-mode 'yatex-mode)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
429 YaTeX-search-file-from-top-directory
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
430 (save-excursion
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
431 (YaTeX-visit-main t)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
432 (get-file-buffer file)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
433 (get-file-buffer file))))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
434
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
435 (defun YaTeX-replace-format-sub (string format repl)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
436 (let ((beg (or (string-match (concat "^\\(%" format "\\)") string)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
437 (string-match (concat "[^%]\\(%" format "\\)") string)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
438 (len (length format)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
439 (if (null beg) string ;no conversion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
440 (concat
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
441 (substring string 0 (match-beginning 1)) (or repl "")
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
442 (substring string (match-end 1))))))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
443
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
444 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
445 (defun YaTeX-replace-format (string format repl)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
446 "In STRING, replace first appearance of FORMAT to REPL as if
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
447 function `format' does. FORMAT does not contain `%'"
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
448 (let ((ans string) (case-fold-search nil))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
449 (while (not (string=
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
450 ans (setq string (YaTeX-replace-format-sub ans format repl))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
451 (setq ans string))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
452 string))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
453
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
454 ;;;###autoload
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
455 (defun YaTeX-replace-formats (string replace-list)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
456 (let ((list replace-list))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
457 (while list
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
458 (setq string (YaTeX-replace-format
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
459 string (car (car list)) (cdr (car list)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
460 list (cdr list)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
461 string))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
462
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
463 ;;;###autoload
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
464 (defun YaTeX-replace-format-args (string &rest args)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
465 "Translate the argument mark #1, #2, ... #n in the STRING into the
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
466 corresponding real arguments ARGS."
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
467 (let ((argp 1))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
468 (while args
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
469 (setq string
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
470 (YaTeX-replace-format string (int-to-string argp) (car args)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
471 (setq args (cdr args) argp (1+ argp))))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
472 string)
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
473
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
474 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
475 (defun rindex (string char)
226
60844b664f54 Add docstring to rindex().
yuuji@gentei.org
parents: 225
diff changeset
476 "Return the last position of STRING where character CHAR found."
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
477 (let ((pos (1- (length string)))(index -1))
174
ab02213f5683 rindex: return nil, instead of -1, if no match found.
yuuji@gentei.org
parents: 168
diff changeset
478 (catch 'rindex
ab02213f5683 rindex: return nil, instead of -1, if no match found.
yuuji@gentei.org
parents: 168
diff changeset
479 (while (>= pos 0)
ab02213f5683 rindex: return nil, instead of -1, if no match found.
yuuji@gentei.org
parents: 168
diff changeset
480 (cond
ab02213f5683 rindex: return nil, instead of -1, if no match found.
yuuji@gentei.org
parents: 168
diff changeset
481 ((= (aref string pos) char)
ab02213f5683 rindex: return nil, instead of -1, if no match found.
yuuji@gentei.org
parents: 168
diff changeset
482 (throw 'rindex pos))
ab02213f5683 rindex: return nil, instead of -1, if no match found.
yuuji@gentei.org
parents: 168
diff changeset
483 (t (setq pos (1- pos))))))))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
484
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
485 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
486 (defun point-beginning-of-line ()
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
487 (save-excursion (beginning-of-line)(point)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
488
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
489 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
490 (defun point-end-of-line ()
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
491 (save-excursion (end-of-line)(point)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
492
354
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
493 (defun YaTeX-showup-buffer-bottom-most (x) (nth 3 (window-edges x)))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
494 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
495 (defun YaTeX-showup-buffer (buffer &optional func select)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
496 "Make BUFFER show up in certain window (but current window)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
497 that gives the maximum value by the FUNC. FUNC should take an argument
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
498 of its window object. Non-nil for optional third argument SELECT selects
49
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 47
diff changeset
499 that window. This function never selects minibuffer window."
86
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
500 (or (and (if (and YaTeX-emacs-19 select window-system)
47
d7e7b4654058 Support special popup frame.
yuuji
parents: 46
diff changeset
501 (get-buffer-window buffer t)
d7e7b4654058 Support special popup frame.
yuuji
parents: 46
diff changeset
502 (get-buffer-window buffer))
d7e7b4654058 Support special popup frame.
yuuji
parents: 46
diff changeset
503 (progn
d7e7b4654058 Support special popup frame.
yuuji
parents: 46
diff changeset
504 (if select
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
505 (goto-buffer-window buffer))
47
d7e7b4654058 Support special popup frame.
yuuji
parents: 46
diff changeset
506 t))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
507 (let ((window (selected-window))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
508 (wlist (YaTeX-window-list)) win w (x 0))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
509 (cond
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
510 ((> (length wlist) 2)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
511 (if func
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
512 (while wlist
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
513 (setq w (car wlist))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
514 (if (and (not (eq window w))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
515 (> (funcall func w) x))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
516 (setq win w x (funcall func w)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
517 (setq wlist (cdr wlist)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
518 (setq win (get-lru-window)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
519 (select-window win)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
520 (switch-to-buffer buffer)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
521 (or select (select-window window)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
522 ((= (length wlist) 2)
49
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 47
diff changeset
523 ;(other-window 1);This does not work properly on Emacs-19
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 47
diff changeset
524 (select-window (get-lru-window))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
525 (switch-to-buffer buffer)
354
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
526 (if (< (window-height) (/ YaTeX-default-pop-window-height 2))
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
527 (enlarge-window (- YaTeX-default-pop-window-height
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
528 (window-height))))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
529 (or select (select-window window)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
530 (t ;if one-window
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
531 (cond
86
f14ec50103d0 as of 2009/9/28
yuuji@gentei.org
parents: 80
diff changeset
532 ((and YaTeX-emacs-19 window-system (get-buffer-window buffer t))
47
d7e7b4654058 Support special popup frame.
yuuji
parents: 46
diff changeset
533 nil) ;if found in other frame
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
534 (YaTeX-default-pop-window-height
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
535 (split-window-calculate-height YaTeX-default-pop-window-height)
59
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
536 ;;(pop-to-buffer buffer) ;damn! emacs-19.30
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
537 (select-window (next-window nil 1))
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
538 (switch-to-buffer (get-buffer-create buffer))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
539 (or select (select-window window)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
540 (t nil)))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
541 ))))
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
542
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
543 (cond
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
544 ((fboundp 'screen-height)
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
545 (fset 'YaTeX-screen-height 'screen-height)
182
67b1e094e151 Direct call to screen-{height,width} avoided for coming emacsen.
yuuji@gentei.org
parents: 174
diff changeset
546 (fset 'YaTeX-screen-width 'screen-width)
67b1e094e151 Direct call to screen-{height,width} avoided for coming emacsen.
yuuji@gentei.org
parents: 174
diff changeset
547 (fset 'YaTeX-set-screen-height 'set-screen-height)
67b1e094e151 Direct call to screen-{height,width} avoided for coming emacsen.
yuuji@gentei.org
parents: 174
diff changeset
548 (fset 'YaTeX-set-screen-width 'set-screen-width))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
549 ((fboundp 'frame-height)
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
550 (fset 'YaTeX-screen-height 'frame-height)
182
67b1e094e151 Direct call to screen-{height,width} avoided for coming emacsen.
yuuji@gentei.org
parents: 174
diff changeset
551 (fset 'YaTeX-screen-width 'frame-width)
67b1e094e151 Direct call to screen-{height,width} avoided for coming emacsen.
yuuji@gentei.org
parents: 174
diff changeset
552 (fset 'YaTeX-set-screen-height 'set-frame-height)
67b1e094e151 Direct call to screen-{height,width} avoided for coming emacsen.
yuuji@gentei.org
parents: 174
diff changeset
553 (fset 'YaTeX-set-screen-width 'set-frame-width))
67b1e094e151 Direct call to screen-{height,width} avoided for coming emacsen.
yuuji@gentei.org
parents: 174
diff changeset
554 (t (error "I don't know how to run YaTeX on this Emacs...")))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
555
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
556 ;;;###autoload
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
557 (defun split-window-calculate-height (height)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
558 "Split current window wight specified HEIGHT.
59
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
559 If HEIGHT is number, make a new window that has HEIGHT lines.
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
560 If HEIGHT is string, make a new window that occupies HEIGT % of screen height.
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
561 Otherwise split window conventionally."
59
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
562 (if (one-window-p t)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
563 (split-window
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
564 (selected-window)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
565 (max
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
566 (min
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
567 (- (YaTeX-screen-height)
59
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
568 (if (numberp height)
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
569 (+ height 2)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
570 (/ (* (YaTeX-screen-height)
451
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
571 (YaTeX-str2int height))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
572 100)))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
573 (- (YaTeX-screen-height) window-min-height 1))
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
574 window-min-height))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
575
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
576 ;;;###autoload
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
577 (defun YaTeX-window-list ()
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
578 (let*((curw (selected-window)) (win curw) (wlist (list curw)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
579 (while (not (eq curw (setq win (next-window win))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
580 (or (eq win (minibuffer-window))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
581 (setq wlist (cons win wlist))))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
582 wlist))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
583
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
584 (if YaTeX-emacs-21
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
585 ;; Emacs-21's next-window returns other frame's window even if called
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
586 ;; with argument ALL-FRAMES nil, when called from minibuffer context.
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
587 ;; Therefore, check frame identity here.
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
588 (defun YaTeX-window-list ()
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
589 (let*((curw (selected-window)) (win curw) (wlist (list curw))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
590 (curf (window-frame curw)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
591 (while (and (not (eq curw (setq win (next-window win))))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
592 (eq curf (window-frame win)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
593 (or (eq win (minibuffer-window))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
594 (setq wlist (cons win wlist))))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
595 wlist)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
596
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
597 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
598 (defun substitute-all-key-definition (olddef newdef keymap)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
599 "Replace recursively OLDDEF with NEWDEF for any keys in KEYMAP now
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
600 defined as OLDDEF. In other words, OLDDEF is replaced with NEWDEF
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
601 where ever it appears."
68
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
602 (if YaTeX-emacs-19
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
603 (substitute-key-definition olddef newdef keymap global-map)
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
604 (mapcar
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
605 (function (lambda (key) (define-key keymap key newdef)))
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
606 (where-is-internal olddef keymap))))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
607
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
608 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
609 (defun YaTeX-match-string (n &optional m)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
610 "Return (buffer-substring (match-beginning n) (match-beginning m))."
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
611 (if (match-beginning n)
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
612 (YaTeX-buffer-substring (match-beginning n)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
613 (match-end (or m n)))))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
614
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
615 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
616 (defun YaTeX-minibuffer-complete ()
49
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 47
diff changeset
617 "Complete in minibuffer.
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
618 If the symbol 'delim is bound and is string, its value is assumed to be
49
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 47
diff changeset
619 the character class of delimiters. Completion will be performed on
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
620 the last field separated by those delimiters.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
621 If the symbol 'quick is bound and is 't, when the try-completion results
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
622 in t, exit minibuffer immediately."
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
623 (interactive)
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
624 (save-restriction
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
625 (narrow-to-region
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
626 (if (fboundp 'field-beginning) (field-beginning (point-max)) (point-min))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
627 (point-max))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
628 (let ((md (match-data)) beg word compl
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
629 (quick (and (boundp 'quick) (eq quick t)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
630 (displist ;function to display completion-list
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
631 (function
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
632 (lambda ()
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
633 (with-output-to-temp-buffer "*Completions*"
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
634 (display-completion-list
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
635 (all-completions word minibuffer-completion-table)))))))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
636 (setq beg (if (and (boundp 'delim) (stringp delim))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
637 (save-excursion
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
638 (skip-chars-backward (concat "^" delim))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
639 (point))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
640 (point-min))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
641 word (buffer-substring beg (point-max))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
642 compl (try-completion word minibuffer-completion-table))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
643 (cond
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
644 ((eq compl t)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
645 (if quick (exit-minibuffer)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
646 (let ((p (point)) (max (point-max)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
647 (unwind-protect
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
648 (progn
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
649 (goto-char max)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
650 (insert " [Sole completion]")
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
651 (goto-char p)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
652 (sit-for 1))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
653 (delete-region max (point-max))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
654 (goto-char p)))))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
655 ((eq compl nil)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
656 (ding)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
657 (save-excursion
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
658 (let (p)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
659 (unwind-protect
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
660 (progn
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
661 (goto-char (setq p (point-max)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
662 (insert " [No match]")
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
663 (goto-char p)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
664 (sit-for 2))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
665 (delete-region p (point-max))))))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
666 ((string= compl word)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
667 (funcall displist))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
668 (t (delete-region beg (point-max))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
669 (insert compl)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
670 (if quick
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
671 (if (eq (try-completion compl minibuffer-completion-table) t)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
672 (exit-minibuffer)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
673 (funcall displist)))))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
674 (store-match-data md))))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
675
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
676 (defun YaTeX-minibuffer-quick-complete ()
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
677 "Set 'quick to 't and call YaTeX-minibuffer-complete.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
678 See documentation of YaTeX-minibuffer-complete."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
679 (interactive)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
680 (let ((quick t))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
681 (self-insert-command 1)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
682 (YaTeX-minibuffer-complete)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
683
168
191cffccc912 Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents: 142
diff changeset
684 (defun YaTeX-yatex-buffer-list ()
191cffccc912 Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents: 142
diff changeset
685 (save-excursion
191cffccc912 Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents: 142
diff changeset
686 (delq nil (mapcar (function (lambda (buf)
191cffccc912 Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents: 142
diff changeset
687 (set-buffer buf)
191cffccc912 Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents: 142
diff changeset
688 (if (eq major-mode 'yatex-mode) buf)))
191cffccc912 Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents: 142
diff changeset
689 (buffer-list)))))
191cffccc912 Replace all \ref{LABEL} when changing \label{LABEL}.
yuuji@gentei.org
parents: 142
diff changeset
690
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
691 (defun foreach-buffers (pattern job)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
692 "For each buffer which matches with PATTERN, do JOB."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
693 (let ((list (buffer-list)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
694 (save-excursion
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
695 (while list
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
696 (set-buffer (car list))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
697 (if (or (and (stringp pattern)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
698 (buffer-file-name)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
699 (string-match pattern (buffer-file-name)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
700 (and (symbolp pattern) major-mode (eq major-mode pattern)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
701 (eval job))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
702 (setq list (cdr list))))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
703
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
704 (defun goto-buffer-window (buffer)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
705 "Select window which is bound to BUFFER.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
706 If no such window exist, switch to buffer BUFFER."
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
707 (interactive "BGoto buffer: ")
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
708 (if (stringp buffer)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
709 (setq buffer (or (get-file-buffer buffer) (get-buffer buffer))))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
710 (if (get-buffer buffer)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
711 (cond
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
712 ((get-buffer-window buffer)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
713 (select-window (get-buffer-window buffer)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
714 ((and YaTeX-emacs-19 (get-buffer-window buffer t))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
715 (let*((win (get-buffer-window buffer t))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
716 (frame (window-frame win)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
717 (select-frame frame)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
718 (raise-frame frame)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
719 (focus-frame frame)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
720 (select-window win)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
721 (set-mouse-position frame 0 0)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
722 (and (featurep 'windows) (fboundp 'win:adjust-window)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
723 (win:adjust-window))))
54
2d45e43fb35f Full support of English documents
yuuji
parents: 53
diff changeset
724 ((and (featurep 'windows) (fboundp 'win:get-buffer-window)
56
a9653fbd1c1c Bug fix version
yuuji
parents: 54
diff changeset
725 (let ((w (win:get-buffer-window buffer)))
a9653fbd1c1c Bug fix version
yuuji
parents: 54
diff changeset
726 (and w (win:switch-window w))))
54
2d45e43fb35f Full support of English documents
yuuji
parents: 53
diff changeset
727 (select-window (get-buffer-window buffer)))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
728 (t (switch-to-buffer buffer)))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
729
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
730 ;; Here starts the functions which support gmhist-vs-Emacs19 compatible
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
731 ;; reading with history.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
732 ;;;###autoload
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
733 (defun completing-read-with-history
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
734 (prompt table &optional predicate must-match initial hsym)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
735 "Completing read with general history: gmhist, Emacs-19."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
736 (let ((minibuffer-history
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
737 (or (symbol-value hsym)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
738 (and (boundp 'minibuffer-history) minibuffer-history)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
739 (minibuffer-history-symbol (or hsym 'minibuffer-history)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
740 (prog1
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
741 (if (fboundp 'completing-read-with-history-in)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
742 (completing-read-with-history-in
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
743 minibuffer-history-symbol prompt table predicate must-match initial)
393
318841b09570 Workaround to avoid cursor warp.
HIROSE Yuuji <yuuji@gentei.org>
parents: 392
diff changeset
744 (save-excursion ;work around to avoid cursor warp
318841b09570 Workaround to avoid cursor warp.
HIROSE Yuuji <yuuji@gentei.org>
parents: 392
diff changeset
745 (completing-read prompt table predicate must-match initial)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
746 (if (and YaTeX-emacs-19 hsym) (set hsym minibuffer-history)))))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
747
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
748 ;;;###autoload
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
749 (defun read-from-minibuffer-with-history (prompt &optional init map read hsym)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
750 "Read from minibuffer with general history: gmhist, Emacs-19."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
751 (cond
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
752 (YaTeX-emacs-19
393
318841b09570 Workaround to avoid cursor warp.
HIROSE Yuuji <yuuji@gentei.org>
parents: 392
diff changeset
753 (save-excursion ;work around to avoid cursor warp
318841b09570 Workaround to avoid cursor warp.
HIROSE Yuuji <yuuji@gentei.org>
parents: 392
diff changeset
754 (read-from-minibuffer prompt init map read hsym)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
755 (t
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
756 (let ((minibuffer-history-symbol hsym))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
757 (read-from-minibuffer prompt init map read)))))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
758
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
759 ;;;###autoload
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
760 (defun read-string-with-history (prompt &optional init hsym)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
761 "Read string with history: gmhist(Emacs-18) and Emacs-19."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
762 (cond
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
763 (YaTeX-emacs-19
393
318841b09570 Workaround to avoid cursor warp.
HIROSE Yuuji <yuuji@gentei.org>
parents: 392
diff changeset
764 (save-excursion ;work around to avoid cursor warp
318841b09570 Workaround to avoid cursor warp.
HIROSE Yuuji <yuuji@gentei.org>
parents: 392
diff changeset
765 (read-from-minibuffer prompt init minibuffer-local-map nil hsym)))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
766 ((featurep 'gmhist-mh)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
767 (read-with-history-in hsym prompt init))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
768 (t (read-string prompt init))))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
769
234
b75390dd4260 C-j can skip further parameter input for table/figure environment.
yuuji@gentei.org
parents: 226
diff changeset
770 (defvar YaTeX-skip-next-reader-char ?\C-j)
237
af1e6c48eac0 YaTeX-skip-next-reader-p turns to YaTeX-read-string-or-skip.
yuuji@gentei.org
parents: 234
diff changeset
771 (defun YaTeX-read-string-or-skip (&rest args)
af1e6c48eac0 YaTeX-skip-next-reader-p turns to YaTeX-read-string-or-skip.
yuuji@gentei.org
parents: 234
diff changeset
772 "Read string, or skip if last input char is \C-j."
293
f5151d4240a9 Fix for going away of last-input-char
HIROSE Yuuji <yuuji@gentei.org>
parents: 290
diff changeset
773 (if (equal (if (boundp 'last-input-event) last-input-event last-input-char)
f5151d4240a9 Fix for going away of last-input-char
HIROSE Yuuji <yuuji@gentei.org>
parents: 290
diff changeset
774 YaTeX-skip-next-reader-char)
237
af1e6c48eac0 YaTeX-skip-next-reader-p turns to YaTeX-read-string-or-skip.
yuuji@gentei.org
parents: 234
diff changeset
775 ""
393
318841b09570 Workaround to avoid cursor warp.
HIROSE Yuuji <yuuji@gentei.org>
parents: 392
diff changeset
776 (save-excursion ;work around to avoid cursor warp
318841b09570 Workaround to avoid cursor warp.
HIROSE Yuuji <yuuji@gentei.org>
parents: 392
diff changeset
777 (apply 'read-string args))))
234
b75390dd4260 C-j can skip further parameter input for table/figure environment.
yuuji@gentei.org
parents: 226
diff changeset
778
244
d5e0c33d7dfd YaTeX-completing-read-or-skip introduced
yuuji@gentei.org
parents: 237
diff changeset
779 (defun YaTeX-completing-read-or-skip (&rest args)
d5e0c33d7dfd YaTeX-completing-read-or-skip introduced
yuuji@gentei.org
parents: 237
diff changeset
780 "Do completing-read, or skip if last input char is \C-j."
293
f5151d4240a9 Fix for going away of last-input-char
HIROSE Yuuji <yuuji@gentei.org>
parents: 290
diff changeset
781 (if (equal (if (boundp 'last-input-event) last-input-event last-input-char)
f5151d4240a9 Fix for going away of last-input-char
HIROSE Yuuji <yuuji@gentei.org>
parents: 290
diff changeset
782 YaTeX-skip-next-reader-char)
244
d5e0c33d7dfd YaTeX-completing-read-or-skip introduced
yuuji@gentei.org
parents: 237
diff changeset
783 ""
393
318841b09570 Workaround to avoid cursor warp.
HIROSE Yuuji <yuuji@gentei.org>
parents: 392
diff changeset
784 (save-excursion ;work around to avoid cursor warp
318841b09570 Workaround to avoid cursor warp.
HIROSE Yuuji <yuuji@gentei.org>
parents: 392
diff changeset
785 (apply 'completing-read args))))
244
d5e0c33d7dfd YaTeX-completing-read-or-skip introduced
yuuji@gentei.org
parents: 237
diff changeset
786
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
787 ;;;###autoload
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
788 (fset 'YaTeX-rassoc
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
789 (if (and nil (fboundp 'rassoc) (subrp (symbol-function 'rassoc)))
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
790 (symbol-function 'rassoc)
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
791 (function
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
792 (lambda (key list)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
793 (let ((l list))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
794 (catch 'found
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
795 (while l
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
796 (if (equal key (cdr (car l)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
797 (throw 'found (car l)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
798 (setq l (cdr l)))))))))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
799
354
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
800 (defun YaTeX-set-file-coding-system (code coding)
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
801 "Set current buffer's coding system according to symbol."
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
802 (cond ((null code)
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
803 nil)
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
804 ((boundp 'MULE)
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
805 (set-file-coding-system coding))
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
806 ((and YaTeX-emacs-20 (boundp 'buffer-file-coding-system))
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
807 (setq buffer-file-coding-system
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
808 (or (and (fboundp 'set-auto-coding) buffer-file-name
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
809 (save-excursion
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
810 (goto-char (point-min))
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
811 (set-auto-coding buffer-file-name (buffer-size))))
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
812 coding)))
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
813 ((featurep 'mule)
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
814 (set-file-coding-system coding))
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
815 ((boundp 'NEMACS)
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
816 (make-local-variable 'kanji-fileio-code)
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
817 (setq kanji-fileio-code code))))
5465428f5a68 `[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents: 353
diff changeset
818
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
819 (defun YaTeX-insert-file-contents (file visit &optional beg end)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
820 (cond
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
821 ((and (string< "19" emacs-version) (not (featurep 'xemacs)))
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
822 (insert-file-contents file visit beg end))
77
1b172d26b55e Fix auto-fill movement on Emacs21.
yuuji
parents: 73
diff changeset
823 ((string-match "unix\\|linux" (symbol-name system-type))
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
824 (let ((default-process-coding-system
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
825 (and (boundp '*noconv*) (list '*noconv*)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
826 (file-coding-system (and (boundp '*noconv*) '*noconv*))
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
827 kanji-fileio-code
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
828 (default-process-kanji-code 0))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
829 (call-process shell-file-name file (current-buffer) nil
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
830 (or (and (boundp 'shell-command-option)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
831 shell-command-option)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
832 "-c")
77
1b172d26b55e Fix auto-fill movement on Emacs21.
yuuji
parents: 73
diff changeset
833 (format "dd bs=1 count=%d | tail -c +%d" end beg))))
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
834 (t (insert-file-contents file))))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
835
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
836 (defun YaTeX-split-string (str &optional sep null)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
837 "Split string STR by every occurrence of SEP(regexp).
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
838 If the optional second argument SEP is nil, it defaults to \"[ \f\t\n\r\v]+\".
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
839 Do not include null string by default. Non-nil for optional third argument
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
840 NULL includes null string in a list."
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
841 (let ((sep (or sep "[ \f\t\n\r\v]+"))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
842 list m)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
843 (while str
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
844 (if (setq m (string-match sep str))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
845 (progn
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
846 (if (or (> m 0) null)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
847 (setq list (cons (substring str 0 m) list)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
848 (setq str (substring str (match-end 0))))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
849 (if (or null (string< "" str))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
850 (setq list (cons str list)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
851 (setq str nil)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
852 (nreverse list)))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
853
73
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
854 ;;;###autoload
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
855 (defun YaTeX-delete1 (elt list)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
856 "Delete"
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
857 (let (e)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
858 (while (setq e (YaTeX-member elt list))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
859 (setq list (delq (car e) list))))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
860 list)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
861 (if (fboundp 'delete)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
862 (fset 'YaTeX-delete (symbol-function 'delete))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
863 (fset 'YaTeX-delete (symbol-function 'YaTeX-delete1)))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
864
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
865 (defun YaTeX-member1 (elt list)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
866 (catch 'found
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
867 (while list
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
868 (if (equal elt (car list))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
869 (throw 'found list))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
870 (setq list (cdr list)))))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
871
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
872 (if (and (fboundp 'member) (subrp (symbol-function 'member)))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
873 (fset 'YaTeX-member (symbol-function 'member))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
874 (fset 'YaTeX-member (symbol-function 'YaTeX-member1)))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
875
53
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
876 ;;;
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
877 ;; Interface function for windows.el
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
878 ;;;
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
879 ;;;###autoload
290
1a4332ecc58b For emacs-24.3+ and NEmacs(last-command-{char,event} handling)
HIROSE Yuuji <yuuji@gentei.org>
parents: 287
diff changeset
880 (fset 'YaTeX-last-key
1a4332ecc58b For emacs-24.3+ and NEmacs(last-command-{char,event} handling)
HIROSE Yuuji <yuuji@gentei.org>
parents: 287
diff changeset
881 (if (fboundp 'win:last-key)
1a4332ecc58b For emacs-24.3+ and NEmacs(last-command-{char,event} handling)
HIROSE Yuuji <yuuji@gentei.org>
parents: 287
diff changeset
882 'win:last-key
353
2a72779d9c50 Rewrite lambda notations to suppress annoying warnings from emacs24
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
883 (function (lambda () (if (boundp 'last-command-char)
2a72779d9c50 Rewrite lambda notations to suppress annoying warnings from emacs24
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
884 last-command-char
2a72779d9c50 Rewrite lambda notations to suppress annoying warnings from emacs24
HIROSE Yuuji <yuuji@gentei.org>
parents: 310
diff changeset
885 last-command-event)))))
53
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
886 (defun YaTeX-switch-to-window ()
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
887 "Switch to windows.el's window decided by last pressed key."
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
888 (interactive)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
889 (or (featurep 'windows) (error "Why don't you use `windows.el'?"))
290
1a4332ecc58b For emacs-24.3+ and NEmacs(last-command-{char,event} handling)
HIROSE Yuuji <yuuji@gentei.org>
parents: 287
diff changeset
890 (win-switch-to-window 1 (- (YaTeX-last-key) win:base-key)))
1a4332ecc58b For emacs-24.3+ and NEmacs(last-command-{char,event} handling)
HIROSE Yuuji <yuuji@gentei.org>
parents: 287
diff changeset
891
53
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
892
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
893 ;;;###autoload
138
b7b54906ac3b add newpage.rb
yuuji@gentei.org
parents: 130
diff changeset
894 (defun YaTeX-command-to-string (cmd)
b7b54906ac3b add newpage.rb
yuuji@gentei.org
parents: 130
diff changeset
895 (if (fboundp 'shell-command-to-string)
b7b54906ac3b add newpage.rb
yuuji@gentei.org
parents: 130
diff changeset
896 (funcall 'shell-command-to-string cmd)
b7b54906ac3b add newpage.rb
yuuji@gentei.org
parents: 130
diff changeset
897 (let ((tbuf " *tmpout*"))
b7b54906ac3b add newpage.rb
yuuji@gentei.org
parents: 130
diff changeset
898 (if (get-buffer-create tbuf) (kill-buffer tbuf))
b7b54906ac3b add newpage.rb
yuuji@gentei.org
parents: 130
diff changeset
899 (let ((standard-output (get-buffer-create tbuf)))
b7b54906ac3b add newpage.rb
yuuji@gentei.org
parents: 130
diff changeset
900 (unwind-protect
b7b54906ac3b add newpage.rb
yuuji@gentei.org
parents: 130
diff changeset
901 (save-excursion
b7b54906ac3b add newpage.rb
yuuji@gentei.org
parents: 130
diff changeset
902 (call-process
b7b54906ac3b add newpage.rb
yuuji@gentei.org
parents: 130
diff changeset
903 shell-file-name nil tbuf nil YaTeX-shell-command-option cmd)
b7b54906ac3b add newpage.rb
yuuji@gentei.org
parents: 130
diff changeset
904 (set-buffer tbuf)
b7b54906ac3b add newpage.rb
yuuji@gentei.org
parents: 130
diff changeset
905 (buffer-string))
b7b54906ac3b add newpage.rb
yuuji@gentei.org
parents: 130
diff changeset
906 (kill-buffer tbuf))))))
b7b54906ac3b add newpage.rb
yuuji@gentei.org
parents: 130
diff changeset
907
372
e8f95c375526 YaTeX-executable-find added
HIROSE Yuuji <yuuji@gentei.org>
parents: 368
diff changeset
908 ;;; (defun YaTeX-executable-find(cmd)...)
e8f95c375526 YaTeX-executable-find added
HIROSE Yuuji <yuuji@gentei.org>
parents: 368
diff changeset
909 (fset 'YaTeX-executable-find
e8f95c375526 YaTeX-executable-find added
HIROSE Yuuji <yuuji@gentei.org>
parents: 368
diff changeset
910 (if (fboundp 'executable-find)
e8f95c375526 YaTeX-executable-find added
HIROSE Yuuji <yuuji@gentei.org>
parents: 368
diff changeset
911 'executable-find
e8f95c375526 YaTeX-executable-find added
HIROSE Yuuji <yuuji@gentei.org>
parents: 368
diff changeset
912 (function (lambda (cmd)
e8f95c375526 YaTeX-executable-find added
HIROSE Yuuji <yuuji@gentei.org>
parents: 368
diff changeset
913 (let ((list exec-path) path)
e8f95c375526 YaTeX-executable-find added
HIROSE Yuuji <yuuji@gentei.org>
parents: 368
diff changeset
914 (catch 'exec
e8f95c375526 YaTeX-executable-find added
HIROSE Yuuji <yuuji@gentei.org>
parents: 368
diff changeset
915 (while list
e8f95c375526 YaTeX-executable-find added
HIROSE Yuuji <yuuji@gentei.org>
parents: 368
diff changeset
916 (if (file-executable-p
e8f95c375526 YaTeX-executable-find added
HIROSE Yuuji <yuuji@gentei.org>
parents: 368
diff changeset
917 (setq path (expand-file-name cmd (car list))))
e8f95c375526 YaTeX-executable-find added
HIROSE Yuuji <yuuji@gentei.org>
parents: 368
diff changeset
918 (throw 'exec path))
e8f95c375526 YaTeX-executable-find added
HIROSE Yuuji <yuuji@gentei.org>
parents: 368
diff changeset
919 (setq list (cdr list)))))))))
e8f95c375526 YaTeX-executable-find added
HIROSE Yuuji <yuuji@gentei.org>
parents: 368
diff changeset
920
138
b7b54906ac3b add newpage.rb
yuuji@gentei.org
parents: 130
diff changeset
921 ;;;###autoload
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
922 (defun YaTeX-reindent (col)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
923 "Remove current indentation and reindento to COL column."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
924 (save-excursion
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
925 (beginning-of-line)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
926 (skip-chars-forward " \t")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
927 (if (/= col (current-column))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
928 (progn
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
929 (delete-region (point) (progn (beginning-of-line) (point)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
930 (indent-to col))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
931 (skip-chars-forward " \t" (point-end-of-line)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
932
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
933 (defun YaTeX-inner-environment (&optional quick)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
934 "Return current inner-most environment.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
935 Non-nil for optional argument QUICK restricts search bound to most
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
936 recent sectioning command. Matching point is stored to property 'point
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
937 of 'YaTeX-inner-environment, which can be referred by
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
938 (get 'YaTeX-inner-environment 'point)."
73
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
939 (put 'YaTeX-inner-environment 'point (point-min))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
940 (put 'YaTeX-inner-environment 'indent 0)
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
941 (let*((nest 0)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
942 (beg (YaTeX-replace-format-args
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
943 (regexp-quote YaTeX-struct-begin)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
944 ;YaTeX-struct-begin ;=== TENTATIVE!! ==
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
945 YaTeX-struct-name-regexp
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
946 (if (eq major-mode 'yahtml-mode) "\\s *.*" "")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
947 ""))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
948 (end (YaTeX-replace-format-args
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
949 (regexp-quote YaTeX-struct-end)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
950 YaTeX-struct-name-regexp "" ""))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
951 (begend (concat "\\(" beg "\\)\\|\\(" end "\\)"))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
952 bound m0
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
953 (htmlp (eq major-mode 'yahtml-mode))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
954 (open
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
955 (concat "^" (or (cdr (assq major-mode '((yahtml-mode . "<")))) "{")))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
956 (close
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
957 (concat "^"
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
958 (or (cdr(assq major-mode '((yahtml-mode . "\n\t >")))) "}"))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
959 (save-excursion
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
960 (if quick
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
961 (setq bound
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
962 (save-excursion
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
963 (if htmlp
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
964 ;;(re-search-backward YaTeX-sectioning-regexp nil 1)
73
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
965 ;;(goto-char (point-min)) ;Is this enough? 97/6/26
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
966 (re-search-backward yahtml-indentation-boundary nil 1)
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
967 (YaTeX-re-search-active-backward
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
968 (concat YaTeX-ec-regexp
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
969 "\\(" YaTeX-sectioning-regexp "\\)\\*?{")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
970 YaTeX-comment-prefix nil 1))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
971 (or (bobp) (end-of-line))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
972 (point))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
973 (if (catch 'begin
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
974 (if (and (numberp bound) (< (point) bound)) (throw 'begin nil))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
975 (while (YaTeX-re-search-active-backward
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
976 begend YaTeX-comment-prefix bound t)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
977 (setq m0 (match-beginning 0))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
978 (if (looking-at end) ;;(match-beginning 2)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
979 (setq nest (1+ nest))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
980 (setq nest (1- nest)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
981 (if (< nest 0)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
982 (progn
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
983 (put 'YaTeX-inner-environment 'point m0)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
984 (goto-char m0)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
985 (put 'YaTeX-inner-environment 'indent (current-column))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
986 (throw 'begin t)))))
187
2f91947a43a1 YaTeX-end-environment
yuuji@gentei.org
parents: 182
diff changeset
987 (YaTeX-buffer-substring
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
988 (progn (skip-chars-forward open) (1+ (point)))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
989 (progn (skip-chars-forward close) (point)))))))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
990
392
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
991 (defun YaTeX-in-environment-p (env)
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
992 "Return if current LaTeX environment is ENV.
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
993 ENV is given in the form of environment's name or its list."
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
994 (let ((md (match-data)) (nest 0) p envrx)
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
995 (cond
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
996 ((atom env)
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
997 (setq envrx
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
998 (concat "\\("
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
999 (regexp-quote
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1000 (YaTeX-replace-format-args
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1001 YaTeX-struct-begin env "" ""))
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1002 "\\>\\)\\|\\("
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1003 (regexp-quote
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1004 (YaTeX-replace-format-args
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1005 YaTeX-struct-end env "" ""))
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1006 "\\)"))
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1007 (save-excursion
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1008 (setq p (catch 'open
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1009 (while (YaTeX-re-search-active-backward
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1010 envrx YaTeX-comment-prefix nil t)
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1011 (if (match-beginning 2)
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1012 (setq nest (1+ nest))
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1013 (setq nest (1- nest)))
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1014 (if (< nest 0)
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1015 (throw 'open (cons env (match-beginning 0)))))))))
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1016 ((listp env)
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1017 (setq p
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1018 (or (YaTeX-in-environment-p (car env))
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1019 (and (cdr env) (YaTeX-in-environment-p (cdr env)))))))
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1020 (store-match-data md)
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1021 p;(or p (YaTeX-in-verb-p (match-beginning 0)))
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1022 ))
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1023
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1024 (defun YaTeX-quick-in-environment-p (env)
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1025 "Check quickly but unsure if current environment is ENV.
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1026 ENV is given in the form of environment's name or its list.
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1027 This function returns correct result only if ENV is NOT nested."
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1028 (save-excursion
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1029 (let ((md (match-data)) m0 (p (point)) rc clfound)
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1030 (cond
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1031 ((listp env)
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1032 (or (YaTeX-quick-in-environment-p (car env))
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1033 (and (cdr env) (YaTeX-quick-in-environment-p (cdr env)))))
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1034 (t
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1035 (unwind-protect
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1036 (if (prog1
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1037 (YaTeX-search-active-backward
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1038 (YaTeX-replace-format-args YaTeX-struct-begin env "" "")
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1039 YaTeX-comment-prefix nil t)
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1040 (setq m0 (match-beginning 0)))
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1041 (if (YaTeX-search-active-forward
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1042 (YaTeX-replace-format-args
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1043 YaTeX-struct-end env)
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1044 YaTeX-comment-prefix p t nil)
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1045 nil ;if \end{env} found, return nil
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1046 (cons env m0))) ;else, return meaningful values
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1047 (store-match-data md)))))))
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1048
451
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
1049 (defun YaTeX-goto-corresponding-environment (&optional allow-mismatch noerr bg)
73
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1050 "Go to corresponding begin/end enclosure.
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1051 Optional argument ALLOW-MISMATCH allows mismatch open/clese. Use this
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1052 for \left(, \right).
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1053 Optional third argument NOERR causes no error for unballanced environment."
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1054 (interactive)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1055 (if (not (YaTeX-on-begin-end-p)) nil
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1056 (let ((p (match-end 0)) b0 b1 env (nest 0) regexp re-s (op (point))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1057 (m0 (match-beginning 0)) ;whole matching
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1058 (m1 (match-beginning 1)) ;environment in \begin{}
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1059 (m2 (match-beginning 2)) ;environment in \end{}
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1060 (m3 (match-beginning 3))) ;environment in \[ \] \( \)
451
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
1061 ;(setq env (regexp-quote (buffer-substring p (match-beginning 0))))
73
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1062 (if (cond
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1063 (m1 ;if begin{xxx}
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1064 (setq env
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1065 (if allow-mismatch YaTeX-struct-name-regexp
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1066 (regexp-quote (buffer-substring m1 (match-end 1)))))
451
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
1067 ; (setq regexp (concat "\\(\\\\end{" env "}\\)\\|"
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
1068 ; "\\(\\\\begin{" env "}\\)"))
73
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1069 (setq regexp
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1070 (concat
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1071 "\\("
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1072 (YaTeX-replace-format-args
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1073 (regexp-quote YaTeX-struct-end) env "" "")
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1074 "\\)\\|\\("
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1075 (YaTeX-replace-format-args
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1076 (regexp-quote YaTeX-struct-begin) env "" "")
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1077 "\\)"))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1078 (setq re-s 're-search-forward))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1079 (m2 ;if end{xxx}
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1080 (setq env
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1081 (if allow-mismatch YaTeX-struct-name-regexp
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1082 (regexp-quote (buffer-substring m2 (match-end 2)))))
451
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
1083 ; (setq regexp (concat "\\(\\\\begin{" env "}\\)\\|"
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
1084 ; "\\(\\\\end{" env "}\\)"))
73
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1085 (setq regexp
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1086 (concat
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1087 "\\("
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1088 (YaTeX-replace-format-args
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1089 (regexp-quote YaTeX-struct-begin) env "" "")
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1090 "\\)\\|\\("
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1091 (YaTeX-replace-format-args
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1092 (regexp-quote YaTeX-struct-end) env "" "")
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1093 "\\)"))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1094 (setq re-s 're-search-backward))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1095 (m3 ;math environment
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1096 (setq env (char-after (1+ m3))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1097 regexp (format "\\(%s%s\\)\\|\\(%s%s\\)"
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1098 YaTeX-ec-regexp
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1099 (regexp-quote
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1100 (cdr (assq env '((?( . ")") (?) . "(")
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1101 (?[ . "]") (?] . "[")))))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1102 YaTeX-ec-regexp
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1103 (regexp-quote (char-to-string env)))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1104 re-s (if (memq env '(?\( ?\[))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1105 're-search-forward
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1106 're-search-backward)))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1107 (t (if noerr nil (error "Corresponding environment not found."))))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1108 (progn
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1109 (while (and (>= nest 0) (funcall re-s regexp nil t))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1110 (setq b0 (match-beginning 0) b1 (match-beginning 1))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1111 (if (or (equal b0 m0)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1112 (YaTeX-literal-p b0))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1113 nil
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1114 (setq nest (if (equal b0 b1)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1115 (1- nest) (1+ nest)))))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1116 (if (< nest 0)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1117 (goto-char (match-beginning 0)) ;found.
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1118 (goto-char op)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1119 (funcall
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1120 (if noerr 'message 'error)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1121 "Corresponding environment `%s' not found." env)
451
2011de73a671 Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents: 443
diff changeset
1122 (or bg (sit-for 1))
73
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1123 nil))))))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1124
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1125 (defun YaTeX-end-environment ()
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1126 "Close opening environment"
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1127 (interactive)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1128 (let ((env (YaTeX-inner-environment)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1129 (if (not env) (error "No premature environment")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1130 (save-excursion
187
2f91947a43a1 YaTeX-end-environment
yuuji@gentei.org
parents: 182
diff changeset
1131 (if (and
2f91947a43a1 YaTeX-end-environment
yuuji@gentei.org
parents: 182
diff changeset
1132 (YaTeX-re-search-active-forward
2f91947a43a1 YaTeX-end-environment
yuuji@gentei.org
parents: 182
diff changeset
1133 (concat
2f91947a43a1 YaTeX-end-environment
yuuji@gentei.org
parents: 182
diff changeset
1134 "\\(" (YaTeX-replace-format-args
2f91947a43a1 YaTeX-end-environment
yuuji@gentei.org
parents: 182
diff changeset
1135 YaTeX-struct-end env "" "")
2f91947a43a1 YaTeX-end-environment
yuuji@gentei.org
parents: 182
diff changeset
1136 "\\)\\|\\(" (YaTeX-replace-format-args
2f91947a43a1 YaTeX-end-environment
yuuji@gentei.org
parents: 182
diff changeset
1137 YaTeX-struct-begin env "" "")
2f91947a43a1 YaTeX-end-environment
yuuji@gentei.org
parents: 182
diff changeset
1138 "\\)")
2f91947a43a1 YaTeX-end-environment
yuuji@gentei.org
parents: 182
diff changeset
1139 YaTeX-comment-prefix nil t)
2f91947a43a1 YaTeX-end-environment
yuuji@gentei.org
parents: 182
diff changeset
1140 (match-beginning 1)) ;is closing struc.
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1141 (if (y-or-n-p
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1142 (concat "Environment `" env
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1143 "' may be already closed. Force close?"))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1144 nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1145 (error "end environment aborted."))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1146 (message "") ;Erase (y or n) message.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1147 (YaTeX-insert-struc 'end env)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1148 (save-excursion
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1149 (goto-char (or (get 'YaTeX-inner-environment 'point) (match-end 0)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1150 (if (pos-visible-in-window-p)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1151 (sit-for (if YaTeX-dos 2 1))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1152 (message "Matches with %s at line %d"
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1153 (YaTeX-replace-format-args YaTeX-struct-begin env "" "")
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
1154 (count-lines (point-min) (point))))))))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1155
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1156 (defun YaTeX-beginning-of-environment (&optional limit-search-bound end)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1157 "Goto the beginning of the current environment.
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1158 Optional argument LIMIT-SEARCH-BOUND non-nil limits the search bound to
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1159 most recent sectioning command. Non-nil for optional third argument END
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1160 goes to end of environment."
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1161 (interactive)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1162 (let ((op (point)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1163 (if (YaTeX-inner-environment limit-search-bound)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1164 (progn
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1165 (goto-char (get 'YaTeX-inner-environment 'point))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1166 (and end (YaTeX-goto-corresponding-environment))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1167 (if (interactive-p) (push-mark op))
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1168 (point)))))
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1169
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1170 (defun YaTeX-end-of-environment (&optional limit-search-bound)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1171 "Goto the end of the current environment.
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1172 Optional argument LIMIT-SEARCH-BOUND non-nil limits the search bound
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1173 to most recent sectioning command."
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1174 (interactive)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1175 (YaTeX-beginning-of-environment limit-search-bound t))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1176
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1177 (defun YaTeX-mark-environment ()
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1178 "Mark current position and move point to end of environment."
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1179 (interactive)
130
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1180 (require 'yatexmth)
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1181 (let ((curp (point)))
130
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1182 (if (YaTeX-in-math-mode-p)
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1183 (YaTeX-mark-mathenv)
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1184 (if (and (YaTeX-on-begin-end-p) (match-beginning 1)) ;if on \\begin
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1185 (progn (goto-char (match-end 0)))
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1186 (if (= (char-after (point)) ?\\) nil ;if on \\end
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1187 (skip-chars-backward "^\n\\\\")
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1188 (or (bolp) (forward-char -1))))
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1189 (if (not (YaTeX-end-of-environment)) ;arg1 turns to match-beginning 1
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1190 (progn
130
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1191 (goto-char curp)
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1192 (error "Cannot found the end of current environment."))
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1193 (YaTeX-goto-corresponding-environment)
380
f061b37c7542 Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents: 376
diff changeset
1194 ;;(beginning-of-line) ;for confirmation ;OUT 2015/1/4
130
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1195 (if (< curp (point))
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1196 (progn
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1197 (message "Mark this environment?(y or n): ")
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1198 (if (= (read-char) ?y) nil
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1199 (goto-char curp)
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1200 (error "Abort. Please call again at more proper position."))))
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1201 (set-mark-command nil)
8703f090c628 `[prefix] t e' for YaTeX-typeset-environment.
yuuji@gentei.org
parents: 88
diff changeset
1202 (YaTeX-goto-corresponding-environment)
380
f061b37c7542 Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents: 376
diff changeset
1203 (goto-char (match-end 0))
f061b37c7542 Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents: 376
diff changeset
1204 ;;(end-of-line) ;OUT 2015/1/5
f061b37c7542 Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents: 376
diff changeset
1205 ;;(if (eobp) nil (forward-char 1)) ;OUT 2015/1/5
f061b37c7542 Equalize boundary of non-math environment with math environment.
HIROSE Yuuji <yuuji@gentei.org>
parents: 376
diff changeset
1206 ))))
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1207
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1208 (defun YaTeX-kill-buffer (buffer)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1209 "Make effort to show parent buffer after kill."
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1210 (interactive "bKill buffer: ")
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1211 (or (get-buffer buffer)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1212 (error "No such buffer %s" buffer))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1213 (let ((pf YaTeX-parent-file))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1214 (kill-buffer buffer)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1215 (and pf
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1216 (get-file-buffer pf)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1217 (switch-to-buffer (get-file-buffer pf)))))
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
1218
225
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1219 (defun YaTeX-getset-builtin (key &optional value)
142
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1220 "Read source built-in command of %# usage."
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1221 (catch 'builtin
225
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1222 (let*((bl (delq nil (list (current-buffer)
142
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1223 (and YaTeX-parent-file
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1224 (get-file-buffer YaTeX-parent-file)))))
225
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1225 (tuple (cdr (assq major-mode
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1226 '((yatex-mode "%#" . "\n")
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1227 (yahtml-mode "<!-- #" . "[ \t]*-->\\|\n")))))
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1228 (leader (or (car tuple) ""))
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1229 (closer (or (cdr tuple) ""))
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1230 (prompt (format "Built-in for %s: " key)))
142
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1231 (save-excursion
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1232 (while bl
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1233 (set-buffer (car bl))
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1234 (save-excursion
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1235 (goto-char (point-min))
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1236 (if (and (re-search-forward
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1237 (concat "^" (regexp-quote (concat leader key))) nil t)
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1238 (not (eolp)))
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1239 (throw 'builtin
225
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1240 (let (b e w)
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1241 (skip-chars-forward " \t" (point-end-of-line))
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1242 (setq b (point)
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1243 e (if (re-search-forward closer nil t)
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1244 (match-beginning 0)
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1245 (point-end-of-line))
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1246 w (YaTeX-buffer-substring b e))
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1247 (if (null value)
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1248 w
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1249 (delete-region b e)
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1250 (goto-char b)
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1251 (if (symbolp value)
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1252 (setq value (read-string prompt w)))
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1253 (insert value)
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1254 value)))))
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1255 (setq bl (cdr bl)))
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1256 ; not found
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1257 (if (null value)
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1258 nil ;not set mode, return simply nil
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1259 (if (symbolp value)
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1260 (setq value (read-string prompt)))
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1261 (save-excursion
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1262 (goto-char (point-min))
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1263 (insert leader key " " value "\n")
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1264 value)))))) ;on set mode, return set value
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1265
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1266 (defun YaTeX-get-builtin (key)
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1267 "Read source built-in command of %# usage."
bd9dc9d53a3a New func. YaTeX-getset-builtin introduced to update builtin line interactive.
yuuji@gentei.org
parents: 195
diff changeset
1268 (YaTeX-getset-builtin key))
142
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1269
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1270 ;;;VER2
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1271 (defun YaTeX-insert-struc (what env)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1272 (cond
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1273 ((eq what 'begin)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1274 (insert (YaTeX-replace-format-args
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1275 YaTeX-struct-begin env (YaTeX-addin env))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1276 ((eq what 'end)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1277 (insert (YaTeX-replace-format-args YaTeX-struct-end env)))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
1278 (t nil)))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1279
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1280 (defun YaTeX-string-width (str)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1281 "Return the display width of string."
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1282 (if (fboundp 'string-width)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1283 (string-width str)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1284 (length str)))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1285 (defun YaTeX-truncate-string-width (str width)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1286 (cond
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1287 ((fboundp 'truncate-string-to-width) (truncate-string-to-width str width))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1288 ((fboundp 'truncate-string) (truncate-string str width))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1289 (t (substring str 0 width))))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1290
142
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1291 (defun YaTeX-hex (str)
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1292 "Return int expressed by hexadecimal string STR."
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1293 (if (string< "20" emacs-version)
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1294 (string-to-number str 16)
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1295 (let ((md (match-data)))
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1296 (unwind-protect
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1297 (if (string-match "[^0-9a-f]" str)
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1298 (error "Non hexadecimal character in %s" str)
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1299 (let ((i 0) d)
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1300 (setq str (downcase str))
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1301 (while (string< "" str)
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1302 (setq d (+ 0 (string-to-char str)) ; + 0 for XEmacs
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1303 i (+ (* 16 i) (- d (if (<= d ?9) ?0 (- ?a 10))))
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1304 str (substring str 1)))
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1305 i))
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1306 (store-match-data md)))))
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1307
b65b3dc543d1 The function YaTeX-hex added.
yuuji@gentei.org
parents: 138
diff changeset
1308
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1309 ;;; Function for menu support
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1310 (defun YaTeX-define-menu (keymap bindlist)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1311 "Define KEYMAP(symbol)'s menu-bindings according to BINDLIST.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1312 KEYMAP should be a quoted symbol of newly allocated keymap.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1313 BINDLIST consists of binding list. Each element is as follows.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1314
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1315 '(menusymbol DOC_String . contents)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1316
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1317 CONTENTS is one of lambda-form, interactive function, or other keymap.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1318 See yatex19.el for example."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1319 (cond
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1320 ((featurep 'xemacs)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1321 (let (name)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1322 (if (keymapp (symbol-value keymap))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1323 (progn
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1324 (setq name (keymap-name (symbol-value keymap)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1325 (set keymap nil))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1326 (setq name (car (symbol-value keymap)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1327 (set keymap (cdr (symbol-value keymap))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1328 (mapcar
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1329 (function
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1330 (lambda (bind)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1331 (setq bind (cdr bind))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1332 (if (eq (car-safe (cdr bind)) 'lambda)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1333 (setcar (cdr bind) 'progn))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1334 (if (stringp (car-safe (cdr bind)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1335 (set keymap
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1336 (cons (cdr bind) (symbol-value keymap)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1337 (set keymap
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1338 (cons (vector (car bind) (cdr bind) t)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1339 (symbol-value keymap))))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1340 bindlist)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1341 (set keymap (cons name (symbol-value keymap)))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1342 (t
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1343 (mapcar
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1344 (function
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1345 (lambda (bind)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1346 (define-key (symbol-value keymap) (vector (car bind)) (cdr bind))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1347 bindlist))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1348
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1349 ;;;
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1350 ;; Emacs 21 compensational wrapper
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1351 ;;;
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1352 (defun YaTeX-minibuffer-begin ()
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1353 (if (fboundp 'field-beginning)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1354 (field-beginning (point-max))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1355 (point-min)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1356
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1357 (defun YaTeX-minibuffer-end ()
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1358 (if (fboundp 'field-end)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1359 (field-end (point-max))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1360 (point-max)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1361
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1362 (defun YaTeX-minibuffer-string ()
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1363 (buffer-substring (YaTeX-minibuffer-begin) (YaTeX-minibuffer-end)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1364
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1365 (defun YaTeX-minibuffer-erase ()
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1366 (if (eq (selected-window) (minibuffer-window))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1367 (if (fboundp 'delete-field) (delete-field) (erase-buffer))))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1368
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1369 (fset 'YaTeX-buffer-substring
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1370 (if (fboundp 'buffer-substring-no-properties)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1371 'buffer-substring-no-properties
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1372 'buffer-substring))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1373
392
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1374 (defun YaTeX-region-active-p ()
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1375 (and (fboundp 'region-active-p) (region-active-p)))
c44910b36b95 Switch to region-mode if completion called with active region.
HIROSE Yuuji <yuuji@gentei.org>
parents: 380
diff changeset
1376
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1377 ;;;
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1378 ;; hilit19 vs. font-lock
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1379 ;;;
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1380 (defvar YaTeX-19-functions-font-lock-direct
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1381 '(YaTeX-19-re-search-in-env))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1382
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1383 (defun YaTeX-convert-pattern-hilit2fontlock (h19pa)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1384 "Convert hilit19's H19PA patterns alist to font-lock's one.
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1385 This function is a makeshift for YaTeX and yahtml."
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1386 (let ((ignorecase (not (null (car h19pa))))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1387 (palist (cdr h19pa))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1388 flpa i newface
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1389 (mapping
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1390 '((bold . YaTeX-font-lock-bold-face)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1391 (italic . YaTeX-font-lock-italic-face)
73
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1392 (defun . font-lock-function-name-face)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1393 (define . font-lock-variable-name-face)
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1394 (keyword . font-lock-keyword-face)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1395 (decl . YaTeX-font-lock-declaration-face)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1396 (label . YaTeX-font-lock-label-face)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1397 (crossref . YaTeX-font-lock-crossref-face)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1398 (include . YaTeX-font-lock-include-face)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1399 (formula . YaTeX-font-lock-formula-face)
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1400 (delimiter . YaTeX-font-lock-delimiter-face)
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1401 (string . ignore) (comment . ignore)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1402 )))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1403 (while (setq i (car palist))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1404 (setq newface (nth 2 i)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1405 newface (or (cdr (assq newface mapping)) newface))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1406 (cond
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1407 ((eq newface 'ignore) nil) ;no translation
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1408 ((stringp (car i)) ;hiliting by regexp
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1409 (setq flpa
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1410 (cons
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1411 (if (numberp (car (cdr i)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1412 (list (car i) ;regexp
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1413 (car (cdr i)) ;matching group number
73
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1414 newface nil) ;'keep) ;keep is hilit19 taste
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1415 (list
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1416 (concat
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1417 (car i) ;original regexp and..
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1418 ;;"[^"
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1419 ;;(regexp-quote (substring (car (cdr i)) 0 1))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1420 ;;"]+" ;for shortest match
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1421 ".*"
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1422 (car (cdr i)))
73
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1423 0 (list 'quote newface) nil)) ;;'keep))
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1424 flpa)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1425 ((and (symbolp (car i)) (fboundp (car i)))
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1426 (if (memq (car i) YaTeX-19-functions-font-lock-direct)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1427 ;; Put direct function call for it.
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1428 ;; When calling this function, fontify entire matched string.
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1429 (setq flpa
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1430 (cons
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1431 (list
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1432 (list 'lambda (list 'dummy) ;dummy should be boundary
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1433 (list (car i) (list 'quote (car (cdr i)))))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1434 (list 0 newface))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1435 flpa))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1436 (setq flpa
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1437 (cons
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1438 (list (car (cdr i)) ;regexp
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1439 (list
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1440 (list
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1441 'lambda (list 'dummy)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1442 '(goto-char (match-beginning 0))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1443 (if (eq (nth 3 i) 'overwrite)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1444 nil
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1445 '(remove-text-properties
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1446 (point) (min (point-max) (1+ (point)))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1447 '(face nil font-lock-multiline nil)))
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1448 (list
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1449 'let (list '(e (match-end 0))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1450 (list 'm (list (car i) (car (cdr i)))))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1451 (list
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1452 'if 'm
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1453 (list
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1454 'YaTeX-font-lock-fillin
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1455 (list 'car 'm)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1456 (list 'cdr 'm)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1457 (list 'quote 'face)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1458 (list 'quote 'font-lock)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1459 (list 'quote newface))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1460 '(goto-char e)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1461 ))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1462 nil) ;retun nil to cheat font-lock
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1463 nil nil)) ;pre-match, post-match both nil
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1464 flpa)))))
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1465 (setq palist (cdr palist)));while
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1466 (if (featurep 'xemacsp)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1467 (nreverse flpa)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1468 flpa)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1469
73
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1470 (if (and (boundp 'YaTeX-use-font-lock)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1471 YaTeX-use-font-lock)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1472 (require 'font-lock))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1473
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1474 (cond
73
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1475 ((and (featurep 'font-lock) (fboundp 'defface))
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1476 ;; In each defface, '(class static-color) is for Emacs-21 -nw
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1477 ;; '(class tty) is for XEmacs-21 -nw
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1478 (defface YaTeX-font-lock-label-face
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1479 '((((class static-color)) (:foreground "yellow" :underline t))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1480 (((type tty)) (:foreground "yellow" :underline t))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1481 (((class color) (background dark)) (:foreground "pink" :underline t))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1482 (((class color) (background light)) (:foreground "red" :underline t))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1483 (t (:bold t :underline t)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1484 "Font Lock mode face used to highlight labels."
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1485 :group 'font-lock-faces)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1486 (defvar YaTeX-font-lock-label-face 'YaTeX-font-lock-label-face)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1487
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1488 (defface YaTeX-font-lock-declaration-face
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1489 '((((class color) (background dark)) (:foreground "cyan"))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1490 (((class color) (background light)) (:foreground "RoyalBlue"))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1491 (t (:bold t :underline t)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1492 "Font Lock mode face used to highlight some declarations."
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1493 :group 'font-lock-faces)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1494 (defvar YaTeX-font-lock-declaration-face 'YaTeX-font-lock-declaration-face)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1495
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1496 (defface YaTeX-font-lock-include-face
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1497 '((((class color) (background dark)) (:foreground "Plum1"))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1498 (((class color) (background light)) (:foreground "purple"))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1499 (t (:bold t :underline t)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1500 "Font Lock mode face used to highlight expression for including."
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1501 :group 'font-lock-faces)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1502 (defvar YaTeX-font-lock-include-face 'YaTeX-font-lock-include-face)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1503
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1504 (defface YaTeX-font-lock-formula-face
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1505 '((((class static-color)) (:bold t))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1506 (((type tty)) (:bold t))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1507 (((class color) (background dark)) (:foreground "khaki" :bold t))
376
1bbd0c2b340f When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents: 372
diff changeset
1508 (((class color) (background light)) (:foreground "DarkGoldenrod4"))
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1509 (t (:bold t :underline t)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1510 "Font Lock mode face used to highlight formula."
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1511 :group 'font-lock-faces)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1512 (defvar YaTeX-font-lock-formula-face 'YaTeX-font-lock-formula-face)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1513
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1514 (defface YaTeX-font-lock-delimiter-face
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1515 '((((class static-color)) (:bold t))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1516 (((type tty)) (:bold t))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1517 (((class color) (background dark))
376
1bbd0c2b340f When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents: 372
diff changeset
1518 (:foreground "lightyellow3" :background "navy" :bold t))
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1519 (((class color) (background light)) (:foreground "red"))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1520 (t (:bold t :underline t)))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1521 "Font Lock mode face used to highlight delimiters."
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1522 :group 'font-lock-faces)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1523 (defvar YaTeX-font-lock-delimiter-face 'YaTeX-font-lock-delimiter-face)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1524
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1525 (defface YaTeX-font-lock-math-sub-face
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1526 '((((class static-color)) (:bold t))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1527 (((type tty)) (:bold t))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1528 (((class color) (background dark))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1529 (:foreground "khaki" :bold t :underline t))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1530 (((class color) (background light))
376
1bbd0c2b340f When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents: 372
diff changeset
1531 (:foreground "DarkGoldenrod4" :underline t))
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1532 (t (:bold t :underline t)))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1533 "Font Lock mode face used to highlight subscripts in formula."
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1534 :group 'font-lock-faces)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1535 (defvar YaTeX-font-lock-math-sub-face 'YaTeX-font-lock-math-sub-face)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1536
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1537 (defface YaTeX-font-lock-math-sup-face
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1538 '((((class static-color)) (:bold t))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1539 (((type tty)) (:bold t))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1540 (((class color) (background dark))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1541 (:bold nil :foreground "ivory" :background "lightyellow4"))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1542 (((class color) (background light))
376
1bbd0c2b340f When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents: 372
diff changeset
1543 (:underline t :foreground "DarkGoldenrod3"))
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1544 (t (:bold t :underline t)))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1545 "Font Lock mode face used to highlight superscripts in formula."
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1546 :group 'font-lock-faces)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1547 (defvar YaTeX-font-lock-math-sup-face 'YaTeX-font-lock-math-sup-face)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1548
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1549 (defface YaTeX-font-lock-crossref-face
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1550 '((((class color) (background dark)) (:foreground "lightgoldenrod"))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1551 (((class color) (background light)) (:foreground "DarkGoldenrod"))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1552 (t (:bold t :underline t)))
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1553 "Font Lock mode face used to highlight cross references."
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1554 :group 'font-lock-faces)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1555 (defvar YaTeX-font-lock-crossref-face 'YaTeX-font-lock-crossref-face)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1556
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1557 (defface YaTeX-font-lock-bold-face
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1558 '((t (:bold t)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1559 "Font Lock mode face used to express bold itself."
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1560 :group 'font-lock-faces)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1561 (defvar YaTeX-font-lock-bold-face 'YaTeX-font-lock-bold-face)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1562
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1563 (defface YaTeX-font-lock-italic-face
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1564 '((t (:italic t)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1565 "Font Lock mode face used to express italic itself."
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1566 :group 'font-lock-faces)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1567 (defvar YaTeX-font-lock-italic-face 'YaTeX-font-lock-italic-face)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1568
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1569 ;; Make sure the 'YaTeX-font-lock-{italic,bold}-face is bound with
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1570 ;; italic/bold fontsets
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1571 (if (and (fboundp 'fontset-list) YaTeX-use-italic-bold)
73
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1572 (let ((flist (fontset-list)) fnt italic bold
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1573 (df (or (and (fboundp 'face-font-name) (face-font-name 'default))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1574 (face-font 'default)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1575 (face-font 'italic)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1576 (face-font 'bold)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1577 "giveup!"))
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1578 sz medium-i bold-r)
310
b16e6b1cf00b Runtime error avoidance
HIROSE Yuuji <yuuji@gentei.org>
parents: 294
diff changeset
1579 (if (string-match
b16e6b1cf00b Runtime error avoidance
HIROSE Yuuji <yuuji@gentei.org>
parents: 294
diff changeset
1580 "^-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-\\(\\([0-9]+\\)\\)" df)
b16e6b1cf00b Runtime error avoidance
HIROSE Yuuji <yuuji@gentei.org>
parents: 294
diff changeset
1581 (setq sz (or (match-string 1 df) "16"))
b16e6b1cf00b Runtime error avoidance
HIROSE Yuuji <yuuji@gentei.org>
parents: 294
diff changeset
1582 (setq sz "16"))
73
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1583 (setq medium-i (format "-medium-i-[^-]+--%s" sz)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1584 bold-r (format "-bold-r-[^-]+--%s" sz))
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1585 (while flist
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1586 (setq fnt (car flist))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1587 (condition-case err
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1588 (cond
73
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1589 ((and (string-match medium-i fnt)
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1590 (null italic))
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1591 (set-face-font 'YaTeX-font-lock-italic-face (setq italic fnt)))
73
f41b01fef5d6 Stable version(hope to be)
yuuji
parents: 72
diff changeset
1592 ((and (string-match bold-r fnt) (null bold))
72
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1593 (set-face-font 'YaTeX-font-lock-bold-face (setq bold fnt))))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1594 (error nil))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1595 (setq flist (cdr flist)))))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1596
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1597 ;;Borrowed from XEmacs's font-lock.el
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1598 (defsubst YaTeX-font-lock-fillin (start end setprop markprop value &optional object)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1599 "Fill in one property of the text from START to END.
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1600 Arguments PROP and VALUE specify the property and value to put where none are
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1601 already in place. Therefore existing property values are not overwritten.
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1602 Optional argument OBJECT is the string or buffer containing the text."
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1603 (let ((start (text-property-any start end markprop nil object)) next
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1604 (putfunc (if (fboundp 'put-nonduplicable-text-property)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1605 'put-nonduplicable-text-property
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1606 'put-text-property)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1607 (if (eq putfunc 'put-text-property)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1608 (setq markprop setprop))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1609 (while start
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1610 (setq next (next-single-property-change start markprop object end))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1611 (funcall putfunc start next setprop value object)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1612 (funcall putfunc start next markprop value object)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1613 (setq start (text-property-any next end markprop nil object)))))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1614
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1615 (defun YaTeX-warning-font-lock (mode)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1616 (let ((sw (selected-window)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1617 ;;(pop-to-buffer (format " *%s warning*" mode))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1618 ;;(erase-buffer)
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1619 (momentary-string-display
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1620 (cond
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1621 (YaTeX-japan
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1622 (concat mode " は、既に font-lock に対応しました。\n"
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1623 "~/.emacs などにある\n"
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1624 "\t(put 'yatex-mode 'font-lock-keywords 'tex-mode)\n"
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1625 "\t(put 'yahtml-mode 'font-lock-keywords 'html-mode)\n"
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1626 "などの間に合わせの記述はもはや不要です。"))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1627 (t
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1628 (concat mode " now supports the font-lock by itself.\n"
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1629 "So you can remove the descriptions such as\n"
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1630 "\t(put 'yatex-mode 'font-lock-keywords 'tex-mode)\n"
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1631 "\t(put 'yahtml-mode 'font-lock-keywords 'html-mode)\n"
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1632 "in your ~/.emacs file. Thank you."))) (point))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1633 (select-window sw)))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1634 ))
0aaebd07dad0 Support font-lock on XEmacs-21, Emacs-20, Emacs-21.
yuuji
parents: 70
diff changeset
1635
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1636 (defun YaTeX-assoc-regexp (elt alist)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1637 "Like assoc, return a list of whose car match with ELT. Search from ALIST.
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1638 Note that each car of cons-cell is regexp. ELT is a plain text to be
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1639 compared by regexp."
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1640 (let (x)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1641 (catch 'found
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1642 (while alist
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1643 (setq x (car (car alist)))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1644 (if (string-match x elt)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1645 (throw 'found (car alist)))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1646 (setq alist (cdr alist))))))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1647
247
3e3ccba06ca1 Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents: 244
diff changeset
1648 (defun YaTeX-push-to-kill-ring (string)
3e3ccba06ca1 Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents: 244
diff changeset
1649 "Push STRING to kill-ring, then show guidance message."
3e3ccba06ca1 Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents: 244
diff changeset
1650 (and (stringp string) (string< "" string)
3e3ccba06ca1 Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents: 244
diff changeset
1651 (let ((key (key-description (where-is-internal 'yank nil t)))
3e3ccba06ca1 Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents: 244
diff changeset
1652 (msg
3e3ccba06ca1 Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents: 244
diff changeset
1653 (if YaTeX-japan
3e3ccba06ca1 Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents: 244
diff changeset
1654 " をkill-ringに入れました。次のyank(%s)で貼付できます"
3e3ccba06ca1 Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents: 244
diff changeset
1655 " is stored into kill-ring. Paste it by yank(%s).")))
3e3ccba06ca1 Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents: 244
diff changeset
1656 (kill-new string)
3e3ccba06ca1 Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents: 244
diff changeset
1657 (message (concat "`%s'" msg) string key))))
3e3ccba06ca1 Construct `bb=...' line automatically and push it into kill-ring.
yuuji@gentei.org
parents: 244
diff changeset
1658
262
15ec86ff549c Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents: 247
diff changeset
1659 (defun YaTeX-elapsed-time (before after)
15ec86ff549c Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents: 247
diff changeset
1660 "Get elapsed time from BEFORE and AFTER, which are given from currente-time."
15ec86ff549c Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents: 247
diff changeset
1661 (if (fboundp 'float) ;Then, current-time function should be.
15ec86ff549c Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents: 247
diff changeset
1662 (let ((mil (float 1000000))) ;To protect parse error before 19
15ec86ff549c Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents: 247
diff changeset
1663 (+ (* (- (nth 0 after) (nth 0 before)) 65536)
15ec86ff549c Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents: 247
diff changeset
1664 (- (nth 1 after) (nth 1 before))
15ec86ff549c Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents: 247
diff changeset
1665 (- (/ (nth 2 after) mil)
15ec86ff549c Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents: 247
diff changeset
1666 (/ (nth 2 before) mil))))))
15ec86ff549c Call always bibtex after first typesetting when document needs bibtex.
HIROSE Yuuji <yuuji@gentei.org>
parents: 247
diff changeset
1667
68
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
1668 ;;;
482
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1669 ;; Moved from comment.el
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1670 ;;;
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1671 (defun YaTeX-comment-region-sub (string &optional beg end once)
483
6dcd746db62e DOC string fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 482
diff changeset
1672 "Insert STRING at the beginning of every line between BEG and END."
482
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1673 (if (not (stringp string)) (setq string YaTeX-comment-prefix))
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1674 (let ((b (or beg (region-beginning))) (e (or end (region-end))))
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1675 (save-excursion
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1676 (goto-char (max b e))
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1677 (if (bolp)
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1678 (forward-line -1))
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1679 (save-restriction
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1680 (narrow-to-region (min b e) (point))
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1681 (goto-char (point-min))
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1682 (message "%s" string)
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1683 (while (re-search-forward "^" nil t)
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1684 (insert string))))))
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1685
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1686 (defun YaTeX-uncomment-region-sub (string &optional beg end once)
483
6dcd746db62e DOC string fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 482
diff changeset
1687 "Delete STRING from the beginning of every line between BEG and END.
6dcd746db62e DOC string fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 482
diff changeset
1688 BEG and END are optional. If omitted, active region used.
6dcd746db62e DOC string fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 482
diff changeset
1689 Non-nil for optional 4th argument ONCE withholds from removing
6dcd746db62e DOC string fixed
HIROSE Yuuji <yuuji@gentei.org>
parents: 482
diff changeset
1690 successive comment chars at the beggining of lines."
482
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1691 (save-excursion
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1692 (save-restriction
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1693 (narrow-to-region (or beg (region-beginning)) (or end (region-end)))
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1694 (goto-char (point-min))
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1695 (while (re-search-forward (concat "^" string) nil t)
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1696 (replace-match "")
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1697 (if once (end-of-line))))))
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1698
9132c20372ec Remove comment.el and incorporate it into yatexlib.el
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
1699 ;;;
68
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
1700 ;; Functions for the Installation time
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
1701 ;;;
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1702
58
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
1703 (defun bcf-and-exit ()
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
1704 "Byte compile rest of argument and kill-emacs."
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
1705 (if command-line-args-left
68
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
1706 (let ((load-path (cons "." load-path)))
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
1707 (and (fboundp 'set-language-environment)
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
1708 (featurep 'mule)
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
1709 (set-language-environment "Japanese"))
58
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
1710 (mapcar 'byte-compile-file command-line-args-left)
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
1711 (kill-emacs))))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
1712
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1713 (defun tfb-and-exit ()
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1714 "Texinfo-format-buffer and kill-emacs."
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1715 (if command-line-args-left
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1716 (let ((load-path (cons ".." load-path)))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1717 (and (fboundp 'set-language-environment)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1718 (featurep 'mule)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1719 (set-language-environment "Japanese"))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1720 (mapcar (function
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1721 (lambda (arg)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1722 (find-file arg)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1723 (texinfo-format-buffer)
266
9d022a531549 Set buffer-file-coding-system for write at tfb-and-exit.
HIROSE Yuuji <yuuji@gentei.org>
parents: 262
diff changeset
1724 (cond
9d022a531549 Set buffer-file-coding-system for write at tfb-and-exit.
HIROSE Yuuji <yuuji@gentei.org>
parents: 262
diff changeset
1725 ((fboundp 'set-buffer-file-coding-system)
9d022a531549 Set buffer-file-coding-system for write at tfb-and-exit.
HIROSE Yuuji <yuuji@gentei.org>
parents: 262
diff changeset
1726 (set-buffer-file-coding-system 'sjis-dos))
9d022a531549 Set buffer-file-coding-system for write at tfb-and-exit.
HIROSE Yuuji <yuuji@gentei.org>
parents: 262
diff changeset
1727 ((fboundp 'set-file-coding-system)
9d022a531549 Set buffer-file-coding-system for write at tfb-and-exit.
HIROSE Yuuji <yuuji@gentei.org>
parents: 262
diff changeset
1728 (set-file-coding-system '*sjis*dos))
9d022a531549 Set buffer-file-coding-system for write at tfb-and-exit.
HIROSE Yuuji <yuuji@gentei.org>
parents: 262
diff changeset
1729 ((boundp 'NEMACS)
9d022a531549 Set buffer-file-coding-system for write at tfb-and-exit.
HIROSE Yuuji <yuuji@gentei.org>
parents: 262
diff changeset
1730 (set (make-local-variable 'kanji-fileio-code) 1)))
9d022a531549 Set buffer-file-coding-system for write at tfb-and-exit.
HIROSE Yuuji <yuuji@gentei.org>
parents: 262
diff changeset
1731 (let ((coding-system-for-write buffer-file-coding-system))
9d022a531549 Set buffer-file-coding-system for write at tfb-and-exit.
HIROSE Yuuji <yuuji@gentei.org>
parents: 262
diff changeset
1732 (basic-save-buffer))))
80
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1733 command-line-args-left)
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1734 (kill-emacs))))
9b4354af748c Too many changes from 1.72.
yuuji
parents: 79
diff changeset
1735
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
1736 (provide 'yatexlib)

yatex.org