yuuji@395: ;;; yatexadd.el --- YaTeX add-in functions -*- coding: sjis -*- yuuji@572: ;;; (c)1991-2019 by HIROSE Yuuji.[yuuji@yatex.org] yuuji@575: ;;; Last modified Thu Oct 17 09:44:48 2019 on firestorm yuuji@366: ;;; $Id$ yuuji@6: yuuji@287: ;;; Code: yuuji@6: ;;; yuuji@6: ;;Sample functions for LaTeX environment. yuuji@6: ;;; yuuji@6: (defvar YaTeX:tabular-default-rule yuuji@6: "@{\\vrule width 1pt\\ }c|c|c@{\\ \\vrule width 1pt}" yuuji@69: "*Your favorite default rule format.") yuuji@69: yuuji@23: (defvar YaTeX:tabular-thick-vrule "\\vrule width %s" yuuji@69: "*Vertical thick line format (without @{}). %s'll be replaced by its width.") yuuji@69: yuuji@23: (defvar YaTeX:tabular-thick-hrule "\\noalign{\\hrule height %s}" yuuji@69: "*Horizontal thick line format. %s will be replaced by its width.") yuuji@69: yuuji@6: (defun YaTeX:tabular () yuuji@18: "YaTeX add-in function for tabular environment. yuuji@18: Notice that this function refers the let-variable `env' in yuuji@18: YaTeX-make-begin-end." yuuji@23: (let ((width "") bars (rule "") (and "") (j 1) loc ans (hline "\\hline")) yuuji@572: (if (string-match "tabular[*x]" YaTeX-env-name) yuuji@572: (setq width (concat "{" (YaTeX:read-length "Table Width: ") "}"))) yuuji@18: (setq loc (YaTeX:read-position "tb") yuuji@452: bars (YaTeX-str2int yuuji@397: (YaTeX-read-string-or-skip yuuji@394: "Number of columns(0 for default format): " "3"))) yuuji@23: (if (<= bars 0) yuuji@23: (setq ;if 0, simple format yuuji@23: rule YaTeX:tabular-default-rule yuuji@23: and "& &") yuuji@23: (while (< j bars) ;repeat bars-1 times yuuji@23: (setq rule (concat rule "c|") yuuji@23: and (concat and "& ") yuuji@23: j (1+ j))) yuuji@23: (setq rule (concat rule "c")) yuuji@23: (message "(N)ormal-frame or (T)hick frame? [nt]") yuuji@23: (setq ans (read-char)) yuuji@23: (cond yuuji@23: ((or (equal ans ?t) (equal ans ?T)) yuuji@394: (setq ans (read-string-with-history "Rule width: " "1pt") yuuji@23: rule (concat yuuji@23: "@{" (format YaTeX:tabular-thick-vrule ans) "}" yuuji@23: rule yuuji@23: "@{\\ " (format YaTeX:tabular-thick-vrule ans) "}") yuuji@23: hline (format YaTeX:tabular-thick-hrule ans))) yuuji@23: (t (setq rule (concat "|" rule "|") yuuji@23: hline "\\hline")))) yuuji@23: yuuji@397: (setq rule (YaTeX-read-string-or-skip "rule format: " rule)) yuuji@72: (setq YaTeX-single-command "hline") yuuji@6: yuuji@69: (format "%s%s{%s}" width loc rule))) yuuji@69: yuuji@18: (fset 'YaTeX:tabular* 'YaTeX:tabular) yuuji@80: (fset 'YaTeX:supertabular 'YaTeX:tabular) yuuji@572: (fset 'YaTeX:tabularx 'YaTeX:tabular) yuuji@80: (defun YaTeX:alignat () yuuji@394: (concat "{" (read-string-with-history "Number of columns: ") "}")) yuuji@18: (defun YaTeX:array () yuuji@18: (concat (YaTeX:read-position "tb") yuuji@394: "{" (read-string-with-history "Column format: ") "}")) yuuji@80: (defun YaTeX:subequations () yuuji@80: (message (if YaTeX-japan "分かりやすいコメントに変えるとref補完が楽よ" yuuji@80: "Changing comment string reduces effort at `ref' completion")) yuuji@80: (concat " " YaTeX-comment-prefix yuuji@447: (YaTeX::ref-default-label " %Y-%m-%d %H:%M") yuuji@80: (if YaTeX-japan "の式群" "equations"))) yuuji@6: yuuji@79: (defun YaTeX:read-oneof (oneof &optional quick allow-dup) yuuji@23: (let ((pos "") loc (guide "")) yuuji@23: (and (boundp 'name) name (setq guide (format "%s " name))) yuuji@79: (catch 'quick yuuji@79: (while (not (string-match yuuji@79: (setq loc (read-key-sequence yuuji@79: (format "%s position (`%s') [%s]: " yuuji@79: guide oneof pos));name is in YaTeX-addin yuuji@79: loc (if (fboundp 'events-to-keys) yuuji@79: (events-to-keys loc) loc)) yuuji@79: "\r\^g\n")) yuuji@79: (cond yuuji@79: ((string-match loc oneof) yuuji@79: (if (or allow-dup (not (string-match loc pos))) yuuji@79: (setq pos (concat pos loc))) yuuji@79: (if quick (throw 'quick t))) yuuji@79: ((and (string-match loc "\C-h\C-?") (> (length pos) 0)) yuuji@79: (setq pos (substring pos 0 (1- (length pos))))) yuuji@79: (t yuuji@79: (ding) yuuji@79: (message "Please input one of `%s'." oneof) yuuji@79: (sit-for 3))))) yuuji@8: (message "") yuuji@69: pos)) yuuji@23: yuuji@23: (defun YaTeX:read-position (oneof) yuuji@23: "Read a LaTeX (optional) position format such as `[htbp]'." yuuji@23: (let ((pos (YaTeX:read-oneof oneof))) yuuji@69: (if (string= pos "") "" (concat "[" pos "]")))) yuuji@8: yuuji@342: (defun YaTeX:read-length (prompt) yuuji@342: "Read a LaTeX dimensional parameter with magnifying numerics prepend." yuuji@342: (let ((minibuffer-local-completion-map YaTeX-minibuffer-completion-map) yuuji@342: (delim "-0-9*+/.") yuuji@342: (tbl (append YaTeX:style-parameters-local yuuji@342: YaTeX:style-parameters-private yuuji@342: YaTeX:style-parameters-default))) yuuji@342: (YaTeX-completing-read-or-skip prompt tbl nil))) yuuji@342: yuuji@220: ;;; yuuji@220: ;; Functions for figure environemnt yuuji@220: ;;; yuuji@220: (defvar YaTeX:figure-caption-first nil yuuji@220: "Non-nil indicates put caption before figure.") yuuji@220: (defun YaTeX:figure (&optional type firstp) yuuji@220: "YaTeX add-in function for figure(*) environment." yuuji@246: (setq YaTeX-section-name yuuji@246: (if YaTeX:figure-caption-first "caption" "includegraphics") yuuji@246: YaTeX-env-name "center") yuuji@246: (YaTeX:read-position "htbp")) yuuji@246: yuuji@220: yuuji@220: (fset 'YaTeX:figure* 'YaTeX:figure) yuuji@220: yuuji@220: ;;; yuuji@220: ;; Functions for table environemnt yuuji@220: ;;; yuuji@220: (defvar YaTeX:table-caption-first t yuuji@220: "*Non-nil indicates put caption before tabular.") yuuji@8: (defun YaTeX:table () yuuji@8: "YaTeX add-in function for table environment." yuuji@73: (cond yuuji@73: ((eq major-mode 'yatex-mode) yuuji@246: (setq YaTeX-section-name yuuji@246: (if YaTeX:table-caption-first "caption" "label") yuuji@246: YaTeX-env-name "tabular") yuuji@246: (YaTeX:read-position "htbp")) yuuji@73: ((eq major-mode 'texinfo-mode) yuuji@73: (concat " " yuuji@73: (completing-read yuuji@73: "Highlights with: " yuuji@73: '(("@samp")("@kbd")("@code")("@asis")("@file")("@var")) yuuji@73: nil nil "@"))))) yuuji@219: (fset 'YaTeX:table* 'YaTeX:table) yuuji@6: yuuji@6: (defun YaTeX:description () yuuji@6: "Truly poor service:-)" yuuji@72: (setq YaTeX-single-command "item[]") yuuji@69: "") yuuji@6: yuuji@6: (defun YaTeX:itemize () yuuji@6: "It's also poor service." yuuji@72: (setq YaTeX-single-command "item") yuuji@69: "") yuuji@6: yuuji@249: (defun YaTeX:enumerate () yuuji@249: (setq YaTeX-single-command "item" yuuji@249: YaTeX-section-name "label") yuuji@249: "") yuuji@8: yuuji@11: (defun YaTeX:picture () yuuji@11: "Ask the size of coordinates of picture environment." yuuji@11: (concat (YaTeX:read-coordinates "Picture size") yuuji@69: (YaTeX:read-coordinates "Initial position"))) yuuji@11: yuuji@12: (defun YaTeX:equation () yuuji@59: (YaTeX-jmode-off) yuuji@12: (if (fboundp 'YaTeX-toggle-math-mode) yuuji@69: (YaTeX-toggle-math-mode t))) ;force math-mode ON. yuuji@69: yuuji@342: (mapcar (function (lambda (f) (fset f 'YaTeX:equation))) yuuji@59: '(YaTeX:eqnarray YaTeX:eqnarray* YaTeX:align YaTeX:align* yuuji@59: YaTeX:split YaTeX:multline YaTeX:multline* YaTeX:gather YaTeX:gather* yuuji@59: YaTeX:aligned* YaTeX:gathered YaTeX:gathered* yuuji@59: YaTeX:alignat YaTeX:alignat* YaTeX:xalignat YaTeX:xalignat* yuuji@59: YaTeX:xxalignat YaTeX:xxalignat*)) yuuji@12: yuuji@16: (defun YaTeX:list () yuuji@69: "%\n{} %default label\n{} %formatting parameter") yuuji@16: yuuji@18: (defun YaTeX:minipage () yuuji@18: (concat (YaTeX:read-position "cbt") yuuji@342: "{" (YaTeX:read-length "Width: ") "}")) yuuji@18: yuuji@64: (defun YaTeX:thebibliography () yuuji@72: (setq YaTeX-section-name "bibitem") yuuji@394: (concat "{" (read-string-with-history "Longest label: ") "}")) yuuji@64: yuuji@80: (defun YaTeX:multicols () yuuji@394: (concat "{" (read-string-with-history "Number of columns: ") "}")) yuuji@80: yuuji@342: yuuji@342: ;; wrapfig.sty yuuji@342: (defun YaTeX:wrapfigure () yuuji@342: (YaTeX-help "wrapfigure") yuuji@342: (concat yuuji@342: (let ((lines (YaTeX-read-string-or-skip "Wrap Lines(Optional): "))) yuuji@342: (if (string< "" lines) yuuji@342: (concat "[" lines "]"))) yuuji@342: "{" (YaTeX:read-oneof "rlioRLIO" t) "}" yuuji@342: "{" (YaTeX:read-length "Image width: ") "}")) yuuji@342: yuuji@342: yuuji@8: ;;; yuuji@8: ;;Sample functions for section-type command. yuuji@8: ;;; yuuji@8: (defun YaTeX:multiput () yuuji@8: (concat (YaTeX:read-coordinates "Pos") yuuji@8: (YaTeX:read-coordinates "Step") yuuji@394: "{" (read-string-with-history "How many times: ") "}")) yuuji@8: yuuji@8: (defun YaTeX:put () yuuji@69: (YaTeX:read-coordinates "Pos")) yuuji@8: yuuji@8: (defun YaTeX:makebox () yuuji@23: (cond yuuji@23: ((YaTeX-in-environment-p "picture") yuuji@23: (concat (YaTeX:read-coordinates "Dimension") yuuji@80: (YaTeX:read-position "lsrtb"))) yuuji@23: (t yuuji@342: (let ((width (YaTeX:read-length "Width: "))) yuuji@23: (if (string< "" width) yuuji@23: (progn yuuji@23: (or (equal (aref width 0) ?\[) yuuji@23: (setq width (concat "[" width "]"))) yuuji@80: (concat width (YaTeX:read-position yuuji@80: (if YaTeX-use-LaTeX2e "lrs" "lr"))))))))) yuuji@8: yuuji@80: ;; (defun YaTeX:framebox () yuuji@80: ;; (if (YaTeX-quick-in-environment-p "picture") yuuji@80: ;; (YaTeX:makebox))) yuuji@80: (fset 'YaTeX:framebox 'YaTeX:makebox) yuuji@80: yuuji@80: (defun YaTeX:parbox () yuuji@80: (YaTeX:read-position "tbc")) yuuji@104: (defun YaTeX::parbox (argp) yuuji@104: (cond yuuji@342: ((= argp 1) (YaTeX:read-length "Width: ")) yuuji@397: ((= argp 2) (YaTeX-read-string-or-skip "Text: ")))) yuuji@8: yuuji@105: (defun YaTeX::dashbox () yuuji@394: (concat "{" (read-string-with-history "Dash dimension: ") "}" yuuji@69: (YaTeX:read-coordinates "Dimension"))) yuuji@8: yuuji@105: (defun YaTeX::savebox (argp) yuuji@80: (cond yuuji@394: ((= argp 1) (read-string-with-history "Saved into name: " "\\")) yuuji@397: ((= argp 2) (YaTeX-read-string-or-skip "Text: ")))) yuuji@80: yuuji@51: (defvar YaTeX-minibuffer-quick-map nil) yuuji@51: (if YaTeX-minibuffer-quick-map nil yuuji@51: (setq YaTeX-minibuffer-quick-map yuuji@51: (copy-keymap minibuffer-local-completion-map)) yuuji@51: (let ((ch (1+ ? ))) yuuji@51: (while (< ch 127) yuuji@51: (define-key YaTeX-minibuffer-quick-map (char-to-string ch) yuuji@51: 'YaTeX-minibuffer-quick-complete) yuuji@51: (setq ch (1+ ch))))) yuuji@51: yuuji@51: (defvar YaTeX:left-right-delimiters yuuji@51: '(("(" . ")") (")" . "(") ("[" . "]") ("]" . "[") yuuji@51: ("\\{" . "\\}") ("\\}" . "\\{") ("|") ("\\|") yuuji@51: ("\\lfloor" . "\\rfloor") ("\\lceil" . "\\rceil") yuuji@51: ("\\langle" . "\\rangle") ("/") (".") yuuji@51: ("\\rfloor" . "\\rfloor") ("\\rceil" . "\\lceil") yuuji@51: ("\\rangle" . "\\langle") ("\\backslash") yuuji@51: ("\\uparrow") ("\\downarrow") ("\\updownarrow") ("\\Updownarrow")) yuuji@51: "TeX math delimiter, which can be completed after \\right or \\left.") yuuji@51: yuuji@51: (defvar YaTeX:left-right-default nil "Default string of YaTeX:right.") yuuji@51: yuuji@23: (defun YaTeX:left () yuuji@51: (let ((minibuffer-completion-table YaTeX:left-right-delimiters) yuuji@72: delimiter (leftp (string= YaTeX-single-command "left"))) yuuji@51: (setq delimiter yuuji@51: (read-from-minibuffer yuuji@51: (format "Delimiter%s: " yuuji@51: (if YaTeX:left-right-default yuuji@51: (format "(default=`%s')" YaTeX:left-right-default) yuuji@51: "(SPC for menu)")) yuuji@51: nil YaTeX-minibuffer-quick-map)) yuuji@51: (if (string= "" delimiter) (setq delimiter YaTeX:left-right-default)) yuuji@72: (setq YaTeX-single-command (if leftp "right" "left") yuuji@51: YaTeX:left-right-default yuuji@51: (or (cdr (assoc delimiter YaTeX:left-right-delimiters)) delimiter)) yuuji@51: delimiter)) yuuji@51: yuuji@23: (fset 'YaTeX:right 'YaTeX:left) yuuji@23: yuuji@80: (defun YaTeX:langle () yuuji@80: (setq YaTeX-single-command "rangle") yuuji@80: nil) yuuji@80: yuuji@8: (defun YaTeX:read-coordinates (&optional mes varX varY) yuuji@8: (concat yuuji@8: "(" yuuji@394: (read-string-with-history yuuji@394: (format "%s %s: " (or mes "Dimension") (or varX "X"))) yuuji@8: "," yuuji@394: (read-string-with-history yuuji@394: (format "%s %s: " (or mes "Dimension") (or varY "Y"))) yuuji@69: ")")) yuuji@8: yuuji@79: (defun YaTeX:itembox () yuuji@397: (concat "{" (YaTeX-read-string-or-skip "Item heading string: ") "}")) yuuji@79: yuuji@8: ;;; yuuji@8: ;;Sample functions for maketitle-type command. yuuji@8: ;;; yuuji@8: (defun YaTeX:sum () yuuji@8: "Read range of summation." yuuji@8: (YaTeX:check-completion-type 'maketitle) yuuji@69: (concat (YaTeX:read-boundary "_") (YaTeX:read-boundary "^"))) yuuji@8: yuuji@8: (fset 'YaTeX:int 'YaTeX:sum) yuuji@8: yuuji@8: (defun YaTeX:lim () yuuji@8: "Insert limit notation of \\lim." yuuji@8: (YaTeX:check-completion-type 'maketitle) yuuji@394: (let ((var (read-string-with-history "Variable: ")) limit) yuuji@8: (if (string= "" var) "" yuuji@394: (setq limit (read-string-with-history "Limit ($ means infinity): ")) yuuji@8: (if (string= "$" limit) (setq limit "\\infty")) yuuji@69: (concat "_{" var " \\rightarrow " limit "}")))) yuuji@8: yuuji@8: (defun YaTeX:gcd () yuuji@8: "Add-in function for \\gcd(m,n)." yuuji@8: (YaTeX:check-completion-type 'maketitle) yuuji@69: (YaTeX:read-coordinates "\\gcd" "(?,)" "(,?)")) yuuji@8: yuuji@8: (defun YaTeX:read-boundary (ULchar) yuuji@8: "Read boundary usage by _ or ^. _ or ^ is indicated by argument ULchar." yuuji@394: (let ((bndry (read-string-with-history yuuji@394: (concat ULchar "{???} ($ for infinity): ")))) yuuji@8: (if (string= bndry "") "" yuuji@11: (if (string= bndry "$") (setq bndry "\\infty")) yuuji@69: (concat ULchar "{" bndry "}")))) yuuji@8: yuuji@14: (defun YaTeX:verb () yuuji@14: "Enclose \\verb's contents with the same characters." yuuji@394: (let ((quote-char (read-string-with-history "Quoting char: " "|")) yuuji@397: (contents (YaTeX-read-string-or-skip "Quoted contents: "))) yuuji@69: (concat quote-char contents quote-char))) yuuji@69: yuuji@23: (fset 'YaTeX:verb* 'YaTeX:verb) yuuji@14: yuuji@43: (defun YaTeX:footnotemark () yuuji@72: (setq YaTeX-section-name "footnotetext") yuuji@69: nil) yuuji@43: yuuji@48: (defun YaTeX:cite () yuuji@397: (let ((comment (YaTeX-read-string-or-skip "Comment for citation: "))) yuuji@48: (if (string= comment "") "" yuuji@69: (concat "[" comment "]")))) yuuji@48: yuuji@48: (defun YaTeX:bibitem () yuuji@397: (let ((label (YaTeX-read-string-or-skip "Citation label for bibitem: "))) yuuji@48: (if (string= label "") "" yuuji@69: (concat "[" label "]")))) yuuji@48: yuuji@53: (defun YaTeX:item () yuuji@73: (cond yuuji@73: ((eq major-mode 'yatex-mode) yuuji@73: (YaTeX-indent-line) yuuji@73: (setq YaTeX-section-name "label")) yuuji@73: ((eq major-mode 'texinfo-mode) yuuji@73: (setq YaTeX-section-name "dots"))) ;?? yuuji@53: " ") yuuji@52: (fset 'YaTeX:item\[\] 'YaTeX:item) yuuji@52: (fset 'YaTeX:subitem 'YaTeX:item) yuuji@52: (fset 'YaTeX:subsubitem 'YaTeX:item) yuuji@52: yuuji@58: (defun YaTeX:linebreak () yuuji@58: (let (obl) yuuji@58: (message "Break strength 0,1,2,3,4 (default: 4): ") yuuji@58: (setq obl (char-to-string (read-char))) yuuji@58: (if (string-match "[0-4]" obl) yuuji@58: (concat "[" obl "]") yuuji@69: ""))) yuuji@58: (fset 'YaTeX:pagebreak 'YaTeX:linebreak) yuuji@58: yuuji@14: ;;; yuuji@14: ;;Subroutine yuuji@14: ;;; yuuji@14: yuuji@8: (defun YaTeX:check-completion-type (type) yuuji@8: "Check valid completion type." yuuji@8: (if (not (eq type YaTeX-current-completion-type)) yuuji@69: (error "This should be completed with %s-type completion." type))) yuuji@11: yuuji@11: yuuji@11: ;;; yuuji@11: ;;; [[Add-in functions for reading section arguments]] yuuji@11: ;;; yuuji@11: ;; All of add-in functions for reading sections arguments should yuuji@11: ;; take an argument ARGP that specify the argument position. yuuji@11: ;; If argument position is out of range, nil should be returned, yuuji@11: ;; else nil should NOT be returned. yuuji@13: yuuji@13: ;; yuuji@13: ; Label selection yuuji@13: ;; yuuji@11: (defvar YaTeX-label-menu-other yuuji@11: (if YaTeX-japan "':他のバッファのラベル\n" "':LABEL IN OTHER BUFFER.\n")) yuuji@23: (defvar YaTeX-label-menu-repeat yuuji@454: (if YaTeX-japan ".:直前の\\refと同じ\n" ".:REPEAT LAST \\ref{}\n")) yuuji@11: (defvar YaTeX-label-menu-any yuuji@11: (if YaTeX-japan "*:任意の文字列\n" "*:ANY STRING.\n")) yuuji@11: (defvar YaTeX-label-buffer "*Label completions*") yuuji@454: (defvar YaTeX-label-guide-msg yuuji@454: "[RET] on the Label. M-a)All M-c)Capt M-e)Eqn M-i)Itm M-s)Sec M-m)misc") yuuji@11: (defvar YaTeX-label-select-map nil yuuji@11: "Key map used in label selection buffer.") yuuji@11: (defun YaTeX::label-setup-key-map () yuuji@11: (if YaTeX-label-select-map nil yuuji@11: (message "Setting up label selection mode map...") yuuji@68: ;(setq YaTeX-label-select-map (copy-keymap global-map)) yuuji@68: (setq YaTeX-label-select-map (make-keymap)) yuuji@11: (suppress-keymap YaTeX-label-select-map) yuuji@11: (substitute-all-key-definition yuuji@11: 'previous-line 'YaTeX::label-previous YaTeX-label-select-map) yuuji@11: (substitute-all-key-definition yuuji@11: 'next-line 'YaTeX::label-next YaTeX-label-select-map) yuuji@11: (define-key YaTeX-label-select-map "\C-n" 'YaTeX::label-next) yuuji@11: (define-key YaTeX-label-select-map "\C-p" 'YaTeX::label-previous) yuuji@11: (define-key YaTeX-label-select-map "<" 'beginning-of-buffer) yuuji@11: (define-key YaTeX-label-select-map ">" 'end-of-buffer) yuuji@11: (define-key YaTeX-label-select-map "\C-m" 'exit-recursive-edit) yuuji@11: (define-key YaTeX-label-select-map "\C-j" 'exit-recursive-edit) yuuji@11: (define-key YaTeX-label-select-map " " 'exit-recursive-edit) yuuji@11: (define-key YaTeX-label-select-map "\C-g" 'abort-recursive-edit) yuuji@11: (define-key YaTeX-label-select-map "/" 'isearch-forward) yuuji@11: (define-key YaTeX-label-select-map "?" 'isearch-backward) yuuji@11: (define-key YaTeX-label-select-map "'" 'YaTeX::label-search-tag) yuuji@23: (define-key YaTeX-label-select-map "." 'YaTeX::label-search-tag) yuuji@11: (define-key YaTeX-label-select-map "*" 'YaTeX::label-search-tag) yuuji@454: (define-key YaTeX-label-select-map "\M-a" 'YaTeX::label-sel-all) yuuji@454: (define-key YaTeX-label-select-map "\M-c" 'YaTeX::label-sel-cap) yuuji@454: (define-key YaTeX-label-select-map "\M-e" 'YaTeX::label-sel-eqn) yuuji@454: (define-key YaTeX-label-select-map "\M-i" 'YaTeX::label-sel-item) yuuji@454: (define-key YaTeX-label-select-map "\M-s" 'YaTeX::label-sel-sec) yuuji@454: (define-key YaTeX-label-select-map "\M-m" 'YaTeX::label-sel-misc) yuuji@11: (message "Setting up label selection mode map...Done") yuuji@11: (let ((key ?A)) yuuji@11: (while (<= key ?Z) yuuji@11: (define-key YaTeX-label-select-map (char-to-string key) yuuji@11: 'YaTeX::label-search-tag) yuuji@11: (define-key YaTeX-label-select-map (char-to-string (+ key (- ?a ?A))) yuuji@11: 'YaTeX::label-search-tag) yuuji@69: (setq key (1+ key)))))) yuuji@69: yuuji@11: (defun YaTeX::label-next () yuuji@11: (interactive) (forward-line 1) (message YaTeX-label-guide-msg)) yuuji@11: (defun YaTeX::label-previous () yuuji@11: (interactive) (forward-line -1) (message YaTeX-label-guide-msg)) yuuji@11: (defun YaTeX::label-search-tag () yuuji@11: (interactive) yuuji@68: (let ((case-fold-search t) yuuji@290: (tag (regexp-quote (char-to-string (YaTeX-last-key))))) yuuji@11: (cond yuuji@11: ((save-excursion yuuji@11: (forward-char 1) yuuji@23: (re-search-forward (concat "^" tag) nil t)) yuuji@11: (goto-char (match-beginning 0))) yuuji@11: ((save-excursion yuuji@11: (goto-char (point-min)) yuuji@23: (re-search-forward (concat "^" tag) nil t)) yuuji@11: (goto-char (match-beginning 0)))) yuuji@69: (message YaTeX-label-guide-msg))) yuuji@69: yuuji@454: (defun YaTeX::label-sel-* (type &optional any) yuuji@454: "Label type filtering out in YaTeX Label completion buffer" yuuji@454: (save-excursion yuuji@454: (let (ov) yuuji@454: (goto-char (point-min)) yuuji@454: (while (not (eobp)) yuuji@454: (goto-char (next-overlay-change (point))) yuuji@454: (if (null (setq ov (car-safe (overlays-at (point))))) yuuji@454: nil ;do nothin if overlays not found yuuji@454: (overlay-put yuuji@454: ov 'invisible (not (or any yuuji@454: (eq (overlay-get ov 'type) type))))))))) yuuji@454: yuuji@454: (defun YaTeX::label-sel-all () yuuji@454: (interactive) yuuji@454: (YaTeX::label-sel-* 'any 'any)) yuuji@454: (defun YaTeX::label-sel-cap () yuuji@454: (interactive) yuuji@454: (YaTeX::label-sel-* 'cap)) yuuji@454: (defun YaTeX::label-sel-eqn () yuuji@454: (interactive) yuuji@454: (YaTeX::label-sel-* 'eqn)) yuuji@454: (defun YaTeX::label-sel-item () yuuji@454: (interactive) yuuji@454: (YaTeX::label-sel-* 'item)) yuuji@454: (defun YaTeX::label-sel-sec () yuuji@454: (interactive) yuuji@454: (YaTeX::label-sel-* 'sec)) yuuji@454: (defun YaTeX::label-sel-misc () yuuji@454: (interactive) yuuji@454: (YaTeX::label-sel-* 'misc)) yuuji@454: yuuji@70: ; (defun YaTeX::ref (argp &optional labelcmd refcmd) yuuji@70: ; (cond yuuji@70: ; ((= argp 1) yuuji@70: ; (let ((lnum 0) e0 label label-list (buf (current-buffer)) yuuji@70: ; (labelcmd (or labelcmd "label")) (refcmd (or refcmd "ref")) yuuji@70: ; (p (point)) initl line cf) yuuji@70: ; (message "Collecting labels...") yuuji@70: ; (save-window-excursion yuuji@70: ; (YaTeX-showup-buffer yuuji@70: ; YaTeX-label-buffer (function (lambda (x) (window-width x)))) yuuji@70: ; (if (fboundp 'select-frame) (setq cf (selected-frame))) yuuji@70: ; (if (eq (window-buffer (minibuffer-window)) buf) yuuji@70: ; (progn yuuji@70: ; (other-window 1) yuuji@70: ; (setq buf (current-buffer)) yuuji@70: ; (set-buffer buf) yuuji@70: ; ;(message "cb=%s" buf)(sit-for 3) yuuji@70: ; )) yuuji@70: ; (save-excursion yuuji@70: ; (set-buffer (get-buffer-create YaTeX-label-buffer)) yuuji@70: ; (setq buffer-read-only nil) yuuji@70: ; (erase-buffer)) yuuji@70: ; (save-excursion yuuji@70: ; (goto-char (point-min)) yuuji@70: ; (let ((standard-output (get-buffer YaTeX-label-buffer))) yuuji@70: ; (princ (format "=== LABELS in [%s] ===\n" (buffer-name buf))) yuuji@70: ; (while (YaTeX-re-search-active-forward yuuji@70: ; (concat "\\\\" labelcmd "\\b") yuuji@70: ; (regexp-quote YaTeX-comment-prefix) nil t) yuuji@70: ; (goto-char (match-beginning 0)) yuuji@70: ; (skip-chars-forward "^{") yuuji@70: ; (setq label yuuji@70: ; (buffer-substring yuuji@70: ; (1+ (point)) yuuji@70: ; (prog2 (forward-list 1) (setq e0 (1- (point))))) yuuji@70: ; label-list (cons label label-list)) yuuji@70: ; (or initl yuuji@70: ; (if (< p (point)) (setq initl lnum))) yuuji@70: ; (beginning-of-line) yuuji@70: ; (skip-chars-forward " \t\n" nil) yuuji@70: ; (princ (format "%c:{%s}\t<<%s>>\n" (+ (% lnum 26) ?A) label yuuji@70: ; (buffer-substring (point) (point-end-of-line)))) yuuji@70: ; (setq lnum (1+ lnum)) yuuji@70: ; (message "Collecting \\%s{}... %d" labelcmd lnum) yuuji@70: ; (goto-char e0)) yuuji@70: ; (princ YaTeX-label-menu-other) yuuji@70: ; (princ YaTeX-label-menu-repeat) yuuji@70: ; (princ YaTeX-label-menu-any) yuuji@70: ; );standard-output yuuji@70: ; (goto-char p) yuuji@70: ; (or initl (setq initl lnum)) yuuji@70: ; (message "Collecting %s...Done" labelcmd) yuuji@70: ; (if (fboundp 'select-frame) (select-frame cf)) yuuji@70: ; (YaTeX-showup-buffer YaTeX-label-buffer nil t) yuuji@70: ; (YaTeX::label-setup-key-map) yuuji@70: ; (setq truncate-lines t) yuuji@70: ; (setq buffer-read-only t) yuuji@70: ; (use-local-map YaTeX-label-select-map) yuuji@70: ; (message YaTeX-label-guide-msg) yuuji@70: ; (goto-line (1+ initl)) ;goto recently defined label line yuuji@70: ; (switch-to-buffer (current-buffer)) yuuji@70: ; (unwind-protect yuuji@70: ; (progn yuuji@70: ; (recursive-edit) yuuji@70: ; (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion yuuji@70: ; (beginning-of-line) yuuji@70: ; (setq line (1- (count-lines (point-min)(point)))) yuuji@70: ; (cond yuuji@70: ; ((= line -1) (setq label "")) yuuji@70: ; ((= line lnum) (setq label (YaTeX-label-other))) yuuji@70: ; ((= line (1+ lnum)) yuuji@70: ; (save-excursion yuuji@70: ; (switch-to-buffer buf) yuuji@70: ; (goto-char p) yuuji@70: ; (if (re-search-backward yuuji@70: ; (concat "\\\\" refcmd "{\\([^}]+\\)}") nil t) yuuji@70: ; (setq label (YaTeX-match-string 1)) yuuji@70: ; (setq label "")))) yuuji@70: ; ((>= line (+ lnum 2)) yuuji@70: ; (setq label (read-string (format "\\%s{???}: " refcmd)))) yuuji@70: ; (t (setq label (nth (- lnum line 1) label-list))))) yuuji@70: ; (bury-buffer YaTeX-label-buffer))) yuuji@70: ; label))))) yuuji@70: yuuji@80: (defvar YaTeX-ref-default-label-string "%H%M%S_%d%b%y" yuuji@80: "*Default \\ref time string format. yuuji@80: This format is like strftime(3) but allowed conversion char are as follows; yuuji@80: %y -> Last 2 digit of year, %b -> Month name, %m -> Monthe number(1-12), yuuji@80: %d -> Day, %H -> Hour, %M -> Minute, %S -> Second, yuuji@80: %qx -> alphabetical-decimal conversion of yymmdd. yuuji@80: %qX -> alphabetical-decimal conversion of HHMMSS. yuuji@80: Beware defualt label-string should be always unique. So this format string yuuji@80: should have both time part (%H+%M+%S or %qX) and date yuuji@80: part (%y+(%b|%m)+%d or %qx).") yuuji@80: yuuji@80: (defun YaTeX::ref-alphabex (n) yuuji@80: (let ((alphabex "")) yuuji@80: (while (> n 0) yuuji@80: (setq alphabex (concat (char-to-string (+ ?a (% n 26))) alphabex) yuuji@80: n (/ n 26))) yuuji@80: alphabex)) yuuji@80: yuuji@80: (defun YaTeX::ref-default-label (&optional format) yuuji@80: "Default auto-genarated label string." yuuji@80: ;; We do not use (format-time-string) for emacs-19 yuuji@80: (let*((ts (substring (current-time-string) 4)) yuuji@447: (Y (substring ts -4)) yuuji@80: (y (substring ts -2)) yuuji@80: (b (substring ts 0 3)) yuuji@451: (d (format "%d" (YaTeX-str2int (substring ts 4 6)))) yuuji@80: (H (substring ts 7 9)) yuuji@80: (M (substring ts 10 12)) yuuji@80: (S (substring ts 13 15)) yuuji@451: (HMS (+ (* 10000 (YaTeX-str2int H)) yuuji@451: (* 100 (YaTeX-str2int M)) yuuji@451: (YaTeX-str2int S))) yuuji@80: (talphabex (YaTeX::ref-alphabex HMS)) yuuji@80: (mnames "JanFebMarAprMayJunJulAugSepOctNovDec") yuuji@80: (m (format "%02d" (/ (string-match b mnames) 3))) yuuji@451: (ymd (+ (* 10000 (YaTeX-str2int y)) yuuji@451: (* 100 (YaTeX-str2int m)) yuuji@451: (YaTeX-str2int d))) yuuji@80: (dalphabex (YaTeX::ref-alphabex ymd))) yuuji@80: (YaTeX-replace-formats yuuji@80: (or format YaTeX-ref-default-label-string) yuuji@80: (list (cons "y" y) yuuji@447: (cons "Y" Y) yuuji@80: (cons "b" b) yuuji@80: (cons "m" m) yuuji@80: (cons "d" d) yuuji@80: (cons "H" H) yuuji@80: (cons "M" M) yuuji@80: (cons "S" S) yuuji@80: (cons "qX" talphabex) yuuji@80: (cons "qx" dalphabex))))) yuuji@80: yuuji@80: (defvar YaTeX-ref-generate-label-function 'YaTeX::ref-generate-label yuuji@80: "*Function to generate default label for unnamed \\label{}s. yuuji@80: The function pointed to this value should take two arguments. yuuji@80: First argument is LaTeX macro's name, second is macro's argument.") yuuji@80: yuuji@80: (defun YaTeX::ref-generate-label (command arg) yuuji@70: "Generate a label string which is unique in current buffer." yuuji@80: (let ((default (condition-case nil yuuji@80: (YaTeX::ref-default-label) yuuji@80: (error (substring (current-time-string) 4))))) yuuji@397: (YaTeX-read-string-or-skip "Give a label for this line: " yuuji@70: (if YaTeX-emacs-19 (cons default 1) default)))) yuuji@70: yuuji@80: (defun YaTeX::ref-getset-label (buffer point &optional noset) yuuji@70: "Get label string in the BUFFER near the POINT. yuuji@80: Make \\label{xx} if no label. yuuji@80: If optional third argument NOSET is non-nil, do not generate new label." yuuji@73: ;;Here, we rewrite the LaTeX source. Therefore we should be careful yuuji@73: ;;to decide the location suitable for \label. Do straightforward! yuuji@80: (let (boundary inspoint cc newlabel (labelholder "label") mathp exp1 env yuuji@80: (r-escape (regexp-quote YaTeX-comment-prefix)) yuuji@80: command arg alreadysought foundpoint) yuuji@80: (set-buffer buffer) yuuji@70: (save-excursion yuuji@70: (goto-char point) yuuji@70: (setq cc (current-column)) yuuji@70: (if (= (char-after (point)) ?\\) (forward-char 1)) yuuji@70: (cond yuuji@259: ;; In each codition, 'inspoint and 'boundary should be set yuuji@70: ((looking-at YaTeX-sectioning-regexp) yuuji@80: (setq command (YaTeX-match-string 0)) yuuji@70: (skip-chars-forward "^{") yuuji@80: (setq arg (buffer-substring yuuji@80: (1+ (point)) yuuji@80: (progn (forward-list 1) (1- (point))))) yuuji@70: (skip-chars-forward " \t\n") yuuji@73: ;(setq boundary "[^\\]") yuuji@77: (setq inspoint (point)) yuuji@73: (setq boundary yuuji@73: (save-excursion yuuji@77: (if (YaTeX-re-search-active-forward yuuji@77: (concat YaTeX-ec-regexp yuuji@77: "\\(" YaTeX-sectioning-regexp "\\|" yuuji@77: "begin\\|item\\)") yuuji@77: r-escape nil 1) yuuji@73: (match-beginning 0) yuuji@73: (1- (point)))))) yuuji@70: ((looking-at "item\\s ") yuuji@80: (setq command "item" yuuji@80: cc (+ cc 6)) yuuji@73: ;(setq boundary (concat YaTeX-ec-regexp "\\(item\\|begin\\|end\\)\\b")) yuuji@73: (setq boundary yuuji@73: (save-excursion yuuji@73: (if (YaTeX-re-search-active-forward yuuji@73: (concat YaTeX-ec-regexp "\\(item\\|begin\\|end\\)\\b") yuuji@73: r-escape nil 1) yuuji@73: (match-beginning 0) yuuji@77: (1- (point)))) yuuji@77: inspoint boundary)) yuuji@70: ((looking-at "bibitem") yuuji@80: (setq labelholder "bibitem" ; label holder is bibitem itself yuuji@80: command "bibitem") yuuji@73: (setq boundary yuuji@73: (save-excursion yuuji@73: (if (YaTeX-re-search-active-forward yuuji@73: (concat YaTeX-ec-regexp "\\(bibitem\\|end\\)\\b") yuuji@73: r-escape nil 1) yuuji@73: (match-beginning 0) yuuji@77: (1- (point)))) yuuji@77: inspoint boundary)) yuuji@80: ((string-match YaTeX::ref-nestable-counter-regexp yuuji@70: (setq env (or (YaTeX-inner-environment t) "document"))) yuuji@80: (let ((curtop (get 'YaTeX-inner-environment 'point)) yuuji@80: (end (point-max)) label) yuuji@80: (skip-chars-forward " \t\n") yuuji@80: (setq inspoint (point) ;initial candidate yuuji@80: cc (current-column) yuuji@80: command env yuuji@80: alreadysought t) yuuji@80: (if (condition-case nil yuuji@80: (progn yuuji@80: (goto-char curtop) yuuji@454: (YaTeX-goto-corresponding-environment nil t 'nonstop)) yuuji@80: (error nil)) yuuji@80: (setq end (point))) yuuji@80: (goto-char inspoint) yuuji@80: (while (YaTeX-re-search-active-forward yuuji@80: (concat YaTeX-ec-regexp "label{\\([^}]+\\)}" ) yuuji@80: r-escape end t) yuuji@80: (setq label (YaTeX-match-string 1)) yuuji@80: (if (and (equal env (YaTeX-inner-environment t)) yuuji@80: (= curtop (get 'YaTeX-inner-environment 'point))) yuuji@80: ;;I found the label yuuji@80: (setq alreadysought label yuuji@80: foundpoint (match-end 0)))) yuuji@80: )) yuuji@80: ((string-match YaTeX::ref-mathenv-regexp env) ;env is set in above case yuuji@80: (setq command env yuuji@80: mathp t yuuji@80: exp1 (string-match YaTeX::ref-mathenv-exp1-regexp env)) yuuji@73: ;;(setq boundary (concat YaTeX-ec-regexp "\\(\\\\\\|end{" env "}\\)")) yuuji@73: (setq boundary yuuji@73: (save-excursion yuuji@259: (or (catch 'bndry yuuji@259: (while (YaTeX-re-search-active-forward yuuji@259: (concat yuuji@259: YaTeX-ec-regexp "\\(" yuuji@259: (if exp1 "" "\\\\\\|") yuuji@259: "\\(end{" env "\\)}\\)") yuuji@259: r-escape nil 1) yuuji@259: (setq foundpoint (match-beginning 0)) yuuji@259: (if (or (match-beginning 2) ;end of outer math-env yuuji@259: (equal env (YaTeX-inner-environment t))) yuuji@259: ;; YaTeX-inner-environment destroys match-data yuuji@259: (throw 'bndry foundpoint)))) yuuji@259: (1- (point)))) yuuji@77: inspoint boundary)) yuuji@73: ((looking-at "footnote\\s *{") yuuji@80: (setq command "footnote") yuuji@73: (skip-chars-forward "^{") ;move onto `{' yuuji@73: (setq boundary yuuji@73: (save-excursion yuuji@73: (condition-case err yuuji@73: (forward-list 1) yuuji@73: (error (error "\\\\footnote at point %s's brace not closed" yuuji@73: (point)))) yuuji@77: (1- (point))) yuuji@77: inspoint boundary)) yuuji@70: ((looking-at "caption\\|\\(begin\\)") yuuji@80: (setq command (YaTeX-match-string 0)) yuuji@70: (skip-chars-forward "^{") yuuji@77: ;;;;;;(if (match-beginning 1) (forward-list 1)) yuuji@77: ;; caption can be treated as mathenv, is it right?? yuuji@80: (setq arg (buffer-substring yuuji@80: (1+ (point)) yuuji@80: (progn (forward-list 1) (1- (point))))) yuuji@73: ;;(setq boundary (concat YaTeX-ec-regexp "\\(begin\\|end\\)\\b")) yuuji@77: (setq inspoint (point)) yuuji@73: (setq boundary yuuji@73: (save-excursion yuuji@73: (if (YaTeX-re-search-active-forward yuuji@73: (concat YaTeX-ec-regexp "\\(begin\\|end\\)\\b") yuuji@73: r-escape nil 1) yuuji@73: (match-beginning 0) yuuji@73: (1- (point)))))) yuuji@70: (t )) yuuji@259: ;;cond by kind of labeling ends here. yuuji@70: (if (save-excursion (skip-chars-forward " \t") (looking-at "%")) yuuji@70: (forward-line 1)) yuuji@80: (cond yuuji@80: ((stringp alreadysought) yuuji@80: (put 'YaTeX::ref-getset-label 'foundpoint foundpoint) ;ugly... yuuji@80: alreadysought) yuuji@80: ((and (null alreadysought) yuuji@80: (> boundary (point)) yuuji@80: (save-excursion yuuji@80: (YaTeX-re-search-active-forward yuuji@80: ;;(concat "\\(" labelholder "\\)\\|\\(" boundary "\\)") yuuji@80: labelholder yuuji@80: (regexp-quote YaTeX-comment-prefix) yuuji@80: boundary 1)) yuuji@80: (match-beginning 0)) yuuji@70: ;; if \label{hoge} found, return it yuuji@80: (put 'YaTeX::ref-getset-label 'foundpoint (1- (match-beginning 0))) yuuji@80: (buffer-substring yuuji@80: (progn yuuji@80: (goto-char (match-end 0)) yuuji@80: (skip-chars-forward "^{") (1+ (point))) yuuji@80: (progn yuuji@80: (forward-sexp 1) (1- (point))))) yuuji@70: ;;else make a label yuuji@73: ;(goto-char (match-beginning 0)) yuuji@80: (noset nil) ;do not set label if noset yuuji@80: (t yuuji@77: (goto-char inspoint) yuuji@70: (skip-chars-backward " \t\n") yuuji@80: (save-excursion yuuji@80: (setq newlabel yuuji@80: (funcall YaTeX-ref-generate-label-function command arg))) yuuji@70: (delete-region (point) (progn (skip-chars-backward " \t") (point))) yuuji@70: (if mathp nil yuuji@70: (insert "\n") yuuji@70: (YaTeX-reindent cc)) yuuji@259: (put 'YaTeX::ref-getset-label 'foundpoint (point)) yuuji@70: (insert (format "\\label{%s}" newlabel)) yuuji@80: newlabel))))) yuuji@70: yuuji@80: (defvar YaTeX::ref-labeling-regexp-alist-default yuuji@80: '(("\\\\begin{\\(java\\|program\\)}{\\([^}]+\\)}" . 2) yuuji@80: ("\\\\label{\\([^}]+\\)}" . 1)) yuuji@80: "Alist of labeling regexp vs. its group number points to label string. yuuji@80: This alist is used in \\ref's argument's completion.") yuuji@80: (defvar YaTeX::ref-labeling-regexp-alist-private nil yuuji@168: "*Private extension to YaTeX::ref-labeling-regexp-alist. yuuji@80: See the documetation of YaTeX::ref-labeling-regexp-alist.") yuuji@70: (defvar YaTeX::ref-labeling-regexp-alist yuuji@80: (append YaTeX::ref-labeling-regexp-alist-default yuuji@80: YaTeX::ref-labeling-regexp-alist-private)) yuuji@70: (defvar YaTeX::ref-labeling-regexp yuuji@70: (mapconcat 'car YaTeX::ref-labeling-regexp-alist "\\|")) yuuji@70: (defvar YaTeX::ref-mathenv-regexp yuuji@80: ;; See also YaTeX-ams-math-begin-alist in yatex.el yuuji@80: ;; Define only envs which has counter.(without *) yuuji@80: "equation\\|eqnarray\\|align\\(at\\)?\\|flalign\\|gather\\|xx?alignat\\|multline") yuuji@80: (defvar YaTeX::ref-mathenv-exp1-regexp yuuji@80: "\\(equation\\|multline\\)\\b" yuuji@80: "*Regexp of math-envname which has only one math-expression.") yuuji@70: (defvar YaTeX::ref-enumerateenv-regexp yuuji@70: "enumerate") yuuji@80: (defvar YaTeX::ref-nestable-counter-regexp yuuji@80: "subequations") yuuji@70: yuuji@70: (defvar YaTeX::ref-labeling-section-level 2 yuuji@72: "*ref補完で収集するセクショニングコマンドの下限レベル yuuji@70: YaTeX-sectioning-levelの数値で指定.") yuuji@70: yuuji@458: (defun YaTeX::ref-1 (&optional nest-level) yuuji@454: ;; Sub-function of YaTeX::ref() for recursive call yuuji@454: ;; DO NOT CALL FROM OTHER FUNCTIONS but YaTeX:ref() yuuji@458: (setq nest-level (or nest-level 0)) yuuji@458: (let ((labelleader (substring " " 0 nest-level)) yuuji@458: label) yuuji@458: (while (YaTeX-re-search-active-forward yuuji@458: regexp ;;counter yuuji@458: percent nil t) yuuji@454: ;(goto-char (match-beginning 0)) yuuji@458: (setq e0 (match-end 0)) yuuji@454: (cond yuuji@458: ;; yuuji@458: ;;2005/10/21 Skip it if predicate function returns nil yuuji@458: ((and predf yuuji@458: (let ((md (match-data))) yuuji@458: (prog1 yuuji@458: (condition-case nil yuuji@458: (not (funcall predf)) yuuji@458: (error nil)) yuuji@458: (store-match-data md))))) yuuji@458: ((YaTeX-literal-p) nil) yuuji@458: ((YaTeX-match-string 1) yuuji@458: ;;if standard counter commands found yuuji@458: (setq cmd (YaTeX-match-string 2) yuuji@458: m0 (match-beginning 0)) yuuji@458: (setq match-point (match-beginning 0)) yuuji@458: (or initl yuuji@458: (if (< p (point)) (setq initl lnum))) yuuji@458: (cond yuuji@458: ;; In any case, variables e0 should be set yuuji@458: ((and YaTeX-use-AMS-LaTeX yuuji@458: (string-match YaTeX::ref-nestable-counter-regexp cmd)) yuuji@454: (skip-chars-forward "}") yuuji@454: (setq label (buffer-substring yuuji@454: (point) (min (+ 80 (point)) (point-max)))) yuuji@454: ;; to skip (maybe)auto-generated comment yuuji@454: (skip-chars-forward " \t") yuuji@454: (if (looking-at YaTeX-comment-prefix) yuuji@454: (forward-line 1)) yuuji@454: (setq e0 (point)) yuuji@454: (skip-chars-forward " \t\n") yuuji@454: (if (looking-at "\\\\label{\\([^}]+\\)}") yuuji@454: (setq label (format "(labe:%s)" (YaTeX-match-string 1)) yuuji@454: e0 (match-end 1))) yuuji@458: (funcall output yuuji@458: (format "--subequation--%s%s" labelleader label) yuuji@458: e0 'eqn)) yuuji@458: ((string-match mathenvs cmd) ;;if matches mathematical env yuuji@458: (skip-chars-forward "}") yuuji@458: (setq x (point) yuuji@458: envname (substring yuuji@458: cmd (match-beginning 0) (match-end 0))) yuuji@458: (save-restriction yuuji@458: (narrow-to-region yuuji@458: m0 yuuji@458: (save-excursion yuuji@458: (YaTeX-re-search-active-forward yuuji@458: (setq endrx (format "%send{%s}" YaTeX-ec-regexp yuuji@458: (regexp-quote envname))) yuuji@458: percent nil t))) yuuji@458: (catch 'scan yuuji@458: (while (YaTeX-re-search-active-forward yuuji@458: (concat yuuji@458: "\\\\end{\\(" (regexp-quote envname) "\\)" ;;(1) yuuji@458: "\\|\\\\\\(notag\\)" ;;2 yuuji@458: (if (string-match yuuji@458: YaTeX::ref-mathenv-exp1-regexp cmd) yuuji@458: "" "\\|\\(\\\\\\\\\\)$") ;;3 yuuji@458: ) yuuji@458: percent nil t) yuuji@458: (let*((quit (match-beginning 1)) yuuji@458: (notag (match-beginning 2)) yuuji@458: (newln (match-beginning 3)) yuuji@458: (label ".......................") l2 yuuji@458: (e (point)) (m0 (match-beginning 0)) yuuji@458: (ln (YaTeX-string-width label))) yuuji@454: (cond yuuji@458: (notag yuuji@458: (YaTeX-re-search-active-forward yuuji@458: "\\\\\\\\" percent nil 1) yuuji@458: (setq x (point))) ;use x as \label search bound yuuji@458: ((and newln ; `\\' found yuuji@458: (not (equal (YaTeX-inner-environment) yuuji@458: envname))) yuuji@454: (YaTeX-end-of-environment) yuuji@458: (goto-char (match-end 0))) yuuji@458: (t yuuji@458: (if (YaTeX-re-search-active-backward yuuji@458: YaTeX::ref-labeling-regexp yuuji@458: percent x t) yuuji@458: ;; if \label{x} in math-expression, display it yuuji@458: ;; because formula source is hard to recognize yuuji@458: (progn yuuji@458: (goto-char (match-end 0)) yuuji@458: (setq l2 (format "\"label:%s\"" yuuji@458: (buffer-substring yuuji@458: (1- (point)) yuuji@458: (progn (forward-sexp -1) yuuji@458: (1+ (point)))))) yuuji@458: (setq label yuuji@458: (if (< (YaTeX-string-width l2) ln) yuuji@458: (concat yuuji@458: l2 yuuji@458: (substring yuuji@458: label yuuji@458: 0 (- ln (YaTeX-string-width l2)))) yuuji@458: l2)) yuuji@458: (goto-char e))) yuuji@458: (funcall output yuuji@458: (concat yuuji@458: labelleader label " " yuuji@458: (buffer-substring x m0)) yuuji@458: x 'eqn) yuuji@458: (cond yuuji@458: ((YaTeX-quick-in-environment-p yuuji@458: YaTeX-math-gathering-list) yuuji@458: ;; if here is inner split/cases/gathered env., yuuji@458: ;; counter for here is only one. yuuji@458: ;; Go out this environment and, yuuji@458: (YaTeX-end-of-environment) yuuji@458: ;; search next expression unit boundary. yuuji@458: (YaTeX-re-search-active-forward yuuji@458: (concat endrx "\\|\\\\begin{") yuuji@458: percent nil 1) yuuji@458: (end-of-line))) yuuji@458: (if quit (throw 'scan t))))) yuuji@458: (setq x (point))))) yuuji@458: (setq e0 (point))) yuuji@458: ((string-match enums cmd) yuuji@454: ;(skip-chars-forward "} \t\n") yuuji@458: (save-restriction yuuji@458: (narrow-to-region yuuji@458: (point) yuuji@458: (save-excursion yuuji@458: (YaTeX-goto-corresponding-environment nil t 'nonstop) (point))) yuuji@458: (forward-line 1) yuuji@458: (let ((b0 nil) mb0) yuuji@458: (while (not (eobp)) yuuji@458: (setq x (and yuuji@458: (YaTeX-re-search-active-forward yuuji@458: (concat YaTeX-ec-regexp "item\\s ") yuuji@458: percent nil 1) yuuji@458: (match-beginning 0))) yuuji@454: yuuji@458: (if b0 ;Inspect sentence after previous \item yuuji@458: (save-excursion yuuji@458: (save-restriction yuuji@458: (let ((md (match-data))) ;save-match-data yuuji@458: (unwind-protect yuuji@458: (progn yuuji@458: (narrow-to-region b0 (or x (point))) yuuji@458: (goto-char (point-min)) yuuji@458: (let ((x x)) (YaTeX::ref-1 (1+ nest-level))) yuuji@458: (goto-char (point-max))) yuuji@458: (store-match-data md)))))) yuuji@458: (if x ;Output THIS \item line yuuji@458: (funcall yuuji@458: output yuuji@458: (concat yuuji@458: labelleader existlabel yuuji@458: (buffer-substring yuuji@458: (match-beginning 0) yuuji@458: (if (re-search-forward itemsep nil 1) yuuji@458: (progn (goto-char (match-beginning 0)) yuuji@458: (skip-chars-backward " \t") yuuji@458: (1- (point))) yuuji@458: (point-end-of-line)))) yuuji@458: x 'item)) yuuji@458: (setq b0 (point)) yuuji@458: )) yuuji@458: (setq e0 (point-max)))) yuuji@458: ((string-match "bibitem" cmd) ;maybe generated by myself yuuji@458: (setq label "") yuuji@458: (skip-chars-forward " \t") yuuji@458: (if (looking-at "{") ;sure to be true!! yuuji@458: (forward-list 1)) yuuji@458: (let ((list '(30 10 65)) yuuji@458: (delim ";") q lim len l str) yuuji@458: (save-excursion yuuji@458: (setq lim (if (re-search-forward itemsep nil 1) yuuji@458: (match-beginning 0) (point)))) yuuji@458: (while list yuuji@458: (skip-chars-forward " \t\n\\") yuuji@458: (setq q (looking-at "[\"'{]") yuuji@458: len (car list) yuuji@458: str yuuji@454: (buffer-substring yuuji@458: (point) yuuji@458: (progn yuuji@458: (if q (forward-sexp 1) yuuji@458: (search-forward delim lim 1) yuuji@458: (forward-char -1)) yuuji@458: (point)))) yuuji@458: (if (> (setq l (YaTeX-string-width str)) len) yuuji@458: (setq str (concat yuuji@458: (YaTeX-truncate-string-width yuuji@458: str (- len (if q 5 4))) yuuji@458: "... " yuuji@458: (if q (substring str -1))))) yuuji@458: (if (< (setq l (YaTeX-string-width str)) len) yuuji@458: (setq str (concat str (make-string (- len l) ? )))) yuuji@458: (if (looking-at delim) (goto-char (match-end 0))) yuuji@458: (setq label (concat label " " str) yuuji@458: list (cdr list))) yuuji@463: (funcall output (concat labelleader label) match-point 'bib))) yuuji@458: ;;else, simple section-type counter yuuji@458: ((= (char-after (1- (point))) ?{) yuuji@458: (setq label (buffer-substring yuuji@458: (match-beginning 0) yuuji@458: (progn (forward-char -1) yuuji@458: (forward-list 1) yuuji@458: (point)))) yuuji@463: (funcall output (concat labelleader label) match-point yuuji@458: (if (string-match "caption" cmd) 'cap 'sec)) yuuji@458: ;; Skip preceding label if exists yuuji@458: (if (YaTeX::ref-getset-label (current-buffer) match-point t) yuuji@458: (goto-char (get 'YaTeX::ref-getset-label 'foundpoint))) yuuji@458: (if (save-excursion yuuji@458: (skip-chars-forward "\t \n") yuuji@458: (looking-at YaTeX::ref-labeling-regexp)) yuuji@458: (setq e0 (match-end 0)))) yuuji@458: (t yuuji@458: (skip-chars-forward " \t") yuuji@458: (setq label (buffer-substring yuuji@458: (match-beginning 0) yuuji@458: (if (re-search-forward yuuji@458: itemsep yuuji@458: nil t) yuuji@458: (progn yuuji@458: (goto-char (match-beginning 0)) yuuji@458: (skip-chars-backward " \t") yuuji@458: (1- (point))) yuuji@458: (point-end-of-line)))) yuuji@463: (funcall output (concat labelleader label) match-point 'misc) yuuji@458: (if (save-excursion yuuji@458: (skip-chars-forward "\t \n") yuuji@458: (looking-at YaTeX::ref-labeling-regexp)) yuuji@458: (setq e0 (match-end 0))))) yuuji@458: ) ;;put label buffer yuuji@458: ;; yuuji@458: ;; if user defined label found yuuji@458: (t yuuji@458: ;; memorize line number and label into property yuuji@458: (goto-char (match-beginning 0)) yuuji@458: (let ((list YaTeX::ref-labeling-regexp-alist) yuuji@458: (cache (symbol-plist 'YaTeX::ref-labeling-regexp))) yuuji@454: (while list yuuji@458: (if (looking-at (car (car list))) yuuji@458: (progn yuuji@458: (setq label (YaTeX-match-string 0)) yuuji@458: (put 'YaTeX::ref-labeling-regexp lnum yuuji@458: (YaTeX-match-string (cdr (car list)))) yuuji@464: (funcall output (concat labelleader label) 0) ;;0 is dummy yuuji@458: (setq list nil))) yuuji@458: (setq list (cdr list)))) yuuji@458: )) yuuji@458: (goto-char e0)))) yuuji@454: yuuji@80: (defun YaTeX::ref (argp &optional labelcmd refcmd predf) yuuji@70: (setplist 'YaTeX::ref-labeling-regexp nil) ;erase memory cache yuuji@70: (require 'yatexsec) yuuji@11: (cond yuuji@11: ((= argp 1) yuuji@80: (let*((lnum 0) m0 e0 x cmd label match-point point-list boundary yuuji@70: (buf (current-buffer)) yuuji@70: (llv YaTeX::ref-labeling-section-level) yuuji@80: (mathenvs YaTeX::ref-mathenv-regexp) envname endrx yuuji@70: (enums YaTeX::ref-enumerateenv-regexp) yuuji@70: (counter yuuji@70: (or labelcmd yuuji@70: (concat yuuji@70: YaTeX-ec-regexp "\\(\\(" yuuji@70: (mapconcat yuuji@70: 'concat yuuji@70: (delq nil yuuji@70: (mapcar yuuji@72: (function yuuji@72: (lambda (s) yuuji@72: (if (>= llv (cdr s)) yuuji@72: (car s)))) yuuji@70: YaTeX-sectioning-level)) yuuji@70: "\\|") yuuji@77: "\\|caption\\(\\[[^]]+\\]\\)?\\|footnote\\){" yuuji@80: "\\|\\(begin{\\(" mathenvs "\\|" enums "\\)}\\)" yuuji@80: (if YaTeX-use-AMS-LaTeX yuuji@80: (concat yuuji@80: "\\|\\(begin{" yuuji@80: YaTeX::ref-nestable-counter-regexp "}\\)")) yuuji@80: "\\)"))) yuuji@70: (regexp (concat "\\(" counter yuuji@70: "\\)\\|\\(" YaTeX::ref-labeling-regexp "\\)")) yuuji@70: (itemsep (concat YaTeX-ec-regexp yuuji@70: "\\(\\(bib\\)?item\\|begin\\|end\\)")) yuuji@86: (refcmd (or refcmd "\\(page\\)?ref")) yuuji@70: (p (point)) initl line cf yuuji@70: (percent (regexp-quote YaTeX-comment-prefix)) yuuji@70: (output yuuji@70: (function yuuji@454: (lambda (label p &optional type) ;type: 'eqn 'item 'cap 'sec 'misc yuuji@80: (while (setq x (string-match "[\n\t]" label)) yuuji@70: (aset label x ? )) yuuji@80: (while (setq x (string-match " +" label)) yuuji@70: (setq label (concat yuuji@70: (substring label 0 (1+ (match-beginning 0))) yuuji@70: (substring label (match-end 0))))) yuuji@454: (save-excursion yuuji@454: (set-buffer standard-output) yuuji@454: (overlay-put yuuji@454: (make-overlay yuuji@454: (point) yuuji@454: (progn yuuji@454: (insert (format "%c: <<%s>>\n" (+ (% lnum 26) ?A) label)) yuuji@454: (point))) yuuji@454: 'type type)) yuuji@70: (setq point-list (cons p point-list)) yuuji@70: (message "Collecting labels... %d" lnum) yuuji@70: (setq lnum (1+ lnum))))) yuuji@80: (me (if (boundp 'me) me 'YaTeX::ref)) yuuji@70: ) yuuji@60: (message "Collecting labels...") yuuji@60: (save-window-excursion yuuji@60: (YaTeX-showup-buffer yuuji@60: YaTeX-label-buffer (function (lambda (x) (window-width x)))) yuuji@60: (if (fboundp 'select-frame) (setq cf (selected-frame))) yuuji@60: (if (eq (window-buffer (minibuffer-window)) buf) yuuji@60: (progn yuuji@60: (other-window 1) yuuji@60: (setq buf (current-buffer)) yuuji@70: (set-buffer buf))) yuuji@60: (save-excursion yuuji@69: (set-buffer (get-buffer-create YaTeX-label-buffer)) yuuji@80: (condition-case () yuuji@80: (if (and YaTeX-use-font-lock (fboundp 'font-lock-mode)) yuuji@80: (font-lock-mode 1)) yuuji@80: (error nil)) yuuji@69: (setq buffer-read-only nil) yuuji@69: (erase-buffer)) yuuji@69: (save-excursion yuuji@70: (set-buffer buf) yuuji@60: (goto-char (point-min)) yuuji@80: (let ((standard-output (get-buffer YaTeX-label-buffer)) existlabel) yuuji@60: (princ (format "=== LABELS in [%s] ===\n" (buffer-name buf))) yuuji@454: yuuji@454: (YaTeX::ref-1) yuuji@454: yuuji@454: yuuji@11: (princ YaTeX-label-menu-other) yuuji@23: (princ YaTeX-label-menu-repeat) yuuji@11: (princ YaTeX-label-menu-any) yuuji@69: );standard-output yuuji@11: (goto-char p) yuuji@60: (or initl (setq initl lnum)) yuuji@70: (message "Collecting labels...Done") yuuji@60: (if (fboundp 'select-frame) (select-frame cf)) yuuji@59: (YaTeX-showup-buffer YaTeX-label-buffer nil t) yuuji@11: (YaTeX::label-setup-key-map) yuuji@11: (setq truncate-lines t) yuuji@11: (setq buffer-read-only t) yuuji@11: (use-local-map YaTeX-label-select-map) yuuji@11: (message YaTeX-label-guide-msg) yuuji@60: (goto-line (1+ initl)) ;goto recently defined label line yuuji@68: (switch-to-buffer (current-buffer)) yuuji@11: (unwind-protect yuuji@11: (progn yuuji@11: (recursive-edit) yuuji@70: yuuji@11: (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion yuuji@11: (beginning-of-line) yuuji@60: (setq line (1- (count-lines (point-min)(point)))) yuuji@11: (cond yuuji@60: ((= line -1) (setq label "")) yuuji@11: ((= line lnum) (setq label (YaTeX-label-other))) yuuji@23: ((= line (1+ lnum)) yuuji@23: (save-excursion yuuji@23: (switch-to-buffer buf) yuuji@23: (goto-char p) yuuji@48: (if (re-search-backward yuuji@86: (concat "\\\\" refcmd "{") nil t) yuuji@86: (setq label (YaTeX-buffer-substring yuuji@86: (progn (goto-char (1- (match-end 0))) yuuji@86: (1+ (point))) yuuji@86: (progn (forward-list 1) yuuji@86: (1- (point))))) yuuji@23: (setq label "")))) yuuji@23: ((>= line (+ lnum 2)) yuuji@48: (setq label (read-string (format "\\%s{???}: " refcmd)))) yuuji@70: (t ;(setq label (nth (- lnum line 1) label-list)) yuuji@70: (setq label yuuji@70: (or (get 'YaTeX::ref-labeling-regexp line) yuuji@70: (YaTeX::ref-getset-label yuuji@70: buf (nth (- lnum line 1) point-list)))) yuuji@70: ))) yuuji@11: (bury-buffer YaTeX-label-buffer))) yuuji@69: label))))) yuuji@69: yuuji@168: (defun YaTeX::label-rename-refs (old new &optional def ref) yuuji@168: "Rename reference tag from OLD to NEW. yuuji@168: Optional arguments DEF and REF specify defining command and yuuji@168: referring command respectively. yuuji@168: --------------------------------------------------------- yuuji@168: CONTROL KEYS - キーの説明 yuuji@168: y Replace 置換する yuuji@168: n Do not replace 置換しない yuuji@168: ! Replace All w/o query 残る全部を確認なしで置換 yuuji@168: r Enter Recursive-edit 再帰編集モードへ yuuji@168: q Quit from replacing ここまでで置換をやめる yuuji@168: yuuji@168: Don't forget to exit from recursive edit by typing \\[exit-recursive-edit] yuuji@168: 再帰編集に入ったら \\[exit-recursive-edit] で抜け忘れなきよう。" yuuji@168: (save-window-excursion yuuji@168: (catch 'exit yuuji@168: (let*((bufs (YaTeX-yatex-buffer-list)) buf b e yuuji@168: (oldptn (regexp-quote old)) yuuji@168: (sw (selected-window)) yuuji@168: (ptn (concat yuuji@168: "\\(" YaTeX-refcommand-ref-regexp "\\)" yuuji@168: "\\s *{" oldptn "}")) yuuji@170: (repface (and (fboundp 'make-overlay) yuuji@170: (fboundp 'internal-find-face) yuuji@170: (if (internal-find-face 'isearch) 'isearch 'region))) yuuji@170: ov yuuji@173: (qmsg "Replace to `%s'? [yn!rq?]") yuuji@168: continue ch) yuuji@168: (while bufs yuuji@168: (set-buffer (setq buf (car bufs))) yuuji@168: (save-excursion yuuji@168: (goto-char (point-min)) yuuji@168: (while (re-search-forward ptn nil t) yuuji@168: (goto-char (match-end 1)) yuuji@168: (skip-chars-forward " \t\n{") yuuji@168: (unwind-protect yuuji@168: (if (and yuuji@168: (looking-at oldptn) yuuji@168: (setq b (match-beginning 0) yuuji@168: e (match-end 0)) yuuji@168: (or continue yuuji@168: (catch 'query yuuji@170: (if repface yuuji@168: (if ov (move-overlay ov b e) yuuji@168: (overlay-put yuuji@168: (setq ov (make-overlay b e)) yuuji@170: 'face repface))) yuuji@532: (set-window-buffer nil buf) ;Emacs26 yuuji@168: (while t yuuji@168: (message qmsg new) yuuji@168: (setq ch (read-char)) yuuji@168: (cond yuuji@168: ((= ch ?q) (throw 'exit t)) yuuji@168: ((= ch ?r) yuuji@168: (message yuuji@173: "Don't forget to exit recursive-edit by `%s'" yuuji@168: (key-description yuuji@168: (where-is-internal yuuji@168: 'exit-recursive-edit '(keymap) t))) yuuji@168: (sleep-for 2) yuuji@168: (recursive-edit)) yuuji@255: ((memq ch '(?y ?\ )) (throw 'query t)) yuuji@168: ((= ch ?!) (throw 'query (setq continue t))) yuuji@168: ((= ch ??) yuuji@168: (describe-function yuuji@168: 'YaTeX::label-rename-refs) yuuji@168: (select-window (get-buffer-window "*Help*")) yuuji@168: (search-forward "----") yuuji@168: (forward-line 1) yuuji@168: (set-window-start (selected-window) (point)) yuuji@168: (sit-for 0) yuuji@168: (select-window sw)) yuuji@168: ((= ch ?n) (throw 'query nil))))))) yuuji@267: (replace-match new t)) yuuji@168: (and ov (delete-overlay ov))))) yuuji@168: (setq bufs (cdr bufs))))))) yuuji@168: yuuji@167: (defun YaTeX::label (argp &optional labname refname) yuuji@163: "Read label name and return it with copying \\ref{LABEL-NAME} to kill-ring." yuuji@163: (cond yuuji@163: ((= argp 1) yuuji@168: (let*((chmode (boundp (intern-soft "old"))) yuuji@168: (dlab (if chmode old ;if called via YaTeX-change-section (tricky...) yuuji@163: (YaTeX::ref-default-label))) yuuji@394: (label (read-string-with-history yuuji@167: (format "New %s name: " (or labname "label")) yuuji@167: (cons dlab 1)))) yuuji@163: (if (string< "" label) yuuji@247: (let ((refstr (format "\\%s{%s}" (or refname "ref") label))) yuuji@247: (YaTeX-push-to-kill-ring refstr) yuuji@170: (and chmode yuuji@170: (not (equal old label)) yuuji@247: (YaTeX::label-rename-refs old label)))) yuuji@163: label)))) yuuji@163: yuuji@163: yuuji@16: (fset 'YaTeX::pageref 'YaTeX::ref) yuuji@312: (fset 'YaTeX::cref 'YaTeX::ref) yuuji@80: (defun YaTeX::tabref (argp) ; For the style file of IPSJ journal yuuji@80: (YaTeX::ref yuuji@80: argp nil nil yuuji@80: (function yuuji@80: (lambda () yuuji@80: (YaTeX-quick-in-environment-p "table"))))) yuuji@80: (defun YaTeX::figref (argp) ; For the style file of IPSJ journal yuuji@80: (YaTeX::ref yuuji@80: argp nil nil yuuji@80: (function yuuji@80: (lambda () yuuji@80: (YaTeX-quick-in-environment-p "figure"))))) yuuji@232: (defun YaTeX::eqref (argp) yuuji@232: (YaTeX::ref yuuji@232: argp nil nil yuuji@232: (function yuuji@232: (lambda () yuuji@232: (YaTeX-in-math-mode-p))))) yuuji@70: yuuji@80: (defun YaTeX::cite-collect-bibs-external (bibptn &rest files) yuuji@80: "Collect bibentry from FILES(variable length argument) ; yuuji@70: and print them to standard output." yuuji@70: ;;Thanks; http://icarus.ilcs.hokudai.ac.jp/comp/biblio.html yuuji@80: (let*((tb (get-buffer-create " *bibtmp*")) yuuji@80: (bibitemsep "^\\s *@[A-Za-z]") yuuji@80: (target (if (string< "" bibptn) bibptn bibitemsep)) yuuji@80: (checkrx (concat "\\(" bibptn "\\)\\|" bibitemsep)) yuuji@80: beg yuuji@80: (searchnext yuuji@80: (if (string< "" bibptn) yuuji@80: (function yuuji@80: (lambda() yuuji@80: (setq beg (point)) yuuji@80: (and yuuji@80: (prog1 yuuji@80: (re-search-forward target nil t) yuuji@80: (end-of-line)) yuuji@80: (re-search-backward bibitemsep beg t)))) yuuji@80: (function yuuji@80: (lambda() yuuji@80: (re-search-forward target nil t))))) yuuji@80: ) yuuji@70: (save-excursion yuuji@70: (set-buffer tb) yuuji@80: (princ (format "%sbegin{thebibliography}\n" YaTeX-ec)) yuuji@70: (while files yuuji@70: (erase-buffer) yuuji@70: (cond yuuji@70: ((file-exists-p (car files)) yuuji@70: (insert-file-contents (car files))) yuuji@70: ((file-exists-p (concat (car files) ".bib")) yuuji@70: (insert-file-contents (concat (car files) ".bib")))) yuuji@70: (save-excursion yuuji@70: (goto-char (point-min)) yuuji@80: (while (funcall searchnext) yuuji@70: (skip-chars-forward "^{,") yuuji@80: (setq beg (point)) yuuji@70: (if (= (char-after (point)) ?{) yuuji@70: (princ (format "%sbibitem{%s}%s\n" yuuji@70: YaTeX-ec yuuji@70: (buffer-substring yuuji@70: (1+ (point)) yuuji@70: (progn (skip-chars-forward "^,\n") yuuji@70: (point))) yuuji@80: (mapconcat yuuji@80: (function yuuji@80: (lambda (kwd) yuuji@80: (goto-char beg) yuuji@80: (if (re-search-forward yuuji@80: (concat kwd "\\s *=") nil t) yuuji@80: (buffer-substring yuuji@80: (progn yuuji@80: (goto-char (match-end 0)) yuuji@80: (skip-chars-forward " \t\n") yuuji@80: (point)) yuuji@80: (progn yuuji@80: (if (looking-at "[{\"]") yuuji@80: (forward-sexp 1) yuuji@80: (forward-char 1) yuuji@80: (skip-chars-forward "^,}")) yuuji@80: (point)))))) yuuji@80: '("author" "year" "title" ) yuuji@80: ";")))) yuuji@80: (and (re-search-forward bibitemsep nil t) yuuji@80: (forward-line -1)))) yuuji@80: (setq files (cdr files))) yuuji@80: (princ (format "%sbegin{thebibliography}\n" YaTeX-ec))))) yuuji@70: yuuji@77: (defvar YaTeX::cite-bibitem-macro-regexp "bibitem\\|harvarditem" yuuji@77: "*Regexp of macro name of bibitem definition") yuuji@77: yuuji@80: (defun YaTeX::cite-collect-bibs-internal (bibptn) yuuji@70: "Collect bibentry in the current buffer and print them to standard output." yuuji@77: (let ((ptn (concat YaTeX-ec-regexp yuuji@77: "\\(" YaTeX::cite-bibitem-macro-regexp "\\)\\b")) yuuji@80: (lim (concat YaTeX-ec-regexp yuuji@80: "\\(" YaTeX::cite-bibitem-macro-regexp "\\b\\)" yuuji@80: "\\|\\(end{\\)")) yuuji@70: (pcnt (regexp-quote YaTeX-comment-prefix))) yuuji@80: ;; Using bibptn not yet implemented. yuuji@80: ;; Do you need it?? 2005/11/22 yuuji@70: (save-excursion yuuji@70: (while (YaTeX-re-search-active-forward ptn pcnt nil t) yuuji@70: (skip-chars-forward "^{\n") yuuji@70: (or (eolp) yuuji@80: (princ (format "%sbibitem%s %s\n" yuuji@70: YaTeX-ec yuuji@70: (buffer-substring yuuji@80: (point) yuuji@80: (progn (forward-sexp 1) (point))) yuuji@80: (buffer-substring yuuji@80: (progn (skip-chars-forward "\n \t") (point)) yuuji@80: (save-excursion yuuji@80: (if (YaTeX-re-search-active-forward yuuji@80: lim pcnt nil t) yuuji@80: (progn yuuji@80: (goto-char (match-beginning 0)) yuuji@80: (skip-chars-backward "\n \t") yuuji@80: (point)) yuuji@80: (point-end-of-line))))))))))) yuuji@70: yuuji@80: (defun YaTeX::cite (argp &rest dummy) yuuji@48: (cond yuuji@48: ((eq argp 1) yuuji@70: (let* ((cb (current-buffer)) yuuji@70: (f (file-name-nondirectory buffer-file-name)) yuuji@70: (d default-directory) yuuji@70: (hilit-auto-highlight nil) yuuji@70: (pcnt (regexp-quote YaTeX-comment-prefix)) yuuji@70: (bibrx (concat YaTeX-ec-regexp "bibliography{\\([^}]+\\)}")) yuuji@397: (bibptn (YaTeX-read-string-or-skip "Pattern: ")) yuuji@70: (bbuf (get-buffer-create " *bibitems*")) yuuji@70: (standard-output bbuf) yuuji@80: (me 'YaTeX::cite) ;shuld set this for using YaTeX::ref yuuji@70: bibs files) yuuji@70: (set-buffer bbuf)(erase-buffer)(set-buffer cb) yuuji@70: (save-excursion yuuji@70: (goto-char (point-min)) yuuji@70: ;;(1)search external bibdata yuuji@70: (while (YaTeX-re-search-active-forward bibrx pcnt nil t) yuuji@70: (apply 'YaTeX::cite-collect-bibs-external yuuji@80: bibptn yuuji@70: (YaTeX-split-string yuuji@70: (YaTeX-match-string 1) ","))) yuuji@70: ;;(2)search direct \bibitem usage yuuji@80: (YaTeX::cite-collect-bibs-internal bibptn) yuuji@70: (if (progn yuuji@70: (YaTeX-visit-main t) yuuji@70: (not (eq (current-buffer) cb))) yuuji@70: (save-excursion yuuji@70: (goto-char (point-min)) yuuji@70: ;;(1)search external bibdata yuuji@70: (while (YaTeX-re-search-active-forward bibrx pcnt nil t) yuuji@70: (apply 'YaTeX::cite-collect-bibs-external yuuji@80: bibptn yuuji@70: (YaTeX-split-string yuuji@70: (YaTeX-match-string 1) ","))) yuuji@70: ;;(2)search internal yuuji@80: (YaTeX::cite-collect-bibs-internal bibptn))) yuuji@70: ;;Now bbuf holds the list of bibitem yuuji@70: (set-buffer bbuf) yuuji@80: ;;;(switch-to-buffer bbuf) yuuji@80: (if (fboundp 'font-lock-fontify-buffer) (font-lock-fontify-buffer)) yuuji@77: (YaTeX::ref yuuji@77: argp yuuji@77: (concat "\\\\\\(" yuuji@77: YaTeX::cite-bibitem-macro-regexp yuuji@77: "\\)\\(\\[.*\\]\\)?") yuuji@77: "cite")))) yuuji@77: yuuji@48: (t nil))) yuuji@11: yuuji@528: (defvar YaTeX::bibliographystyle-alist-default yuuji@528: '(("unsrt")("junsrt")("plain")("jplain")("alpha")("jalpha") yuuji@528: ("abbrv")("jabbrv")("jipsj")("jname")("tieice")("tipsj") yuuji@528: ("apalike")("ieeetr")("siam"))) yuuji@528: (defvar YaTeX::bibliographystyle-alist-private yuuji@528: nil yuuji@528: "*Completion table for bibliographystyle") yuuji@528: yuuji@528: (defun YaTeX::bibliographystyle(argp) yuuji@528: (cond yuuji@528: ((= argp 1) yuuji@528: (YaTeX-completing-read-or-skip yuuji@528: "BibStyle: " yuuji@528: (append YaTeX::bibliographystyle-alist-private yuuji@528: YaTeX::bibliographystyle-alist-default) yuuji@528: nil)))) yuuji@528: yuuji@167: (defun YaTeX::bibitem (argp) yuuji@167: "Add-in function to insert argument of \\bibitem." yuuji@167: (YaTeX::label argp "label" "cite")) yuuji@167: yuuji@77: ;;; for Harvard citation style yuuji@77: (fset 'YaTeX::citeasnoun 'YaTeX::cite) yuuji@77: (fset 'YaTeX::possessivecite 'YaTeX::cite) yuuji@77: (fset 'YaTeX::citeyear 'YaTeX::cite) yuuji@77: (fset 'YaTeX::citename 'YaTeX::cite) yuuji@80: (fset 'YaTeX::citep 'YaTeX::cite) yuuji@80: (fset 'YaTeX::citet 'YaTeX::cite) yuuji@70: yuuji@48: (defun YaTeX-select-other-yatex-buffer () yuuji@48: "Select buffer from all yatex-mode's buffers interactivelly." yuuji@48: (interactive) yuuji@48: (let ((lbuf "*YaTeX mode buffers*") (blist (YaTeX-yatex-buffer-list)) yuuji@48: (lnum -1) buf rv yuuji@11: (ff "**find-file**")) yuuji@12: (YaTeX-showup-buffer yuuji@12: lbuf (function (lambda (x) 1))) ;;Select next window surely. yuuji@69: (save-excursion yuuji@69: (set-buffer (get-buffer lbuf)) yuuji@69: (setq buffer-read-only nil) yuuji@69: (erase-buffer)) yuuji@69: (let ((standard-output (get-buffer lbuf))) yuuji@11: (while blist yuuji@48: (princ yuuji@48: (format "%c:{%s}\n" (+ (% (setq lnum (1+ lnum)) 26) ?A) yuuji@48: (buffer-name (car blist)))) yuuji@11: (setq blist (cdr blist))) yuuji@11: (princ (format "':{%s}" ff))) yuuji@59: (YaTeX-showup-buffer lbuf nil t) yuuji@11: (YaTeX::label-setup-key-map) yuuji@11: (setq buffer-read-only t) yuuji@11: (use-local-map YaTeX-label-select-map) yuuji@11: (message YaTeX-label-guide-msg) yuuji@11: (unwind-protect yuuji@11: (progn yuuji@11: (recursive-edit) yuuji@11: (set-buffer lbuf) yuuji@11: (beginning-of-line) yuuji@11: (setq rv yuuji@11: (if (re-search-forward "{\\([^\\}]+\\)}" (point-end-of-line) t) yuuji@11: (buffer-substring (match-beginning 1) (match-end 1)) nil))) yuuji@11: (kill-buffer lbuf)) yuuji@48: (if (string= rv ff) yuuji@48: (progn yuuji@48: (call-interactively 'find-file) yuuji@48: (current-buffer)) yuuji@69: rv))) yuuji@48: yuuji@48: (defun YaTeX-label-other () yuuji@48: (let ((rv (YaTeX-select-other-yatex-buffer))) yuuji@11: (cond yuuji@11: ((null rv) "") yuuji@11: (t yuuji@11: (set-buffer rv) yuuji@80: (funcall me argp labelcmd refcmd))))) yuuji@11: yuuji@13: ;; yuuji@13: ; completion for the arguments of \newcommand yuuji@13: ;; yuuji@13: (defun YaTeX::newcommand (&optional argp) yuuji@13: (cond yuuji@13: ((= argp 1) yuuji@394: (let ((command (read-string-with-history "Define newcommand: " "\\"))) yuuji@13: (put 'YaTeX::newcommand 'command (substring command 1)) yuuji@13: command)) yuuji@13: ((= argp 2) yuuji@13: (let ((argc yuuji@452: (YaTeX-str2int yuuji@394: (read-string-with-history "Number of arguments(Default 0): "))) yuuji@397: (def (YaTeX-read-string-or-skip "Definition: ")) yuuji@13: (command (get 'YaTeX::newcommand 'command))) yuuji@13: ;;!!! It's illegal to insert string in the add-in function !!! yuuji@13: (if (> argc 0) (insert (format "[%d]" argc))) yuuji@13: (if (and (stringp command) yuuji@13: (string< "" command) yuuji@51: (y-or-n-p "Update dictionary?")) yuuji@18: (cond yuuji@18: ((= argc 0) yuuji@18: (YaTeX-update-table yuuji@18: (list command) yuuji@18: 'singlecmd-table 'user-singlecmd-table 'tmp-singlecmd-table)) yuuji@18: ((= argc 1) yuuji@18: (YaTeX-update-table yuuji@18: (list command) yuuji@18: 'section-table 'user-section-table 'tmp-section-table)) yuuji@18: (t (YaTeX-update-table yuuji@18: (list command argc) yuuji@18: 'section-table 'user-section-table 'tmp-section-table)))) yuuji@13: (message "") yuuji@13: def ;return command name yuuji@13: )) yuuji@69: (t ""))) yuuji@13: yuuji@80: (defun YaTeX::newcounter (&optional argp) yuuji@80: (cond yuuji@80: ((= argp 1) yuuji@394: (read-string-with-history "New counter name: ")) yuuji@80: (t ""))) yuuji@80: yuuji@16: ;; yuuji@16: ; completion for the arguments of \pagestyle yuuji@16: ;; yuuji@16: (defun YaTeX::pagestyle (&optional argp) yuuji@16: "Read the pagestyle with completion." yuuji@16: (completing-read yuuji@16: "Page style: " yuuji@69: '(("plain") ("empty") ("headings") ("myheadings") ("normal") nil))) yuuji@69: yuuji@51: (fset 'YaTeX::thispagestyle 'YaTeX::pagestyle) yuuji@51: yuuji@16: ;; yuuji@16: ; completion for the arguments of \pagenumbering yuuji@16: ;; yuuji@16: (defun YaTeX::pagenumbering (&optional argp) yuuji@16: "Read the numbering style." yuuji@16: (completing-read yuuji@16: "Page numbering style: " yuuji@69: '(("arabic") ("Alpha") ("alpha") ("Roman") ("roman")))) yuuji@13: yuuji@23: ;; yuuji@23: ; Length yuuji@23: ;; yuuji@23: (defvar YaTeX:style-parameters-default yuuji@23: '(("\\arraycolsep") yuuji@23: ("\\arrayrulewidth") yuuji@23: ("\\baselineskip") yuuji@23: ("\\columnsep") yuuji@23: ("\\columnseprule") yuuji@23: ("\\doublerulesep") yuuji@23: ("\\evensidemargin") yuuji@23: ("\\footheight") yuuji@23: ("\\footskip") yuuji@23: ("\\headheight") yuuji@23: ("\\headsep") yuuji@23: ("\\itemindent") yuuji@23: ("\\itemsep") yuuji@23: ("\\labelsep") yuuji@23: ("\\labelwidth") yuuji@23: ("\\leftmargin") yuuji@23: ("\\linewidth") yuuji@23: ("\\listparindent") yuuji@23: ("\\marginparsep") yuuji@23: ("\\marginparwidth") yuuji@23: ("\\mathindent") yuuji@23: ("\\oddsidemargin") yuuji@23: ("\\parindent") yuuji@23: ("\\parsep") yuuji@23: ("\\parskip") yuuji@23: ("\\partopsep") yuuji@23: ("\\rightmargin") yuuji@23: ("\\tabcolsep") yuuji@23: ("\\textheight") yuuji@23: ("\\textwidth") yuuji@324: ("\\columnwidth") yuuji@23: ("\\topmargin") yuuji@23: ("\\topsep") yuuji@23: ("\\topskip") yuuji@23: ) yuuji@23: "Alist of LaTeX style parameters.") yuuji@23: (defvar YaTeX:style-parameters-private nil yuuji@23: "*User definable alist of style parameters.") yuuji@49: (defvar YaTeX:style-parameters-local nil yuuji@49: "*User definable alist of local style parameters.") yuuji@23: yuuji@23: (defvar YaTeX:length-history nil "Holds history of length.") yuuji@51: (put 'YaTeX:length-history 'no-default t) yuuji@23: (defun YaTeX::setlength (&optional argp) yuuji@23: "YaTeX add-in function for arguments of \\setlength." yuuji@23: (cond yuuji@23: ((equal 1 argp) yuuji@49: ;;(completing-read "Length variable: " YaTeX:style-parameters nil nil "\\") yuuji@49: (YaTeX-cplread-with-learning yuuji@49: "Length variable: " yuuji@49: 'YaTeX:style-parameters-default yuuji@49: 'YaTeX:style-parameters-private yuuji@49: 'YaTeX:style-parameters-local yuuji@49: nil nil "\\") yuuji@49: ) yuuji@23: ((equal 2 argp) yuuji@397: (YaTeX-read-string-or-skip "Length: " nil 'YaTeX:length-history)))) yuuji@69: yuuji@23: (fset 'YaTeX::addtolength 'YaTeX::setlength) yuuji@23: yuuji@23: (defun YaTeX::settowidth (&optional argp) yuuji@23: "YaTeX add-in function for arguments of \\settowidth." yuuji@23: (cond yuuji@23: ((equal 1 argp) yuuji@49: (YaTeX-cplread-with-learning yuuji@49: "Length variable: " yuuji@49: 'YaTeX:style-parameters-default yuuji@49: 'YaTeX:style-parameters-private yuuji@49: 'YaTeX:style-parameters-local yuuji@49: nil nil "\\")) yuuji@23: ((equal 2 argp) yuuji@397: (YaTeX-read-string-or-skip "Text: ")))) yuuji@69: yuuji@23: (defun YaTeX::newlength (&optional argp) yuuji@23: "YaTeX add-in function for arguments of \\newlength" yuuji@23: (cond yuuji@23: ((equal argp 1) yuuji@394: (let ((length (read-string-with-history "Length variable: " "\\"))) yuuji@49: (if (string< "" length) yuuji@49: (YaTeX-update-table yuuji@49: (list length) yuuji@49: 'YaTeX:style-parameters-default yuuji@49: 'YaTeX:style-parameters-private yuuji@49: 'YaTeX:style-parameters-local)) yuuji@69: length)))) yuuji@23: yuuji@23: ;; \multicolumn's arguments yuuji@23: (defun YaTeX::multicolumn (&optional argp) yuuji@23: "YaTeX add-in function for arguments of \\multicolumn." yuuji@23: (cond yuuji@23: ((equal 1 argp) yuuji@394: (read-string-with-history "Number of columns: ")) yuuji@23: ((equal 2 argp) yuuji@79: (YaTeX:read-oneof "|lrc" nil t)) yuuji@23: ((equal 3 argp) yuuji@397: (YaTeX-read-string-or-skip "Item: ")))) yuuji@23: yuuji@49: (defvar YaTeX:documentstyles-default yuuji@49: '(("article") ("jarticle") ("j-article") yuuji@49: ("book") ("jbook") ("j-book") yuuji@49: ("report") ("jreport") ("j-report") yuuji@49: ("letter") ("ascjletter")) yuuji@49: "List of LaTeX documentstyles.") yuuji@49: (defvar YaTeX:documentstyles-private nil yuuji@49: "*User defined list of LaTeX documentstyles.") yuuji@49: (defvar YaTeX:documentstyles-local nil yuuji@49: "*User defined list of local LaTeX documentstyles.") yuuji@49: (defvar YaTeX:documentstyle-options-default yuuji@49: '(("a4j") ("a5j") ("b4j") ("b5j") yuuji@49: ("twocolumn") ("jtwocolumn") ("epsf") ("epsfig") ("epsbox") ("nfig")) yuuji@49: "List of LaTeX documentstyle options.") yuuji@49: (defvar YaTeX:documentstyle-options-private nil yuuji@49: "*User defined list of LaTeX documentstyle options.") yuuji@49: (defvar YaTeX:documentstyle-options-local nil yuuji@49: "List of LaTeX local documentstyle options.") yuuji@49: yuuji@49: (defun YaTeX:documentstyle () yuuji@49: (let*((delim ",") yuuji@49: (dt (append YaTeX:documentstyle-options-local yuuji@49: YaTeX:documentstyle-options-private yuuji@49: YaTeX:documentstyle-options-default)) yuuji@49: (minibuffer-completion-table dt) yuuji@49: (opt (read-from-minibuffer yuuji@49: "Style options ([opt1,opt2,...]): " yuuji@51: nil YaTeX-minibuffer-completion-map nil)) yuuji@49: (substr opt) o) yuuji@49: (if (string< "" opt) yuuji@49: (progn yuuji@49: (while substr yuuji@49: (setq o (substring substr 0 (string-match delim substr))) yuuji@49: (or (assoc o dt) yuuji@49: (YaTeX-update-table yuuji@49: (list o) yuuji@49: 'YaTeX:documentstyle-options-default yuuji@49: 'YaTeX:documentstyle-options-private yuuji@49: 'YaTeX:documentstyle-options-local)) yuuji@49: (setq substr yuuji@49: (if (string-match delim substr) yuuji@49: (substring substr (1+ (string-match delim substr)))))) yuuji@49: (concat "[" opt "]")) yuuji@49: ""))) yuuji@49: yuuji@49: (defun YaTeX::documentstyle (&optional argp) yuuji@51: "YaTeX add-in function for arguments of \\documentstyle." yuuji@49: (cond yuuji@49: ((equal argp 1) yuuji@72: (setq YaTeX-env-name "document") yuuji@49: (let ((sname yuuji@49: (YaTeX-cplread-with-learning yuuji@49: (format "Documentstyle (default %s): " yuuji@49: YaTeX-default-document-style) yuuji@49: 'YaTeX:documentstyles-default yuuji@49: 'YaTeX:documentstyles-private yuuji@49: 'YaTeX:documentstyles-local))) yuuji@49: (if (string= "" sname) (setq sname YaTeX-default-document-style)) yuuji@69: (setq YaTeX-default-document-style sname))))) yuuji@49: yuuji@80: (defun YaTeX::include (argp &optional prompt) yuuji@86: "Read file name setting default directory to that of main file." yuuji@80: (cond yuuji@80: ((= argp 1) yuuji@86: (save-excursion yuuji@86: (YaTeX-visit-main t) yuuji@86: (let*((insert-default-directory) yuuji@321: (default (and (boundp 'old) (stringp old) old)) yuuji@321: (file (read-file-name (or prompt "Input file: ") "" yuuji@321: default nil default))) yuuji@86: (setq file (substring file 0 (string-match "\\.tex$" file)))))))) yuuji@80: yuuji@80: (fset 'YaTeX::input 'YaTeX::include) yuuji@510: (fset 'YaTeX::svg 'YaTeX::include) yuuji@80: yuuji@80: yuuji@57: ;;; -------------------- LaTeX2e stuff -------------------- yuuji@57: (defvar YaTeX:documentclass-options-default yuuji@70: '(("a4paper") ("a5paper") ("b4paper") ("b5paper") ("10pt") ("11pt") ("12pt") yuuji@57: ("latterpaper") ("legalpaper") ("executivepaper") ("landscape") yuuji@57: ("oneside") ("twoside") ("draft") ("final") ("leqno") ("fleqn") ("openbib") yuuji@70: ("tombow") ("titlepage") ("notitlepage") ("dvips") yuuji@175: ("mingoth") ;for jsarticle yuuji@57: ("clock") ;for slides class only yuuji@57: ) yuuji@57: "Default options list for documentclass") yuuji@57: (defvar YaTeX:documentclass-options-private nil yuuji@57: "*User defined options list for documentclass") yuuji@57: (defvar YaTeX:documentclass-options-local nil yuuji@57: "*User defined options list for local documentclass") yuuji@57: yuuji@57: (defun YaTeX:documentclass () yuuji@57: (let*((delim ",") yuuji@57: (dt (append YaTeX:documentclass-options-local yuuji@57: YaTeX:documentclass-options-private yuuji@57: YaTeX:documentclass-options-default)) yuuji@57: (minibuffer-completion-table dt) yuuji@57: (opt (read-from-minibuffer yuuji@57: "Documentclass options ([opt1,opt2,...]): " yuuji@57: nil YaTeX-minibuffer-completion-map nil)) yuuji@57: (substr opt) o) yuuji@57: (if (string< "" opt) yuuji@57: (progn yuuji@57: (while substr yuuji@70: yuuji@57: (setq o (substring substr 0 (string-match delim substr))) yuuji@57: (or (assoc o dt) yuuji@57: (YaTeX-update-table yuuji@57: (list o) yuuji@57: 'YaTeX:documentclass-options-default yuuji@57: 'YaTeX:documentclass-options-private yuuji@57: 'YaTeX:documentclass-options-local)) yuuji@57: (setq substr yuuji@57: (if (string-match delim substr) yuuji@57: (substring substr (1+ (string-match delim substr)))))) yuuji@57: (concat "[" opt "]")) yuuji@57: ""))) yuuji@57: yuuji@57: (defvar YaTeX:documentclasses-default yuuji@57: '(("article") ("jarticle") ("report") ("jreport") ("book") ("jbook") yuuji@175: ("jsarticle") ("jsbook") yuuji@57: ("j-article") ("j-report") ("j-book") yuuji@57: ("letter") ("slides") ("ltxdoc") ("ltxguide") ("ltnews") ("proc")) yuuji@57: "Default documentclass alist") yuuji@57: (defvar YaTeX:documentclasses-private nil yuuji@57: "*User defined documentclass alist") yuuji@57: (defvar YaTeX:documentclasses-local nil yuuji@57: "*User defined local documentclass alist") yuuji@563: (defvar YaTeX-default-documentclass (if YaTeX-japan "jsarticle" "article") yuuji@57: "*Default documentclass") yuuji@57: yuuji@57: (defun YaTeX::documentclass (&optional argp) yuuji@57: (cond yuuji@57: ((equal argp 1) yuuji@72: (setq YaTeX-env-name "document") yuuji@57: (let ((sname yuuji@57: (YaTeX-cplread-with-learning yuuji@57: (format "Documentclass (default %s): " YaTeX-default-documentclass) yuuji@57: 'YaTeX:documentclasses-default yuuji@57: 'YaTeX:documentclasses-private yuuji@57: 'YaTeX:documentclasses-local))) yuuji@57: (if (string= "" sname) (setq sname YaTeX-default-documentclass)) yuuji@252: (setq YaTeX-section-name "title" yuuji@252: YaTeX-default-documentclass sname))))) yuuji@57: yuuji@249: (defun YaTeX::title (&optional argp) yuuji@397: (prog1 (YaTeX-read-string-or-skip "Document Title: ") yuuji@249: (setq YaTeX-section-name "author" yuuji@249: YaTeX-single-command "maketitle"))) yuuji@249: yuuji@249: (defun YaTeX::author (&optional argp) yuuji@397: (prog1 (YaTeX-read-string-or-skip "Document Author: ") yuuji@249: (setq YaTeX-section-name "date" yuuji@249: YaTeX-single-command "maketitle"))) yuuji@249: yuuji@252: (defun YaTeX:document () yuuji@252: (setq YaTeX-section-name yuuji@252: (if (string-match "book\\|bk" YaTeX-default-documentclass) yuuji@252: "chapter" yuuji@252: "section")) yuuji@252: "") yuuji@252: yuuji@252: yuuji@70: (defvar YaTeX:latex2e-named-color-alist yuuji@70: '(("GreenYellow") ("Yellow") ("Goldenrod") ("Dandelion") ("Apricot") yuuji@70: ("Peach") ("Melon") ("YellowOrange") ("Orange") ("BurntOrange") yuuji@70: ("Bittersweet") ("RedOrange") ("Mahogany") ("Maroon") ("BrickRed") yuuji@70: ("Red") ("OrangeRed") ("RubineRed") ("WildStrawberry") ("Salmon") yuuji@70: ("CarnationPink") ("Magenta") ("VioletRed") ("Rhodamine") ("Mulberry") yuuji@70: ("RedViolet") ("Fuchsia") ("Lavender") ("Thistle") ("Orchid")("DarkOrchid") yuuji@70: ("Purple") ("Plum") ("Violet") ("RoyalPurple") ("BlueViolet") yuuji@70: ("Periwinkle") ("CadetBlue") ("CornflowerBlue") ("MidnightBlue") yuuji@70: ("NavyBlue") ("RoyalBlue") ("Blue") ("Cerulean") ("Cyan") ("ProcessBlue") yuuji@70: ("SkyBlue") ("Turquoise") ("TealBlue") ("Aquamarine") ("BlueGreen") yuuji@70: ("Emerald") ("JungleGreen") ("SeaGreen") ("Green") ("ForestGreen") yuuji@70: ("PineGreen") ("LimeGreen") ("YellowGreen") ("SpringGreen") ("OliveGreen") yuuji@70: ("RawSienna") ("Sepia") ("Brown") ("Tan") ("Gray") ("Black") ("White")) yuuji@141: "Colors defined in $TEXMF/tex/plain/dvips/colordvi.tex") yuuji@70: yuuji@70: (defvar YaTeX:latex2e-basic-color-alist yuuji@70: '(("black") ("white") ("red") ("blue") ("yellow") ("green") ("cyan") yuuji@70: ("magenta")) yuuji@70: "Basic colors") yuuji@70: yuuji@70: (defun YaTeX:textcolor () yuuji@70: "Add-in for \\color's option" yuuji@70: (if (y-or-n-p "Use `named' color? ") yuuji@70: "[named]")) yuuji@70: yuuji@70: (defun YaTeX::color-completing-read (prompt) yuuji@70: (let ((completion-ignore-case t) yuuji@70: (namedp (save-excursion yuuji@70: (skip-chars-backward "^\n\\[\\\\") yuuji@70: (looking-at "named")))) yuuji@70: (completing-read yuuji@70: prompt yuuji@70: (if namedp yuuji@70: YaTeX:latex2e-named-color-alist yuuji@70: YaTeX:latex2e-basic-color-alist) yuuji@70: nil t))) yuuji@70: yuuji@70: (defun YaTeX::textcolor (argp) yuuji@70: "Add-in for \\color's argument" yuuji@70: (cond yuuji@70: ((= argp 1) (YaTeX::color-completing-read "Color: ")) yuuji@397: ((= argp 2) (YaTeX-read-string-or-skip "Colored string: ")))) yuuji@70: yuuji@70: (fset 'YaTeX:color 'YaTeX:textcolor) yuuji@70: (fset 'YaTeX::color 'YaTeX::textcolor) yuuji@70: (fset 'YaTeX:colorbox 'YaTeX:textcolor) yuuji@70: (fset 'YaTeX::colorbox 'YaTeX::textcolor) yuuji@70: (fset 'YaTeX:fcolorbox 'YaTeX:textcolor) yuuji@80: (fset 'YaTeX:pagecolor 'YaTeX:textcolor) yuuji@80: (fset 'YaTeX::pagecolor 'YaTeX::textcolor) yuuji@70: yuuji@70: (defun YaTeX::fcolorbox (argp) yuuji@70: (cond yuuji@70: ((= argp 1) (YaTeX::color-completing-read "Frame color: ")) yuuji@70: ((= argp 2) (YaTeX::color-completing-read "Inner color: ")) yuuji@397: ((= argp 3) (YaTeX-read-string-or-skip "Colored string: ")))) yuuji@70: yuuji@70: (defun YaTeX:scalebox () yuuji@80: "Add-in for \\scalebox" yuuji@397: (let ((vmag (YaTeX-read-string-or-skip (if YaTeX-japan "倍率(負で反転): " yuuji@80: "Magnification(Negative for flipped): "))) yuuji@397: (hmag (YaTeX-read-string-or-skip (if YaTeX-japan "縦倍率(省略可): " yuuji@80: "Vertical magnification(Optional): ")))) yuuji@70: (if (and hmag (string< "" hmag)) yuuji@70: (format "{%s}[%s]" vmag hmag) yuuji@70: (format "{%s}" vmag)))) yuuji@70: yuuji@80: (defun YaTeX:rotatebox () yuuji@80: "Optional argument add-in for \\rotatebox" yuuji@80: (message "Rotate origin? (N)one (O)rigin (X)-Y: ") yuuji@80: (let ((c (read-char)) r (defx "x=mm") x (defy "y=mm") y something) yuuji@80: (cond yuuji@80: ((memq c '(?O ?o)) yuuji@80: (if (string< "" (setq r (YaTeX:read-oneof "htbpB"))) yuuji@80: (concat "[origin=" r "]"))) yuuji@80: ((memq c '(?X ?x ?Y ?y)) yuuji@394: (setq r (read-string-with-history yuuji@394: "" (if YaTeX-emacs-19 (cons defx 3) defx)) yuuji@80: x (if (string< "x=" r) r) yuuji@394: r (read-string-with-history yuuji@394: "" (if YaTeX-emacs-19 (cons defy 3) defy)) yuuji@80: y (if (string< "y=" r) r) yuuji@80: something (or x y)) yuuji@80: (format "%s%s%s%s%s" yuuji@80: (if something "[" "") yuuji@80: (if x x "") yuuji@80: (if (and x y) "," "") yuuji@80: (if y y "") yuuji@80: (if something "]" "")))))) yuuji@80: yuuji@80: (defun YaTeX::rotatebox (argp) yuuji@80: "Argument add-in for \\rotatebox" yuuji@80: (cond yuuji@80: ((= argp 1) yuuji@394: (read-string-with-history (if YaTeX-japan "回転角(度; 左回り): " yuuji@80: "Angle in degree(unclockwise): "))) yuuji@80: ((= argp 2) yuuji@397: (YaTeX-read-string-or-skip (if YaTeX-japan "テキスト: " "Text: "))))) yuuji@80: yuuji@73: (defun YaTeX:includegraphics () yuuji@73: "Add-in for \\includegraphics's option" yuuji@342: (let (width height (scale "") angle str) yuuji@342: (setq width (YaTeX:read-length "Width: ") yuuji@342: height (YaTeX:read-length "Height: ")) yuuji@254: (or (string< "" width) (string< "" height) yuuji@237: (setq scale (YaTeX-read-string-or-skip "Scale: "))) yuuji@237: (setq angle (YaTeX-read-string-or-skip "Angle(0-359): ")) yuuji@73: (setq str yuuji@73: (mapconcat yuuji@73: 'concat yuuji@73: (delq nil yuuji@342: (mapcar (function (lambda (s) yuuji@73: (and (stringp (symbol-value s)) yuuji@73: (string< "" (symbol-value s)) yuuji@349: (format "%s=%s" s (symbol-value s))))) yuuji@349: '(width height scale angle))) yuuji@73: ",")) yuuji@567: (if (string= "" str) "" yuuji@567: (concat "[" str "]")))) yuuji@73: yuuji@413: (defvar YaTeX::get-boundingbox-cmd YaTeX-cmd-gs yuuji@413: "Command to get bounding box from PDF files. yuuji@413: Possible values are `gs' and `extractbb'.") yuuji@413: yuuji@308: (defun YaTeX::get-boundingbox (file) yuuji@308: "Return the bound box as a string yuuji@308: This function relies on gs(ghostscript) command installed." yuuji@308: (let ((str (YaTeX-command-to-string yuuji@413: (format yuuji@413: (cond yuuji@413: ((string-match "extractbb" YaTeX::get-boundingbox-cmd) yuuji@413: "%s -O %s") yuuji@413: ((string-match "gs" YaTeX::get-boundingbox-cmd) yuuji@413: "%s -sDEVICE=bbox -dBATCH -dNOPAUSE %s") yuuji@413: (t "echo %s %s")) yuuji@413: YaTeX::get-boundingbox-cmd file)))) yuuji@308: (if (string-match yuuji@308: "%%BoundingBox:\\s \\([0-9]+\\s [0-9]+\\s [0-9]+\\s [0-9]+\\)" yuuji@308: str) yuuji@308: (substring str (match-beginning 1) (match-end 1))))) yuuji@308: yuuji@330: (defun YaTeX::includegraphics (argp &optional file doclip) yuuji@70: "Add-in for \\includegraphics" yuuji@340: (let*((imgfile (or file (YaTeX::include argp "Image File: "))) yuuji@338: (imgfilepath yuuji@338: (save-excursion yuuji@338: (YaTeX-visit-main t) yuuji@338: (expand-file-name imgfile default-directory))) yuuji@254: (case-fold-search t) info bb noupdate needclose c) yuuji@308: (and (string-match "\\.\\(jpe?g\\|png\\|gif\\|bmp\\|pdf\\)$" imgfile) yuuji@338: (file-exists-p imgfilepath) yuuji@247: (or (fboundp 'yahtml-get-image-info) yuuji@247: (progn yuuji@247: (load "yahtml" t) (featurep 'yahtml))) ;(require 'yahtml nil t) yuuji@308: (if (string-match "\\.pdf" imgfile) yuuji@308: (and yuuji@338: (setq info (YaTeX::get-boundingbox imgfilepath)) yuuji@308: (stringp info) yuuji@308: (string< "" info) yuuji@308: (setq bb (format "bb=%s" info))) yuuji@338: (setq info (yahtml-get-image-info imgfilepath)) yuuji@308: (car info) ;if has width value yuuji@308: (car (cdr info)) ;if has height value yuuji@308: (setq bb (format "bb=%d %d %d %d" 0 0 (car info) (car (cdr info))))) yuuji@248: (save-excursion yuuji@248: (cond yuuji@254: ((and (save-excursion yuuji@254: (YaTeX-re-search-active-backward yuuji@254: "\\\\\\(includegraphics\\)\\|\\(bb=[-+ \t0-9]+\\)" yuuji@254: YaTeX-comment-prefix nil t)) yuuji@248: (match-beginning 2) yuuji@248: (not (setq noupdate (equal (YaTeX-match-string 2) bb))) yuuji@248: (y-or-n-p (format "Update `bb=' line to `%s'?: " bb))) yuuji@248: (message "") yuuji@248: (replace-match bb)) yuuji@248: (noupdate nil) yuuji@248: ((and (match-beginning 1) yuuji@330: (or doclip yuuji@330: (prog2 yuuji@330: (message "Insert `%s'? Y)es N)o C)yes+`clip': " bb) yuuji@330: (memq (setq c (read-char)) '(?y ?Y ?\ ?c ?C)) yuuji@332: (setq doclip (memq c '(?c ?C))) yuuji@330: (message "")))) yuuji@248: (goto-char (match-end 0)) yuuji@308: (message "`bb=' %s" yuuji@308: (format yuuji@308: (if YaTeX-japan yuuji@308: "の値はファイル名の上で `%s' を押してファイル名を再入力して更新できます。" yuuji@308: "values can be update by typing `%s' on file name.") yuuji@308: (key-description yuuji@308: (car (where-is-internal 'YaTeX-change-*))))) yuuji@248: (if (looking-at "\\[") (forward-char 1) yuuji@248: (insert-before-markers "[") yuuji@248: (setq needclose t)) yuuji@248: (insert-before-markers bb) yuuji@332: (if doclip (insert-before-markers ",clip")) yuuji@248: (if needclose (insert-before-markers "]") yuuji@248: (or (looking-at "\\]") (insert-before-markers ",")))) yuuji@248: (t (YaTeX-push-to-kill-ring bb))))) yuuji@248: (setq YaTeX-section-name "caption") yuuji@247: imgfile)) yuuji@70: yuuji@86: (defun YaTeX::verbfile (argp) yuuji@86: "Add-in for \\verbfile" yuuji@86: (YaTeX::include argp "Virbatim File: ")) yuuji@86: yuuji@68: (defun YaTeX:caption () yuuji@72: (setq YaTeX-section-name "label") yuuji@68: nil) yuuji@68: yuuji@551: (defun YaTeX:subfigure () yuuji@551: (let ((subcap (YaTeX-read-string-or-skip "Sub-caption: "))) yuuji@551: (if (string= "" subcap) "" yuuji@551: (concat "[" subcap "]")))) yuuji@551: yuuji@552: (defun YaTeX::subfigure (argp) yuuji@551: (setq YaTeX-section-name "includegraphics") yuuji@551: nil) yuuji@551: yuuji@554: ;; for okumacro yuuji@554: (defun YaTeX::ruby (argp) yuuji@554: (cond yuuji@554: ((= argp 1) (YaTeX-read-string-or-skip "Kanji: ")) yuuji@554: ((= argp 2) (YaTeX-read-string-or-skip "Yomi: ")))) yuuji@80: yuuji@565: ;;(require 'yatexpkg) yuuji@565: (autoload 'YaTeX::usepackage "yatexpkg" "Add-in for \\usepackage{}") yuuji@565: ;;; (defun YaTeX::usepackage()...) MOVED to yatexpkg.el yuuji@565: ;;; See yatexpkg.el yuuji@79: yuuji@79: yuuji@79: (defun YaTeX::mask (argp) yuuji@79: (cond yuuji@79: ((equal argp 1) yuuji@397: (YaTeX-read-string-or-skip "String: ")) yuuji@79: ((equal argp 2) yuuji@79: (let (c) yuuji@79: (while (not (memq c '(?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K))) yuuji@79: (message "Mask type(A..K): ") yuuji@79: (setq c (upcase (read-char)))) yuuji@79: (format "%c" c))))) yuuji@79: yuuji@79: (defun YaTeX::maskbox (argp) yuuji@79: (cond yuuji@79: ((equal argp 1) yuuji@342: (YaTeX:read-length "Width: ")) yuuji@79: ((equal argp 2) yuuji@342: (YaTeX:read-length "Height: ")) yuuji@79: ((equal argp 3) yuuji@79: (let (c) yuuji@79: (while (not (memq c '(?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K))) yuuji@79: (message "Mask type(A..K): ") yuuji@79: (setq c (upcase (read-char)))) yuuji@79: (format "%c" c))) yuuji@79: ((equal argp 4) yuuji@79: (YaTeX:read-oneof "lcr" 'quick)) yuuji@79: ((equal argp 5) yuuji@397: (YaTeX-read-string-or-skip "String: ")))) yuuji@80: yuuji@80: (defun YaTeX::textcircled (argp) yuuji@80: (cond yuuji@80: ((equal argp 1) yuuji@394: (let ((char (read-string-with-history "Circled char: ")) yuuji@80: (left "") (right "") c) yuuji@80: (setq c (read-char yuuji@80: "Enclose also with (s)mall (t)iny s(C)riptsize (N)one:")) yuuji@80: (cond yuuji@80: ((memq c '(?s ?S)) (setq left "{\\small " right "}")) yuuji@80: ((memq c '(?t ?T)) (setq left "{\\tiny " right "}")) yuuji@80: ((memq c '(?c ?C)) (setq left "{\\scriptsize " right "}"))) yuuji@80: (format "%s%s%s" left char right))))) yuuji@79: yuuji@422: ;;; -------------------- beamer stuff -------------------- yuuji@422: (defvar YaTeX:frame-option-alist-default yuuji@423: '(("plain") ("containsverbatim") ("shrink") ("squeeze") yuuji@422: ("allowframebreaks") ("label="))) yuuji@422: (defvar YaTeX:frame-option-alist-private nil yuuji@422: "*Alist for completion list of the argument for `frame' environemnt") yuuji@422: (defvar YaTeX:frame-option-alist yuuji@422: (append YaTeX:frame-option-alist-private YaTeX:frame-option-alist-default)) yuuji@422: yuuji@422: (defun YaTeX:frame () yuuji@422: (let*((minibuffer-local-completion-map YaTeX-minibuffer-completion-map) yuuji@422: (delim ",") yuuji@422: (opt (YaTeX-completing-read-or-skip yuuji@422: "Frame option: " YaTeX:frame-option-alist)) yuuji@422: (title (YaTeX-read-string-or-skip "Title: ")) yuuji@422: (subtitle (YaTeX-read-string-or-skip "Subtitle: "))) yuuji@424: (setq YaTeX-env-name "columns") yuuji@422: (concat yuuji@422: (if (string< "" opt) (concat "[" opt "]")) yuuji@422: (if (string< "" title) (concat "{" title "}")) yuuji@422: (if (string< "" subtitle) (concat "{" subtitle "}"))))) yuuji@422: yuuji@424: (defun YaTeX:column-read-width () yuuji@424: "Completing function for column environment/macro of Beamer" yuuji@424: (let ((md (match-data)) (colsinf (YaTeX-quick-in-environment-p "columns")) yuuji@427: (totalw (float 1)) restw (ww "\\textwidth") defw cw) yuuji@424: (unwind-protect yuuji@424: (progn yuuji@427: (if (save-excursion yuuji@427: (YaTeX-re-search-active-backward yuuji@427: "totalwidth=\\([.0-9]+\\)\\(\\\\.*width\\)" yuuji@427: YaTeX-comment-prefix (cdr colsinf) t)) yuuji@427: (setq totalw (float (string-to-number (YaTeX-match-string 1))) yuuji@427: ww (YaTeX-match-string 2))) yuuji@427: (setq restw totalw) yuuji@424: (save-excursion yuuji@424: (while (YaTeX-re-search-active-backward yuuji@424: (concat yuuji@424: "\\\\begin{column}{\\([.0-9]+\\)\\(\\\\.*width\\)}" yuuji@424: "\\|" yuuji@424: "\\\\column{\\([.0-9]+\\)\\(\\\\.*width\\)}") yuuji@424: YaTeX-comment-prefix yuuji@424: (cdr colsinf) t) yuuji@427: (setq restw (- restw (string-to-number yuuji@427: (or (YaTeX-match-string 1) yuuji@427: (YaTeX-match-string 3))))))) yuuji@427: (setq defw (format "%.2f%s" yuuji@427: (if (= totalw restw) (/ totalw 2) restw) yuuji@424: (or (YaTeX-match-string 2) yuuji@424: (YaTeX-match-string 4) yuuji@427: ww)) yuuji@424: cw (YaTeX:read-length yuuji@424: (format "Column width(default: %s): " defw))) yuuji@424: (if (string= "" cw) (setq cw defw)) yuuji@424: (prog1 yuuji@424: cw yuuji@424: (setq YaTeX-section-name "column"))) yuuji@424: (store-match-data md)))) yuuji@424: yuuji@424: (defun YaTeX:column () yuuji@424: (if (eq YaTeX-current-completion-type 'begin) yuuji@424: (concat "{" (YaTeX:column-read-width) "}"))) yuuji@424: (defun YaTeX::column (argp) yuuji@424: (cond yuuji@424: ((= argp 1) (YaTeX:column-read-width)))) yuuji@424: (defvar YaTeX:columns-option-alist yuuji@426: '(("t") ("T") ("b") ("c") ("onlytextwidth") ("totalwidth=0.9\\textwidth")) yuuji@424: "*Default option alist for completing columns environment of Beamer") yuuji@424: yuuji@424: (defun YaTeX:columns () yuuji@424: (setq YaTeX-section-name "column" yuuji@424: YaTeX-env-name "column") yuuji@424: (let*((minibuffer-local-completion-map YaTeX-minibuffer-completion-map) yuuji@424: (delim ",=") yuuji@424: (tbl (append YaTeX:columns-option-alist)) ;XX yuuji@424: (opt (YaTeX-completing-read-or-skip "columns option: " tbl))) yuuji@424: (if (string< "" opt) yuuji@424: (concat "[" opt "]")))) yuuji@424: yuuji@68: ;;; -------------------- math-mode stuff -------------------- yuuji@68: (defun YaTeX::tilde (&optional pos) yuuji@68: "For accent macros in mathmode" yuuji@68: (cond yuuji@68: ((equal pos 1) yuuji@68: (message "Put accent on variable: ") yuuji@68: (let ((v (char-to-string (read-char))) (case-fold-search nil)) yuuji@68: (message "") yuuji@68: (cond yuuji@68: ((string-match "i\\|j" v) yuuji@68: (concat "\\" v "math")) yuuji@68: ((string-match "[\r\n\t ]" v) yuuji@68: "") yuuji@68: (t v)))) yuuji@68: (nil ""))) yuuji@68: yuuji@68: (fset 'YaTeX::hat 'YaTeX::tilde) yuuji@68: (fset 'YaTeX::check 'YaTeX::tilde) yuuji@68: (fset 'YaTeX::bar 'YaTeX::tilde) yuuji@68: (fset 'YaTeX::dot 'YaTeX::tilde) yuuji@68: (fset 'YaTeX::ddot 'YaTeX::tilde) yuuji@68: (fset 'YaTeX::vec 'YaTeX::tilde) yuuji@68: yuuji@68: (defun YaTeX::widetilde (&optional pos) yuuji@68: "For multichar accent macros in mathmode" yuuji@68: (cond yuuji@68: ((equal pos 1) yuuji@68: (let ((m "Put over chars[%s ]: ") v v2) yuuji@68: (message m " ") yuuji@68: (setq v (char-to-string (read-char))) yuuji@68: (message "") yuuji@68: (if (string-match "[\r\n\t ]" v) yuuji@68: "" yuuji@68: (message m v) yuuji@68: (setq v2 (char-to-string (read-char))) yuuji@68: (message "") yuuji@68: (if (string-match "[\r\n\t ]" v2) yuuji@68: v yuuji@68: (concat v v2))))) yuuji@68: (nil ""))) yuuji@68: yuuji@68: (fset 'YaTeX::widehat 'YaTeX::widetilde) yuuji@68: (fset 'YaTeX::overline 'YaTeX::widetilde) yuuji@68: (fset 'YaTeX::overrightarrow 'YaTeX::widetilde) yuuji@68: yuuji@79: ; yuuji@79: ; for \frac{}{} region yuuji@79: (defun YaTeX::frac-region (beg end) yuuji@79: (if (catch 'done yuuji@79: (while (re-search-forward "\\s *\\(\\\\over\\|/\\)\\s *" end t) yuuji@79: (goto-char (match-beginning 0)) yuuji@79: (if (y-or-n-p yuuji@79: (format "Replace this `%s' with `}{'" (YaTeX-match-string 0))) yuuji@79: (throw 'done t)) yuuji@79: (goto-char (match-end 0)))) yuuji@79: (let (p (b0 (match-beginning 0)) e0) yuuji@79: (replace-match "}{") yuuji@79: (setq e0 (point)) yuuji@79: (save-restriction yuuji@79: (narrow-to-region beg end) yuuji@79: (goto-char e0) yuuji@79: (skip-chars-forward " \t") yuuji@79: (setq p (point)) yuuji@79: (YaTeX-goto-corresponding-paren) yuuji@79: (forward-char 1) yuuji@79: (skip-chars-forward " \t\r\n") yuuji@79: (if (= end (1+ (point))) yuuji@79: (progn yuuji@79: (goto-char p) yuuji@79: (if (looking-at "\\\\") (forward-char 1)) yuuji@79: (YaTeX-kill-paren nil))) yuuji@79: (goto-char beg) yuuji@79: (skip-chars-forward " \t") yuuji@79: (setq p (point)) yuuji@79: (YaTeX-goto-corresponding-paren) yuuji@79: (forward-char 1) yuuji@79: (skip-chars-forward " \t\r\n") yuuji@79: (if (>= (point) b0) yuuji@79: (progn yuuji@79: (goto-char p) yuuji@79: (if (looking-at "\\\\") (forward-char 1)) yuuji@79: (YaTeX-kill-paren nil)))))) yuuji@79: (message "")) yuuji@68: yuuji@80: (defun YaTeX::DeclareMathOperator (argp) yuuji@80: (cond yuuji@80: ((equal argp 1) yuuji@397: (YaTeX-read-string-or-skip "Operator: " "\\")))) yuuji@80: yuuji@68: ;;; yuuji@68: ;; Add-in functions for large-type command. yuuji@68: ;;; yuuji@68: (defun YaTeX:em () yuuji@68: (cond yuuji@68: ((eq YaTeX-current-completion-type 'large) "\\/") yuuji@68: (t nil))) yuuji@68: (fset 'YaTeX:it 'YaTeX:em) yuuji@68: yuuji@575: ;;; twocolumn yuuji@575: (defun YaTeX:twocolumn () yuuji@575: (format "[%s]" (YaTeX-read-string-or-skip "One column paragraph: "))) yuuji@575: yuuji@23: ;;; -------------------- End of yatexadd -------------------- yuuji@23: (provide 'yatexadd) yuuji@72: ; Local variables: yuuji@72: ; fill-prefix: ";;; " yuuji@72: ; paragraph-start: "^$\\| \\|;;;$" yuuji@72: ; paragraph-separate: "^$\\| \\|;;;$" yuuji@72: ; End: