yatex
annotate yatexadd.el @ 16:cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
Hack for gmhist&gmhist-mh.
Fix the bug on \ref-completion.
YaTeX-help is now available.
author | yuuji |
---|---|
date | Fri, 06 May 1994 21:14:11 +0000 |
parents | b7b023a74293 |
children | adc2f1472409 |
rev | line source |
---|---|
yuuji@6 | 1 ;;; -*- Emacs-Lisp -*- |
yuuji@8 | 2 ;;; YaTeX add-in functions. |
yuuji@16 | 3 ;;; yatexadd.el rev.8 |
yuuji@14 | 4 ;;; (c )1991-1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] |
yuuji@16 | 5 ;;; Last modified Sat May 7 06:09:39 1994 on pajero |
yuuji@8 | 6 ;;; $Id$ |
yuuji@6 | 7 |
yuuji@6 | 8 (provide 'yatexadd) |
yuuji@6 | 9 |
yuuji@6 | 10 ;;; |
yuuji@6 | 11 ;;Sample functions for LaTeX environment. |
yuuji@6 | 12 ;;; |
yuuji@6 | 13 (defvar YaTeX:tabular-default-rule |
yuuji@6 | 14 "@{\\vrule width 1pt\\ }c|c|c@{\\ \\vrule width 1pt}" |
yuuji@6 | 15 "*Your favorite default rule format." |
yuuji@6 | 16 ) |
yuuji@6 | 17 (defun YaTeX:tabular () |
yuuji@8 | 18 "YaTeX add-in function for tabular environment." |
yuuji@8 | 19 (let (bars (rule "") (j 0) (loc (YaTeX:read-position "tb"))) |
yuuji@6 | 20 (setq bars (string-to-int (read-string "Number of `|': "))) |
yuuji@6 | 21 (if (> bars 0) |
yuuji@6 | 22 (while (< j bars) (setq rule (concat rule "|")) (setq j (1+ j))) |
yuuji@6 | 23 (setq rule YaTeX:tabular-default-rule)) |
yuuji@6 | 24 (setq rule (read-string "rule format: " rule)) |
yuuji@6 | 25 |
yuuji@8 | 26 (message "") |
yuuji@8 | 27 (format "%s{%s}" loc rule)) |
yuuji@6 | 28 ) |
yuuji@6 | 29 |
yuuji@8 | 30 (defun YaTeX:read-position (oneof) |
yuuji@8 | 31 (let ((pos "") loc) |
yuuji@6 | 32 (while (not (string-match |
yuuji@8 | 33 (setq loc (read-key-sequence |
yuuji@8 | 34 (format "Position (`%s') [%s]: " oneof pos))) |
yuuji@6 | 35 "\r\^g\n")) |
yuuji@6 | 36 (cond |
yuuji@8 | 37 ((string-match loc oneof) |
yuuji@6 | 38 (if (not (string-match loc pos)) |
yuuji@6 | 39 (setq pos (concat pos loc)))) |
yuuji@6 | 40 ((and (string-match loc "\C-h\C-?") (> (length pos) 0)) |
yuuji@6 | 41 (setq pos (substring pos 0 (1- (length pos))))) |
yuuji@6 | 42 (t |
yuuji@6 | 43 (ding) |
yuuji@8 | 44 (message "Please input one of `%s'." oneof) |
yuuji@6 | 45 (sit-for 3)))) |
yuuji@8 | 46 (message "") |
yuuji@8 | 47 (if (string= pos "") "" |
yuuji@8 | 48 (concat "[" pos "]"))) |
yuuji@8 | 49 ) |
yuuji@8 | 50 |
yuuji@8 | 51 (defun YaTeX:table () |
yuuji@8 | 52 "YaTeX add-in function for table environment." |
yuuji@8 | 53 (YaTeX:read-position "htbp") |
yuuji@6 | 54 ) |
yuuji@6 | 55 |
yuuji@6 | 56 (defun YaTeX:description () |
yuuji@6 | 57 "Truly poor service:-)" |
yuuji@6 | 58 (setq single-command "item[]") |
yuuji@8 | 59 "" |
yuuji@6 | 60 ) |
yuuji@6 | 61 |
yuuji@6 | 62 (defun YaTeX:itemize () |
yuuji@6 | 63 "It's also poor service." |
yuuji@6 | 64 (setq single-command "item") |
yuuji@8 | 65 "" |
yuuji@6 | 66 ) |
yuuji@6 | 67 |
yuuji@6 | 68 (fset 'YaTeX:enumerate 'YaTeX:itemize) |
yuuji@8 | 69 |
yuuji@11 | 70 (defun YaTeX:picture () |
yuuji@11 | 71 "Ask the size of coordinates of picture environment." |
yuuji@11 | 72 (concat (YaTeX:read-coordinates "Picture size") |
yuuji@11 | 73 (YaTeX:read-coordinates "Initial position")) |
yuuji@11 | 74 ) |
yuuji@11 | 75 |
yuuji@12 | 76 (defun YaTeX:equation () |
yuuji@12 | 77 (if (fboundp 'YaTeX-toggle-math-mode) |
yuuji@12 | 78 (YaTeX-toggle-math-mode t)) ;force math-mode ON. |
yuuji@12 | 79 ) |
yuuji@12 | 80 (fset 'YaTeX:eqnarray 'YaTeX:equation) |
yuuji@12 | 81 (fset 'YaTeX:displaymath 'YaTeX:equation) |
yuuji@12 | 82 |
yuuji@16 | 83 (defun YaTeX:list () |
yuuji@16 | 84 "%\n{} %default label\n{} %formatting parameter" |
yuuji@16 | 85 ) |
yuuji@16 | 86 |
yuuji@8 | 87 ;;; |
yuuji@8 | 88 ;;Sample functions for section-type command. |
yuuji@8 | 89 ;;; |
yuuji@8 | 90 (defun YaTeX:multiput () |
yuuji@8 | 91 (concat (YaTeX:read-coordinates "Pos") |
yuuji@8 | 92 (YaTeX:read-coordinates "Step") |
yuuji@8 | 93 "{" (read-string "How many times: ") "}") |
yuuji@8 | 94 ) |
yuuji@8 | 95 |
yuuji@8 | 96 (defun YaTeX:put () |
yuuji@8 | 97 (YaTeX:read-coordinates "Pos") |
yuuji@8 | 98 ) |
yuuji@8 | 99 |
yuuji@8 | 100 (defun YaTeX:makebox () |
yuuji@8 | 101 (concat (YaTeX:read-coordinates "Dimension") |
yuuji@8 | 102 (YaTeX:read-position "lrtb")) |
yuuji@8 | 103 ) |
yuuji@8 | 104 |
yuuji@8 | 105 (defun YaTeX:framebox () |
yuuji@8 | 106 (if (YaTeX-quick-in-environment-p "picture") |
yuuji@8 | 107 (YaTeX:makebox)) |
yuuji@8 | 108 ) |
yuuji@8 | 109 |
yuuji@8 | 110 (defun YaTeX:dashbox () |
yuuji@8 | 111 (concat "{" (read-string "Dash dimension: ") "}" |
yuuji@8 | 112 (YaTeX:read-coordinates "Dimension")) |
yuuji@8 | 113 ) |
yuuji@8 | 114 |
yuuji@8 | 115 (defun YaTeX:read-coordinates (&optional mes varX varY) |
yuuji@8 | 116 (concat |
yuuji@8 | 117 "(" |
yuuji@8 | 118 (read-string (format "%s %s: " (or mes "Dimension") (or varX "X"))) |
yuuji@8 | 119 "," |
yuuji@8 | 120 (read-string (format "%s %s: " (or mes "Dimension") (or varY "Y"))) |
yuuji@8 | 121 ")") |
yuuji@8 | 122 ) |
yuuji@8 | 123 |
yuuji@8 | 124 ;;; |
yuuji@8 | 125 ;;Sample functions for maketitle-type command. |
yuuji@8 | 126 ;;; |
yuuji@8 | 127 (defun YaTeX:sum () |
yuuji@8 | 128 "Read range of summation." |
yuuji@8 | 129 (YaTeX:check-completion-type 'maketitle) |
yuuji@8 | 130 (concat (YaTeX:read-boundary "_") (YaTeX:read-boundary "^")) |
yuuji@8 | 131 ) |
yuuji@8 | 132 |
yuuji@8 | 133 (fset 'YaTeX:int 'YaTeX:sum) |
yuuji@8 | 134 |
yuuji@8 | 135 (defun YaTeX:lim () |
yuuji@8 | 136 "Insert limit notation of \\lim." |
yuuji@8 | 137 (YaTeX:check-completion-type 'maketitle) |
yuuji@8 | 138 (let ((var (read-string "Variable: ")) limit) |
yuuji@8 | 139 (if (string= "" var) "" |
yuuji@8 | 140 (setq limit (read-string "Limit ($ means infinity): ")) |
yuuji@8 | 141 (if (string= "$" limit) (setq limit "\\infty")) |
yuuji@8 | 142 (concat "_{" var " \\rightarrow " limit "}"))) |
yuuji@8 | 143 ) |
yuuji@8 | 144 |
yuuji@8 | 145 (defun YaTeX:gcd () |
yuuji@8 | 146 "Add-in function for \\gcd(m,n)." |
yuuji@8 | 147 (YaTeX:check-completion-type 'maketitle) |
yuuji@8 | 148 (YaTeX:read-coordinates "\\gcd" "(?,)" "(,?)") |
yuuji@8 | 149 ) |
yuuji@8 | 150 |
yuuji@8 | 151 (defun YaTeX:read-boundary (ULchar) |
yuuji@8 | 152 "Read boundary usage by _ or ^. _ or ^ is indicated by argument ULchar." |
yuuji@11 | 153 (let ((bndry (read-string (concat ULchar "{???} ($ for infinity): ")))) |
yuuji@8 | 154 (if (string= bndry "") "" |
yuuji@11 | 155 (if (string= bndry "$") (setq bndry "\\infty")) |
yuuji@8 | 156 (concat ULchar "{" bndry "}"))) |
yuuji@8 | 157 ) |
yuuji@8 | 158 |
yuuji@14 | 159 (defun YaTeX:verb () |
yuuji@14 | 160 "Enclose \\verb's contents with the same characters." |
yuuji@14 | 161 (let ((quote-char (read-string "Quoting char: " "|")) |
yuuji@14 | 162 (contents (read-string "Quoted contents: "))) |
yuuji@14 | 163 (concat quote-char contents quote-char)) |
yuuji@14 | 164 ) |
yuuji@14 | 165 |
yuuji@14 | 166 ;;; |
yuuji@14 | 167 ;;Subroutine |
yuuji@14 | 168 ;;; |
yuuji@14 | 169 |
yuuji@8 | 170 (defun YaTeX:check-completion-type (type) |
yuuji@8 | 171 "Check valid completion type." |
yuuji@8 | 172 (if (not (eq type YaTeX-current-completion-type)) |
yuuji@8 | 173 (error "This should be completed with %s-type completion." type)) |
yuuji@8 | 174 ) |
yuuji@11 | 175 |
yuuji@11 | 176 |
yuuji@11 | 177 ;;; |
yuuji@11 | 178 ;;; [[Add-in functions for reading section arguments]] |
yuuji@11 | 179 ;;; |
yuuji@11 | 180 ;; All of add-in functions for reading sections arguments should |
yuuji@11 | 181 ;; take an argument ARGP that specify the argument position. |
yuuji@11 | 182 ;; If argument position is out of range, nil should be returned, |
yuuji@11 | 183 ;; else nil should NOT be returned. |
yuuji@13 | 184 |
yuuji@13 | 185 ;; |
yuuji@13 | 186 ; Label selection |
yuuji@13 | 187 ;; |
yuuji@11 | 188 (defvar YaTeX-label-menu-other |
yuuji@11 | 189 (if YaTeX-japan "':他のバッファのラベル\n" "':LABEL IN OTHER BUFFER.\n")) |
yuuji@11 | 190 (defvar YaTeX-label-menu-any |
yuuji@11 | 191 (if YaTeX-japan "*:任意の文字列\n" "*:ANY STRING.\n")) |
yuuji@11 | 192 (defvar YaTeX-label-buffer "*Label completions*") |
yuuji@11 | 193 (defvar YaTeX-label-guide-msg "Select label and hit RETURN.") |
yuuji@11 | 194 (defvar YaTeX-label-select-map nil |
yuuji@11 | 195 "Key map used in label selection buffer.") |
yuuji@11 | 196 (defun YaTeX::label-setup-key-map () |
yuuji@11 | 197 (if YaTeX-label-select-map nil |
yuuji@11 | 198 (message "Setting up label selection mode map...") |
yuuji@11 | 199 (setq YaTeX-label-select-map (copy-keymap global-map)) |
yuuji@11 | 200 (suppress-keymap YaTeX-label-select-map) |
yuuji@11 | 201 (substitute-all-key-definition |
yuuji@11 | 202 'previous-line 'YaTeX::label-previous YaTeX-label-select-map) |
yuuji@11 | 203 (substitute-all-key-definition |
yuuji@11 | 204 'next-line 'YaTeX::label-next YaTeX-label-select-map) |
yuuji@11 | 205 (define-key YaTeX-label-select-map "\C-n" 'YaTeX::label-next) |
yuuji@11 | 206 (define-key YaTeX-label-select-map "\C-p" 'YaTeX::label-previous) |
yuuji@11 | 207 (define-key YaTeX-label-select-map "<" 'beginning-of-buffer) |
yuuji@11 | 208 (define-key YaTeX-label-select-map ">" 'end-of-buffer) |
yuuji@11 | 209 (define-key YaTeX-label-select-map "\C-m" 'exit-recursive-edit) |
yuuji@11 | 210 (define-key YaTeX-label-select-map "\C-j" 'exit-recursive-edit) |
yuuji@11 | 211 (define-key YaTeX-label-select-map " " 'exit-recursive-edit) |
yuuji@11 | 212 (define-key YaTeX-label-select-map "\C-g" 'abort-recursive-edit) |
yuuji@11 | 213 (define-key YaTeX-label-select-map "/" 'isearch-forward) |
yuuji@11 | 214 (define-key YaTeX-label-select-map "?" 'isearch-backward) |
yuuji@11 | 215 (define-key YaTeX-label-select-map "'" 'YaTeX::label-search-tag) |
yuuji@11 | 216 (define-key YaTeX-label-select-map "*" 'YaTeX::label-search-tag) |
yuuji@11 | 217 (message "Setting up label selection mode map...Done") |
yuuji@11 | 218 (let ((key ?A)) |
yuuji@11 | 219 (while (<= key ?Z) |
yuuji@11 | 220 (define-key YaTeX-label-select-map (char-to-string key) |
yuuji@11 | 221 'YaTeX::label-search-tag) |
yuuji@11 | 222 (define-key YaTeX-label-select-map (char-to-string (+ key (- ?a ?A))) |
yuuji@11 | 223 'YaTeX::label-search-tag) |
yuuji@11 | 224 (setq key (1+ key))))) |
yuuji@11 | 225 ) |
yuuji@11 | 226 (defun YaTeX::label-next () |
yuuji@11 | 227 (interactive) (forward-line 1) (message YaTeX-label-guide-msg)) |
yuuji@11 | 228 (defun YaTeX::label-previous () |
yuuji@11 | 229 (interactive) (forward-line -1) (message YaTeX-label-guide-msg)) |
yuuji@11 | 230 (defun YaTeX::label-search-tag () |
yuuji@11 | 231 (interactive) |
yuuji@11 | 232 (let ((case-fold-search t)) |
yuuji@11 | 233 (cond |
yuuji@11 | 234 ((save-excursion |
yuuji@11 | 235 (forward-char 1) |
yuuji@11 | 236 (re-search-forward (concat "^" (this-command-keys)) nil t)) |
yuuji@11 | 237 (goto-char (match-beginning 0))) |
yuuji@11 | 238 ((save-excursion |
yuuji@11 | 239 (goto-char (point-min)) |
yuuji@11 | 240 (re-search-forward (concat "^" (this-command-keys)) nil t)) |
yuuji@11 | 241 (goto-char (match-beginning 0)))) |
yuuji@11 | 242 (message YaTeX-label-guide-msg)) |
yuuji@11 | 243 ) |
yuuji@11 | 244 (defun YaTeX::ref (argp) |
yuuji@11 | 245 (cond |
yuuji@11 | 246 ((= argp 1) |
yuuji@11 | 247 (save-excursion |
yuuji@11 | 248 (let ((lnum 0) e0 m1 e1 label label-list (buf (current-buffer)) |
yuuji@11 | 249 (p (point)) initl line) |
yuuji@11 | 250 (goto-char (point-min)) |
yuuji@11 | 251 (message "Collecting labels...") |
yuuji@11 | 252 (save-window-excursion |
yuuji@12 | 253 (YaTeX-showup-buffer |
yuuji@12 | 254 YaTeX-label-buffer (function (lambda (x) (window-width x)))) |
yuuji@11 | 255 (with-output-to-temp-buffer YaTeX-label-buffer |
yuuji@11 | 256 (while (re-search-forward "\\label{\\([^}]+\\)}" nil t) |
yuuji@11 | 257 (setq e0 (match-end 0) m1 (match-beginning 1) e1 (match-end 1)) |
yuuji@11 | 258 (if (search-backward |
yuuji@11 | 259 YaTeX-comment-prefix (point-beginning-of-line) t) nil |
yuuji@11 | 260 (setq label (buffer-substring m1 e1) |
yuuji@11 | 261 label-list (cons label label-list)) |
yuuji@11 | 262 (or initl |
yuuji@11 | 263 (if (< p (point)) (setq initl lnum))) |
yuuji@11 | 264 (beginning-of-line) |
yuuji@11 | 265 (skip-chars-forward " \t\n" nil) |
yuuji@11 | 266 (princ (format "%c:{%s}\t<<%s>>\n" (+ (% lnum 26) ?A) label |
yuuji@11 | 267 (buffer-substring (point) (point-end-of-line)))) |
yuuji@11 | 268 (setq lnum (1+ lnum)) |
yuuji@11 | 269 (message "Collecting \\label{}... %d" lnum)) |
yuuji@11 | 270 (goto-char e0)) |
yuuji@11 | 271 (princ YaTeX-label-menu-other) |
yuuji@11 | 272 (princ YaTeX-label-menu-any) |
yuuji@11 | 273 );with |
yuuji@11 | 274 (goto-char p) |
yuuji@11 | 275 (message "Collecting labels...Done") |
yuuji@11 | 276 (pop-to-buffer YaTeX-label-buffer) |
yuuji@11 | 277 (YaTeX::label-setup-key-map) |
yuuji@11 | 278 (setq truncate-lines t) |
yuuji@11 | 279 (setq buffer-read-only t) |
yuuji@11 | 280 (use-local-map YaTeX-label-select-map) |
yuuji@11 | 281 (message YaTeX-label-guide-msg) |
yuuji@11 | 282 (goto-line (or initl lnum)) ;goto recently defined label line |
yuuji@11 | 283 (unwind-protect |
yuuji@11 | 284 (progn |
yuuji@11 | 285 (recursive-edit) |
yuuji@11 | 286 (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion |
yuuji@11 | 287 (beginning-of-line) |
yuuji@11 | 288 (setq line (count-lines (point-min)(point))) |
yuuji@11 | 289 (cond |
yuuji@11 | 290 ((= line lnum) (setq label (YaTeX-label-other))) |
yuuji@11 | 291 ((>= line (1+ lnum )) |
yuuji@11 | 292 (setq label (read-string "\\ref{???}: "))) |
yuuji@11 | 293 (t (setq label (nth (- lnum line 1) label-list))))) |
yuuji@11 | 294 (bury-buffer YaTeX-label-buffer))) |
yuuji@11 | 295 label |
yuuji@11 | 296 )) |
yuuji@11 | 297 )) |
yuuji@11 | 298 ) |
yuuji@16 | 299 (fset 'YaTeX::pageref 'YaTeX::ref) |
yuuji@11 | 300 |
yuuji@11 | 301 (defun YaTeX-label-other () |
yuuji@11 | 302 (let ((lbuf "*YaTeX mode buffers*") (blist (buffer-list)) (lnum -1) buf rv |
yuuji@11 | 303 (ff "**find-file**")) |
yuuji@12 | 304 (YaTeX-showup-buffer |
yuuji@12 | 305 lbuf (function (lambda (x) 1))) ;;Select next window surely. |
yuuji@11 | 306 (with-output-to-temp-buffer lbuf |
yuuji@11 | 307 (while blist |
yuuji@11 | 308 (if (and (buffer-file-name (setq buf (car blist))) |
yuuji@11 | 309 (progn (set-buffer buf) (eq major-mode 'yatex-mode))) |
yuuji@11 | 310 (princ |
yuuji@11 | 311 (format "%c:{%s}\n" (+ (% (setq lnum (1+ lnum)) 26) ?A) |
yuuji@11 | 312 (buffer-name buf)))) |
yuuji@11 | 313 (setq blist (cdr blist))) |
yuuji@11 | 314 (princ (format "':{%s}" ff))) |
yuuji@11 | 315 (pop-to-buffer lbuf) |
yuuji@11 | 316 (YaTeX::label-setup-key-map) |
yuuji@11 | 317 (setq buffer-read-only t) |
yuuji@11 | 318 (use-local-map YaTeX-label-select-map) |
yuuji@11 | 319 (message YaTeX-label-guide-msg) |
yuuji@11 | 320 (unwind-protect |
yuuji@11 | 321 (progn |
yuuji@11 | 322 (recursive-edit) |
yuuji@11 | 323 (set-buffer lbuf) |
yuuji@11 | 324 (beginning-of-line) |
yuuji@11 | 325 (setq rv |
yuuji@11 | 326 (if (re-search-forward "{\\([^\\}]+\\)}" (point-end-of-line) t) |
yuuji@11 | 327 (buffer-substring (match-beginning 1) (match-end 1)) nil))) |
yuuji@11 | 328 (kill-buffer lbuf)) |
yuuji@11 | 329 (cond |
yuuji@11 | 330 ((null rv) "") |
yuuji@11 | 331 ((string= rv ff) |
yuuji@11 | 332 (call-interactively 'find-file) |
yuuji@11 | 333 (YaTeX::ref argp)) |
yuuji@11 | 334 (t |
yuuji@11 | 335 (set-buffer rv) |
yuuji@11 | 336 (YaTeX::ref argp))) |
yuuji@11 | 337 ) |
yuuji@11 | 338 ) |
yuuji@11 | 339 |
yuuji@13 | 340 ;; |
yuuji@13 | 341 ; completion for the arguments of \newcommand |
yuuji@13 | 342 ;; |
yuuji@13 | 343 (defun YaTeX::newcommand (&optional argp) |
yuuji@13 | 344 (cond |
yuuji@13 | 345 ((= argp 1) |
yuuji@13 | 346 (let ((command (read-string "Define newcommand: " "\\"))) |
yuuji@13 | 347 (put 'YaTeX::newcommand 'command (substring command 1)) |
yuuji@13 | 348 command)) |
yuuji@13 | 349 ((= argp 2) |
yuuji@13 | 350 (let ((argc |
yuuji@13 | 351 (string-to-int (read-string "Number of arguments(Default 0): "))) |
yuuji@13 | 352 (def (read-string "Definition: ")) |
yuuji@13 | 353 (command (get 'YaTeX::newcommand 'command))) |
yuuji@13 | 354 ;;!!! It's illegal to insert string in the add-in function !!! |
yuuji@13 | 355 (if (> argc 0) (insert (format "[%d]" argc))) |
yuuji@13 | 356 (if (and (stringp command) |
yuuji@13 | 357 (string< "" command) |
yuuji@13 | 358 (y-or-n-p "Update user completion table?")) |
yuuji@13 | 359 (YaTeX-update-table |
yuuji@13 | 360 (if (> argc 1) (list command argc) (list command)) |
yuuji@13 | 361 'section-table 'user-section-table 'tmp-section-table)) |
yuuji@13 | 362 (message "") |
yuuji@13 | 363 def ;return command name |
yuuji@13 | 364 )) |
yuuji@13 | 365 (t "")) |
yuuji@13 | 366 ) |
yuuji@13 | 367 |
yuuji@16 | 368 ;; |
yuuji@16 | 369 ; completion for the arguments of \pagestyle |
yuuji@16 | 370 ;; |
yuuji@16 | 371 (defun YaTeX::pagestyle (&optional argp) |
yuuji@16 | 372 "Read the pagestyle with completion." |
yuuji@16 | 373 (completing-read |
yuuji@16 | 374 "Page style: " |
yuuji@16 | 375 '(("plain") ("empty") ("headings") ("myheadings") ("normal") nil)) |
yuuji@16 | 376 ) |
yuuji@16 | 377 ;; |
yuuji@16 | 378 ; completion for the arguments of \pagenumbering |
yuuji@16 | 379 ;; |
yuuji@16 | 380 (defun YaTeX::pagenumbering (&optional argp) |
yuuji@16 | 381 "Read the numbering style." |
yuuji@16 | 382 (completing-read |
yuuji@16 | 383 "Page numbering style: " |
yuuji@16 | 384 '(("arabic") ("Alpha") ("alpha") ("Roman") ("roman"))) |
yuuji@16 | 385 ) |
yuuji@13 | 386 |
yuuji@11 | 387 ;;; |
yuuji@11 | 388 ;; global subroutines |
yuuji@11 | 389 ;;; |
yuuji@11 | 390 (defun substitute-all-key-definition (olddef newdef keymap) |
yuuji@11 | 391 "Replace recursively OLDDEF with NEWDEF for any keys in KEYMAP now |
yuuji@11 | 392 defined as OLDDEF. In other words, OLDDEF is replaced with NEWDEF |
yuuji@11 | 393 where ever it appears." |
yuuji@11 | 394 (if (arrayp keymap) |
yuuji@11 | 395 (let ((len (length keymap)) |
yuuji@11 | 396 (i 0)) |
yuuji@11 | 397 (while (< i len) |
yuuji@11 | 398 (let ((map (aref keymap i))) |
yuuji@11 | 399 (cond |
yuuji@11 | 400 ((arrayp map) (substitute-key-definition olddef newdef map)) |
yuuji@11 | 401 ((equal map olddef) |
yuuji@11 | 402 (aset keymap i newdef))) |
yuuji@11 | 403 (setq i (1+ i))))) |
yuuji@11 | 404 (while keymap |
yuuji@11 | 405 (if (equal (cdr-safe (car-safe keymap)) olddef) |
yuuji@11 | 406 (setcdr (car keymap) newdef)) |
yuuji@11 | 407 (setq keymap (cdr keymap))))) |