annotate yatexlib.el @ 68:0eb6997bee16

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

yatex.org