annotate yatexlib.el @ 70:44e3a5e1e883

Fix makefile for Windows Brush up label completion \cite completion Support much more about LaTeX2e --- [yahtml] English Info (By Jun Ohya) Automatic pixel size detection for <img src="..."> Aware global-class of css definition & for char-entity reference
author yuuji
date Sun, 09 Apr 2000 03:37:47 +0000
parents 807c1e7e68b7
children 0aaebd07dad0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
1 ;;; -*- Emacs-Lisp -*-
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
2 ;;; YaTeX and yahtml common libraries, general functions and definitions
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
3 ;;; yatexlib.el
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
4 ;;; (c )1994-2000 by HIROSE Yuuji.[yuuji@yatex.org]
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
5 ;;; Last modified Sun Apr 9 12:36:25 2000 on firestorm
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
6 ;;; $Id$
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
7
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
8 ;; General variables
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
9 (defvar YaTeX-dos (memq system-type '(ms-dos windows-nt OS/2)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
10 (defvar YaTeX-emacs-19 (>= (string-to-int emacs-version) 19))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
11 (defvar YaTeX-emacs-20 (>= (string-to-int emacs-version) 20))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
12 (defvar YaTeX-user-completion-table
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
13 (if YaTeX-dos "~/_yatexrc" "~/.yatexrc")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
14 "*Default filename in which user completion table is saved.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
15
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
16 (defvar YaTeX-japan (or (boundp 'NEMACS) (boundp 'MULE) YaTeX-emacs-20)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
17 "Whether yatex mode is running on Japanese environment or not.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
18
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
19 ;; autoload from yahtml.el
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
20 (autoload 'yahtml-inner-environment-but "yahtml" "yahtml internal func." t)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
21
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
22 (defvar YaTeX-kanji-code-alist
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
23 (cond
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
24 ((boundp '*junet*)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
25 (list (cons
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
26 1
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
27 (if YaTeX-dos (if (boundp '*sjis-dos*) *sjis-dos* *sjis*dos)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
28 *sjis*))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
29 '(2 . *junet*) '(3 . *euc-japan*)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
30 (YaTeX-emacs-20
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
31 ;;(cdr-safe(assq 'coding-system (assoc "Japanese" language-info-alist)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
32 (list (cons
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
33 1 (cond (YaTeX-dos 'shift_jis-dos)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
34 ((member 'shift_jis (coding-system-list)) 'shift_jis-unix)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
35 (t 'sjis)))
68
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
36 '(2 . iso-2022-jp-unix)
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
37 '(3 . euc-jp-unix))))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
38 "Kanji-code expression translation table.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
39 (defvar YaTeX-inhibit-prefix-letter nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
40 "*T for changing key definitions from [prefix] Letter to [prefix] C-Letter.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
41
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
42 (defvar YaTeX-no-begend-shortcut nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
43 "*T for disabling shortcut of begin-type completion, [prefix] b d, etc.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
44
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
45 (defvar YaTeX-default-pop-window-height 10
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
46 "Default typesetting buffer height.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
47 If integer, sets the window-height of typesetting buffer.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
48 If string, sets the percentage of it.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
49 If nil, use default pop-to-buffer.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
50
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
51 (defvar YaTeX-create-file-prefix-g nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
52 "*Non-nil creates new file when [prefix] g on \\include{foo}.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
53
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
54 (defvar YaTeX-nervous t
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
55 "*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
56 And you will have the local dictionary.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
57
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
58 ;----------- work variables ----------------------------------------
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
59 (defvar YaTeX-typesetting-mode-map nil
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
60 "Keymap used in YaTeX typesetting buffer")
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
61
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
62 (if YaTeX-typesetting-mode-map nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
63 (setq YaTeX-typesetting-mode-map (make-keymap))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
64 ;(suppress-keymap YaTeX-typesetting-mode-map t)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
65 (define-key YaTeX-typesetting-mode-map " " 'YaTeX-jump-error-line)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
66 (define-key YaTeX-typesetting-mode-map "\C-m" 'YaTeX-send-string)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
67 (define-key YaTeX-typesetting-mode-map "1" 'delete-other-windows)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
68 (define-key YaTeX-typesetting-mode-map "0" 'delete-window)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
69 (define-key YaTeX-typesetting-mode-map "q" 'delete-window))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
70
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
71 (defvar YaTeX-parent-file nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
72 "*Main LaTeX source file name used when %#! expression doesn't exist.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
73 (make-variable-buffer-local 'YaTeX-parent-file)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
74
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
75 ;---------- Define default key bindings on YaTeX mode map ----------
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
76 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
77 (defun YaTeX-define-key (key binding &optional map)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
78 "Define key on YaTeX-prefix-map."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
79 (if YaTeX-inhibit-prefix-letter
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
80 (let ((c (aref key 0)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
81 (cond
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
82 ((and (>= c ?a) (<= c ?z)) (aset key 0 (1+ (- c ?a))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
83 ((and (>= c ?A) (<= c ?Z) (numberp YaTeX-inhibit-prefix-letter))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
84 (aset key 0 (1+ (- c ?A))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
85 (t nil))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
86 (define-key (or map YaTeX-prefix-map) key binding))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
87
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
88 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
89 (defun YaTeX-local-table-symbol (symbol)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
90 "Return the lisp symbol which keeps local completion table of SYMBOL."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
91 (intern (concat "YaTeX$"
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
92 default-directory
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
93 (symbol-name symbol))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
94
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
95 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
96 (defun YaTeX-sync-local-table (symbol)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
97 "Synchronize local variable SYMBOL.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
98 Copy its corresponding directory dependent completion table to SYMBOL."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
99 (if (boundp (YaTeX-local-table-symbol symbol))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
100 (set symbol (symbol-value (YaTeX-local-table-symbol symbol)))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
101
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
102 (defvar YaTeX-user-table-is-read nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
103 "Flag that means whether user completion table has been read or not.")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
104 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
105 (defun YaTeX-read-user-completion-table (&optional forcetoread)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
106 "Append user completion table of LaTeX macros"
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
107 (let*((user-table (expand-file-name YaTeX-user-completion-table))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
108 (local-table (expand-file-name (file-name-nondirectory user-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
109 var localvar localbuf (curbuf (current-buffer)) sexp)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
110 (if YaTeX-user-table-is-read nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
111 (message "Loading user completion table")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
112 (if (file-exists-p user-table) (load-file user-table)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
113 (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
114 (setq YaTeX-user-table-is-read t)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
115 (cond
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
116 ((file-exists-p local-table)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
117 (set-buffer (setq localbuf (find-file-noselect local-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
118 (widen)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
119 (goto-char (point-min))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
120 (while (re-search-forward "(setq \\([^ ]+\\)" nil t)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
121 (setq var (intern (buffer-substring
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
122 (match-beginning 1) (match-end 1)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
123 localvar (YaTeX-local-table-symbol var))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
124 (goto-char (match-beginning 0))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
125 (setq sexp (buffer-substring (point)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
126 (progn (forward-sexp) (point))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
127 (set-buffer curbuf)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
128 (or (assq var (buffer-local-variables)) (make-local-variable var))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
129 (eval (read sexp))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
130 (or (and (boundp localvar)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
131 (symbol-value localvar)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
132 (not forcetoread))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
133 (set localvar (symbol-value var)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
134 (set-buffer localbuf))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
135 (kill-buffer localbuf)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
136 (set-buffer curbuf)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
137
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
138 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
139 (defun YaTeX-reload-dictionary ()
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
140 "Reload local dictionary.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
141 Use this function after editing ./.yatexrc."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
142 (interactive)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
143 (let ((YaTeX-user-table-is-read nil))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
144 (YaTeX-read-user-completion-table t)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
145
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
146 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
147 (defun YaTeX-lookup-table (word type)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
148 "Lookup WORD in completion table whose type is TYPE.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
149 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
150 Typically, TYPE is one of 'env, 'section, 'fontsize, 'singlecmd."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
151 (if (symbolp type) (setq type (symbol-name type)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
152 (or (assoc word (symbol-value (intern (concat "tmp-" type "-table"))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
153 (assoc word (symbol-value (intern (concat "user-" type "-table"))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
154 (assoc word (symbol-value (intern (concat type "-table"))))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
155
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
156 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
157 (defun YaTeX-update-table (vallist default-table user-table local-table)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
158 "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
159 Second argument DEFAULT-TABLE is the quoted symbol of default completion
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
160 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
161 YaTeX-user-completion-table, fourth argument LOCAL-TABLE should have the
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
162 completion which is valid during current Emacs's session. If you
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
163 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
164 create the file in current directory which has the same name with
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
165 YaTeX-user-completion-table."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
166 (let ((car-v (car vallist)) key answer
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
167 (file (file-name-nondirectory YaTeX-user-completion-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
168 (cond
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
169 ((assoc car-v (symbol-value default-table))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
170 nil) ;Nothing to do
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
171 ((setq key (assoc car-v (symbol-value user-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
172 (if (equal (cdr vallist) (cdr key)) nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
173 ;; if association hits, but contents differ.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
174 (message
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
175 "%s's attributes turned into %s" (car vallist) (cdr vallist))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
176 (set user-table (delq key (symbol-value user-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
177 (set user-table (cons vallist (symbol-value user-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
178 (YaTeX-update-dictionary
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
179 YaTeX-user-completion-table user-table "user")))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
180 ((setq key (assoc car-v (symbol-value local-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
181 (if (equal (cdr vallist) (cdr key)) nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
182 (message
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
183 "%s's attributes turned into %s" (car vallist) (cdr vallist))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
184 (set local-table (delq key (symbol-value local-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
185 (set local-table (cons vallist (symbol-value local-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
186 (set (YaTeX-local-table-symbol local-table) (symbol-value local-table))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
187 (YaTeX-update-dictionary file local-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
188 ;; All of above cases, there are some completion in tables.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
189 ;; Then update tables.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
190 (t
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
191 (if (not YaTeX-nervous)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
192 (setq answer "u")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
193 (message
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
194 (cond
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
195 (YaTeX-japan
68
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
196 "`%s'‚Ì“o˜^æ: U)ƒ†[ƒUŽ«‘ L)ƒ[ƒJƒ‹Ž«‘ N)ƒƒ‚ƒŠ D)‚µ‚È‚¢")
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
197 (t
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
198 "Register `%s' into: U)serDic L)ocalDic N)one D)iscard"))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
199 (if (> (length car-v) 23)
68
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
200 (concat (substring car-v 0 10) "..." (substring car-v -9))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
201 car-v))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
202 (setq answer (char-to-string (read-char))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
203 (cond
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
204 ((string-match answer "uy")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
205 (set user-table (cons vallist (symbol-value user-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
206 (YaTeX-update-dictionary YaTeX-user-completion-table user-table "user")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
207 )
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
208 ((string-match answer "tl")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
209 (set local-table (cons vallist (symbol-value local-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
210 (set (YaTeX-local-table-symbol local-table) (symbol-value local-table))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
211 (YaTeX-update-dictionary file local-table))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
212 ((string-match answer "d") nil) ;discard it
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
213 (t (set default-table
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
214 (cons vallist (symbol-value default-table)))))))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
215
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
216 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
217 (defun YaTeX-cplread-with-learning
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
218 (prom default-table user-table local-table
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
219 &optional pred reqmatch init hsym)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
220 "Completing read with learning.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
221 Do a completing read with prompt PROM. Completion table is what
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
222 DEFAULT-TABLE, USER-TABLE, LOCAL table are appended in reverse order.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
223 Note that these tables are passed by the symbol.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
224 Optional arguments PRED, REQMATH and INIT are passed to completing-read
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
225 as its arguments PREDICATE, REQUIRE-MATCH and INITIAL-INPUT respectively.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
226 If optional 8th argument HSYM, history symbol, is passed, use it as
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
227 history list variable."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
228 (YaTeX-sync-local-table local-table)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
229 (let*((table (append (symbol-value local-table)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
230 (symbol-value user-table)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
231 (symbol-value default-table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
232 (word (completing-read-with-history
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
233 prom table pred reqmatch init hsym)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
234 (if (and (string< "" word) (not (assoc word table)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
235 (YaTeX-update-table (list word) default-table user-table local-table))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
236 word))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
237
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
238 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
239 (defun YaTeX-update-dictionary (file symbol &optional type)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
240 (let ((local-table-buf (find-file-noselect file))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
241 (name (symbol-name symbol))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
242 (value (symbol-value symbol)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
243 (save-excursion
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
244 (message "Updating %s dictionary..." (or type "local"))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
245 (set-buffer local-table-buf)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
246 (goto-char (point-max))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
247 (search-backward (concat "(setq " name) nil t)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
248 (delete-region (point) (progn (forward-sexp) (point)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
249 (delete-blank-lines)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
250 (insert "(setq " name " '(\n")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
251 (mapcar '(lambda (s)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
252 (insert (format "%s\n" (prin1-to-string s))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
253 value)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
254 (insert "))\n\n")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
255 (delete-blank-lines)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
256 (basic-save-buffer)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
257 (kill-buffer local-table-buf)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
258 (message "Updating %s dictionary...Done" (or type "local")))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
259
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
260 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
261 (defun YaTeX-define-begend-key-normal (key env &optional map)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
262 "Define short cut YaTeX-make-begin-end key."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
263 (YaTeX-define-key
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
264 key
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
265 (list 'lambda '(arg) '(interactive "P")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
266 (list 'YaTeX-insert-begin-end env 'arg))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
267 map))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
268
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
269 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
270 (defun YaTeX-define-begend-region-key (key env &optional map)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
271 "Define short cut YaTeX-make-begin-end-region key."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
272 (YaTeX-define-key key (list 'lambda nil '(interactive)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
273 (list 'YaTeX-insert-begin-end env t)) map))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
274
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
275 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
276 (defun YaTeX-define-begend-key (key env &optional map)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
277 "Define short cut key for begin type completion both for normal
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
278 and region mode. To customize YaTeX, user should use this function."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
279 (YaTeX-define-begend-key-normal key env map)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
280 (if YaTeX-inhibit-prefix-letter nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
281 (YaTeX-define-begend-region-key
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
282 (concat (upcase (substring key 0 1)) (substring key 1)) env)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
283
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
284 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
285 (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
286 "Search STRING which is not commented out by CMNTRX.
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
287 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
288 or search-backward.
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
289 Optional sixth argument FUNC changes search-function."
49
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 47
diff changeset
290 (let ((sfunc (or func 'search-forward)) found md)
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
291 (while (and (prog1
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
292 (setq found (funcall sfunc string bound err cnt))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
293 (setq md (match-data)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
294 (or
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
295 (and (eq major-mode 'yatex-mode)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
296 (YaTeX-in-verb-p (match-beginning 0)))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
297 (save-excursion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
298 (beginning-of-line)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
299 (re-search-forward cmntrx (match-beginning 0) t)))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
300 (store-match-data md)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
301 found))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
302
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
303 (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
304 "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
305 See also YaTeX-search-active-forward."
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
306 (YaTeX-search-active-forward regexp cmntrx bound err cnt 're-search-forward))
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
307
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
308 (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
309 "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
310 See also YaTeX-search-active-forward."
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
311 (YaTeX-search-active-forward string cmntrx bound err cnt 'search-backward))
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
312
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
313 (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
314 "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
315 See also YaTeX-search-active-forward."
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
316 (YaTeX-search-active-forward
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
317 regexp cmntrx bound err cnt 're-search-backward))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
318
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
319 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
320 (defun YaTeX-switch-to-buffer (file &optional setbuf)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
321 "Switch to buffer if buffer exists, find file if not.
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
322 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
323 (interactive "Fswitch to file: ")
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
324 (if (bufferp file)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
325 (setq file (buffer-file-name file))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
326 (and (string-match "^[^/].*/" file)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
327 (eq major-mode 'yatex-mode)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
328 YaTeX-search-file-from-top-directory
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
329 (save-excursion
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
330 (YaTeX-visit-main t)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
331 (setq file (expand-file-name file)))))
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
332 (let (buf (hilit-auto-highlight (not setbuf)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
333 (cond
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
334 ((setq buf (get-file-buffer file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
335 (funcall (if setbuf 'set-buffer 'switch-to-buffer)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
336 (get-file-buffer file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
337 buf)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
338 ((or YaTeX-create-file-prefix-g (file-exists-p file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
339 (or ;find-file returns nil but set current-buffer...
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
340 (if setbuf (set-buffer (find-file-noselect file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
341 (find-file file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
342 (current-buffer)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
343 (t (message "%s was not found in this directory." file)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
344 nil))))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
345
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
346 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
347 (defun YaTeX-switch-to-buffer-other-window (file)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
348 "Switch to buffer if buffer exists, find file if not."
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
349 (interactive "Fswitch to file: ")
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
350 (and (eq major-mode 'yatex-mode)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
351 (stringp file)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
352 (string-match "^[^/].*/" file)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
353 YaTeX-search-file-from-top-directory
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
354 (save-excursion
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
355 (YaTeX-visit-main t)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
356 (setq file (expand-file-name file))))
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
357 (if (bufferp file) (setq file (buffer-file-name file)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
358 (cond
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
359 ((get-file-buffer file)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
360 (switch-to-buffer-other-window (get-file-buffer file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
361 t)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
362 ((or YaTeX-create-file-prefix-g (file-exists-p file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
363 (find-file-other-window file) t)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
364 (t (message "%s was not found in this directory." file)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
365 nil)))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
366
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
367 (defun YaTeX-get-file-buffer (file)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
368 "Return the FILE's buffer.
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
369 Base directory is that of main file or current directory."
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
370 (let (dir main (cdir default-directory))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
371 (or (and (eq major-mode 'yatex-mode)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
372 YaTeX-search-file-from-top-directory
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
373 (save-excursion
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
374 (YaTeX-visit-main t)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
375 (get-file-buffer file)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
376 (get-file-buffer file))))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
377
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
378 (defun YaTeX-replace-format-sub (string format repl)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
379 (let ((beg (or (string-match (concat "^\\(%" format "\\)") string)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
380 (string-match (concat "[^%]\\(%" format "\\)") string)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
381 (len (length format)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
382 (if (null beg) string ;no conversion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
383 (concat
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
384 (substring string 0 (match-beginning 1)) (or repl "")
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
385 (substring string (match-end 1))))))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
386
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
387 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
388 (defun YaTeX-replace-format (string format repl)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
389 "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
390 function `format' does. FORMAT does not contain `%'"
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
391 (let ((ans string))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
392 (while (not (string=
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
393 ans (setq string (YaTeX-replace-format-sub ans format repl))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
394 (setq ans string))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
395 string))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
396
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
397 ;;;###autoload
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
398 (defun YaTeX-replace-formats (string replace-list)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
399 (let ((list replace-list))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
400 (while list
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
401 (setq string (YaTeX-replace-format
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
402 string (car (car list)) (cdr (car list)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
403 list (cdr list)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
404 string))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
405
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
406 ;;;###autoload
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
407 (defun YaTeX-replace-format-args (string &rest args)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
408 "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
409 corresponding real arguments ARGS."
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
410 (let ((argp 1))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
411 (while args
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
412 (setq string
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
413 (YaTeX-replace-format string (int-to-string argp) (car args)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
414 (setq args (cdr args) argp (1+ argp))))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
415 string)
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
416
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
417 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
418 (defun rindex (string char)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
419 (let ((pos (1- (length string)))(index -1))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
420 (while (>= pos 0)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
421 (cond
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
422 ((= (aref string pos) char)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
423 (setq index pos) (setq pos -1))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
424 (t (setq pos (1- pos))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
425 )
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
426 index))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
427
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
428 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
429 (defun point-beginning-of-line ()
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
430 (save-excursion (beginning-of-line)(point)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
431
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
432 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
433 (defun point-end-of-line ()
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
434 (save-excursion (end-of-line)(point)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
435
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
436
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
437 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
438 (defun YaTeX-showup-buffer (buffer &optional func select)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
439 "Make BUFFER show up in certain window (but current window)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
440 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
441 of its window object. Non-nil for optional third argument SELECT selects
49
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 47
diff changeset
442 that window. This function never selects minibuffer window."
53
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
443 (or (and (if (and YaTeX-emacs-19 select)
47
d7e7b4654058 Support special popup frame.
yuuji
parents: 46
diff changeset
444 (get-buffer-window buffer t)
d7e7b4654058 Support special popup frame.
yuuji
parents: 46
diff changeset
445 (get-buffer-window buffer))
d7e7b4654058 Support special popup frame.
yuuji
parents: 46
diff changeset
446 (progn
d7e7b4654058 Support special popup frame.
yuuji
parents: 46
diff changeset
447 (if select
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
448 (goto-buffer-window buffer))
47
d7e7b4654058 Support special popup frame.
yuuji
parents: 46
diff changeset
449 t))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
450 (let ((window (selected-window))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
451 (wlist (YaTeX-window-list)) win w (x 0))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
452 (cond
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
453 ((> (length wlist) 2)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
454 (if func
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
455 (while wlist
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
456 (setq w (car wlist))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
457 (if (and (not (eq window w))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
458 (> (funcall func w) x))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
459 (setq win w x (funcall func w)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
460 (setq wlist (cdr wlist)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
461 (setq win (get-lru-window)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
462 (select-window win)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
463 (switch-to-buffer buffer)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
464 (or select (select-window window)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
465 ((= (length wlist) 2)
49
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 47
diff changeset
466 ;(other-window 1);This does not work properly on Emacs-19
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 47
diff changeset
467 (select-window (get-lru-window))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
468 (switch-to-buffer buffer)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
469 (or select (select-window window)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
470 (t ;if one-window
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
471 (cond
47
d7e7b4654058 Support special popup frame.
yuuji
parents: 46
diff changeset
472 ((and YaTeX-emacs-19 (get-buffer-window buffer t))
d7e7b4654058 Support special popup frame.
yuuji
parents: 46
diff changeset
473 nil) ;if found in other frame
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
474 (YaTeX-default-pop-window-height
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
475 (split-window-calculate-height YaTeX-default-pop-window-height)
59
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
476 ;;(pop-to-buffer buffer) ;damn! emacs-19.30
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
477 (select-window (next-window nil 1))
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
478 (switch-to-buffer (get-buffer-create buffer))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
479 (or select (select-window window)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
480 (t nil)))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
481 ))))
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
482
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
483 (cond
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
484 ((fboundp 'screen-height)
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
485 (fset 'YaTeX-screen-height 'screen-height)
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
486 (fset 'YaTeX-screen-width 'screen-width))
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
487 ((fboundp 'frame-height)
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
488 (fset 'YaTeX-screen-height 'frame-height)
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
489 (fset 'YaTeX-screen-width 'frame-width))
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
490 (t (error "I don't know how to run windows.el on this Emacs...")))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
491
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
492 ;;;###autoload
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
493 (defun split-window-calculate-height (height)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
494 "Split current window wight specified HEIGHT.
59
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
495 If HEIGHT is number, make a new window that has HEIGHT lines.
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
496 If HEIGHT is string, make a new window that occupies HEIGT % of screen height.
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
497 Otherwise split window conventionally."
59
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
498 (if (one-window-p t)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
499 (split-window
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
500 (selected-window)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
501 (max
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
502 (min
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
503 (- (YaTeX-screen-height)
59
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
504 (if (numberp height)
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
505 (+ height 2)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
506 (/ (* (YaTeX-screen-height)
59
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
507 (string-to-int height))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
508 100)))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
509 (- (YaTeX-screen-height) window-min-height 1))
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
510 window-min-height))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
511
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
512 ;;;###autoload
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
513 (defun YaTeX-window-list ()
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
514 (let*((curw (selected-window)) (win curw) (wlist (list curw)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
515 (while (not (eq curw (setq win (next-window win))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
516 (or (eq win (minibuffer-window))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
517 (setq wlist (cons win wlist))))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
518 wlist))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
519
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
520 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
521 (defun substitute-all-key-definition (olddef newdef keymap)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
522 "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
523 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
524 where ever it appears."
68
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
525 (if YaTeX-emacs-19
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
526 (substitute-key-definition olddef newdef keymap global-map)
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
527 (mapcar
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
528 (function (lambda (key) (define-key keymap key newdef)))
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
529 (where-is-internal olddef keymap))))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
530
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
531 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
532 (defun YaTeX-match-string (n &optional m)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
533 "Return (buffer-substring (match-beginning n) (match-beginning m))."
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
534 (if (match-beginning n)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
535 (buffer-substring (match-beginning n)
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
536 (match-end (or m n)))))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
537
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
538 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
539 (defun YaTeX-minibuffer-complete ()
49
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 47
diff changeset
540 "Complete in minibuffer.
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
541 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
542 the character class of delimiters. Completion will be performed on
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
543 the last field separated by those delimiters.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
544 If the symbol 'quick is bound and is 't, when the try-completion results
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
545 in t, exit minibuffer immediately."
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
546 (interactive)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
547 (let ((md (match-data)) beg word compl
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
548 (quick (and (boundp 'quick) (eq quick t)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
549 (displist ;function to display completion-list
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
550 (function
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
551 (lambda ()
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
552 (with-output-to-temp-buffer "*Completions*"
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
553 (display-completion-list
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
554 (all-completions word minibuffer-completion-table)))))))
49
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 47
diff changeset
555 (setq beg (if (and (boundp 'delim) (stringp delim))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
556 (save-excursion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
557 (skip-chars-backward (concat "^" delim))
49
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 47
diff changeset
558 (point))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
559 (point-min))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
560 word (buffer-substring beg (point-max))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
561 compl (try-completion word minibuffer-completion-table))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
562 (cond
49
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 47
diff changeset
563 ((eq compl t)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
564 (if quick (exit-minibuffer)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
565 (let ((p (point)) (max (point-max)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
566 (unwind-protect
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
567 (progn
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
568 (goto-char max)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
569 (insert " [Sole completion]")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
570 (goto-char p)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
571 (sit-for 1))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
572 (delete-region max (point-max))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
573 (goto-char p)))))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
574 ((eq compl nil)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
575 (ding)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
576 (save-excursion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
577 (let (p)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
578 (unwind-protect
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
579 (progn
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
580 (goto-char (setq p (point-max)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
581 (insert " [No match]")
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
582 (goto-char p)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
583 (sit-for 2))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
584 (delete-region p (point-max))))))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
585 ((string= compl word)
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
586 (funcall displist))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
587 (t (delete-region beg (point-max))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
588 (insert compl)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
589 (if quick
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
590 (if (eq (try-completion compl minibuffer-completion-table) t)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
591 (exit-minibuffer)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
592 (funcall displist)))))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
593 (store-match-data md)))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
594
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
595 (defun YaTeX-minibuffer-quick-complete ()
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
596 "Set 'quick to 't and call YaTeX-minibuffer-complete.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
597 See documentation of YaTeX-minibuffer-complete."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
598 (interactive)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
599 (let ((quick t))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
600 (self-insert-command 1)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
601 (YaTeX-minibuffer-complete)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
602
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
603 (defun foreach-buffers (pattern job)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
604 "For each buffer which matches with PATTERN, do JOB."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
605 (let ((list (buffer-list)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
606 (save-excursion
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
607 (while list
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
608 (set-buffer (car list))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
609 (if (or (and (stringp pattern)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
610 (buffer-file-name)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
611 (string-match pattern (buffer-file-name)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
612 (and (symbolp pattern) major-mode (eq major-mode pattern)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
613 (eval job))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
614 (setq list (cdr list))))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
615
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
616 (defun goto-buffer-window (buffer)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
617 "Select window which is bound to BUFFER.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
618 If no such window exist, switch to buffer BUFFER."
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents: 51
diff changeset
619 (interactive "BGoto buffer: ")
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
620 (if (stringp buffer)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
621 (setq buffer (or (get-file-buffer buffer) (get-buffer buffer))))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
622 (if (get-buffer buffer)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
623 (cond
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
624 ((get-buffer-window buffer)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
625 (select-window (get-buffer-window buffer)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
626 ((and YaTeX-emacs-19 (get-buffer-window buffer t))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
627 (let*((win (get-buffer-window buffer t))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
628 (frame (window-frame win)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
629 (select-frame frame)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
630 (raise-frame frame)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
631 (focus-frame frame)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
632 (select-window win)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
633 (set-mouse-position frame 0 0)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
634 (and (featurep 'windows) (fboundp 'win:adjust-window)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
635 (win:adjust-window))))
54
2d45e43fb35f Full support of English documents
yuuji
parents: 53
diff changeset
636 ((and (featurep 'windows) (fboundp 'win:get-buffer-window)
56
a9653fbd1c1c Bug fix version
yuuji
parents: 54
diff changeset
637 (let ((w (win:get-buffer-window buffer)))
a9653fbd1c1c Bug fix version
yuuji
parents: 54
diff changeset
638 (and w (win:switch-window w))))
54
2d45e43fb35f Full support of English documents
yuuji
parents: 53
diff changeset
639 (select-window (get-buffer-window buffer)))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
640 (t (switch-to-buffer buffer)))))
51
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
641
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
642 ;; Here starts the functions which support gmhist-vs-Emacs19 compatible
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
643 ;; reading with history.
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
644 ;;;###autoload
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
645 (defun completing-read-with-history
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
646 (prompt table &optional predicate must-match initial hsym)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
647 "Completing read with general history: gmhist, Emacs-19."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
648 (let ((minibuffer-history
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
649 (or (symbol-value hsym)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
650 (and (boundp 'minibuffer-history) minibuffer-history)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
651 (minibuffer-history-symbol (or hsym 'minibuffer-history)))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
652 (prog1
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
653 (if (fboundp 'completing-read-with-history-in)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
654 (completing-read-with-history-in
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
655 minibuffer-history-symbol prompt table predicate must-match initial)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
656 (completing-read prompt table predicate must-match initial))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
657 (if (and YaTeX-emacs-19 hsym) (set hsym minibuffer-history)))))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
658
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
659 ;;;###autoload
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
660 (defun read-from-minibuffer-with-history (prompt &optional init map read hsym)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
661 "Read from minibuffer with general history: gmhist, Emacs-19."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
662 (cond
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
663 (YaTeX-emacs-19
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
664 (read-from-minibuffer prompt init map read hsym))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
665 (t
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
666 (let ((minibuffer-history-symbol hsym))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
667 (read-from-minibuffer prompt init map read)))))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
668
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
669 ;;;###autoload
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
670 (defun read-string-with-history (prompt &optional init hsym)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
671 "Read string with history: gmhist(Emacs-18) and Emacs-19."
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
672 (cond
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
673 (YaTeX-emacs-19
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
674 (read-from-minibuffer prompt init minibuffer-local-map nil hsym))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
675 ((featurep 'gmhist-mh)
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
676 (read-with-history-in hsym prompt init))
b0371b6ed799 Created `ChangeLog'.
yuuji
parents: 49
diff changeset
677 (t (read-string prompt init))))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
678
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
679 ;;;###autoload
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
680 (fset 'YaTeX-rassoc
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
681 (if (and nil (fboundp 'rassoc) (subrp (symbol-function 'rassoc)))
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
682 (symbol-function 'rassoc)
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
683 (function
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
684 (lambda (key list)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
685 (let ((l list))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
686 (catch 'found
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
687 (while l
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
688 (if (equal key (cdr (car l)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
689 (throw 'found (car l)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
690 (setq l (cdr l)))))))))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
691
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
692 (defun YaTeX-insert-file-contents (file visit &optional beg end)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
693 (cond
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
694 ((string< "19" emacs-version)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
695 (insert-file-contents file visit beg end))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
696 ((string-match "unix" (symbol-name system-type))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
697 (let ((default-process-coding-system
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
698 (and (boundp '*noconv*) (list *noconv*)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
699 file-coding-system (and (boundp '*noconv*) *noconv*)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
700 kanji-fileio-code
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
701 (default-process-kanji-code 0))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
702 (call-process shell-file-name file (current-buffer) nil
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
703 (or (and (boundp 'shell-command-option)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
704 shell-command-option)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
705 "-c")
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
706 (format "head -c %d | tail -c +%d" end beg))))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
707 (t (insert-file-contents file))))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
708
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
709 (defun YaTeX-split-string (str &optional sep null)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
710 "Split string STR by every occurrence of SEP(regexp).
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
711 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
712 Do not include null string by default. Non-nil for optional third argument
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
713 NULL includes null string in a list."
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
714 (let ((sep (or sep "[ \f\t\n\r\v]+"))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
715 list m)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
716 (while str
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
717 (if (setq m (string-match sep str))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
718 (progn
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
719 (if (or (> m 0) null)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
720 (setq list (cons (substring str 0 m) list)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
721 (setq str (substring str (match-end 0))))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
722 (if (or null (string< "" str))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
723 (setq list (cons str list)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
724 (setq str nil)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
725 (nreverse list)))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
726
53
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
727 ;;;
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
728 ;; Interface function for windows.el
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
729 ;;;
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
730 ;;;###autoload
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
731 (defun YaTeX-switch-to-window ()
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
732 "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
733 (interactive)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
734 (or (featurep 'windows) (error "Why don't you use `windows.el'?"))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
735 (win-switch-to-window 1 (- last-command-char win:base-key)))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 52
diff changeset
736
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
737 ;;;###autoload
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
738 (defun YaTeX-reindent (col)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
739 "Remove current indentation and reindento to COL column."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
740 (save-excursion
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
741 (beginning-of-line)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
742 (skip-chars-forward " \t")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
743 (if (/= col (current-column))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
744 (progn
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
745 (delete-region (point) (progn (beginning-of-line) (point)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
746 (indent-to col))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
747 (skip-chars-forward " \t" (point-end-of-line)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
748
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
749 (defun YaTeX-inner-environment (&optional quick)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
750 "Return current inner-most environment.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
751 Non-nil for optional argument QUICK restricts search bound to most
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
752 recent sectioning command. Matching point is stored to property 'point
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
753 of 'YaTeX-inner-environment, which can be referred by
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
754 (get 'YaTeX-inner-environment 'point)."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
755 (let*((nest 0)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
756 (beg (YaTeX-replace-format-args
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
757 (regexp-quote YaTeX-struct-begin)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
758 ;YaTeX-struct-begin ;=== TENTATIVE!! ==
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
759 YaTeX-struct-name-regexp
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
760 (if (eq major-mode 'yahtml-mode) "\\s *.*" "")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
761 ""))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
762 (end (YaTeX-replace-format-args
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
763 (regexp-quote YaTeX-struct-end)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
764 YaTeX-struct-name-regexp "" ""))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
765 (begend (concat "\\(" beg "\\)\\|\\(" end "\\)"))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
766 bound m0
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
767 (htmlp (eq major-mode 'yahtml-mode))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
768 (open
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
769 (concat "^" (or (cdr (assq major-mode '((yahtml-mode . "<")))) "{")))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
770 (close
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
771 (concat "^"
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
772 (or (cdr(assq major-mode '((yahtml-mode . "\n\t >")))) "}"))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
773 (save-excursion
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
774 (if quick
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
775 (setq bound
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
776 (save-excursion
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
777 (if htmlp
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
778 ;;(re-search-backward YaTeX-sectioning-regexp nil 1)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
779 (goto-char (point-min)) ;Is this enough? 97/6/26
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
780 (YaTeX-re-search-active-backward
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
781 (concat YaTeX-ec-regexp
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
782 "\\(" YaTeX-sectioning-regexp "\\)\\*?{")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
783 YaTeX-comment-prefix nil 1))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
784 (or (bobp) (end-of-line))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
785 (point))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
786 (if (catch 'begin
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
787 (if (and (numberp bound) (< (point) bound)) (throw 'begin nil))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
788 (while (YaTeX-re-search-active-backward
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
789 begend YaTeX-comment-prefix bound t)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
790 (setq m0 (match-beginning 0))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
791 (if (looking-at end) ;;(match-beginning 2)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
792 (setq nest (1+ nest))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
793 (setq nest (1- nest)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
794 (if (< nest 0)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
795 (progn
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
796 (put 'YaTeX-inner-environment 'point m0)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
797 (goto-char m0)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
798 (put 'YaTeX-inner-environment 'indent (current-column))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
799 (throw 'begin t)))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
800 (buffer-substring
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
801 (progn (skip-chars-forward open) (1+ (point)))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
802 (progn (skip-chars-forward close) (point)))))))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
803
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
804 (defun YaTeX-end-environment ()
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
805 "Close opening environment"
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
806 (interactive)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
807 (let ((env (YaTeX-inner-environment)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
808 (if (not env) (error "No premature environment")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
809 (save-excursion
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
810 (if (YaTeX-search-active-forward
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
811 (YaTeX-replace-format-args YaTeX-struct-end env "" "")
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
812 YaTeX-comment-prefix nil t)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
813 (if (y-or-n-p
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
814 (concat "Environment `" env
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
815 "' may be already closed. Force close?"))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
816 nil
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
817 (error "end environment aborted."))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
818 (message "") ;Erase (y or n) message.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
819 (YaTeX-insert-struc 'end env)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
820 (save-excursion
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
821 (goto-char (or (get 'YaTeX-inner-environment 'point) (match-end 0)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
822 (if (pos-visible-in-window-p)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
823 (sit-for (if YaTeX-dos 2 1))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
824 (message "Matches with %s at line %d"
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
825 (YaTeX-replace-format-args YaTeX-struct-begin env "" "")
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
826 (count-lines (point-min) (point))))))))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
827
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
828 (defun YaTeX-beginning-of-environment (&optional limit-search-bound end)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
829 "Goto the beginning of the current environment.
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
830 Optional argument LIMIT-SEARCH-BOUND non-nil limits the search bound to
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
831 most recent sectioning command. Non-nil for optional third argument END
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
832 goes to end of environment."
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
833 (interactive)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
834 (let ((op (point)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
835 (if (YaTeX-inner-environment limit-search-bound)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
836 (progn
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
837 (goto-char (get 'YaTeX-inner-environment 'point))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
838 (and end (YaTeX-goto-corresponding-environment))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
839 (if (interactive-p) (push-mark op))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
840 t))))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
841
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
842 (defun YaTeX-end-of-environment (&optional limit-search-bound)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
843 "Goto the end of the current environment.
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
844 Optional argument LIMIT-SEARCH-BOUND non-nil limits the search bound
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
845 to most recent sectioning command."
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
846 (interactive)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
847 (YaTeX-beginning-of-environment limit-search-bound t))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
848
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
849 (defun YaTeX-mark-environment ()
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
850 "Mark current position and move point to end of environment."
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
851 (interactive)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
852 (let ((curp (point)))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
853 (if (and (YaTeX-on-begin-end-p) (match-beginning 1)) ;if on \\begin
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
854 (forward-line 1)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
855 (beginning-of-line))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
856 (if (not (YaTeX-end-of-environment)) ;arg1 turns to match-beginning 1
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
857 (progn
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
858 (goto-char curp)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
859 (error "Cannot found the end of current environment."))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
860 (YaTeX-goto-corresponding-environment)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
861 (beginning-of-line) ;for confirmation
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
862 (if (< curp (point))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
863 (progn
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
864 (message "Mark this environment?(y or n): ")
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
865 (if (= (read-char) ?y) nil
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
866 (goto-char curp)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
867 (error "Abort. Please call again at more proper position."))))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
868 (set-mark-command nil)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
869 (YaTeX-goto-corresponding-environment)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
870 (end-of-line)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
871 (if (eobp) nil (forward-char 1)))))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
872
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 69
diff changeset
873
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
874 ;;;VER2
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
875 (defun YaTeX-insert-struc (what env)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
876 (cond
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
877 ((eq what 'begin)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
878 (insert (YaTeX-replace-format-args
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
879 YaTeX-struct-begin env (YaTeX-addin env))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
880 ((eq what 'end)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
881 (insert (YaTeX-replace-format-args YaTeX-struct-end env)))
69
807c1e7e68b7 yahtml-escape-chars-region
yuuji
parents: 68
diff changeset
882 (t nil)))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
883
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
884 ;;; Function for menu support
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
885 (defun YaTeX-define-menu (keymap bindlist)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
886 "Define KEYMAP(symbol)'s menu-bindings according to BINDLIST.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
887 KEYMAP should be a quoted symbol of newly allocated keymap.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
888 BINDLIST consists of binding list. Each element is as follows.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
889
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
890 '(menusymbol DOC_String . contents)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
891
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
892 CONTENTS is one of lambda-form, interactive function, or other keymap.
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
893 See yatex19.el for example."
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
894 (cond
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
895 ((featurep 'xemacs)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
896 (let (name)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
897 (if (keymapp (symbol-value keymap))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
898 (progn
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
899 (setq name (keymap-name (symbol-value keymap)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
900 (set keymap nil))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
901 (setq name (car (symbol-value keymap)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
902 (set keymap (cdr (symbol-value keymap))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
903 (mapcar
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
904 (function
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
905 (lambda (bind)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
906 (setq bind (cdr bind))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
907 (if (eq (car-safe (cdr bind)) 'lambda)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
908 (setcar (cdr bind) 'progn))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
909 (if (stringp (car-safe (cdr bind)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
910 (set keymap
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
911 (cons (cdr bind) (symbol-value keymap)))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
912 (set keymap
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
913 (cons (vector (car bind) (cdr bind) t)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
914 (symbol-value keymap))))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
915 bindlist)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
916 (set keymap (cons name (symbol-value keymap)))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
917 (t
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
918 (mapcar
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
919 (function
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
920 (lambda (bind)
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
921 (define-key (symbol-value keymap) (vector (car bind)) (cdr bind))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
922 bindlist))))
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
923
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
924
68
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
925 ;;;
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
926 ;; Functions for the Installation time
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
927 ;;;
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
928
58
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
929 (defun bcf-and-exit ()
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
930 "Byte compile rest of argument and kill-emacs."
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
931 (if command-line-args-left
68
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
932 (let ((load-path (cons "." load-path)))
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
933 (and (fboundp 'set-language-environment)
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
934 (featurep 'mule)
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 64
diff changeset
935 (set-language-environment "Japanese"))
58
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
936 (mapcar 'byte-compile-file command-line-args-left)
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
937 (kill-emacs))))
64
36a48185b95a Changes are listed in yatex.new.
yuuji
parents: 59
diff changeset
938
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
939 (provide 'yatexlib)

yatex.org