yatex_1.77+dfsg1/0000755000175000017500000000000012126311540012345 5ustar kurakurayatex_1.77+dfsg1/manifest0000644000175000017500000000314211754151142014104 0ustar kurakuracomment.el コメントアウト関連 dir sample `dir' file for Info docs/htmlqa yahtmlに関する一般的な質問と回答 docs/htmlqa.eng Q and A on using yahtml docs/qanda 野鳥に関する一般的な質問と回答 docs/qanda.eng Q and A on using YaTeX docs/yahtmle yahtml Texinfo Manual docs/yahtmle.tex yahtml Texinfo Manual source text docs/yahtmlj yahtml 日本語 Texinfo マニュアル docs/yahtmlj.tex yahtml 日本語 Texinfo マニュアルのソース docs/yatex.ref 野鳥・キーバインド早見表 docs/yatexadd.doc 野鳥用付加関数の仕様説明 docs/yatexe YaTeX Texinfo Manual docs/yatexe.tex YaTeX Texinfo Manual source text docs/yatexgen.doc 付加関数自動作成モード使用上の注意 docs/yatexj 野鳥・日本語 Texinfo マニュアル docs/yatexj.tex 野鳥・日本語 Texinfo マニュアルのソース docs/yatexref.eng Quick reference of YaTeX's key bindings help/YATEXHLP.jp オンラインヘルプデータ help/YATEXHLP.eng LaTeX on-line help text install インストールガイド newpage.rb yahtml用新規ページ生成補助スクリプト readme.meadow.j Meadow 用インストールガイド yahtml.el 野鳥風 html モード yatex.el 野鳥・主 Emacs-Lisp ファイル yatex.new 各バージョンの変更履歴 yatex19.el Emacs-19(Mule2)用の設定 yatexadd.el 付加関数の定義例 yatexenv.el LaTeX 環境依存の関数 yatexgen.el 野鳥用付加関数自動作成モード yatexhie.el 野鳥用ドキュメント階層表示プログラム yatexhks.el hook を詰め込むために使う(ユーザ用) yatexhlp.el オンラインヘルププログラム yatexlib.el 野鳥用ライブラリ関数 yatexm-o.el .emacs の設定例(min-outを使用) yatexmth.el 数式環境用記号補完モード yatexpkg.el 野鳥用 \usepackage 解決プログラム yatexprc.el 野鳥・プロセス処理関数 yatexsec.el セクション抽出関数 yatex_1.77+dfsg1/readme.meadow.j0000644000175000017500000001030411260026714015232 0ustar kurakura Meadow(Mule for Windows) への 野鳥のインストール ************************************************************* 野鳥のインストールは、以下の3ステップで完了します。 (1) 初期設定ファイル(~/.emacs)の設定 (2) Emacs Lispファイル(*.el)のコピー (3) 取扱説明書(help/info)の設定 順に説明します。 (1) 初期設定ファイル(~/.emacs)の設定 Emacsは、ユーザそれぞれの初期設定をホームディレクトリ(~/)の中にある .emacsというファイル(あるいは.emacs.elというファイル)から読み込みます。 ここでは、拡張子が.texであるファイルを読み込むと、自動的に野鳥が読み込 まれるように設定します。 まず ~/.emacsに下の2項目を加えます。 (setq auto-mode-alist (cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist)) (autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t) 次に野鳥の emacs-lisp ファイル群を置くディレクトリを load-path に加えます。 たとえば、`~/src/emacs/yatex'に置くのであれば、 (setq load-path (cons "~/src/emacs/yatex" load-path)) などとします。もし、pLaTeX2e, dviout などのコマンドをインストールした場 所にPATHを通していないときはこれらを明示的に指定します。以下の例は c:\ptex\bin にLaTeX関係のコマンドをインストールしてある場合の指定です。 (setq tex-command "c:/ptex/bin/platex") (setq dvi2-command "c:/ptex/bin/dviout") これで、初期設定ファイルの設定は終了です。 (2) Emacs Lispファイル(*.el)のコピー Emacs Lispで書かれた野鳥本体をインストールするには、(i) makeを使う方法 と、(ii) 手動でコピーする方法とがあります。 (i) makeを使う方法 Windows環境に Unix ライクなコマンドを提供する「Cygwin」を導入したりし て、makeが使える環境にある方は、次のような方法でインストールできます。 そうでない方は(ii)に進んでください。 まず、Emacsなどのエディタでこのファイルと同じディレクトリにある makefileというファイルを開き、自分の環境にあわせて編集します。 たとえば、 PREFIX = /usr/localを、PREFIX = /usrにしたり、 ## mule2 EMACS = mule EMACSDIR= ${PREFIX}/lib/${EMACS} ## emacs20 #EMACS = emacs #EMACSDIR= ${PREFIX}/share/${EMACS} ## XEmacs #EMACS = xemacs #EMACSDIR= ${PREFIX}/lib/${EMACS} を自分の使っているEmacsの種類にあわせたりします。行頭に#をつけるとコメ ント扱いとなり、その行は無効化されます。その行を有効にするためには、行 頭の#を外します。 また、次の行の行頭に#をつけてください。 GEO = -geometry 80x20+0+0 以下は書き換えた部分の例です PREFIX=/usr/local/meadow EMACS=meadow EMACSDIR=${PREFIX}/site-lisp #GEO = -geometry 80x20+0+0 以上の作業が終わったら、makefileを保存し、bashなどのシェルで、 % export DISPLAY=":0.0" % make install とすれば、インストールされます。 (3)の取扱説明書のインストールも基本的には終わっていますが、Emacsから読 めるようにするために、info ディレクトリの dir というファイルにこのディ レクトリの dir ファイルの中身を追加してください。 (ii) 手動でコピーする方法 Windows環境などでmakeがなかったり、上記(i)のmake installが失敗する場合 は、手動で必要ファイルをインストール(コピー)することができます。 たとえば、Meadow 用の外部Emacs-Lispパッケージをインストールするディレク トリが /usr/local/meadow/site-lisp/ だったとします。その場合、 このアーカイブ(yatex.tar.gz)を展開したディレクトリ (yatex) をそこに移動します。すると、 /usr/local/meadow/site-lisp/yatex/ というディレクト リになりますので、これをバージョン番号無しの /usr/local/meadow/site-lisp/yatex/ にします。 これで野鳥は使えるようになっているはずですが、さらに実行速度をわずかばか り稼ぐため、Emacs Lispファイルをコンパイル(バイトコンパイル)することもで きます。ただし、バイトコンパイルする手順が決まっているので手動でやるのは Emacsについての知識が必要です。さらにバイトコンパイルしても実感できるほ ど速くはならないのであまりお勧めしません。それでもバイトコンパイルしたい 場合は、Cygwinなど、makeの使える環境を用意して、それで自動的に処理する方 が良いと思います。 (3) 取扱説明書(help/info)の設定 次に、各種の説明書をインストールします。 LaTeXマクロの利用解説書である help/YATEXHLP.jp ファイルを /usr/local/meadow/site-lisp/ にコピーします。 野鳥自身のマニュアルである docs/yatexj, docs/yatexe と yahtml のマニュアルである docs/yahtmlj, docs/yahtmle を /usr/local/meadow/1.10/info/ にコピーし、info ディレクトリの dir というファイルに このディレクトリの dir ファイルの中身を追加します。 以上でインストールは完了です。 yatex_1.77+dfsg1/dir0000644000175000017500000000040411260026713013047 0ustar kurakura* YaTeX: (yatexj). Yet Another tex-mode for Emacs. (Japanese). * YaTeX-e: (yatexe). Yet Another tex-mode for Emacs. (English). * yahtml: (yahtmlj). Yet Another HTML-mode for Emacs. (Japanese). * yahtml-e: (yahtmle). Yet Another HTML-mode for Emacs. (English). yatex_1.77+dfsg1/yatex.el0000444000175000017500000034215512126310635014035 0ustar kurakura;;; yatex.el --- Yet Another tex-mode for emacs //野鳥// -*- coding: sjis -*- ;;; (c)1991-2013 by HIROSE Yuuji.[yuuji@yatex.org] ;;; Last modified Mon Apr 1 22:40:25 2013 on firestorm ;;; $Id: yatex.el,v 1.77 2013/04/01 13:53:45 yuuji Rel $ ;;; The latest version of this software is always available at; ;;; http://www.yatex.org/ ;;; Code: (require 'comment) (require 'yatexlib) (defconst YaTeX-revision-number "1.77" "Revision number of running yatex.el") ;---------- Local variables ---------- (defvar YaTeX-prefix "\C-c" "*Prefix key to call YaTeX functions. You can select favorite prefix key by setq in your ~/.emacs.") (defvar YaTeX-environment-indent 1 "*Indentation depth at column width in LaTeX environments.") (defvar YaTeX-fill-prefix nil "*fill-prefix used for auto-fill-mode. The default value is nil.") (defvar YaTeX-fill-column 72 "*fill-column used for auto-fill-mode.") (defvar YaTeX-comment-prefix "%" "TeX comment prefix.") (defvar YaTeX-current-position-register ?3 "*Position register to keep where the last completion was done. All of YaTeX completing input store the current position into the register YaTeX-current-position-register. So every time you make a trip to any other part of text other than you are writing, you can return to the editing paragraph by calling register-to-point with argument YaTeX-current-position-register.") ;;(defvar YaTeX-tmp-dic-unit 'main-file ;; "*Default switching unit of temporary dictionary. ;;There are two switching unit: ;;'main-file : switch tmp-dic according to main-file directory. ;;'directory : switch tmp-dic dir by dir." ;;) (defvar YaTeX-use-LaTeX2e t "*Use LaTeX2e or not. Nil means latex 2.09") (defvar tex-command (cond (YaTeX-use-LaTeX2e "platex") (YaTeX-japan "jlatex") (t "latex")) "*Default command for typesetting LaTeX text.") (defvar bibtex-command (if YaTeX-japan "jbibtex" "bibtex") "*Default command of BibTeX.") (defvar dvi2-command ;previewer command for your site (if YaTeX-dos "dviout -wait=0" "xdvi -geo +0+0 -s 4") "*Default previewer command including its option. This default value is for X window system.") (defvar makeindex-command (if YaTeX-dos "makeind" "makeindex") "*Default makeindex command.") (defvar dviprint-command-format (if YaTeX-dos "dviprt %s %f%t" "dvi2ps %f %t %s | lpr") "*Command line string to print out current file. Format string %s will be replaced by the filename. Do not forget to specify the `from usage' and `to usage' with their option by format string %f and %t. See also documentation of dviprint-from-format and dviprint-to-format.") (defvar dviprint-from-format (if YaTeX-dos "%b-" "-f %b") "*`From' page format of dvi filter. %b will turn to beginning page number.") (defvar dviprint-to-format (if YaTeX-dos "%e" "-t %e") "*`To' page format of dvi filter. %e will turn to end page number.") (defvar YaTeX-dvipdf-command "dvipdfmx" "*Command name to convert dvi file to PDF.") (defvar YaTeX-default-document-style (concat (if YaTeX-japan "j") "article") "*Default LaTeX Documentstyle for YaTeX-typeset-region.") (defvar YaTeX-need-nonstop nil "*T for adding `\\nonstopmode{}' to text before invoking latex command.") (defvar latex-warning-regexp "line.* [0-9]*" "*Regular expression of line number of warning message by latex command.") (defvar latex-error-regexp "l\\.[1-9][0-9]*" "*Regular expression of line number of latex error. Perhaps your latex command stops at this error message with line number of LaTeX source text.") (defvar latex-dos-emergency-message "Emergency stop" ;<- for Micro tex, ASCII-pTeX 1.6 "Message pattern of emergency stop of typesetting. Because Demacs (GNU Emacs on DOS) cannot have concurrent process, the latex command which is stopping on a LaTeX error, is terminated by Demacs. Many latex command on DOS display some messages when it is terminated by other process, user or OS. Define to this variable a message string of your latex command on DOS shown at abnormal termination. Remember Demacs's call-process function is not oriented for interactive process.") (defvar NTT-jTeX nil "*T for using NTT-jTeX for latex command. More precisely, setting t to this variables inhibits inter-word break on typeset document by line-break of source text. That is, YaTeX automatically put % after each line at filling. 改行+インデントによって、タイプセット後の字間が空いてしまうのを抑制する場合に tにする(古いNTT-jTeXで顕著に現れる)。具体的には、fillするときに各行の終わりに %を付加する。") (defvar YaTeX-item-regexp (concat (regexp-quote "\\") "\\(sub\\|bib\\)*item") "*Regular expression of item command.") (defvar YaTeX-sectioning-regexp "\\(part\\|chapter\\*?\\|\\(sub\\)*\\(section\\|paragraph\\)\\)\\(\\*\\|\\b\\)" "*LaTeX sectioning commands regexp.") (defvar YaTeX-paragraph-start (concat "^[ \t]*%\\|^[ \t]*$\\|\\'\\|^\C-l\\|\\\\\\\\$\\|^[ \t]*\\\\\\(" YaTeX-sectioning-regexp ;sectioning commands "\\|[A-z]*item\\|begin{\\|end{" ;special declaration "\\|\\[\\|\\]" "\\|newpage\\b\\|vspace\\b" "\\)") "*Paragraph starting regexp of common LaTeX source. Use this value for YaTeX-uncomment-paragraph.") (defvar YaTeX-paragraph-separate (concat "^[ \t]*%\\|^[ \t]*$\\|^\C-l\\|\\\\\\\\$\\|^[ \t]*\\\\\\(" YaTeX-sectioning-regexp ;sectioning commands "\\|begin{\\|end{" ;special declaration "\\|\\[\\|\\]" "\\|newpage\\b\\|vspace\\b" "\\)") "*Paragraph delimiter regexp of common LaTeX source. Use this value for YaTeX-uncomment-paragraph.") (defvar YaTeX-verbatim-environments '("verbatim" "verbatim*" "alltt") "*Assume these environments of this variable disable LaTeX commands.") (defvar YaTeX-verb-regexp "verb\\*?\\|path" "*Regexp of verb family. Do not contain preceding \\\\ nor \\(\\).") (defvar YaTeX-fill-inhibit-environments (append '("tabular" "tabular*" "array" "picture" "eqnarray" "eqnarray*" "equation" "equation*" "math" "displaymath") YaTeX-verbatim-environments) "*In these environments, YaTeX inhibits fill-paragraph from formatting. Define those environments as a form of list.") (defvar YaTeX-itemizing-env-regexp "itemize\\|enumerate\\|description\\|list\\|thebibliography" "*Regexp of itemizing environments") (defvar YaTeX-equation-env-regexp "array\\*?\\|equation\\*?" "*Regexp of environments for equations") (defvar YaTeX-array-env-regexp (concat "array\\*?\\|eqnarray\\*?\\|tabbing\\|tabular\\*?\\|" ;LaTeX "matrix\\|pmatrix\\|bmatrix\\|vmatrix\\|Vmatrix\\|" ;AMS-LaTeX "align\\*?\\|split\\*?\\|aligned\\*?\\|alignat\\*?\\|" ;AMS-LaTeX "[bpvV]?matrix\\|smallmatrix\\|cases\\|" ;AMS-LaTeX "xalignat\\*?\\|xxalignat\\*?") ;AMS-LaTeX "*Regexp of environments where `&' becomes field delimiter.") (defvar YaTeX-uncomment-once t "*T for removing all continuous commenting character(%). Nil for removing only one commenting character at the beginning-of-line.") (defvar YaTeX-close-paren-always t "*Close parenthesis always when YaTeX-modify-mode is nil.") (defvar YaTeX-greek-by-maketitle-completion nil "*T for greek letters completion by maketitle-type completion.") (defvar YaTeX-auto-math-mode t "*T for changing YaTeX-math mode automatically.") (defvar YaTeX-use-AMS-LaTeX nil "*T for using AMS-LaTeX") (defvar yatex-mode-hook nil "*List of functions to be called at the end of yatex-mode initializations.") (defvar YaTeX-search-file-from-top-directory t "*Non-nil means to search input-files from the directory where main file exists.") (defvar YaTeX-use-font-lock (and (featurep 'font-lock) (fboundp 'x-color-values) (fboundp 'font-lock-fontify-region)) "*Use font-lock to fontify buffer or not.") (defvar YaTeX-use-hilit19 (and (featurep 'hilit19) (fboundp 'x-color-values) (fboundp 'hilit-translate) (not YaTeX-use-font-lock)) "*Use hilit19 to highlight buffer or not.") (defvar YaTeX-tabular-indentation 4 "*Indentation column-depth of continueing line in tabular environment.") ;;-- Math mode values -- (defvar YaTeX-math-key-list-default '((";" . YaTeX-math-sign-alist) (":" . YaTeX-greek-key-alist)) "Default key sequence to invoke math-mode's image completion.") (defvar YaTeX-math-key-list-private nil "*User defined alist, math-mode-prefix vs completion alist.") (defvar YaTeX-math-key-list (append YaTeX-math-key-list-private YaTeX-math-key-list-default) "Key sequence to invoke math-mode's image completion.") (defvar YaTeX-skip-default-reader nil "Non-nil skips default argument reader of section-type completion.") (defvar YaTeX-simple-messages nil "Non-nil makes minibuffer messages simpler.") (defvar YaTeX-template-file "~/work/template.tex" "*Template TeX source file. This will be inserted to empty file.") (defvar YaTeX-addin-prefix "YaTeX:") (defvar yatex-mode-abbrev-table nil "*Abbrev table in use in yatex-mode buffers.") (define-abbrev-table 'yatex-mode-abbrev-table ()) ;------------ Completion table ------------ ; Set tex-section-like command possible completion (defvar section-table (append '(("part") ("chapter") ("chapter*") ("section") ("section*") ("subsection") ("subsection*") ("subsubsection") ("paragraph") ("subparagraph") ("author") ("thanks") ("documentstyle") ("pagestyle") ("thispagestyle") ("title") ("underline") ("label") ("makebox") ("footnote") ("footnotetext") ("index") ("hspace*") ("vspace*") ("bibliography") ("bibitem") ("cite") ("input") ("include") ("includeonly") ("mbox") ("hbox") ("caption") ("arabic") ("newcounter") ("newlength") ("setlength" 2) ("addtolength" 2) ("settowidth" 2) ("setcounter" 2) ("addtocounter" 2) ("stepcounter" 2) ("newcommand" 2) ("renewcommand" 2) ("newenvironment" 3) ("newtheorem" 2) ("cline") ("framebox") ("savebox" 2) ("sbox" 2) ("newsavebox") ("usebox") ("date") ("put") ("ref") ("pageref") ("tabref") ("figref") ("raisebox" 2) ("multicolumn" 3) ("shortstack") ("parbox" 2) ;; for mathmode accent ("tilde") ("hat") ("check") ("bar") ("dot") ("ddot") ("vec") ("widetilde") ("widehat") ("overline") ("overrightarrow") ;; section types in mathmode ("frac" 2) ("sqrt") ("mathrm") ("mathbf") ("mathit") ) (if YaTeX-use-LaTeX2e '(("documentclass") ("usepackage") ("textbf") ("textgt") ("textit") ("textmc") ("textmd") ("textnormal") ("textrm") ("textsc") ("textsf") ("textsl") ("texttt") ("textup") ("mathbf") ("mathcal") ("mathit") ("mathnormal") ("mathrm") ("mathsf") ("mathtt") ("textcircled") ("scalebox" 1) ;is faking of argument position ("rotatebox" 2) ("resizebox" 3) ("reflectbox") ("colorbox" 2) ("fcolorbox" 3) ("textcolor" 2) ("color") ("pagecolor") ("includegraphics") ("includegraphics*") ("bou") ;defined in plext ("url") ;defined in url ("shadowbox") ("doublebox") ("ovalbox") ("Ovalbox") ("fancyoval") ;defined in fancybox ("keytop") ("mask" 2) ("maskbox" 5) ;defined in ascmac ("bm") ;deined in bm ("verbfile") ("listing") ;defined in misc ("slashbox" 2) ("backslashbox" 2) ;defined in slashbox )) (if YaTeX-use-AMS-LaTeX '(("DeclareMathOperator" 2) ("boldsymbol") ("pmb") ("eqref") ("tag") ("tag*")))) "Default completion table for section-type completion.") (defvar user-section-table nil) (defvar tmp-section-table nil) (defvar YaTeX-ams-math-begin-alist '(("align") ("align*") ("multline") ("multline*") ("gather") ("gather*") ("alignat") ("alignat*") ("xalignat") ("xalignat*") ("xxalignat") ("xxalignat*") ("flalign") ("flalign*") ("equation*"))) (defvar YaTeX-ams-math-gathering-alist '(("matrix") ("pmatrix") ("bmatrix") ("Bmatrix") ("vmatrix") ("Vmatrix") ("split") ("split*") ("aligned") ("aligned*") ("alignedat") ("gathered") ("smallmatrix") ("cases") ("subequations"))) ;; Prepare list(not alist) for YaTeX::ref in yatexadd.el (defvar YaTeX-math-begin-list (mapcar 'car YaTeX-ams-math-begin-alist)) (defvar YaTeX-math-gathering-list ;used in yatexadd.el#yatex::ref (mapcar 'car YaTeX-ams-math-gathering-alist)) (defvar YaTeX-ams-env-table (append YaTeX-ams-math-begin-alist YaTeX-ams-math-gathering-alist) "*Standard AMS-LaTeX(2e) environment completion table.") ; Set tex-environment possible completion (defvar env-table (append '(("quote") ("quotation") ("center") ("verse") ("document") ("verbatim") ("itemize") ("enumerate") ("description") ("list") ("tabular") ("tabular*") ("table") ("tabbing") ("titlepage") ("sloppypar") ("picture") ("displaymath") ("eqnarray") ("eqnarray*") ("figure") ("equation") ("equation*") ("abstract") ("array") ("thebibliography") ("theindex") ("flushleft") ("flushright") ("minipage") ("supertabular") ) (if YaTeX-use-LaTeX2e '(("comment") ;defined in version ("longtable") ;defined in longtable ("screen") ("boxnote") ("shadebox") ;; ("itembox") ;in ascmac ("alltt") ;defined in alltt ("multicols") ;defined in multicol ("breakbox"))) ;defined in eclbkbox (if YaTeX-use-AMS-LaTeX YaTeX-ams-env-table)) "Default completion table for begin-type completion.") (defvar user-env-table nil) (defvar tmp-env-table nil) ; Set {\Large }-like completion (defvar fontsize-table '(("rm") ("em") ("bf") ("boldmath") ("it") ("sl") ("sf") ("sc") ("tt") ("dg") ("dm") ("tiny") ("scriptsize") ("footnotesize") ("small")("normalsize") ("large") ("Large") ("LARGE") ("huge") ("Huge") ("rmfamily") ("sffamily") ("ttfamily") ("mdseries") ("bfseries") ("upshape") ("itshape") ("slshape") ("scshape") ) "Default completion table for large-type completion.") (defvar LaTeX2e-fontstyle-alist '(("rm" . "rmfamily") ("sf" . "sffamily") ("tt" . "ttfamily") ("md" . "mdseries") ("bf" . "bfseries") ("up" . "upshape") ("it" . "itshape") ("sl" . "slshape") ("sc" . "scshape"))) (defvar user-fontsize-table nil) (defvar tmp-fontsize-table nil) (defvar singlecmd-table (append '(("maketitle") ("makeindex") ("sloppy") ("protect") ("par") ("LaTeX") ("TeX") ("item") ("item[]") ("appendix") ("hline") ("kill") ;;("rightarrow") ("Rightarrow") ("leftarrow") ("Leftarrow") ("pagebreak") ("nopagebreak") ("tableofcontents") ("newpage") ("clearpage") ("cleardoublepage") ("footnotemark") ("verb") ("verb*") ("linebreak") ("pagebreak") ("noindent") ("indent") ("left") ("right") ("dots") ("smallskip") ("medskip") ("bigskip") ("displaystyle") ) (if YaTeX-greek-by-maketitle-completion '(("alpha") ("beta") ("gamma") ("delta") ("epsilon") ("varepsilon") ("zeta") ("eta") ("theta")("vartheta") ("iota") ("kappa") ("lambda") ("mu") ("nu") ("xi") ("pi") ("varpi") ("rho") ("varrho") ("sigma") ("varsigma") ("tau") ("upsilon") ("phi") ("varphi") ("chi") ("psi") ("omega") ("Gamma") ("Delta") ("Theta") ("Lambda")("Xi") ("Pi") ("Sigma") ("Upsilon") ("Phi") ("Psi") ("Omega"))) (if YaTeX-use-LaTeX2e '(("return") ("Return") ("yen"))) ;defined in ascmac (if YaTeX-use-AMS-LaTeX '(("nonumber"))) ) "Default completion table for maketitle-type completion.") (defvar user-singlecmd-table nil) (defvar tmp-singlecmd-table nil) ;---------- Key mode map ---------- ;;; ;; Create new key map: YaTeX-mode-map ;; Do not change this section. ;;; (defvar YaTeX-mode-map nil "Keymap used in YaTeX mode") (defvar YaTeX-prefix-map nil "Keymap used when YaTeX-prefix key pushed") (defvar YaTeX-user-extensional-map (make-sparse-keymap) "*Keymap used for the user's customization") (defvar YaTeX-current-completion-type nil "Has current completion type. This may be used in YaTeX addin functions.") (defvar YaTeX-modify-mode nil "*Current editing mode. When non-nil, each opening parentheses only opens, nil enters both open/close parentheses when opening parentheses key pressed.") (defvar YaTeX-math-mode nil "Holds whether current mode is math-mode.") ;;; ;; Define key table ;;; (if YaTeX-mode-map nil (setq YaTeX-mode-map (make-sparse-keymap)) (setq YaTeX-prefix-map (make-sparse-keymap)) (define-key YaTeX-mode-map "\"" 'YaTeX-insert-quote) (define-key YaTeX-mode-map "{" 'YaTeX-insert-braces) (define-key YaTeX-mode-map "(" 'YaTeX-insert-parens) (define-key YaTeX-mode-map "$" 'YaTeX-insert-dollar) (define-key YaTeX-mode-map "|" 'YaTeX-insert-bar) (define-key YaTeX-mode-map "&" 'YaTeX-insert-amper) (define-key YaTeX-mode-map "[" 'YaTeX-insert-brackets) (define-key YaTeX-mode-map YaTeX-prefix YaTeX-prefix-map) (define-key YaTeX-mode-map "\M-\C-@" 'YaTeX-mark-environment) (define-key YaTeX-mode-map "\M-\C-a" 'YaTeX-beginning-of-environment) (define-key YaTeX-mode-map "\M-\C-e" 'YaTeX-end-of-environment) (define-key YaTeX-mode-map "\M-\C-m" 'YaTeX-intelligent-newline) (define-key YaTeX-mode-map "\C-i" 'YaTeX-indent-line) (YaTeX-define-key "%" 'YaTeX-%-menu) (YaTeX-define-key "t" 'YaTeX-typeset-menu) (YaTeX-define-key "w" 'YaTeX-switch-mode-menu) (YaTeX-define-key "'" 'YaTeX-prev-error) (YaTeX-define-key "^" 'YaTeX-visit-main) (YaTeX-define-key "4^" 'YaTeX-visit-main-other-window) (YaTeX-define-key "4g" 'YaTeX-goto-corresponding-*-other-window) (YaTeX-define-key "44" 'YaTeX-switch-to-window) (and YaTeX-emacs-19 window-system (progn (YaTeX-define-key "5^" 'YaTeX-visit-main-other-frame) (YaTeX-define-key "5g" 'YaTeX-goto-corresponding-*-other-frame) (YaTeX-define-key "55" 'YaTeX-switch-to-window))) (YaTeX-define-key " " 'YaTeX-do-completion) (YaTeX-define-key "v" 'YaTeX-version) (YaTeX-define-key "}" 'YaTeX-insert-braces-region) (YaTeX-define-key "]" 'YaTeX-insert-brackets-region) (YaTeX-define-key ")" 'YaTeX-insert-parens-region) (YaTeX-define-key "$" 'YaTeX-insert-dollars-region) (YaTeX-define-key "i" 'YaTeX-fill-item) (YaTeX-define-key "\\" '(lambda () (interactive) (insert (if (YaTeX-in-math-mode-p) "\\backslash" "\\textbackslash")))) (if YaTeX-no-begend-shortcut (progn (YaTeX-define-key "B" 'YaTeX-make-begin-end-region) (YaTeX-define-key "b" 'YaTeX-make-begin-end)) (YaTeX-define-begend-key "bc" "center") (YaTeX-define-begend-key "bd" "document") (YaTeX-define-begend-key "bD" "description") (YaTeX-define-begend-key "be" "enumerate") (YaTeX-define-begend-key "bE" "equation") (YaTeX-define-begend-key "bi" "itemize") (YaTeX-define-begend-key "bl" "flushleft") (YaTeX-define-begend-key "bm" "minipage") (YaTeX-define-begend-key "bt" "tabbing") (YaTeX-define-begend-key "bT" "tabular") (YaTeX-define-begend-key "b\^t" "table") (YaTeX-define-begend-key "bp" "picture") (YaTeX-define-begend-key "bq" "quote") (YaTeX-define-begend-key "bQ" "quotation") (YaTeX-define-begend-key "br" "flushright") (YaTeX-define-begend-key "bv" "verbatim") (YaTeX-define-begend-key "bV" "verse") (YaTeX-define-key "B " 'YaTeX-make-begin-end-region) (YaTeX-define-key "b " 'YaTeX-make-begin-end)) (YaTeX-define-key "e" 'YaTeX-end-environment) (YaTeX-define-key "S" 'YaTeX-make-section-region) (YaTeX-define-key "s" 'YaTeX-make-section) (YaTeX-define-key "L" 'YaTeX-make-fontsize-region) (YaTeX-define-key "l" 'YaTeX-make-fontsize) (YaTeX-define-key "m" 'YaTeX-make-singlecmd) (YaTeX-define-key "." 'YaTeX-comment-paragraph) (YaTeX-define-key "," 'YaTeX-uncomment-paragraph) (YaTeX-define-key ">" 'YaTeX-comment-region) (YaTeX-define-key "<" 'YaTeX-uncomment-region) (YaTeX-define-key "g" 'YaTeX-goto-corresponding-*) (YaTeX-define-key "k" 'YaTeX-kill-*) (YaTeX-define-key "c" 'YaTeX-change-*) (YaTeX-define-key "a" 'YaTeX-make-accent) (YaTeX-define-key "?" 'YaTeX-help) (YaTeX-define-key "/" 'YaTeX-apropos) (YaTeX-define-key "&" 'YaTeX-what-column) (YaTeX-define-key "d" 'YaTeX-display-hierarchy) (YaTeX-define-key "x" YaTeX-user-extensional-map) (YaTeX-define-key "n" '(lambda () (interactive) (insert "\\" (if (YaTeX-on-section-command-p "o?oalign") "crcr" "\\")))) (if YaTeX-dos (define-key YaTeX-prefix-map "\C-r" '(lambda () (interactive) (YaTeX-set-screen-height YaTeX-saved-screen-height) (recenter))))) (defvar YaTeX-section-completion-map nil "*Key map used at YaTeX completion in the minibuffer.") (if YaTeX-section-completion-map nil (setq YaTeX-section-completion-map (copy-keymap (or (and (boundp 'gmhist-completion-map) gmhist-completion-map) minibuffer-local-completion-map))) (define-key YaTeX-section-completion-map " " 'YaTeX-minibuffer-complete) (define-key YaTeX-section-completion-map "\C-i" 'YaTeX-minibuffer-complete) (define-key YaTeX-section-completion-map "\C-v" 'YaTeX-read-section-with-overview)) (defvar YaTeX-recursive-map nil "*Key map used at YaTeX reading arguments in the minibuffer.") (if YaTeX-recursive-map nil (setq YaTeX-recursive-map (copy-keymap global-map)) (define-key YaTeX-recursive-map YaTeX-prefix YaTeX-prefix-map) (mapcar (function (lambda (key) (define-key YaTeX-mode-map (car key) 'YaTeX-math-insert-sequence) (define-key YaTeX-recursive-map (car key) 'YaTeX-math-insert-sequence))) YaTeX-math-key-list)) ;---------- Define other variable ---------- (defvar YaTeX-env-name "document" "*Initial tex-environment completion") (defvar YaTeX-section-name (if YaTeX-use-LaTeX2e "documentclass" "documentstyle") "*Initial tex-section completion") (defvar YaTeX-fontsize-name "large" "*Initial fontsize completion") (defvar YaTeX-single-command "maketitle" "*Initial LaTeX single command") (defvar YaTeX-kanji-code (if YaTeX-dos 1 2) "*File kanji code used by Japanese TeX. nil: Do not care (Preserve coding-system) 0: no-converion (mule) 1: Shift JIS 2: JIS 3: EUC 4: UTF-8") (defvar YaTeX-coding-system nil "File coding system used by Japanese TeX.") (cond (YaTeX-emacs-20 (setq YaTeX-coding-system (cdr (assoc YaTeX-kanji-code YaTeX-kanji-code-alist)))) ((boundp 'MULE) (setq YaTeX-coding-system (symbol-value (cdr (assoc YaTeX-kanji-code YaTeX-kanji-code-alist)))))) (defvar YaTeX-mode-syntax-table nil "*Syntax table for yatex-mode") (if YaTeX-mode-syntax-table nil (setq YaTeX-mode-syntax-table (make-syntax-table (standard-syntax-table))) (modify-syntax-entry ?\n " " YaTeX-mode-syntax-table) (modify-syntax-entry ?\{ "(}" YaTeX-mode-syntax-table) (modify-syntax-entry ?\} "){" YaTeX-mode-syntax-table) (modify-syntax-entry ?\t " " YaTeX-mode-syntax-table) (modify-syntax-entry ?\f ">" YaTeX-mode-syntax-table) (modify-syntax-entry ?\n ">" YaTeX-mode-syntax-table) (modify-syntax-entry ?$ "$$" YaTeX-mode-syntax-table) (modify-syntax-entry ?% "<" YaTeX-mode-syntax-table) (modify-syntax-entry ?\\ "/" YaTeX-mode-syntax-table) (modify-syntax-entry ?~ " " YaTeX-mode-syntax-table)) ;---------- Provide YaTeX-mode ---------- ;;; ;; Major mode definition ;;; (defun yatex-mode () " Yet Another LaTeX mode: Major mode for editing input files of LaTeX. -You can invoke processes concerning LaTeX typesetting by \\[YaTeX-typeset-menu] -Complete LaTeX environment form of `\\begin{env} ... \\end{env}' by \\[YaTeX-make-begin-end] -Enclose region into some environment by \\[universal-argument] \\[YaTeX-make-begin-end] -Complete LaTeX command which takes argument like `\\section{}' by \\[YaTeX-make-section] -Put LaTeX command which takes no arguments like `\\maketitle' by \\[YaTeX-make-singlecmd] -Complete font or character size descriptor like `{\\large }' by \\[YaTeX-make-fontsize] -Enclose region into those descriptors above by \\[universal-argument] \\[YaTeX-make-fontsize] -Enter European accent notations by \\[YaTeX-make-accent] -Toggle various modes of YaTeX by \\[YaTeX-switch-mode-menu] -Change environt name (on the begin/end line) by \\[YaTeX-change-*] -Kill LaTeX command/environment sequences by \\[YaTeX-kill-*] -Kill LaTeX command/environment with its contents \\[universal-argument] \\[YaTeX-kill-*] -Go to corresponding object (begin/end, file, labels) by \\[YaTeX-goto-corresponding-*] or \\[YaTeX-goto-corresponding-*-other-window] (in other window) \\[YaTeX-goto-corresponding-*-other-frame] (in other frame) -Go to main LaTeX source text by \\[YaTeX-visit-main] or \\[YaTeX-visit-main-other-window] (in other window) \\[YaTeX-visit-main-other-frame] (in other frame) -Comment out or uncomment region by \\[YaTeX-comment-region] or \\[YaTeX-uncomment-region] -Comment out or uncomment paragraph by \\[YaTeX-comment-paragraph] or \\[YaTeX-uncomment-paragraph] -Make an \\item entry hang-indented by \\[YaTeX-fill-item] -Enclose the region with parentheses by \\[YaTeX-insert-parens-region] \\[YaTeX-insert-braces-region] \\[YaTeX-insert-brackets-region] \\[YaTeX-insert-dollars-region] -Look up the corresponding column header of tabular environment by \\[YaTeX-what-column] -Enter a newline and an entry suitable for environment by \\[YaTeX-intelligent-newline] -View the structure of file inclusion by \\[YaTeX-display-hierarchy] -Refer the online help of popular LaTeX commands by \\[YaTeX-help] (help) \\[YaTeX-apropos] (apropos) -Edit `%# notation' by \\[YaTeX-%-menu] Those are enough for fastening your editing of LaTeX source. But further more features are available and they are documented in the manual. " (interactive) (kill-all-local-variables) (setq major-mode 'yatex-mode) (setq mode-name (if YaTeX-japan "やてふ" "YaTeX")) (mapcar 'make-local-variable '(dvi2-command fill-column fill-prefix tmp-env-table tmp-section-table tmp-fontsize-table tmp-singlecmd-table paragraph-start paragraph-separate YaTeX-math-mode indent-line-function comment-line-break-function comment-start comment-start-skip )) (cond ((null YaTeX-kanji-code) nil) ((boundp 'MULE) (set-file-coding-system YaTeX-coding-system)) ((and YaTeX-emacs-20 (boundp 'buffer-file-coding-system)) (setq buffer-file-coding-system (or (and (fboundp 'set-auto-coding) buffer-file-name (save-excursion (goto-char (point-min)) (set-auto-coding buffer-file-name (buffer-size)))) YaTeX-coding-system))) ((featurep 'mule) (set-file-coding-system YaTeX-coding-system)) ((boundp 'NEMACS) (make-local-variable 'kanji-fileio-code) (setq kanji-fileio-code YaTeX-kanji-code))) (setq fill-column YaTeX-fill-column fill-prefix YaTeX-fill-prefix paragraph-start YaTeX-paragraph-start paragraph-separate YaTeX-paragraph-separate indent-line-function 'YaTeX-indent-line comment-start YaTeX-comment-prefix comment-end "" comment-start-skip "[^\\\\]%+[ \t]*" local-abbrev-table yatex-mode-abbrev-table) (if (fboundp 'comment-indent-new-line) ;for Emacs21 (setq comment-line-break-function 'YaTeX-comment-line-break)) (if (and YaTeX-use-font-lock (featurep 'font-lock)) (progn (require 'yatex19) (YaTeX-font-lock-set-default-keywords) (or (featurep 'xemacs) (set (make-local-variable 'font-lock-defaults) (get 'yatex-mode 'font-lock-defaults))) ;;(font-lock-mode 1) )) (use-local-map YaTeX-mode-map) (set-syntax-table YaTeX-mode-syntax-table) (if YaTeX-dos (setq YaTeX-saved-screen-height (YaTeX-screen-height))) (YaTeX-read-user-completion-table) (and (fboundp 'YaTeX-hilit-setup-alist) (YaTeX-hilit-setup-alist)) (makunbound 'inenv) (turn-on-auto-fill) ;1.63 (and (= 0 (buffer-size)) (file-exists-p YaTeX-template-file) (y-or-n-p (format "Insert %s?" YaTeX-template-file)) (insert-file-contents (expand-file-name YaTeX-template-file))) (run-hooks 'text-mode-hook 'yatex-mode-hook)) ;---------- Define YaTeX-mode functions ---------- (defvar YaTeX-ec "\\" "Escape character of current mark-up language.") (defvar YaTeX-ec-regexp (regexp-quote YaTeX-ec)) (defvar YaTeX-struct-begin (concat YaTeX-ec "begin{%1}%2") "Keyword format of begin-environment.") (defvar YaTeX-struct-end (concat YaTeX-ec "end{%1}") "Keyword format of end-environment.") (defvar YaTeX-struct-name-regexp "[^}]*" "Environment name regexp.") (defvar YaTeX-TeX-token-regexp (cond (YaTeX-japan "[A-Za-z*ぁ-ん亜-龠]+") (t "[A-Za-z*]+")) "Regexp of characters which can be a member of TeX command's name.") (defvar YaTeX-kanji-regexp "[ぁ-ん亜-龠]" "Generic regexp of Japanese Kanji (and symbol) characters.") (defvar YaTeX-command-token-regexp YaTeX-TeX-token-regexp "Regexp of characters which can be a member of current mark up language's command name.") ;;(defvar YaTeX-struct-section ;; (concat YaTeX-ec "%1{%2}") ;; "Keyword to make section.") ;;; ;; autoload section ;;; ;;autoload from yatexprc.el (autoload 'YaTeX-visit-main "yatexprc" "Visit main LaTeX file." t) (autoload 'YaTeX-visit-main-other-window "yatexprc" "Visit main other window." t) (autoload 'YaTeX-main-file-p "yatexprc" "Check if the file is main." t) (autoload 'YaTeX-get-builtin "yatexprc" "Get %# built-in." t) (autoload 'YaTeX-system "yatexprc" "Call system command" t) (autoload 'YaTeX-save-buffers "yatexprc" "Save buffers of same major mode" t) ;;autoload from yatexmth.el (autoload 'YaTeX-math-insert-sequence "yatexmth" "Image input." t) (autoload 'YaTeX-in-math-mode-p "yatexmth" "Check if in math-env." t) (autoload 'YaTeX-toggle-math-mode "yatexmth" "YaTeX math-mode interfaces." t) (autoload 'YaTeX-math-member-p "yatexmth" "Check if a word is math command." t) (autoload 'YaTeX-insert-amsparens-region "yatexmth" "AMS parens region" t) (autoload 'YaTeX-insert-amsbraces-region "yatexmth" "AMS braces region" t) (autoload 'YaTeX-insert-amsbrackets-region "yatexmth" "AMS brackets region" t) (autoload 'YaTeX-on-parenthesis-p "yatexmth" "Check if on math-parens" t) (autoload 'YaTeX-goto-open-paren "yatexmth" "Goto opening paren" t) (autoload 'YaTeX-change-parentheses "yatexmth" "Change corresponding parens" t) (autoload 'YaTeX-goto-corresponding-paren "yatexmth" "\bigl\bigr jumps" t) (autoload 'YaTeX-typeset-math-region "yatexmth" "Typeset math-region" t) ;;autoload from yatexhlp.el (autoload 'YaTeX-help "yatexhlp" "YaTeX helper with LaTeX commands." t) (autoload 'YaTeX-apropos "yatexhlp" "Apropos for (La)TeX commands." t) ;;autoload from yatexgen.el (autoload 'YaTeX-generate "yatexgen" "YaTeX add-in function generator." t) (autoload 'YaTeX-generate-simple "yatexgen" "YaTeX add-in support." t) ;;autoload from yatexsec.el (autoload 'YaTeX-section-overview "yatexsec" "YaTeX sectioning(view)" t) (autoload 'YaTeX-read-section-in-minibuffer "yatexsec" "YaTeX sectioning" t) (autoload 'YaTeX-make-section-with-overview "yatexsec" "YaTeX sectioning" t) ;;autoload from yatexenv.el (autoload 'YaTeX-what-column "yatexenv" "YaTeX env. specific funcs" t) (autoload 'YaTeX-intelligent-newline "yatexenv" "YaTeX env. specific funcs" t) (autoload 'YaTeX-indent-line-equation "yatexenv" "Indent equation lines." t) (autoload 'YaTeX-goto-corresponding-leftright "yatexenv" "\left\right jumps" t) ;;autoload from yatexhie.el (autoload 'YaTeX-display-hierarchy "yatexhie" "YaTeX document hierarchy browser" t) (autoload 'YaTeX-display-hierarchy-directly "yatexhie" "Same as YaTeX-display-hierarchy. Call from mouse." t) ;;autoload from yatexpkg.el (autoload 'YaTeX-package-auto-usepackage "yatexpkg" "Auto \\usepackage" t) ;;; ;; YaTeX-mode functions ;;; (defun YaTeX-insert-begin-end (env region-mode) "Insert \\begin{mode-name} and \\end{mode-name}. This works also for other defined begin/end tokens to define the structure." (setq YaTeX-current-completion-type 'begin) (let*((ccol (current-column)) beg beg2 exchange (arg region-mode) ;for old compatibility (indent-column (+ ccol YaTeX-environment-indent))(i 1) func) (if (and region-mode (> (point) (mark))) (progn (exchange-point-and-mark) (setq exchange t ccol (current-column) indent-column (+ ccol YaTeX-environment-indent)))) ;;VER2 (insert "\\begin{" env "}" (YaTeX-addin env)) (setq beg (point)) (YaTeX-insert-struc 'begin env) (setq beg2 (point)) (insert "\n") (indent-to indent-column) (save-excursion ;;indent optional argument of \begin{env}, if any (while (> (point-beginning-of-line) beg) (skip-chars-forward "\\s " (point-end-of-line)) (indent-to indent-column) (forward-line -1))) (require 'yatexenv) (if region-mode ;;if region-mode, indent all text in the region (save-excursion (if (fboundp (intern-soft (concat "YaTeX-enclose-" env))) (funcall (intern-soft (concat "YaTeX-enclose-" env)) (point) (mark)) (while (< (progn (forward-line 1) (point)) (mark)) (if (eolp) nil (skip-chars-forward " \t\n") (indent-to indent-column)))))) (if region-mode (exchange-point-and-mark)) (indent-to ccol) ;;VER2 (insert "\\end{" env "}\n") (YaTeX-insert-struc 'end env) (YaTeX-reindent ccol) (if region-mode (progn (insert "\n") (or exchange (exchange-point-and-mark))) (goto-char beg2) (YaTeX-intelligent-newline nil) (if (fboundp (intern-soft (concat "YaTeX-intelligent-newline-" env))) (progn (message (cond (YaTeX-japan "%s で次の行の入力に進みます。") (t "`%s' produces the next line's template.")) (key-description (car (where-is-internal 'YaTeX-intelligent-newline)))))) (YaTeX-indent-line)) (YaTeX-package-auto-usepackage env 'env) (if YaTeX-current-position-register (point-to-register YaTeX-current-position-register)))) (defun YaTeX-make-begin-end (arg) "Make LaTeX environment command of \\begin{env.} ... \\end{env.} by completing read. If you invoke this command with universal argument, \(key binding for universal-argument is \\[universal-argument]\) you can put REGION into that environment between \\begin and \\end." (interactive "P") (let* ((mode (if arg " region" "")) (env (YaTeX-read-environment (format "Begin environment%s(default %s): " mode YaTeX-env-name)))) (if (string= env "") (setq env YaTeX-env-name)) (setq YaTeX-env-name env) (YaTeX-update-table (list YaTeX-env-name) 'env-table 'user-env-table 'tmp-env-table) (YaTeX-insert-begin-end YaTeX-env-name arg))) (defun YaTeX-make-begin-end-region () "Call YaTeX-make-begin-end with ARG to specify region mode." (interactive) (YaTeX-make-begin-end t)) (defun YaTeX-guess-section-type () (if (eq major-mode 'yatex-mode) (save-excursion (cond ((save-excursion (not (search-backward YaTeX-ec nil t))) (if YaTeX-use-LaTeX2e "documentclass" "documentstyle")) ((progn (if (= (char-after (1- (point))) ?~) (forward-char -1)) (forward-char -1) (looking-at "表\\|図\\|式\\|第")) "ref") ((and (looking-at "[a-z \t]") (progn (skip-chars-backward "a-z \t") (looking-at "table\\|figure\\|formula"))) "ref") ((save-excursion (skip-chars-backward "[^ア-ン]") (looking-at "プログラム\\|リスト")) "ref") ((YaTeX-re-search-active-backward (concat YaTeX-ec-regexp "begin{\\([^}]+\\)}") (regexp-quote YaTeX-comment-prefix) (save-excursion (forward-line -1) (point)) t) (let ((env (YaTeX-match-string 1))) (cdr (assoc env '(("table" . "caption")))))) )))) (defun YaTeX-make-section (arg &optional beg end cmd) "Make LaTeX \\section{} type command with completing read. With numeric ARG, you can specify the number of arguments of LaTeX command. For example, if you want to produce LaTeX command \\addtolength{\\topmargin}{8mm} which has two arguments. You can produce that sequence by typing... ESC 2 C-c s add SPC RET \\topm SPC RET 8mm RET \(by default\) Then yatex will automatically complete `addtolength' with two arguments next time. You can complete symbol at LaTeX command and the 1st argument. If the optional 2nd and 3rd argument BEG END are specified, enclose the region from BEG to END into the first argument of the LaTeX sequence. Optional 4th arg CMD is LaTeX command name, for non-interactive use." (interactive "P") (setq YaTeX-current-completion-type 'section) (if (equal arg '(4)) (setq beg (region-beginning) end (region-end))) (unwind-protect (let* ((source-window (selected-window)) guess (section (or cmd (progn (setq guess (or (YaTeX-guess-section-type) YaTeX-section-name)) (YaTeX-read-section (if YaTeX-simple-messages (format "Section-type (default %s): " guess) (if (> (minibuffer-depth) 0) (format "%s???{} (default %s)%s: " YaTeX-ec guess (format "[level:%d]" (minibuffer-depth))) (format "(C-v for view-section) %s???{%s} (default %s): " YaTeX-ec (if beg "region" "") guess))) nil)))) (section (if (string= section "") guess section)) (numarg ;; The number of section-type command's argument (or (and (numberp arg) arg) (nth 1 (YaTeX-lookup-table section 'section)) 1)) (arg-reader (intern-soft (concat "YaTeX::" section))) (addin-args (and arg-reader (fboundp arg-reader))) (title "") (j 1) (after-change-functions nil) ;inhibit font-locking temporarily (enable-recursive-minibuffers t) (mkarg-func (function (lambda (n) (while (<= j n) (unwind-protect (setq title (cond (addin-args (funcall arg-reader j)) (YaTeX-skip-default-reader "") (t (read-string (format "Argument %d of %s: " j section))))) (insert (concat ;to allow nil return value "{" title "}"))) (setq j (1+ j)))))) );;let (setq YaTeX-section-name section) (if beg (let*((e (make-marker)) (ar2 (intern-soft (concat "YaTeX::" section "-region"))) (arp (and ar2 (fboundp ar2)))) (goto-char end) (insert "}") (set-marker e (point)) (goto-char beg) (unwind-protect (progn (insert YaTeX-ec YaTeX-section-name (YaTeX-addin YaTeX-section-name)) (if (> numarg 1) (funcall mkarg-func (1- numarg)))) (insert "{")) (if arp (funcall ar2 (point) e)) (goto-char e) (set-marker e nil)) (use-global-map YaTeX-recursive-map) (if (= numarg 0) (YaTeX-make-singlecmd YaTeX-section-name) (progn (insert YaTeX-ec YaTeX-section-name) (insert (YaTeX-addin YaTeX-section-name)))) ;;read arguments with add-in (funcall mkarg-func numarg)) (YaTeX-update-table (if (/= numarg 1) (list section numarg) (list section)) 'section-table 'user-section-table 'tmp-section-table) (if YaTeX-current-position-register (point-to-register YaTeX-current-position-register)) (if (string= (YaTeX-buffer-substring (- (point) 2) (point)) "{}") (forward-char -1)) (while (string= (YaTeX-buffer-substring (- (point) 3) (1- (point))) "{}") (forward-char -2)) (YaTeX-package-auto-usepackage section 'section)) (if (<= (minibuffer-depth) 0) (use-global-map global-map)) (insert ""))) ;insert dummy string to fontify(Emacs20) (defun YaTeX-make-section-region (args beg end) "Call YaTeX-make-section with arguments to specify region mode." (interactive "P\nr") (YaTeX-make-section args beg end)) (defun YaTeX-make-fontsize (arg &optional fontsize) "Make completion like {\\large ...} or {\\slant ...} in minibuffer. If you invoke this command with universal argument, you can put region into {\\xxx } braces. \(key binding for universal-argument is \\[universal-argument]\)" (interactive "P") (YaTeX-sync-local-table 'tmp-fontsize-table) (let* ((mode (if arg "region" "")) (fontsize (or fontsize (YaTeX-read-fontsize (if YaTeX-simple-messages (format "Font or size (default %s): " YaTeX-fontsize-name) (format "{\\??? %s} (default %s)%s: " mode YaTeX-fontsize-name (if (> (minibuffer-depth) 0) (format "[level:%d]" (minibuffer-depth)) ""))) nil nil)))) (if (string= fontsize "") (setq fontsize YaTeX-fontsize-name)) (setq YaTeX-current-completion-type 'large) (setq YaTeX-fontsize-name fontsize) (YaTeX-update-table (list YaTeX-fontsize-name) 'fontsize-table 'user-fontsize-table 'tmp-fontsize-table) (and YaTeX-use-LaTeX2e (YaTeX-latex2e-p) (setq fontsize (cdr (assoc YaTeX-fontsize-name LaTeX2e-fontstyle-alist))) (setq YaTeX-fontsize-name fontsize)) (if arg (save-excursion (if (> (point) (mark)) (exchange-point-and-mark)) (insert "{\\" YaTeX-fontsize-name " ") (exchange-point-and-mark) (insert "}")) (insert (concat "{\\" YaTeX-fontsize-name " }")) (forward-char -1) (if YaTeX-current-position-register (point-to-register YaTeX-current-position-register)) (save-excursion (insert (YaTeX-addin YaTeX-fontsize-name))) (YaTeX-package-auto-usepackage YaTeX-fontsize-name 'large)))) (defun YaTeX-make-fontsize-region () "Call function:YaTeX-make-fontsize with ARG to specify region mode." (interactive) (YaTeX-make-fontsize t)) (defvar YaTeX-singlecmd-suffix "" "*Suffix for maketitle-type commands.") (defvar YaTeX-read-singlecmd-history nil "Holds maketitle-type history.") (put 'YaTeX-read-singlecmd-history 'no-default t) (defun YaTeX-make-singlecmd (single) (interactive (list (YaTeX-cplread-with-learning (if YaTeX-simple-messages (format "maketitle-type (default %s): " YaTeX-single-command) (format "%s??? (default %s)%s: " YaTeX-ec YaTeX-single-command (if (> (minibuffer-depth) 0) (format "[level:%d]" (minibuffer-depth)) ""))) 'singlecmd-table 'user-singlecmd-table 'tmp-singlecmd-table nil nil nil 'YaTeX-read-singlecmd-history))) (if (string= single "") (setq single YaTeX-single-command)) (setq YaTeX-single-command single) (setq YaTeX-current-completion-type 'maketitle) (let ((dollar (and (not (YaTeX-in-math-mode-p)) (YaTeX-math-member-p YaTeX-single-command))) p q) (if dollar (insert "$")) (insert YaTeX-ec YaTeX-single-command) (setq p (point)) (insert (YaTeX-addin single) YaTeX-singlecmd-suffix) (if dollar (insert "$")) (setq q (point)) (goto-char p) (forward-char -2) (if (looking-at "\\[\\]") (forward-char 1) (goto-char q))) (YaTeX-package-auto-usepackage YaTeX-single-command 'maketitle) (if YaTeX-current-position-register (point-to-register YaTeX-current-position-register))) (defvar YaTeX-completion-begin-regexp "[{\\]" "Regular expression of limit where LaTeX command's completion begins.") (defun YaTeX-do-completion () "Try completion on LaTeX command preceding point." (interactive) (if (or (eq (preceding-char) ? ) (eq (preceding-char) ?\t) (eq (preceding-char) ?\n) (bobp)) (message "Nothing to complete.") ;Do not complete (let* ((end (point)) (limit (point-beginning-of-line)) (completion-begin (progn (re-search-backward "[ \t\n]" limit 1) (point))) (begin (progn (goto-char end) (if (re-search-backward YaTeX-completion-begin-regexp completion-begin t) (1+ (point)) nil)))) (goto-char end) (cond ((null begin) (message "I think it is not a LaTeX sequence.")) (t (mapcar 'YaTeX-sync-local-table '(tmp-section-table tmp-env-table tmp-singlecmd-table)) (let*((pattern (YaTeX-buffer-substring begin end)) (all-table (append section-table user-section-table tmp-section-table env-table user-env-table tmp-env-table singlecmd-table user-singlecmd-table tmp-singlecmd-table)) ;; First, ;; search completion without backslash. (completion (try-completion pattern all-table))) (if (eq completion nil) ;; Next, ;; search completion with backslash (setq completion (try-completion (YaTeX-buffer-substring (1- begin) end) all-table nil) begin (1- begin))) (cond ((null completion) (message (concat "Can't find completion for '" pattern "'")) (ding)) ((eq completion t) (message "Sole completion.")) ((not (string= completion pattern)) (delete-region begin end) (insert completion) ) (t (message "Making completion list...") (with-output-to-temp-buffer "*Help*" (display-completion-list (all-completions pattern all-table))))))))))) (defun YaTeX-toggle-modify-mode (&optional arg) (interactive "P") (or (memq 'YaTeX-modify-mode mode-line-format) (setq mode-line-format (append (list "" 'YaTeX-modify-mode) mode-line-format))) (if (or arg (null YaTeX-modify-mode)) (progn (setq YaTeX-modify-mode "*m*") (message "Modify mode")) (setq YaTeX-modify-mode nil) (message "Cancel modify mode.")) (set-buffer-modified-p (buffer-modified-p))) ;redraw mode-line (defun YaTeX-switch-mode-menu (arg &optional char) (interactive "P") (message "Toggle: (M)odify-mode ma(T)h-mode") (let ((c (or char (read-char)))) (cond ((= c ?m) (YaTeX-toggle-modify-mode arg)) ((or (= c ?$) (= c ?t)) (if YaTeX-auto-math-mode (message "Makes no sense in YaTeX-auto-math-mode.") (YaTeX-toggle-math-mode arg)))))) (defun YaTeX-insert-quote () (interactive) (insert (cond ((YaTeX-literal-p) ?\") ((= (preceding-char) ?\\ ) ?\") ;((= (preceding-char) ?\( ) ?\") ((or (= (preceding-char) 32) (= (preceding-char) 9) (= (preceding-char) ?\n) (bobp) (string-match (regexp-quote (char-to-string (preceding-char))) "、。,.?!「」『』【】()")) "``") (t "''")))) (defun YaTeX-closable-p () (and (not YaTeX-modify-mode) (not (eq YaTeX-close-paren-always 'never)) (or YaTeX-close-paren-always (eolp)) (not (input-pending-p)) (not (YaTeX-literal-p))) ;;(or YaTeX-modify-mode ;; (and (not YaTeX-close-paren-always) (not (eolp))) ;; (input-pending-p) ;; (YaTeX-quick-in-environment-p "verbatim")) ) (defun YaTeX-insert-braces-region (beg end &optional open close) (interactive "r") (save-excursion (goto-char end) (YaTeX-insert-inherit (or close "}")) (goto-char beg) (YaTeX-insert-inherit (or open "{")))) (defun YaTeX-get-macro-at-point (&optional p) "Get (La)TeX macro around point P." (interactive "d") (save-excursion (goto-char (setq p (or p (point)))) (let ((token (substring (substring YaTeX-TeX-token-regexp 1) 0 -2)) bsend) (and (not (bobp)) (or (looking-at YaTeX-TeX-token-regexp) (string-match YaTeX-TeX-token-regexp (char-to-string (preceding-char)))) (progn (skip-chars-backward token) (equal (preceding-char) ?\\)) (save-excursion (setq bsend (point)) (skip-chars-backward "\\\\") ;emacs18 doesn't return distance (/= (% (- bsend (point)) 2) 0)) ;consider \\ (looking-at YaTeX-TeX-token-regexp) (YaTeX-match-string 0))))) (defun YaTeX-insert-braces (arg &optional open close) (interactive "p") (let ((begend-guide (function (lambda () (if (equal (get 'YaTeX-insert-braces 'begend-guide) 2) nil ;if triggered thrice, do nothing (momentary-string-display (format (cond (YaTeX-japan "begin/end入力には %s を使いましょう") (t "You don't understand Zen of `%s'!")) (key-description (car (where-is-internal 'YaTeX-make-begin-end)))) (point)) (put 'YaTeX-insert-braces 'begend-guide (+ 1 (string-to-int ;increment counter of beg-end guidance (prin1-to-string (get 'YaTeX-insert-braces 'begend-guide))))))))) env macro not-literal b e) (cond ((YaTeX-jmode) (YaTeX-self-insert arg)) ((not (YaTeX-closable-p)) (YaTeX-self-insert arg)) ((save-excursion (and (> (- (point) (point-min)) 6) (condition-case () (forward-char -6) (error nil))) (looking-at "\\\\left\\\\")) (insert "{\\right\\}") (forward-char -8)) ((save-excursion ;from matsumath.s.chiba-u.ac.jp (and (> (- (point) (point-min)) 6) (forward-char -6)) (looking-at "\\\\[bB]igl\\\\")) (insert (concat "{" (buffer-substring (match-beginning 0) (- (match-end 0) 2)) "r\\}")) (forward-char -7)) ((save-excursion (and (> (- (point) (point-min)) 7) (condition-case () (forward-char -7) (error nil))) (looking-at "\\\\[bB]iggl\\\\")) (insert (concat "{" (buffer-substring (match-beginning 0) (- (match-end 0) 2)) "r\\}")) (forward-char -8)) ((= (preceding-char) ?\\ ) (insert "{\\}") (forward-char -2)) ;matsu's hack ends here ((and (setq not-literal (not (YaTeX-literal-p))) (equal "end" (setq macro (YaTeX-get-macro-at-point))) (setq env (YaTeX-inner-environment))) (funcall begend-guide) (insert "{" env "}")) ((and not-literal (equal "begin" macro)) (insert "{") (save-excursion (indent-to (prog1 (- (current-column) 7) (insert "}\n"))) (insert "\\end{}") (setq e (point))) (setq env (YaTeX-read-environment (format "Begin environment(default %s): " YaTeX-env-name))) (if (string= "" env) (setq env YaTeX-env-name)) (setq YaTeX-env-name env) (funcall begend-guide) (delete-region (- (point) 7) e) (YaTeX-insert-begin-end env nil)) (t (insert (or open "{") (or close "}")) (forward-char -1) (if (and (eq (char-after (point)) ?\}) ;; the case `\\{}' (eq (char-after (- (point) 2)) ?\\ )) (progn (insert "\\") (forward-char -1))) )))) (defun YaTeX-jmode () (or (and (boundp 'canna:*japanese-mode*) canna:*japanese-mode*) (and (boundp 'egg:*mode-on*) egg:*mode-on* egg:*input-mode*) (and (boundp 'skk-mode) skk-mode (not skk-latin-mode)) (and (boundp 'default-input-method) default-input-method current-input-method))) (defun YaTeX-jmode-off () (if (cond ((and (boundp 'canna:*japanese-mode*) canna:*japanese-mode*) (canna-toggle-japanese-mode) t) ((and (boundp 'egg:*mode-on*) egg:*mode-on* egg:*input-mode*) (egg:toggle-egg-mode-on-off) t) ((and (fboundp 'skk-mode) (boundp 'skk-mode) skk-mode) (cond ((fboundp 'skk-latin-mode) (or (and (boundp 'skk-henkan-mode) skk-henkan-mode) (and (boundp 'skk-henkan-on) (or skk-henkan-mode skk-henkan-active)) (and (boundp 'j-henkan-on) (or j-henkan-on j-henkan-active)) ;; Deactivate jmode if henkan-mode is not running. ;; Suggested by tt.tetsuo.tsukamoto. (progn (put 'YaTeX-jmode-on 'skkkata skk-katakana) (skk-latin-mode t)))) ((fboundp 'skk-mode-off) (skk-mode-off)) (t (j-mode-off))) t) ((and (fboundp 'toggle-input-method) current-input-method) (toggle-input-method) t) ((and (fboundp 'fep-force-off) (fep-force-off)))) (put 'YaTeX-jmode 'jmode t))) (defun YaTeX-jmode-on () (cond ((boundp 'canna:*japanese-mode*) (if (not canna:*japanese-mode*) (canna-toggle-japanese-mode))) ((boundp 'egg:*mode-on*) (and (not egg:*mode-on*) (not egg:*input-mode*) (egg:toggle-egg-mode-on-off))) ((and (fboundp 'skk-mode) (boundp 'skk-mode)) (if (get 'YaTeX-jmode-on 'skkkata) (skk-j-mode-on t) (skk-mode 1)) (put 'YaTeX-jmode-on 'skkkata nil)) ((fboundp 'toggle-input-method) (if (not current-input-method) (toggle-input-method))) ((and (fboundp 'fep-force-on) (fep-force-on))))) (defun YaTeX-jmode-back () (if (get 'YaTeX-jmode 'jmode) (YaTeX-jmode-on)) (setplist 'YaTeX-jmode nil)) (defun YaTeX-self-insert (arg) (call-interactively (global-key-binding (char-to-string (YaTeX-last-key))))) (defun YaTeX-insert-inherit (&rest args) (apply (if (fboundp 'insert-and-inherit) 'insert-and-inherit 'insert) args)) (defun YaTeX-insert-brackets (arg) "Insert Kagi-kakko or \\ [ \\] pair or simply \[." (interactive "p") (let ((col (1- (current-column)))) (cond ((YaTeX-jmode) (YaTeX-self-insert arg)) ((not (YaTeX-closable-p)) (YaTeX-self-insert arg)) ((save-excursion (and (> (- (point) (point-min)) 5) (forward-char -5)) (looking-at "\\\\left")) (YaTeX-insert-inherit "[\\right]") (forward-char -7)) ((save-excursion ;from matsumath.s.chiba-u.ac.jp (and (> (- (point) (point-min)) 5) (forward-char -5)) (looking-at "\\\\[bB]igl")) (YaTeX-insert-inherit (concat "[" (buffer-substring (match-beginning 0) (- (match-end 0) 1)) "r]")) (forward-char -6)) ((save-excursion (and (> (- (point) (point-min)) 6) (forward-char -6)) (looking-at "\\\\[bB]iggl")) (YaTeX-insert-inherit (concat "[" (buffer-substring (match-beginning 0) (- (match-end 0) 1)) "r]")) (forward-char -7)) ;matsu's hack ends here ((and (= (preceding-char) ?\\ ) (/= (char-after (- (point) 2)) ?\\ ) (not (YaTeX-in-math-mode-p))) (YaTeX-insert-inherit (YaTeX-last-key) "\n") (indent-to (max 0 col)) (YaTeX-insert-inherit "\\]") (beginning-of-line) (open-line 1) (delete-region (point) (progn (beginning-of-line) (point))) (indent-to (+ YaTeX-environment-indent (max 0 col))) (or YaTeX-auto-math-mode YaTeX-math-mode (YaTeX-toggle-math-mode 1))) ((YaTeX-closable-p) (YaTeX-insert-inherit "[]") (backward-char 1)) (t (YaTeX-self-insert arg))))) (defun YaTeX-insert-brackets-region (beg end) (interactive "r") (YaTeX-insert-braces-region beg end "[" "]")) (defun YaTeX-insert-parens (arg) "Insert parenthesis pair." (interactive "p") (cond ((YaTeX-jmode) (YaTeX-self-insert arg)) ((not (YaTeX-closable-p)) (YaTeX-self-insert arg)) ((save-excursion (and (> (- (point) (point-min)) 5) (forward-char -5)) (looking-at "\\\\left")) (YaTeX-insert-inherit "(\\right)") (forward-char -7)) ((save-excursion ;from matsumath.s.chiba-u.ac.jp (and (> (- (point) (point-min)) 5) (forward-char -5)) (looking-at "\\\\[bB]igl")) (YaTeX-insert-inherit (concat "(" (buffer-substring (match-beginning 0) (- (match-end 0) 1)) "r)")) (forward-char -6)) ((save-excursion (and (> (- (point) (point-min)) 6) (forward-char -6)) (looking-at "\\\\[bB]iggl")) (YaTeX-insert-inherit (concat "(" (buffer-substring (match-beginning 0) (- (match-end 0) 1)) "r)")) (forward-char -7)) ((= (preceding-char) ?\\ ) ;matsu's hack ends here (YaTeX-insert-inherit "(\\)") (backward-char 2)) ((YaTeX-closable-p) (YaTeX-insert-inherit "()") (backward-char 1)) (t (YaTeX-self-insert arg)))) (defun YaTeX-insert-parens-region (beg end) (interactive "r") (YaTeX-insert-braces-region beg end "(" ")")) (defun YaTeX-insert-bar (arg) "Insert bar pair." (interactive "p") (cond ((YaTeX-jmode) (YaTeX-self-insert arg)) ((not (YaTeX-closable-p)) (YaTeX-self-insert arg)) ((save-excursion (and (> (- (point) (point-min)) 5) (forward-char -5)) (looking-at "\\\\left")) (YaTeX-insert-inherit "|\\right|") (forward-char -7)) ((save-excursion ;from matsumath.s.chiba-u.ac.jp (and (> (- (point) (point-min)) 5) (forward-char -5)) (looking-at "\\\\[bB]igl")) (insert (concat "|" (buffer-substring (match-beginning 0) (- (match-end 0) 1)) "r|")) (forward-char -6)) ((save-excursion (and (> (- (point) (point-min)) 6) (forward-char -6)) (looking-at "\\\\[bB]iggl")) (insert (concat "|" (buffer-substring (match-beginning 0) (- (match-end 0) 1)) "r|")) (forward-char -7)) ((save-excursion ; added by Jin nifty.ne.jp> (and (> (- (point) (point-min)) 6) (forward-char -6)) (looking-at "\\\\left\\\\")) (YaTeX-insert-inherit "|\\right\\|") (forward-char -8)) ((save-excursion (and (> (- (point) (point-min)) 6) (forward-char -6)) (looking-at "\\\\[bB]igl\\\\")) (insert (concat "|" (buffer-substring (match-beginning 0) (- (match-end 0) 2)) "r\\|")) (forward-char -7)) ((save-excursion (and (> (- (point) (point-min)) 7) (forward-char -7)) (looking-at "\\\\[bB]iggl\\\\")) (insert (concat "|" (buffer-substring (match-beginning 0) (- (match-end 0) 2)) "r\\|")) (forward-char -8)) ; added by Jin up to here. ((= (preceding-char) ?\\ ) (YaTeX-insert-inherit "|\\|") (backward-char 2)) ; ((and (YaTeX-closable-p) ; (/= (preceding-char) ?|) ; (/= (following-char) ?|)) ; (YaTeX-insert-inherit "||") ; (backward-char 1)) (t (YaTeX-self-insert arg)))) (defvar YaTeX-use-jmode-hook (and (featurep 'canna) (boundp 'canna:*initialized*) canna:*initialized*) ;; (not (and (fboundp 'skk-mode) (boundp 'skk-mode))) "*Non-nil means activate automatic jmode switcher within/out math mode. Hopefully, change default to t in the next version of 1.75.") (defun YaTeX-jmode-hook (old new) "A hook controling jmode on/off." ;; This function is called via point-entered/leave hook, so that ;; codes in it is evaluated on such emacsen as having text-properties. (let ((inhibit-point-motion-hooks t) (oldp (plist-get (text-properties-at old) 'point-left)) (newp (plist-get (text-properties-at new) 'point-left)) (lnew (plist-get (text-properties-at new) 'last-new)) (mjmode (plist-get (text-properties-at new) 'mjmode)) (bmp (buffer-modified-p)) (jm (YaTeX-jmode)) b e) (unwind-protect (cond ((eq lnew new) nil) ;Do nothing if continuous entry ((and (not (eq newp 'YaTeX-jmode-hook)) (eq oldp 'YaTeX-jmode-hook) (plist-get (text-properties-at old) 'entered)) ;; leave (remove-text-properties (setq b (1+ (or (previous-single-property-change old 'point-left) (1- (point))))) (setq e (1- (or (next-single-property-change old 'point-left) (1+ (point))))) (list 'last-new nil 'entered nil)) (add-text-properties b e (list 'mjmode jm)) (if (boundp 'skk-katakana) (put 'YaTeX-jmode-on 'skkkata skk-katakana)) (if (plist-get (text-properties-at old) 'jmode) (YaTeX-jmode-on))) ((and (not (eq oldp 'YaTeX-jmode-hook)) (eq newp 'YaTeX-jmode-hook) (not (plist-get (text-properties-at new) 'entered))) ;; enter (add-text-properties (1+ (or (previous-single-property-change new 'point-left) (1- (point)))) (1- (or (next-single-property-change new 'point-left) (1+ (point)))) (list 'jmode jm 'last-new new 'entered t)) (if (boundp 'skk-katakana) ;care for skk katakana mode (put 'YaTeX-jmode-on 'skkkata skk-katakana)) (if mjmode (YaTeX-jmode-on) (YaTeX-jmode-off)))) ;;unwind job (set-buffer-modified-p bmp)))) (defun YaTeX-insert-dollar () (interactive) (if (or (not (YaTeX-closable-p)) (= (preceding-char) 92) (and (YaTeX-in-math-mode-p) (or (/= (preceding-char) ?$) (/= (following-char) ?$)))) (insert "$") (insert "$$") (forward-char -1) (and YaTeX-use-jmode-hook (fboundp 'add-text-properties) (add-text-properties (1- (point)) (1+ (point)) (list 'point-left 'YaTeX-jmode-hook 'point-entered 'YaTeX-jmode-hook 'front-sticky t 'rear-nonsticky t 'mjmode nil 'jmode (YaTeX-jmode)))) (YaTeX-jmode-off) (or YaTeX-auto-math-mode YaTeX-math-mode (YaTeX-toggle-math-mode 1)))) (defun YaTeX-insert-dollars-region (beg end) (interactive "r") (YaTeX-insert-braces-region beg end "$" "$")) (defun YaTeX-insert-amper () (interactive) (if (or (string-match YaTeX-array-env-regexp (or (YaTeX-inner-environment t) "document")) (= (preceding-char) 92) (YaTeX-literal-p) (YaTeX-in-math-mode-p)) (insert "&") (insert "\\&"))) (defun YaTeX-version () "Return string of the version of running YaTeX." (interactive) (message (concat "Yet Another tex-mode " (if YaTeX-japan "「野鳥」" "`Wild Bird'") " Revision " YaTeX-revision-number))) (defun YaTeX-typeset-menu (arg &optional char) "Typeset, preview, visit error and miscellaneous convenient menu. Optional second argument CHAR is for non-interactive call from menu." (interactive "P") (message (concat "J)latex R)egion E)nv B)ibtex mk(I)dx " "latex+p(D)f " (if (fboundp 'start-process) "K)ill ") "P)review " (and (boundp 'window-system) window-system "S)earch ") "V)iewErr L)pr")) (let ((sw (selected-window)) (c (or char (read-char)))) (require 'yatexprc) ;for Nemacs's bug (select-window sw) (cond ((= c ?j) (YaTeX-typeset-buffer)) ((= c ?r) (YaTeX-typeset-region)) ((= c ?e) (YaTeX-typeset-environment)) ((= c ?b) (YaTeX-call-builtin-on-file "BIBTEX" bibtex-command arg)) ((= c ?i) (YaTeX-call-builtin-on-file "MAKEINDEX" makeindex-command arg)) ((= c ?k) (YaTeX-kill-typeset-process YaTeX-typeset-process)) ((= c ?p) (call-interactively 'YaTeX-preview)) ((= c ?q) (YaTeX-system "lpq" "*Printer queue*")) ((= c ?d) (YaTeX-typeset-buffer (or (YaTeX-get-builtin "DVIPDF") YaTeX-dvipdf-command))) ((= c ?v) (YaTeX-view-error)) ((= c ?l) (YaTeX-lpr arg)) ((= c ?m) (YaTeX-switch-mode-menu arg)) ((= c ?b) (YaTeX-insert-string "\\")) ((= c ?s) (YaTeX-xdvi-remote-search arg))))) (if (fboundp 'wrap-function-to-control-ime) (wrap-function-to-control-ime 'YaTeX-typeset-menu t "P")) (defun YaTeX-%-menu (&optional beg end char) "Operate %# notation." ;;Do not use interactive"r" for the functions which require no mark (interactive) (message "!)Edit-%%#! B)EGIN-END-region P)review L)Edit-%%#LPR make(I)ndex B)ibtex") (let ((c (or char (read-char))) (string "") key (b (make-marker)) (e (make-marker))) (save-excursion (cond ((rindex "!plib" c) ;Edit %#xxx (setq key (cdr (assq c '((?! . "!") (?p . "PREVIEW") (?l . "LPR") (?i . "MAKEINDEX") (?b . "BIBTEX"))))) (YaTeX-getset-builtin key t)) ((= c ?b) ;%#BEGIN %#END region (or end (setq beg (min (point) (mark)) end (max (point) (mark)))) (set-marker b beg) (set-marker e end) (goto-char (point-min)) (while (re-search-forward "^%#\\(BEGIN\\)\\|\\(END\\)$" nil t) (beginning-of-line) (delete-region (point) (progn (forward-line 1) (point)))) (goto-char b) (open-line 1) (delete-region (point) (progn (beginning-of-line)(point)));for 19 :-< (insert "%#BEGIN") (goto-char e) (insert "%#END\n") (set-marker b nil) (set-marker e nil)) )))) (defvar YaTeX-refcommand-def-regexp-default "label\\|bibitem") (defvar YaTeX-refcommand-def-regexp-private nil "*Regexp of defining label commands") (defvar YaTeX-refcommand-def-regexp (concat (if YaTeX-refcommand-def-regexp-private (concat YaTeX-refcommand-def-regexp-private "\\|")) YaTeX-refcommand-def-regexp-default)) (defvar YaTeX-refcommand-ref-regexp-default "\\(page\\|eq\\|fig\\)?ref\\|cite") (defvar YaTeX-refcommand-ref-regexp-private nil "*Regexp of referring label commands") (defvar YaTeX-refcommand-ref-regexp (concat (if YaTeX-refcommand-ref-regexp-private (concat YaTeX-refcommand-ref-regexp-private "\\|")) YaTeX-refcommand-ref-regexp-default)) (defvar YaTeX-refcommand-regexp (concat YaTeX-refcommand-def-regexp "\\|" YaTeX-refcommand-ref-regexp) "Regexp of label defining/referring command name.") (defun YaTeX-goto-corresponding-label (reverse &optional otherwin) "Jump to corresponding \\label{} and \\ref{} or \\cite and \\bibitem. The default search direction depends on the command at the cursor position. When the cursor is on \\ref(\\cite), YaTeX will try to search the corresponding \\label(\\bibitem) backward, and if it fails search forward again. And when the cursor is on \\label(\\bibitem), YaTeX will search the corresponding \\ref(\\cite) forward at first and secondary backward. Argument REVERSE non-nil makes the default direction rule reverse. Since Search string is automatically set in search-last-string, you can repeat search the same label/ref by typing \\[isearch-forward] or \\[isearch-backward]. If optional second argument OTHERWIN is non-nil, move to other window." (let ((scmd "") label direc string blist (p (point)) (cb (current-buffer)) (refcommands YaTeX-refcommand-regexp) (foundmsg (format "Type %s %c to return to original position." (key-description (car (or (where-is-internal 'register-to-point) (where-is-internal 'jump-to-register)))) YaTeX-current-position-register)) (func (function (lambda (string sfunc) (or (funcall sfunc string nil t) (funcall (if (eq sfunc 're-search-forward) 're-search-backward 're-search-forward) string nil t)))))) (cond ((YaTeX-on-section-command-p refcommands) (setq scmd (cdr (assoc (YaTeX-match-string 1) '(("label" . "\\\\\\(page\\|eq\\)?ref{%k}") ("ref" . "\\\\label{%k}") ("eqref" . "\\\\label{%k}") ("pageref" . "\\\\label{%k}") ("cite" . "\\\\bibitem\\(\\[[^]]+\\]\\)?{%k}\\|^\\s *@[a-z]+{%k,") ("bibitem" . "\\\\cite\\(\\[[^]]+\\]\\)?"))))) (goto-char (match-end 0)) (let ((label (YaTeX-buffer-substring (1- (point)) (progn (backward-list 1) (1+ (point))))) (fp (make-marker))fl fn (goother (function (lambda (buffer point) (goto-char point) (if (one-window-p) (split-window-calculate-height YaTeX-default-pop-window-height)) (select-window (get-lru-window)) (switch-to-buffer buffer))))) ;(setq string (concat "\\" scmd "{" label "}")) ;(setq string (concat "\\\\" scmd "{" (regexp-quote label) "}")) (setq string (YaTeX-replace-format scmd "k" (regexp-quote label))) (setq direc (if (string-match "ref\\|cite" scmd) 're-search-forward 're-search-backward)) (if YaTeX-current-position-register (point-to-register YaTeX-current-position-register)) (if reverse (setq direc (if (eq direc 're-search-forward) 're-search-backward 're-search-forward))) (if (funcall func string direc) ;label/ref found! (progn (if otherwin (funcall goother cb p)) (goto-char (match-beginning 0)) (push-mark p)) ;;if label/ref not found, search through all yatex buffers. (goto-char p) ;resume position of current buffer (catch 'found (setq blist (YaTeX-yatex-buffer-list)) (while blist ;; search for corresponding keyword (set-buffer (car blist)) (if (YaTeX-on-section-command-p refcommands) (goto-char (match-beginning 0))) (cond ; cond1 ((funcall func string direc) (cond (otherwin (set-buffer cb) (funcall goother (car blist) p)) ((or (get-buffer-window (car blist)) (and YaTeX-emacs-19 (get-buffer-window (car blist) t))) (goto-buffer-window (car blist))) (t (switch-to-buffer (car blist)) (message foundmsg))) (goto-char (match-beginning 0)) (throw 'found t)) ; cond2 ((and (string-match "bibitem" scmd) (catch 'found2 (save-excursion (goto-char (point-min)) (while (YaTeX-re-search-active-forward "\\\\bibliography{\\([^}]*\\)}" "%" nil t) (setq fl (YaTeX-split-string (YaTeX-match-string 1) ",")) (while fl (if (or (file-exists-p (setq fn (car fl))) (file-exists-p (setq fn (concat fn ".bib")))) (progn (set-buffer (find-file-noselect fn)) (save-excursion (goto-char (point-min)) (if (YaTeX-re-search-active-forward string "%" nil t) (throw 'found2 (set-marker fp (point))))))) (setq fl (cdr fl))))))) (if otherwin (funcall goother (marker-buffer fp) fp) (switch-to-buffer (marker-buffer fp)) (goto-char fp)) (set-marker fp nil) (message foundmsg) (throw 'found t))) (setq blist (cdr blist))) ;; search for bibliography ))) (if YaTeX-emacs-19 (setq regexp-search-ring (cons string (delete string regexp-search-ring))) (setq search-last-regexp string))) (t nil)))) ;;YaTeX-goto-corresponding-environment was moved to yatexlib (defun YaTeX-goto-corresponding-file (&optional other) "Visit or switch buffer of corresponding file, looking at \\input or \\include or \\includeonly on current line." (if (not (YaTeX-on-includes-p)) nil (let ((parent buffer-file-name) input-file b) (save-excursion (if (and (re-search-forward "[{%]" (point-end-of-line) t) (= ?{ (char-after (match-beginning 0)))) nil (skip-chars-backward "^,{")) (setq input-file (YaTeX-buffer-substring (point) (progn (skip-chars-forward "^ ,}") (point)))) (if (not (string-match "\\.\\(tex\\|sty\\)$" input-file)) (setq input-file (concat input-file ".tex")))) (cond (other (YaTeX-switch-to-buffer-other-window input-file)) ((setq b (YaTeX-get-file-buffer input-file)) (goto-buffer-window b)) (t (YaTeX-switch-to-buffer input-file))) (or (YaTeX-get-builtin "!") YaTeX-parent-file (setq YaTeX-parent-file parent))))) (defun YaTeX-goto-corresponding-BEGIN-END () (if (not (YaTeX-on-BEGIN-END-p)) nil (if (cond ((equal (match-beginning 0) (match-beginning 1)) ;if on %#BEGIN (not (search-forward "%#END" nil t))) (t ; if on %#END (not (search-backward "%#BEGIN" nil t)))) (error "Corresponding %%#BEGIN/END not found.")) (beginning-of-line) t)) (defvar YaTeX-processed-file-regexp-alist nil "Alist of regexp of processed file regexp vs. its file name part; For example, if you include image file with `\\epsfile{file=FILE}' where `FILE' is processed file. You might want to view FILE with other previewer such as ghostview, or want to preview its source which was drawn with other drawing tool, tgif for example. Then you should set entire regexp of including expression and enclose its file name part with \\\\( and \\\\). Ex. (\"\\\\\\\\epsfile{[^}]*file=\\\\([^,} ]+\\\\)\\\\(\\\\.e?ps\\\\)?[^}]*}\" 1) Where the first group surrounded by \\\\( and \\\\) is the file name part of expression. So you should set 1 to second element. And the first matching group is sent to (image) processor defined by the variable YaTeX-file-processor-alist. See also the documentation of YaTeX-file-processor-alist. ↑じゃ良くわかんないすね。例えば tgif hoge.obj して hoge.eps を \\epsfile{file=hoge.eps} でインクルードしているとしよう。その行で \[prefix\] g を押した時に tgif を起動して欲しかったら、まず上のような 正規表現を設定する。\\\\(と\\\\)で囲んだところがファイル名になるように 注意する。でファイル名部分が何番目の\\\\(\\\\)になるかをリストの2番目に書く。 すると、その部分が変数 YaTeX-file-processor-alist で定義された 処理プログラムに渡される。というわけ。 ん〜やっぱりむずかしいね。分からない時は隣の Lisper に聞くか、 fj野鳥の会で聞こう! ") (defvar YaTeX-processed-file-regexp-alist-default '(("\\\\epsfile\\(\\[[^]]+\\]\\)?{[^},]*file=\\(\\([^,} ]*/\\)?[^,}. ]+\\)\\(\\.e?ps\\)?[^}]*}" 2) ("\\\\epsfig{[^},]*fi\\(le\\|gure\\)=\\(\\([^,} ]*/\\)?[^,}. ]+\\)\\(\\.e?ps\\)?[^}]*}" 2) ("\\\\postscriptbox{[^}]*}{[^}]*}{\\(\\([^,} ]*/\\)?[^}. ]+\\)\\(\\.e?ps\\)?}" 1) ("\\\\\\(epsfbox\\|epsfig\\)\\*?{\\(\\([^,} ]*/\\)?[^}. ]+\\)\\(\\.e?ps\\)?}" 2) ;\epsfbox{hoge.ps} ("\\\\includegraphics\\*?\\(.*\\]\\|\\s \\)?{\\(.*\\)\\(\\.ai\\|\\.pdf\\|\\.svg\\|\\.png\\|\\.jpe?g\\|\\.e?ps\\)}" 2) ;\includegraphics[options...]{hoge.eps} ("\\\\\\(psbox\\)\\(\\[[^]]+\\]\\)?{\\(\\([^,} ]*/\\)?[^} ]+\\)\\(\\.e?ps\\)}" 3) ;\psbox[options...]{hoge.eps} (97/1/11) ("\\\\input{\\([^} ]+\\)\\(\\.tps\\)}" 1) ;tgif2tex (1998/9/16) ) "See the documentation of YaTeX-processed-file-regexp-alist.") (defvar YaTeX-file-processor-alist nil "*Alist of files' processor vs. its extension; See also the documentation of YaTeX-processed-file-regexp-alist.") (defvar YaTeX-file-processor-alist-default '(("tgif" . ".obj") ("gimp" . ".xcf") ("gimp" . ".xcf.gz") ("gimp" . ".xcf.bz2") ("inkscape" . ".svg") ("inkscape" . ".svgz") ("inkscape" . ".ai") ("soffice" . ".odg") ("gimp" . ".jpeg") ("gimp" . ".jpg") ("gimp" . ".png") ("evince" . ".ps") ("evince" . ".eps") ("soffice" . ".pdf") (t . ".tex") (t . ".sty") (t . "")) "See the documentation of YaTeX-file-processor-alist.") (defun YaTeX-goto-corresponding-file-processor (&optional other) "Execute corresponding file processor." (save-excursion (or (looking-at YaTeX-ec-regexp) (skip-chars-backward (concat "^" YaTeX-ec) (point-beginning-of-line))) (let ((list (append YaTeX-processed-file-regexp-alist YaTeX-processed-file-regexp-alist-default)) (p (point)) flist file (peol (point-end-of-line)) (basedir (if YaTeX-search-file-from-top-directory (save-excursion (YaTeX-visit-main t) default-directory) "."))) (setq flist (catch 'found (while list (goto-char p) (if (re-search-forward (car (car list)) peol t) (progn (setq file (YaTeX-match-string (car (cdr (car list))))) (throw 'found (cdr (car list))))) (setq list (cdr list))))) (if flist ;if pattern and file name found (let*((plist (append YaTeX-file-processor-alist YaTeX-file-processor-alist-default)) (plist0 plist) ext cmd src buf (alt (car (cdr flist)))) (if (and (re-search-forward (concat YaTeX-comment-prefix "\\s *\\(.*\\)$") peol t) (assoc (setq cmd (YaTeX-match-string 1)) YaTeX-file-processor-alist)) (setq src ;if processor is specified (concat file (cdr (assoc cmd YaTeX-file-processor-alist)))) (while plist ;if processor is not specified (setq ext (cdr (car plist))) (if (and (string< "" (concat file ext)) (file-exists-p (expand-file-name (concat file ext) basedir))) (setq cmd (car (car plist)) src (concat file ext) plist nil)) (setq plist (cdr plist))) (if (and (null src) alt YaTeX-create-file-prefix-g) (setq cmd alt src (concat file (cdr (assoc alt plist0)))))) (if src ;if processor and src file found (let ((default-directory basedir)) (cond ((stringp cmd) (let ((buf (concat "* " cmd " " src " *"))) (YaTeX-system (concat cmd " " src) buf) t)) ((eq t cmd) (let ((parent buffer-file-name)) (funcall (cond (other 'YaTeX-switch-to-buffer-other-window) ((get-file-buffer src) 'goto-buffer-window) (t 'YaTeX-switch-to-buffer)) src) (or (YaTeX-get-builtin "!") YaTeX-parent-file (setq YaTeX-parent-file parent)) t)) ((symbolp cmd) (cond ((symbol-function cmd) (funcall cmd src other))) t))))))))) (defun YaTeX-on-section-command-p (command) "Check if point is on the LaTeX command: COMMAND(regexp). Return nil if point is not on it. Otherwise return the number of argument position. Section command name is stored in match-data #1. Parsing information is stored to plist. Macros name stored to propname 'command. Macro's argument number stored to propname 'argc." (let ((p (point)) md (parg 0) (argc 1) word (grouping 0) (i 0) (ec+command (concat YaTeX-ec-regexp "\\(" command "\\)"))) (setplist 'YaTeX-on-section-command-p nil) (while (setq i (string-match "\\\\(" command i)) (setq grouping (1+ grouping) i (+ i 2))) (save-excursion (if (looking-at ec+command) nil (catch 'found ;caught value has no meaning ;;(1) looking at current position (and (looking-at command) (save-excursion (while (and (not (bobp)) (looking-at command)) (forward-char -1)) (looking-at ec+command)) (goto-char (match-beginning 0)) (throw 'found t)) ;;If inside of parentheses, try to escape. (while (condition-case err (progn (up-list -1) t) (error nil))) (while (equal (preceding-char) ?\]) (backward-list)) ;;(2) search command directly (skip-chars-forward "^{}[]") (and (YaTeX-re-search-active-backward ec+command YaTeX-comment-prefix nil t) (>= p (match-beginning 0)) (throw 'found (goto-char (match-beginning 0)))) ;;(3) search token (goto-char p) (while t (if (bobp) (throw 'found nil)) (cond ((looking-at YaTeX-ec-regexp) (throw 'found t)) ((looking-at "[[{]") nil) ((looking-at "[]}]")(condition-case nil (up-list -1) (error nil))) (t (skip-chars-backward " \t\r\n"))) (skip-chars-backward (concat "^ \t\r\n{}[]" YaTeX-ec-regexp)) (or (bobp) (forward-char -1))))) (if (and (looking-at (concat ec+command "\\(\\(\\[[^]]+\\]\\|([0-9,]+)\\)*\\)" ;optional arg ;"[ \t\n\r]*{[^}]+}")) ;arg braces "[ \t\n\r]*{[^}]*}")) ;arg braces (not (YaTeX-lookup-table (setq word (YaTeX-match-string 1)) 'singlecmd))) (progn (setq md (match-data)) (skip-chars-forward "^{") (if (<= (point) p) (setq parg (1+ parg))) (setq argc (or (car (cdr (YaTeX-lookup-table word 'section))) argc)) (put 'YaTeX-on-section-command-p 'argc argc) (put 'YaTeX-on-section-command-p 'command argc) (while (and (>= (setq argc (1- argc)) 0) (progn (skip-chars-forward " \t\n\r") (looking-at "{"))) (forward-list 1) (if (<= (point) p) (setq parg (1+ parg)))) (store-match-data md) (setq i (+ 2 grouping)) (if (and (match-beginning i) (>= p (match-beginning i)) (< p (match-end i))) -1 ;return -1 if point is on optional arg (if (< p (point)) parg)) ))))) (defun YaTeX-on-maketitle-p () "Check if point is on maketitle type commands. Call this function after YaTeX-on-section-command-p." (let ((p (point))) (save-excursion (or (= (char-after (point)) ?\\ ) (progn (skip-chars-backward (concat "^" YaTeX-ec-regexp) (point-beginning-of-line)) (or (bobp) (bolp) (backward-char 1)))) (and (looking-at (concat YaTeX-ec-regexp YaTeX-TeX-token-regexp)) (<= (match-beginning 0) p) (> (match-end 0) p))))) (defun YaTeX-on-begin-end-p () (save-excursion (if (and (boundp 'in-leftright-p) in-leftright-p) ;; Dirty workaround for YaTeX-goto-corresponding-leftright 2003/3/28 (let ((md (match-data))) ; for safety (if (looking-at YaTeX-ec-regexp) nil ; stay here (cond ((looking-at "\\w") (skip-chars-backward "A-Za-z")) ((looking-at "\\.()\\[\\]|") (forward-char -1))) (if (equal (char-after (1- (point))) (string-to-char YaTeX-ec)) (forward-char -1)))) ;(beginning-of-line) (if (equal (char-after (point)) ?\\) nil ;stay here (skip-chars-backward "^\n\\\\") (or (bolp) (forward-char -1)))) (re-search-forward ;;"\\\\begin{\\([^}]+\\)}\\|\\\\end{\\([^}]+\\)}" (concat (YaTeX-replace-format-args (regexp-quote YaTeX-struct-begin) (concat "\\(" YaTeX-struct-name-regexp "\\)") "" "" "") "\\|" (YaTeX-replace-format-args (regexp-quote YaTeX-struct-end) (concat "\\(" YaTeX-struct-name-regexp "\\)") "" "" "") "\\|\\(" YaTeX-ec-regexp ;;"[][()]\\)" "[][]\\)" ) (point-end-of-line) t))) (defun YaTeX-on-includes-p () (save-excursion (beginning-of-line) (re-search-forward "\\(\\(include[^}]*\\)\\|\\(input\\)\\){[^}]*}" (point-end-of-line) t))) (defun YaTeX-on-comment-p (&optional sw) "Return t if current line is commented out. Optional argument SW t to treat all `%' lines as comment, even if on `%#' notation." (save-excursion (beginning-of-line) (skip-chars-forward "\\s ") (looking-at (if sw "%" "%[^#]")))) (defun YaTeX-on-BEGIN-END-p () (save-excursion (let ((case-fold-search nil)) (beginning-of-line) (re-search-forward "\\(%#BEGIN\\)\\|\\(%#END\\)" (point-end-of-line) t)))) (defun YaTeX-goto-corresponding-* (arg) "Parse current line and call suitable function." (interactive "P") (let (mm) (cond ((YaTeX-goto-corresponding-label arg)) ((YaTeX-goto-corresponding-environment)) ((YaTeX-goto-corresponding-file-processor arg)) ((YaTeX-goto-corresponding-file arg)) ((YaTeX-goto-corresponding-BEGIN-END)) ((and (setq mm (YaTeX-in-math-mode-p)) (YaTeX-goto-corresponding-leftright))) ((and ;;mm YaTeX-use-AMS-LaTeX (YaTeX-goto-corresponding-paren))) ;;((and (string-match ;; YaTeX-equation-env-regexp ;to delay loading ;; (or (YaTeX-inner-environment t) "document")) ;; (YaTeX-goto-corresponding-leftright))) (t (message "I don't know where to go."))))) (defun YaTeX-goto-corresponding-*-other-window (arg) "Parse current line and call suitable function." (interactive "P") (cond ((YaTeX-goto-corresponding-label arg t)) ;;((YaTeX-goto-corresponding-environment)) ((YaTeX-goto-corresponding-file t)) ;;((YaTeX-goto-corresponding-BEGIN-END)) (t (message "I don't know where to go.")))) (defun YaTeX-comment-region (alt-prefix) "Comment out region by '%'. If you call this function on the 'begin{}' or 'end{}' line, it comments out whole environment" (interactive "P") (if (not (YaTeX-on-begin-end-p)) (comment-out-region (if alt-prefix (read-string "Insert prefix: ") YaTeX-comment-prefix)) (YaTeX-comment-uncomment-env 'comment-out-region))) (defun YaTeX-uncomment-region (alt-prefix) "Uncomment out region by '%'." (interactive "P") (if (not (YaTeX-on-begin-end-p)) (uncomment-out-region (if alt-prefix (read-string "Remove prefix: ") YaTeX-comment-prefix) (region-beginning) (region-end) YaTeX-uncomment-once) (YaTeX-comment-uncomment-env 'uncomment-out-region))) (defun YaTeX-comment-uncomment-env (func) "Comment or uncomment out one LaTeX environment switching function by FUNC." (let (beg (p (point))) (save-excursion (beginning-of-line) (setq beg (point)) (YaTeX-goto-corresponding-environment) (beginning-of-line) (if (> p (point)) (setq beg (1+ beg)) (forward-char 1)) (funcall func YaTeX-comment-prefix beg (point) YaTeX-uncomment-once))) (message "%sommented out current environment." (if (eq func 'comment-out-region) "C" "Un-c"))) (defun YaTeX-comment-paragraph () "Comment out current paragraph." (interactive) (save-excursion (cond ((YaTeX-on-begin-end-p) (beginning-of-line) (insert YaTeX-comment-prefix) (YaTeX-goto-corresponding-environment) (beginning-of-line) (insert YaTeX-comment-prefix)) ((YaTeX-on-comment-p) (message "Already commented out.")) (t (mark-paragraph) (if (looking-at paragraph-separate) (forward-line 1)) (comment-out-region "%"))))) (defun YaTeX-uncomment-paragraph () "Uncomment current paragraph." (interactive) (save-excursion (if (YaTeX-on-begin-end-p) (let ((p (point-marker))) (YaTeX-goto-corresponding-environment) (YaTeX-remove-prefix YaTeX-comment-prefix YaTeX-uncomment-once) (goto-char p) (YaTeX-remove-prefix YaTeX-comment-prefix YaTeX-uncomment-once) (set-marker p nil)) (if (YaTeX-on-comment-p) (let*((fill-prefix "") ;;append `^%' to head of paragraph delimiter. (paragraph-start (concat "^$\\|^%\\(" YaTeX-paragraph-separate "\\)")) (paragraph-separate paragraph-start)) (mark-paragraph) (if (not (bobp)) (forward-line 1)) (uncomment-out-region "%" nil nil YaTeX-uncomment-once)) (message "This line is not a comment line."))))) (defun YaTeX-remove-prefix (prefix &optional once) "Remove prefix on current line as far as prefix detected. But optional argument ONCE makes deletion once." (interactive "sPrefix:") (beginning-of-line) (while (re-search-forward (concat "^" prefix) (point-end-of-line) t) (replace-match "") (if once (end-of-line)))) (defun YaTeX-kill-some-pairs (predicate gofunc kill-contents) "Kill some matching pair. This function assumes that pairs occupy whole of each line where they resid." (if (not (funcall predicate)) nil (let ((b1 (match-beginning 0)) (e1 (match-end 0)) b2 e2) (save-excursion (funcall gofunc) (funcall predicate) ;get match data (if (< (point) e1) ;if currently on begin-line (progn (setq b2 b1 e2 e1 b1 (match-beginning 0) e1 (match-end 0)) (goto-char e2)) ;goto end-line's end (setq b2 (match-beginning 0) e2 (match-end 0)) (goto-char e2)) ;now e2 has surely end-line's end (skip-chars-forward " \t") (and (eolp) (not (eobp)) (setq e2 (1+ (point)))) (if (not kill-contents) (kill-region (progn (goto-char b2) (skip-chars-backward " \t%") (if (bolp) (point) b2)) e2)) (goto-char b1) (skip-chars-backward " \t%") (if (not kill-contents) (progn (kill-append (buffer-substring (setq b1 (if (bolp) (point) b1)) (setq e1 (progn (goto-char e1) (while (looking-at "{\\| \t") (forward-list 1)) (skip-chars-forward " \t") (if (and (eolp) (not (eobp))) (1+ (point)) (point))))) t) (delete-region b1 e1)) (kill-region (if (bolp) (point) b1) e2))) t))) (defun YaTeX-kill-section-command (point kill-all) "Kill section-type command at POINT leaving its last argument. Non-nil for the second argument kill its last argument too." (let ((cmd (get 'YaTeX-on-section-command-p 'command)) (argc (get 'YaTeX-on-section-command-p 'argc)) beg (end (make-marker))) (save-excursion (goto-char point) (or (looking-at YaTeX-ec-regexp) (progn (skip-chars-backward (concat "^" YaTeX-ec-regexp)) (forward-char -1))) (setq beg (point)) (skip-chars-forward "^{") (while (> (setq argc (1- argc)) 0) (skip-chars-forward "^{") (forward-list 1)) (kill-region beg (point)) (forward-list 1) (set-marker end (point)) (if kill-all (progn (kill-append (buffer-substring beg end) nil) (delete-region beg end)) (goto-char beg) (kill-append (buffer-substring (point) (progn (skip-chars-forward "^{" end) (1+ (point)))) nil) (delete-region beg (1+ (point))) (goto-char end) (set-marker end nil) (kill-append (buffer-substring (point) (1- (point))) nil) (delete-backward-char 1))))) (defun YaTeX-kill-paren (kill-contents) "Kill parentheses leaving its contents. But kill its contents if the argument KILL-CONTENTS is non-nil." (interactive "P") (let (p bsl (backslash-syntax (char-to-string (char-syntax ?\\))) (md (match-data))) (unwind-protect (save-excursion (modify-syntax-entry ?\\ " ") (if (looking-at "\\s(\\|\\(\\s)\\)") (progn (if (match-beginning 1) (up-list -1)) (if (and (> (point) (point-min)) (= (char-after (1- (point))) ?\\ )) (setq p (1- (point)) bsl t) (setq p (point))) (forward-list 1) ;(YaTeX-goto-open-paren t) (if kill-contents (delete-region p (point)) (backward-delete-char 1) (cond ((save-excursion (forward-char -2) (looking-at (concat YaTeX-ec-regexp "/"))) (backward-delete-char 2)) ((= (char-after (1- (point))) ?\\) (backward-delete-char 1))) (goto-char p) (if (looking-at (concat "{" YaTeX-ec-regexp YaTeX-command-token-regexp "+" "\\s +")) (delete-region (point) (match-end 0)) (delete-char 1) (if bsl (delete-char 1)))) t))) (modify-syntax-entry ?\\ backslash-syntax) (store-match-data md)))) (defvar YaTeX-read-environment-history nil "Holds history of environments.") (put 'YaTeX-read-environment-history 'no-default t) (defun YaTeX-read-environment (prompt &optional predicate must-match initial) "Read a LaTeX environment name with completion." (YaTeX-sync-local-table 'tmp-env-table) (completing-read-with-history prompt (append tmp-env-table user-env-table env-table) predicate must-match initial 'YaTeX-read-environment-history)) (defvar YaTeX-read-section-history nil "Holds history of section-types.") (put 'YaTeX-read-section-history 'no-default t) (defun YaTeX-read-section (prompt &optional predicate initial) "Read a LaTeX section-type command with completion." (YaTeX-sync-local-table 'tmp-section-table) (let ((minibuffer-completion-table (append tmp-section-table user-section-table section-table))) (read-from-minibuffer-with-history prompt initial YaTeX-section-completion-map nil 'YaTeX-read-section-history))) (defun YaTeX-read-section-with-overview () "Read sectioning command with overview. This function refers a local variable `source-window' in YaTeX-make-section, because this function is called with no argument." (interactive) (require 'yatexsec) ;some case needs this (if (> (minibuffer-depth) 1) (error "Too many minibuffer levels for overview.")) (let ((sw (selected-window)) (minibuffer-max-depth nil) ; for XEmacs20 (enable-recursive-minibuffers t) sect) (unwind-protect (progn (select-window source-window) (setq sect (YaTeX-read-section-in-minibuffer "Sectioning(Up=C-p, Down=C-n, Help=?): " YaTeX-sectioning-level (YaTeX-section-overview)))) (select-window sw)) (YaTeX-minibuffer-erase) (insert sect) (exit-minibuffer))) (defvar YaTeX-read-fontsize-history nil "Holds history of font designator.") (put 'YaTeX-read-fontsize-history 'no-default t) (defun YaTeX-read-fontsize (prompt &optional predicate must-match initial) "Read a LaTeX font changing command with completion." (YaTeX-sync-local-table 'tmp-fontsize-table) (completing-read-with-history prompt (append tmp-fontsize-table user-fontsize-table fontsize-table) predicate must-match initial 'YaTeX-read-fontsize-history)) (defun YaTeX-change-environment () "Change the name of environment." (interactive) (if (not (YaTeX-on-begin-end-p)) nil (save-excursion (let (p env newenv (m1 (match-beginning 1)) (m2 (match-beginning 2))) (setq env (if m1 (YaTeX-buffer-substring m1 (match-end 1)) (YaTeX-buffer-substring m2 (match-end 2)))) (goto-char (match-beginning 0)) (set-mark-command nil) (YaTeX-goto-corresponding-environment) (setq newenv (YaTeX-read-environment (format "Change environment `%s' to: " env))) (cond ((string= newenv "") (message "Change environment cancelled.")) ((string= newenv env) (message "No need to change.")) (t (search-forward (concat "{" env) (point-end-of-line) t) (replace-match (concat "{" newenv) t) (exchange-point-and-mark) (search-forward (concat "{" env) (point-end-of-line) t) (replace-match (concat "{" newenv) t))) t)))) (defun YaTeX-change-section () "Change section-type command." (interactive) (let*((where (YaTeX-on-section-command-p YaTeX-command-token-regexp)) (p (point)) (cmd (YaTeX-match-string 1)) (beg (make-marker)) (end (make-marker)) old new) (if (null where) nil (unwind-protect (let ((source-window (selected-window))) (cond ((equal where 0);;if point is on section command (set-marker beg (match-beginning 1)) (set-marker end (match-end 1)) (goto-char beg) ;beginning of the command (setq new (YaTeX-read-section (format "Change `%s' to: " cmd) nil) old cmd)) ((= where -1);;if point is on a optional parameter (set-marker beg (match-beginning 2)) (skip-chars-forward "^{") (set-marker end (point)) (goto-char p) (setq new (if (fboundp (intern-soft (concat YaTeX-addin-prefix cmd))) (YaTeX-addin cmd) (concat "[" (read-string (format "Change `%s' to: " (setq old (YaTeX-buffer-substring (1+ beg) (1- end))))) "]")))) ((> where 0);;if point is in arguments' braces (or (looking-at "{") (progn (skip-chars-backward "^{") (forward-char -1))) (set-marker beg (1+ (point))) (forward-list 1) (forward-char -1) (set-marker end (point)) (setq old (YaTeX-buffer-substring beg end)) (goto-char p) (if (> (length old) 40) (setq old (concat (substring old 0 12) "..." (substring old -12)))) (setq new (if (intern-soft (concat "YaTeX::" cmd)) (funcall (intern-soft (concat "YaTeX::" cmd)) where) (read-string (format "Change `%s' to: " old))))) ) ;cond (if (string= old new) nil ;do not replace (delete-region beg end) (goto-char beg) (insert-before-markers new))) (set-marker beg nil) (set-marker end nil)) ;;(goto-char (marker-position p)) new))) (defun YaTeX-change-fontsize () "Change large-type command." (let ((lt (append tmp-fontsize-table user-fontsize-table fontsize-table)) (p (point)) large old new beg end) ;;(and (looking-at "}") (up-list -1)) ;;(and (looking-at "{") (forward-char 1)) ;;Is above convenient? (save-excursion (or (looking-at YaTeX-ec-regexp) (progn (skip-chars-backward (concat "^" YaTeX-ec-regexp)) (forward-char -1))) (cond ((and (looking-at (concat YaTeX-ec-regexp "\\(" YaTeX-TeX-token-regexp "\\)")) (< p (match-end 0)) (assoc (setq old (YaTeX-match-string 1)) lt)) (goto-char p) (setq beg (match-beginning 1) end (match-end 1) ;save match position new (completing-read (format "Change font/size `%s' to : " old) lt)) (delete-region beg end) (goto-char beg) (insert-before-markers new) new) (t nil) )))) (defun YaTeX-change-math-image () "Change with image completion." (let (maketitle memberp beg end) (if (and (YaTeX-on-maketitle-p) (progn (setq maketitle (substring (YaTeX-match-string 0) 1)) (setq memberp (YaTeX-math-member-p maketitle)))) (let*((last-command-char (string-to-char (car memberp))) (last-command-event last-command-char)) (setq beg (match-beginning 0) end (match-end 0)) (delete-region beg end) (YaTeX-math-insert-sequence t (cdr memberp)))))) (defun YaTeX-kill-* (&optional arg) "Parse current line and call suitable function. Non-nil for ARG kills its contents too." (interactive "P") (cond ((YaTeX-kill-some-pairs 'YaTeX-on-begin-end-p 'YaTeX-goto-corresponding-environment arg)) ((YaTeX-kill-some-pairs 'YaTeX-on-BEGIN-END-p 'YaTeX-goto-corresponding-BEGIN-END arg)) ((YaTeX-on-section-command-p YaTeX-command-token-regexp);on any command (YaTeX-kill-section-command (match-beginning 0) arg)) ((YaTeX-kill-paren arg)) (t (message "I don't know what to kill.")))) (defun YaTeX-change-* () "Parse current line and call suitable function." (interactive) (cond ((YaTeX-change-parentheses)) ((YaTeX-change-environment)) ((YaTeX-change-section)) ((YaTeX-change-fontsize)) ((YaTeX-change-math-image)) (t (message "I don't know what to change.")))) ;;; ;Check availability of add-in functions ;;; (cond ((featurep 'yatexadd) nil) ;Already provided. ((progn (load "yatexadd" t) (featurep 'yatexadd)) nil) (t (message "YaTeX add-in functions not supplied."))) (defun YaTeX-addin (name) "Check availability of addin function and call it if exists." (if (and (not (get 'YaTeX-generate 'disabled)) (intern-soft (concat YaTeX-addin-prefix name)) (fboundp (intern-soft (concat YaTeX-addin-prefix name)))) (let ((s (funcall (intern (concat YaTeX-addin-prefix name))))) (if (stringp s) s "")) "")) ;Add in function is not bound. (defun YaTeX-on-item-p (&optional point) "Return t if POINT (default is (point)) is on \\item." (let ((p (or point (point)))) (save-excursion (goto-char p) (end-of-line) (setq p (point)) (re-search-backward YaTeX-paragraph-delimiter nil t) (re-search-forward YaTeX-item-regexp p t)))) (defun YaTeX-in-verb-p (&optional point) "Check if POINT is in verb or verb*. Default of POINT is (point)." (setq point (or point (point))) (save-excursion (let ((md (match-data))) (goto-char point) (unwind-protect (if (not (re-search-backward (concat YaTeX-ec-regexp "\\(" YaTeX-verb-regexp "\\)" "\\([^-A-Za-z_*]\\)") (point-beginning-of-line) t)) nil (goto-char (match-end 2)) (skip-chars-forward (concat "^" (YaTeX-buffer-substring (match-beginning 2) (match-end 2)))) (and (< (match-beginning 2) point) (< (1- point) (point)))) (store-match-data md))))) (defun YaTeX-literal-p (&optional point) "Check if POINT is in verb or verb* or verbatime environment family. Default of POINT is (point)." (let ((md (match-data))) (unwind-protect (cond ((equal YaTeX-ec "\\") ;maybe LaTeX (save-excursion (and point (goto-char point)) (or (YaTeX-in-verb-p (point)) (and (not (looking-at "\\\\end{verb")) (YaTeX-quick-in-environment-p YaTeX-verbatim-environments)))))) (store-match-data md)))) (defun YaTeX-in-environment-p (env) "Return if current LaTeX environment is ENV. ENV is given in the form of environment's name or its list." (let ((md (match-data)) (nest 0) p envrx) (cond ((atom env) (setq envrx (concat "\\(" (regexp-quote (YaTeX-replace-format-args YaTeX-struct-begin env "" "")) "\\)\\|\\(" (regexp-quote (YaTeX-replace-format-args YaTeX-struct-end env "" "")) "\\)")) (save-excursion (setq p (catch 'open (while (YaTeX-re-search-active-backward envrx YaTeX-comment-prefix nil t) (if (match-beginning 2) (setq nest (1+ nest)) (setq nest (1- nest))) (if (< nest 0) (throw 'open (cons env (match-beginning 0))))))))) ((listp env) (setq p (or (YaTeX-in-environment-p (car env)) (and (cdr env) (YaTeX-in-environment-p (cdr env))))))) (store-match-data md) p;(or p (YaTeX-in-verb-p (match-beginning 0))) )) (defun YaTeX-quick-in-environment-p (env) "Check quickly but unsure if current environment is ENV. ENV is given in the form of environment's name or its list. This function returns correct result only if ENV is NOT nested." (save-excursion (let ((md (match-data)) m0 (p (point)) rc clfound) (cond ((listp env) (or (YaTeX-quick-in-environment-p (car env)) (and (cdr env) (YaTeX-quick-in-environment-p (cdr env))))) (t (unwind-protect (if (prog1 (YaTeX-search-active-backward (YaTeX-replace-format-args YaTeX-struct-begin env "" "") YaTeX-comment-prefix nil t) (setq m0 (match-beginning 0))) (if (YaTeX-search-active-forward (YaTeX-replace-format-args YaTeX-struct-end env) YaTeX-comment-prefix p t nil) nil ;if \end{env} found, return nil (cons env m0))) ;else, return meaningful values (store-match-data md))))))) ;; Filling \item (defun YaTeX-remove-trailing-comment (start end) "Remove trailing comment from START to end." (save-excursion (let ((trcom (concat YaTeX-comment-prefix "$"))) (goto-char start) (while (re-search-forward trcom end t) (if (/= (char-after (1- (match-beginning 0))) ?\\ ) (replace-match "\\1")))))) (defvar YaTeX-itemize-withlabel-max-indent-depth 8) (defun YaTeX-get-item-info (&optional recent thisenv) "Return the list of the beginning of \\item and column of its item. If it seems to be outside of itemizing environment, just return nil. Non-nil for optional argument RECENT refers recent \\item. Optional second argument THISENV omits calling YaTeX-inner-environment." (save-excursion (let* ((p (point)) env e0 c cc md (bndry (and (setq env (or thisenv (YaTeX-inner-environment t))) (get 'YaTeX-inner-environment 'point)))) (end-of-line) (if (if recent (catch 'found (while (YaTeX-re-search-active-backward YaTeX-item-regexp YaTeX-comment-prefix bndry t) (setq md (match-data)) (YaTeX-inner-environment t) (store-match-data md) (if (= bndry (get 'YaTeX-inner-environment 'point)) (throw 'found t)))) (goto-char bndry) (YaTeX-re-search-active-forward YaTeX-item-regexp YaTeX-comment-prefix p t)) (progn (goto-char (match-end 0)) ;(setq c (current-column)) (if (string-match "desc" env) (setq c 6) (setq cc (current-column)) (if (equal (following-char) ?\[) (forward-list 1)) (if (< (- (current-column) cc) YaTeX-itemize-withlabel-max-indent-depth) (setq c 0) (move-to-column cc) (setq c YaTeX-itemize-withlabel-max-indent-depth))) (skip-chars-forward " \t" (point-end-of-line)) (list (point-beginning-of-line) (+ c (current-column)))))))) (defun YaTeX-fill-item () "Fill item in itemize environment." (interactive) (save-excursion (let* ((p (point)) (item-term (concat "\\(^[ \t]*$\\)\\|" YaTeX-item-regexp "\\|\\(" YaTeX-ec-regexp "\\(begin\\|end\\)\\)")) ;;This value depends on LaTeX. fill-prefix start col (info (YaTeX-get-item-info t))) (if (null info) nil ;not on \item, do nothing (setq start (car info) col (car (cdr info))) (save-excursion (if (re-search-backward "^\\s *$" start t) ;;if separated from \item line, isolate this block (progn (setq start (1+ (match-end 0))) (goto-char start) (skip-chars-forward " \t") (delete-region (point) start) ;is this your favor??? (indent-to col)))) (beginning-of-line) (if (<= (save-excursion (re-search-forward (concat "\\\\end{\\|\\\\begin{\\|^[ \t]*$") nil t) (match-beginning 0)) p) (progn (message "Not on itemize.") nil) (end-of-line) (newline) (indent-to col) (setq fill-prefix (YaTeX-buffer-substring (point-beginning-of-line)(point))) (beginning-of-line) (delete-region (point) (progn (forward-line 1) (point))) (re-search-forward item-term nil 1) (YaTeX-remove-trailing-comment start (point)) (beginning-of-line) (push-mark (point) t) (goto-char start) (forward-line 1) (while (< (point) (mark)) (delete-region (point) (progn (skip-chars-forward " \t") (point))) (forward-line 1)) (fill-region-as-paragraph start (mark)) (if NTT-jTeX (while (progn(forward-line -1)(end-of-line) (> (point) start)) (insert ?%))) (pop-mark)))))) (defun YaTeX-fill-paragraph (arg) "YaTeX adjustment function for fill-paragraph. *Protect \\verb from unexpected broken up." (interactive "P") (cond ((not (eq major-mode 'yatex-mode)) (fill-paragraph arg)) ((YaTeX-quick-in-environment-p YaTeX-fill-inhibit-environments) nil) ((YaTeX-in-math-mode-p) nil) (t (save-excursion (let*((verbrex (concat YaTeX-ec-regexp "\\(" YaTeX-verb-regexp "\\)" ;match#1 "\\(.\\).*\\(\\2\\)")) ;match #2 and #3 (tilderex (concat "\\(" YaTeX-kanji-regexp "~" "\\)" YaTeX-ec-regexp "\\|\\(" "~" YaTeX-kanji-regexp "\\)")) (p (point)) ii end poslist spacelist lenlist b e n (fill-prefix fill-prefix) (inenv (or (YaTeX-inner-environment t) "document")) (border (get 'YaTeX-inner-environment 'point))) (cond ((save-excursion (beginning-of-line) ;if point is on the first (setq end (point)) ;non-whitespace char (skip-chars-forward " \t") (equal (point) p)) (setq fill-prefix (YaTeX-buffer-substring p end))) ((and ;;(not YaTeX-emacs-19) (string-match YaTeX-itemizing-env-regexp inenv) (setq ii (YaTeX-get-item-info))) (save-excursion (beginning-of-line) (indent-to-column (car (cdr ii))) (setq fill-prefix (YaTeX-buffer-substring (point) (point-beginning-of-line))) (delete-region (point) (progn (beginning-of-line) (point)))))) (cond ((string-match "tabular" inenv) (let ((b (point-beginning-of-line)) (e (point-end-of-line))) (if (re-search-backward "&\\|\\\\\\\\\\|\\\\\\(begin\\|end\\){" border t) (setq b (if (match-beginning 1) (progn (forward-line 1) (point)) (point-beginning-of-line)))) (goto-char p) (if (re-search-forward "&\\|\\\\\\\\\\|\\\\\\(end\\|begin\\){" nil t) (setq e (if (match-beginning 1) (progn (forward-line -1) (point-end-of-line)) (match-beginning 0)))) (set-mark e) (goto-char b))) (t (mark-paragraph))) (save-restriction (narrow-to-region (region-beginning) (region-end)) (YaTeX-remove-trailing-comment (point-min) (point-max)) ;; First, replace spaces in verb to _ temporarily. (goto-char (point-min)) (while (YaTeX-re-search-active-forward verbrex YaTeX-comment-prefix (point-max) t) (setq end (match-beginning 3)) (goto-char (match-beginning 2)) (while (re-search-forward "\\s " end t) (setq poslist (cons (make-marker) poslist) spacelist (cons (preceding-char) spacelist) lenlist (cons 1 lenlist)) (replace-match "_") (set-marker (car poslist) (match-beginning 0)))) ;; Second, replace "表~\ref{...}" to "\\\ref{...}" (goto-char (point-min)) (while (YaTeX-re-search-active-forward tilderex YaTeX-comment-prefix (point-max) t) (if (match-beginning 1) (setq b (match-beginning 1) e (match-end 1) n 1) (setq b (match-beginning 2) e (match-end 2) n 2)) (setq poslist (cons (make-marker) poslist) spacelist (cons (YaTeX-match-string n) spacelist) lenlist (cons 2 lenlist)) (goto-char (match-beginning 0)) (delete-region (point) e) (insert YaTeX-ec YaTeX-ec) ;set-marker should be here (set-marker (car poslist) b)) ;;(fill-paragraph arg) (fill-region-as-paragraph (point-min) (point-max) arg) (while spacelist (goto-char (car poslist)) (set-marker (car poslist) nil) (and (eolp) (skip-chars-forward "\n\t ")) (delete-char (car lenlist)) (insert (car spacelist)) (setq spacelist (cdr spacelist) poslist (cdr poslist) lenlist (cdr lenlist))) (goto-char (point-min)) (forward-word 1) (beginning-of-line) (while (re-search-forward "\\\\\\([a-z]*ref\\|cite\\){" nil t) (if (< (point-end-of-line) (save-excursion (forward-char -1) (forward-list 1) (point))) (progn (end-of-line) (if (save-excursion (backward-word 1) (looking-at "[^0-9A-z!-)]")) (insert YaTeX-comment-prefix))))) ;; Nonbreak space `~' (goto-char (point-min)) (while (YaTeX-re-search-active-forward "~\\(\\s *\\)$" YaTeX-comment-prefix (point-max) t) (delete-region (match-beginning 1) (match-end 1)) (insert YaTeX-comment-prefix)) (goto-char (point-min)) (if (and NTT-jTeX (looking-at "[ \t]\\|^$")) (progn (goto-char (point-min)) (while (not (eobp)) (end-of-line) (or (bolp) (save-excursion (backward-word 1) (looking-at "[0-9A-z!-)]")) ;is not japanese string (progn (setq p (point)) (insert YaTeX-comment-prefix))) (forward-line 1)) (goto-char p) (if (looking-at "%") (delete-char 1)) ;remove last inserted `%' )))))))) (if (fboundp 'YaTeX-saved-indent-new-comment-line) nil (fset 'YaTeX-saved-indent-new-comment-line (symbol-function 'indent-new-comment-line)) (fset 'indent-new-comment-line 'YaTeX-indent-new-comment-line)) (defun YaTeX-indent-new-comment-line (&optional soft) "Tuned `indent-new-comment-line' function for yatex. See the documentation of `YaTeX-saved-indent-new-comment-line'." (interactive) (cond ((or (not (memq major-mode '(yatex-mode yahtml-mode))) (string-match "document" (or (and (boundp 'inenv) inenv) (or (YaTeX-inner-environment t) "document")))) (apply 'YaTeX-saved-indent-new-comment-line (if soft (list soft)))) ; ((and (eq major-mode 'yahtml-mode) ; (string-match ; "^[Pp][Rr][Ee]" (yahtml-inner-environment-but "^[Aa]\\b" t))) ; (yahtml-indent-new-commnet-line)) ((and (eq major-mode 'yatex-mode) ;1997/2/4 (YaTeX-in-math-mode-p)) nil) ;1996/12/30 (t (let (fill-prefix) (apply 'YaTeX-saved-indent-new-comment-line (if soft (list soft))))))) (defun YaTeX-fill-* () "Fill paragraph according to its condition." (interactive) (cond ((YaTeX-fill-item)) )) ;; Accent completion (defun YaTeX-read-accent-char (x) "Read char in accent braces." (let ((c (read-char))) (concat (if (and (or (= c ?i) (= c ?j)) (not (string-match (regexp-quote x) "cdb"))) "\\" "") (char-to-string c)))) (defun YaTeX-make-accent () "Make accent usage." (interactive) (message "1:` 2:' 3:^ 4:\" 5:~ 6:= 7:. u v H t c d b") (let ((c (read-char))(case-fold-search nil)) (setq c (cond ((and (> c ?0) (< c ?8)) (substring "`'^\"~=." (1- (- c ?0)) (- c ?0))) ((= c ?h) "H") (t (char-to-string c)))) (if (not (string-match c "`'^\"~=.uvHtcdb")) nil (insert "\\" c "{}") (backward-char 1) (insert (YaTeX-read-accent-char c)) (if (string= c "t") (insert (YaTeX-read-accent-char c))) (forward-char 1)))) ;; Indentation (defun YaTeX-current-indentation () "Return the indentation of current environment." (save-excursion ;;(beginning-of-line) (if (YaTeX-beginning-of-environment t) (goto-char (get 'YaTeX-inner-environment 'point)) (forward-line -1) (beginning-of-line) (skip-chars-forward " \t")) (current-column))) (defun YaTeX-previous-line-indentation () (save-excursion (forward-line -1) (skip-chars-forward " \t") (current-column))) (defvar YaTeX-noindent-env-regexp "verbatim\\*?\\|alltt" "*Regexp of environment names that should begin with no indentation. All verbatime-like environment name should match with.") (defun YaTeX-indent-line () "Indent corrent line referrin current environment." (interactive) (let ((indent-relative (function (lambda (&optional additional) (YaTeX-reindent (+ (YaTeX-current-indentation) (or additional 0) YaTeX-environment-indent))))) sect depth iteminfo (p (point)) pp (peol (point-end-of-line)) begend ;;inenv below is sometimes defined in YaTeX-indent-new-comment-line (inenv (or (and (boundp 'inenv) inenv) (YaTeX-inner-environment t)))) ;;(if NTT-jTeX ;;Do you need this section? ;; (save-excursion ;; (end-of-line) ;; (let ((p (point))) ;; (forward-line -1) ;; (end-of-line) ;; (or (= p (point)) ;; (progn (backward-char (length YaTeX-comment-prefix)) ;; (not (looking-at (regexp-quote YaTeX-comment-prefix)))) ;; (progn ;; (skip-chars-backward YaTeX-comment-prefix) ;; (kill-line)))))) (or inenv (setq inenv "document")) ;is the default environment (cond ((and (prog1 (YaTeX-on-begin-end-p) (setq begend (match-beginning 0))) (or (match-beginning 2) ;if \end (and (match-beginning 3) ;if \) \] (= (char-syntax (char-after (1+ (match-beginning 3)))) ?\))))) (YaTeX-reindent (save-excursion (YaTeX-goto-corresponding-environment) (current-column)))) ;; on the begining of verbatime line, remove all indentation ((and begend ;; match-beginning 0 of \begin YaTeX-noindent-env-regexp (stringp YaTeX-noindent-env-regexp) (save-excursion (and ;; if the \begin is the first declaration of this line (progn (beginning-of-line) (skip-chars-forward " \t") (= begend (point))) (progn (goto-char begend) (looking-at (concat YaTeX-ec-regexp "begin{\\(" YaTeX-noindent-env-regexp "\\)}")))))) (save-excursion (goto-char begend) (delete-region (point) (point-beginning-of-line)))) ((string-match YaTeX-equation-env-regexp inenv) (YaTeX-indent-line-equation)) ;autoload-ed from yatexenv (;(YaTeX-in-environment-p '("itemize" "enumerate" "description" "list")) (string-match YaTeX-itemizing-env-regexp inenv) ;;(YaTeX-on-item-p) ?? ;;(setq iteminfo (YaTeX-get-item-info t)) (if (save-excursion (beginning-of-line) (re-search-forward YaTeX-item-regexp peol t)) (progn (save-excursion (goto-char (1+ (match-beginning 0))) (setq depth (* YaTeX-environment-indent (cond ((looking-at "subsubsub") 3) ((looking-at "subsub") 2) ((looking-at "sub") 1) (t 0))))) (funcall indent-relative depth)) (YaTeX-reindent (or (car (cdr (YaTeX-get-item-info t inenv))) (+ (save-excursion (beginning-of-line) (YaTeX-current-indentation)) YaTeX-environment-indent)))) ) ((YaTeX-literal-p) ;verbatims (tab-to-tab-stop)) ((string-match "\\(tabular\\|array\\)" inenv) ;1.73 (let ((n 1)) (condition-case err (save-excursion (beginning-of-line) (skip-chars-forward "[ \t]") ;;(if (looking-at "&") (forward-char 1)) (require 'yatexenv) (setq n (car (YaTeX-array-what-column-internal)))) (error nil)) (YaTeX-reindent (+ (YaTeX-current-indentation) YaTeX-environment-indent (* (1- n) YaTeX-tabular-indentation))))) ((and inenv (not (equal "document" inenv))) (funcall indent-relative)) ((YaTeX-on-section-command-p YaTeX-sectioning-regexp) (require 'yatexsec) ;to know YaTeX-sectioning-level (setq sect (YaTeX-match-string 1)) (if (string-match "\\*$" sect) (setq sect (substring sect 0 -1))) (YaTeX-reindent (* (max (1- ;I want chapter to have indentation 0 (or (cdr (assoc sect YaTeX-sectioning-level)) 0)) 0) YaTeX-environment-indent))) ;;Default movement ((and (bolp) fill-prefix) (insert fill-prefix)) (t (save-excursion (beginning-of-line) (if fill-prefix (progn (delete-region (point) (progn (skip-chars-forward " \t") (point))) (insert fill-prefix)) (skip-chars-forward " \t") (if (bobp) nil (indent-relative-maybe)))) (skip-chars-forward " \t"))) ;;if current line is \begin, re-indent \end too (if (and (YaTeX-on-begin-end-p) (match-beginning 1)) (save-excursion ;;(beginning-of-line) ;;(search-forward "\\begin") (goto-char (match-beginning 0)) (setq depth (current-column)) (YaTeX-goto-corresponding-environment) (YaTeX-reindent depth))) (if (or (and NTT-jTeX (save-excursion (beginning-of-line) (looking-at "[ \t]"))) (save-excursion (beginning-of-line) (and (not (bobp)) (progn (backward-char 1) (re-search-backward "\\\\\\(\\(page\\)?ref\\|cite\\){" (point-beginning-of-line) t)) (goto-char (1- (match-end 0))) (> (save-excursion (condition-case () (progn (forward-list 1) (point)) (error (point-max)))) (point-end-of-line))))) (save-excursion (end-of-line) (let ((p (point))) (forward-line -1) (end-of-line) (or (= p (point)) (looking-at (regexp-quote YaTeX-comment-prefix)) (bobp) (bolp) (save-excursion (backward-word 1) (looking-at "\\sw+")) ;is not japanese string (insert YaTeX-comment-prefix))))))) (defun YaTeX-comment-line-break (&optional soft) "Call comment-indent-new-line and YaTeX-indent-line" (comment-indent-new-line soft) (YaTeX-indent-line)) (defun YaTeX-latex2e-p () (let ((b (current-buffer)) (ptn (concat YaTeX-ec "documentclass"))) (unwind-protect (or (save-excursion (search-backward ptn nil t)) (progn (YaTeX-visit-main t) (save-excursion (search-backward ptn nil t)))) (set-buffer b)))) (provide 'yatex) (defvar yatex-mode-load-hook nil "*List of functions to be called when yatex.el is loaded.") (if (and YaTeX-emacs-19 YaTeX-display-color-p (not (featurep 'yatex19))) (load "yatex19")) (load "yatexhks" t) ;;-------------------- Final hook jobs -------------------- (substitute-all-key-definition 'fill-paragraph 'YaTeX-fill-paragraph YaTeX-mode-map) (substitute-all-key-definition 'kill-buffer 'YaTeX-kill-buffer YaTeX-mode-map) (run-hooks 'yatex-mode-load-hook) ;; `History' was moved to ChangeLog ;----------------------------- End of yatex.el ----------------------------- ; Local variables: ; coding: sjis ; End: yatex_1.77+dfsg1/yatexhlp.el0000444000175000017500000002771012126310635014536 0ustar kurakura;;; yatexhlp.el --- YaTeX helper with LaTeX commands and macros ;;; ;;; (c)1994,1998,2004 by HIROSE Yuuji.[yuuji@yatex.org] ;;; Last modified Sat Sep 1 08:11:14 2012 on firestorm ;;; $Id: yatexhlp.el,v 1.77 2013/04/01 13:53:45 yuuji Rel $ ;;; Code: (let ((help-file (concat "YATEXHLP." (cond (YaTeX-japan "jp") (t "eng")))) (help-dir (cond ((and (boundp 'site-directory) site-directory) site-directory) ((string-match "\\.app/" doc-directory) ;For Emacs.app(Darwin) (expand-file-name "../site-lisp" doc-directory)) (YaTeX-emacs-19 (expand-file-name "../../site-lisp" doc-directory)) (t exec-directory)))) (defvar YaTeX-help-file (expand-file-name help-file help-dir) "*Help file of LaTeX/TeX commands or macros.") (defvar YaTeX-help-file-private (expand-file-name (concat "~/" help-file)) "*Private help file of LaTeX/TeX macros.")) (defvar YaTeX-help-delimiter "\C-_" "Delimiter of each help entry.") (defvar YaTeX-help-entry-map (copy-keymap YaTeX-mode-map) "Key map used in help entry.") (defvar YaTeX-help-file-current nil "Holds help file name to which the description in current buffer should go.") (defvar YaTeX-help-command-current nil "Holds command name on which the user currently write description.") (defvar YaTeX-help-saved-config nil "Holds window configruation before the editing of manual.") (defvar YaTeX-help-synopsis (cond (YaTeX-japan "【書式】") (t "[[ Synopsis ]]")) "Section header of synopsis.") (defvar YaTeX-help-description (cond (YaTeX-japan "【説明】") (t "[[ Description ]]")) "Section header of description.") (defvar YaTeX-help-mode-map nil "Keymap used in YaTeX-help buffer") (if YaTeX-help-mode-map nil (setq YaTeX-help-mode-map (make-sparse-keymap)) (let ((map YaTeX-help-mode-map)) (suppress-keymap map) (define-key map "j" '(lambda () (interactive) (scroll-up 1))) (define-key map "k" '(lambda () (interactive) (scroll-up -1))) (define-key map "n" 'next-line) (define-key map "p" 'previous-line) (define-key map " " 'scroll-up) (define-key map "\C-?" 'scroll-down) (define-key map "o" 'other-window) (define-key map "h" 'describe-bindings) (define-key map "q" 'YaTeX-help-quit) (define-key map "<" 'beginning-of-buffer) (define-key map ">" 'end-of-buffer))) (defun YaTeX-help-quit () "Close help and return to privious buffer" (interactive) (bury-buffer (current-buffer)) (set-window-configuration YaTeX-help-saved-config)) (defvar YaTeX-help-reference-regexp "]+\\)>" "Regexp of reference format of YaTeX-help file.") (defvar YaTeX-help-buffer "** YaTeX HELP **" "Help buffer name for yatexhlp") (defun YaTeX-help-entries () "Return the alist which contains all the entries in YaTeX-help file." (let (entries entry) (save-excursion (mapcar (function (lambda (help) (if (file-exists-p help) (progn (set-buffer (find-file-noselect help)) (save-excursion (goto-char (point-min)) (while (re-search-forward (concat "^" (regexp-quote YaTeX-help-delimiter) "\\(.+\\)$") nil t) (setq entry (buffer-substring (match-beginning 1) (match-end 1))) (or (assoc entry entries) (setq entries (cons (list entry) entries))))))))) (list YaTeX-help-file YaTeX-help-file-private))) entries)) (defvar YaTeX-help-entries nil "Helo entries alist.") (setq YaTeX-help-entries (YaTeX-help-entries)) (defun YaTeX-help-resolve-reference (buffer1 buffer2 &optional done-list) "Replace reference format in buffer1 with refered contents in buffer2." (let (ref ref-list beg end) (save-excursion (switch-to-buffer buffer1) (goto-char (point-min)) (while (re-search-forward YaTeX-help-reference-regexp nil t) (setq ref (buffer-substring (match-beginning 1) (match-end 1)) ref-list (cons (list ref) ref-list)) (replace-match "") (if (assoc ref done-list) nil ;already documented. (switch-to-buffer buffer2) (save-excursion (goto-char (point-min)) (if (re-search-forward (concat (regexp-quote YaTeX-help-delimiter) (regexp-quote ref) "$") nil t) (progn (setq beg (progn (forward-line 2) (point)) end (progn (re-search-forward (concat "^" (regexp-quote YaTeX-help-delimiter)) nil 1) (goto-char (match-beginning 0)) (forward-line -1) (while (and (bolp) (eolp) (not (bobp))) (forward-char -1)) (point))) (switch-to-buffer buffer1) (insert-buffer-substring buffer2 beg end)))) (switch-to-buffer buffer1))) (if beg (YaTeX-help-resolve-reference buffer1 buffer2 (append done-list ref-list)))))) (defun YaTeX-refer-help (command help-file &optional append) "Refer the COMMAND's help into HELP-FILE. \[Help-file format\] Where: is the value of YaTeX-help-delimiter. is newline. is newline or end of buffer." (let ((hfbuf (find-file-noselect help-file)) (hbuf (get-buffer-create YaTeX-help-buffer)) (curwin (selected-window)) sb se db de) (set-buffer hfbuf) (goto-char (point-min)) (if (null (let ((case-fold-search nil)) (re-search-forward (concat (regexp-quote YaTeX-help-delimiter) (regexp-quote command) "$") nil t))) nil ;if not found, return nil (forward-line 1) (setq sb (point) se (progn (forward-line 1) (point)) db (point) de (progn (re-search-forward (concat "^" (regexp-quote YaTeX-help-delimiter)) nil 1) (- (point) (length YaTeX-help-delimiter)))) (YaTeX-showup-buffer hbuf (function (lambda (x) (nth 3 (window-edges x)))) t) (set-buffer hbuf) (setq buffer-read-only nil) (if append (goto-char (point-max)) (erase-buffer)) (insert YaTeX-help-synopsis "\n") (insert-buffer-substring hfbuf sb se) (insert "\n" YaTeX-help-description "\n") (insert-buffer-substring hfbuf db de) (YaTeX-help-resolve-reference hbuf hfbuf (list (list command))) (goto-char (point-min)) (setq buffer-read-only t) (set-buffer-modified-p nil) (YaTeX-help-mode) (select-window curwin) t))) (defun YaTeX-help-mode () (interactive) (use-local-map YaTeX-help-mode-map) (setq major-mode 'yatex-help-mode mode-name "YaTeX-HELP")) (defun YaTeX-help-newline (&optional arg) (interactive "P") (if (and (= (current-column) 1) (= (preceding-char) ?.) (eolp)) (let ((cbuf (current-buffer))) (beginning-of-line) (delete-region (point) (progn (forward-line 1) (point))) (save-excursion (YaTeX-help-add-entry YaTeX-help-command-current YaTeX-help-file-current)) (set-window-configuration YaTeX-help-saved-config) (bury-buffer cbuf)) (newline arg))) (defun YaTeX-help-add-entry (command help-file) (let ((hfbuf (find-file-noselect help-file)) (dbuf (current-buffer)) beg end) (goto-char (point-min)) (re-search-forward (concat "^" (regexp-quote YaTeX-help-synopsis))) (forward-line 1) (setq beg (point)) (end-of-line) (setq end (point)) (set-buffer hfbuf) (goto-char (point-min)) (insert YaTeX-help-delimiter command "\n") (insert-buffer-substring dbuf beg end) (insert "\n") (set-buffer dbuf) (re-search-forward (concat "^" (regexp-quote YaTeX-help-description))) (forward-line 1) (setq beg (point)) (setq end (point-max)) (set-buffer hfbuf) (insert-buffer-substring dbuf beg end) (insert "\n\n") (forward-line -1) (delete-blank-lines) (let ((make-backup-files t)) (basic-save-buffer)) (bury-buffer hfbuf) (setq YaTeX-help-entries (cons (list command) YaTeX-help-entries)))) (defun YaTeX-help-prepare-entry (command help-file) "Read help description on COMMAND and add it to HELP-FILE." (let ((buf (get-buffer-create "**Description**")) (conf (current-window-configuration))) (YaTeX-showup-buffer buf (function (lambda (x) (nth 3 (window-edges x)))) t) (make-local-variable 'YaTeX-help-file-current) (make-local-variable 'YaTeX-help-command-current) (make-local-variable 'YaTeX-help-saved-config) (setq YaTeX-help-file-current help-file YaTeX-help-command-current command YaTeX-help-saved-config conf mode-name "Text" major-mode 'text) (erase-buffer) (insert YaTeX-help-synopsis "\n\n" YaTeX-help-description "\n\n") (define-key YaTeX-help-entry-map "\r" 'YaTeX-help-newline) (use-local-map YaTeX-help-entry-map) (message (cond (YaTeX-japan "入力を終えたら . のみ入力してRET") (t "Type only `.' and RET to exit."))))) (defun YaTeX-enrich-help (command) "Add the COMMAND's help to help file." (if (y-or-n-p (format "No help on `%s'. Create help?" command)) (YaTeX-help-prepare-entry command (if (y-or-n-p "Add help to global documentation?") YaTeX-help-file YaTeX-help-file-private)))) (defun YaTeX-help-sort (&optional help-file) "Sort help file HELP-FILE. If HELP-FILE is nil or called interactively, sort current buffer as a help file." (interactive) (if help-file (set-buffer (find-file-noselect help-file))) (sort-regexp-fields nil "\\(\\sw+\\)\\([^]+\\|\\s'\\)" "\\1" (point-min) (point-max))) (defun YaTeX-apropos-file (keyword help-file &optional append) (let ((hb (find-file-noselect help-file)) (ab (get-buffer-create YaTeX-help-buffer)) (sw (selected-window)) (head (concat "^" (regexp-quote YaTeX-help-delimiter))) pt command) (YaTeX-showup-buffer ab (function (lambda (x) (nth 3 (window-edges x))))) (select-window (get-buffer-window ab)) (set-buffer ab) ;assertion (setq buffer-read-only nil) (or append (erase-buffer)) (set-buffer hb) (goto-char (point-min)) (while (re-search-forward keyword nil t) (setq pt (point)) (re-search-backward head nil t) (setq command (buffer-substring (match-end 0) (point-end-of-line))) (switch-to-buffer ab) (goto-char (point-max)) (insert-char ?- (1- (window-width))) (insert (format "\n<<%s>>\n" command)) (YaTeX-refer-help command help-file t) ;append mode (setq buffer-read-only nil) (set-buffer hb) (goto-char pt) (if (re-search-forward head nil 1) (goto-char (1- (match-beginning 0))))) (setq buffer-read-only t) (select-window sw) pt)) ;;;###autoload (defun YaTeX-apropos (key) (interactive "sLaTeX apropos (regexp): ") (if (string= "" key) (error "Nothing to show")) (setq YaTeX-help-saved-config (current-window-configuration)) (or (YaTeX-apropos-file key YaTeX-help-file) (YaTeX-apropos-file key YaTeX-help-file-private t) (message "No matches found."))) ;;;###autoload (defun YaTeX-help () "Show help buffer of LaTeX/TeX commands or macros." (interactive) (let (p beg end command) (save-excursion (if (looking-at YaTeX-ec-regexp) (goto-char (match-end 0))) (setq p (point)) ;remember current position. (cond ((YaTeX-on-begin-end-p) ;;if on \begin or \end, extract its environment. (setq command (cond ((match-beginning 1) (buffer-substring (match-beginning 1) (match-end 1))) ((match-beginning 2) (buffer-substring (match-beginning 2) (match-end 2)))))) ((search-backward YaTeX-ec (point-beginning-of-line) t) (goto-char (setq beg (match-end 0))) (re-search-forward YaTeX-TeX-token-regexp (point-end-of-line) t) (setq end (point)) (if (and (<= beg p) (<= p end)) (setq command (buffer-substring beg end))))) (if (or (string= command "begin") (string= command "end")) (progn (search-forward "{" (point-end-of-line)) (setq beg (point)) (search-forward "}" (point-end-of-line)) (setq command (buffer-substring beg (match-beginning 0))))) (setq command (completing-read "Describe (La)TeX command: " YaTeX-help-entries nil nil command)) );end excursion (setq YaTeX-help-saved-config (current-window-configuration)) (or (YaTeX-refer-help command YaTeX-help-file) (YaTeX-refer-help command YaTeX-help-file-private) (YaTeX-enrich-help command)))) yatex_1.77+dfsg1/yatexlib.el0000444000175000017500000015651212126310635014524 0ustar kurakura;;; yatexlib.el --- YaTeX and yahtml common libraries ;;; ;;; (c)1994-2013 by HIROSE Yuuji.[yuuji@yatex.org] ;;; Last modified Mon Apr 1 22:44:06 2013 on firestorm ;;; $Id: yatexlib.el,v 1.77 2013/04/01 13:53:45 yuuji Rel $ ;;; Code: ;; General variables (defvar YaTeX-dos (memq system-type '(ms-dos windows-nt OS/2))) (defvar YaTeX-macos (memq system-type '(darwin))) (defvar YaTeX-emacs-19 (>= (string-to-int emacs-version) 19)) (defvar YaTeX-emacs-20 (>= (string-to-int emacs-version) 20)) (defvar YaTeX-emacs-21 (>= (string-to-int emacs-version) 21)) (defvar YaTeX-user-completion-table (if YaTeX-dos "~/_yatexrc" "~/.yatexrc") "*Default filename in which user completion table is saved.") (defvar YaTeX-display-color-p (or (and (fboundp 'display-color-p) (display-color-p)) (and (fboundp 'device-class) (eq 'color (device-class (selected-device)))) window-system) ; falls down lazy check.. "Current display's capability of expressing colors.") (defvar YaTeX-japan (or (boundp 'NEMACS) (boundp 'MULE) (and (boundp 'current-language-environment) (string-match "[Jj]apanese" current-language-environment))) "Whether yatex mode is running on Japanese environment or not.") ;; autoload from yahtml.el (autoload 'yahtml-inner-environment-but "yahtml" "yahtml internal func." t) (defvar latex-message-kanji-code 2 "*Kanji coding system latex command types out. 1 = Shift JIS, 2 = JIS, 3 = EUC. 4 = UTF-8") (defvar YaTeX-kanji-code-alist (cond ((boundp '*junet*) (list '(0 . *noconv*) (cons 1 (cond (YaTeX-dos (if (boundp '*sjis-dos*) *sjis-dos* *sjis*dos)) (YaTeX-macos (if (boundp '*sjis-mac*) *sjis-mac* *sjis*mac)) (t *sjis*))) '(2 . *junet*) '(3 . *euc-japan*))) ((and YaTeX-emacs-20 (featurep 'mule)) ;;(cdr-safe(assq 'coding-system (assoc "Japanese" language-info-alist))) (list '(0 . no-conversion) (cons 1 (cond (YaTeX-dos 'shift_jis-dos) (YaTeX-macos 'shift_jis-mac) ((member 'shift_jis (coding-system-list)) 'shift_jis-unix) (t 'sjis))) '(2 . iso-2022-jp-unix) '(3 . euc-jp-unix) '(4 . utf-8)))) "Kanji-code expression translation table.") (defvar YaTeX-inhibit-prefix-letter nil "*T for changing key definitions from [prefix] Letter to [prefix] C-Letter.") (defvar YaTeX-no-begend-shortcut nil "*T for disabling shortcut of begin-type completion, [prefix] b d, etc.") (defvar YaTeX-default-pop-window-height 10 "Default typesetting buffer height. If integer, sets the window-height of typesetting buffer. If string, sets the percentage of it. If nil, use default pop-to-buffer.") (defvar YaTeX-create-file-prefix-g nil "*Non-nil creates new file when [prefix] g on \\include{foo}.") (defvar YaTeX-nervous t "*If you are nervous about maintenance of yatexrc, set this value to T. And you will have the local dictionary.") (defvar YaTeX-use-italic-bold (string< "20" emacs-version) "*Non-nil tries to find italic/bold fontset. This variable is effective when font-lock is used. \it, \bf 内部での日本語が□になってしまう場合はこれをnilにして下さい。") ;----------- work variables ---------------------------------------- (defvar YaTeX-minibuffer-completion-map nil "Minibuffer completion key map that allows comma completion.") (if YaTeX-minibuffer-completion-map nil (setq YaTeX-minibuffer-completion-map (copy-keymap minibuffer-local-completion-map)) (define-key YaTeX-minibuffer-completion-map " " 'YaTeX-minibuffer-complete) (define-key YaTeX-minibuffer-completion-map "\t" 'YaTeX-minibuffer-complete)) (defvar YaTeX-typesetting-mode-map nil "Keymap used in YaTeX typesetting buffer") (if YaTeX-typesetting-mode-map nil (setq YaTeX-typesetting-mode-map (make-keymap)) ;(suppress-keymap YaTeX-typesetting-mode-map t) (define-key YaTeX-typesetting-mode-map " " 'YaTeX-jump-error-line) (define-key YaTeX-typesetting-mode-map "\C-m" 'YaTeX-send-string) (define-key YaTeX-typesetting-mode-map "1" 'delete-other-windows) (define-key YaTeX-typesetting-mode-map "0" 'delete-window) (define-key YaTeX-typesetting-mode-map "q" 'delete-window)) (defvar YaTeX-parent-file nil "*Main LaTeX source file name used when %#! expression doesn't exist.") (make-variable-buffer-local 'YaTeX-parent-file) ;---------- Define default key bindings on YaTeX mode map ---------- ;;;###autoload (defun YaTeX-define-key (key binding &optional map) "Define key on YaTeX-prefix-map." (if YaTeX-inhibit-prefix-letter (let ((c (aref key 0))) (cond ((and (>= c ?a) (<= c ?z)) (aset key 0 (1+ (- c ?a)))) ((and (>= c ?A) (<= c ?Z) (numberp YaTeX-inhibit-prefix-letter)) (aset key 0 (1+ (- c ?A)))) (t nil)))) (define-key (or map YaTeX-prefix-map) key binding)) ;;;###autoload (defun YaTeX-local-table-symbol (symbol) "Return the lisp symbol which keeps local completion table of SYMBOL." (intern (concat "YaTeX$" default-directory (symbol-name symbol)))) ;;;###autoload (defun YaTeX-sync-local-table (symbol) "Synchronize local variable SYMBOL. Copy its corresponding directory dependent completion table to SYMBOL." (if (boundp (YaTeX-local-table-symbol symbol)) (set symbol (symbol-value (YaTeX-local-table-symbol symbol))))) (defvar YaTeX-user-table-is-read nil "Flag that means whether user completion table has been read or not.") ;;;###autoload (defun YaTeX-read-user-completion-table (&optional forcetoread) "Append user completion table of LaTeX macros" (interactive) (let*((user-table (expand-file-name YaTeX-user-completion-table)) (local-table (expand-file-name (file-name-nondirectory user-table))) var localvar localbuf (curbuf (current-buffer)) sexp) (if YaTeX-user-table-is-read nil (message "Loading user completion table") (if (file-exists-p user-table) (load-file user-table) (message "Welcome to the field of YaTeX. I'm glad to see you!"))) (setq YaTeX-user-table-is-read t) (cond ((file-exists-p local-table) (set-buffer (setq localbuf (find-file-noselect local-table))) (widen) (goto-char (point-min)) (while (re-search-forward "(setq \\([^ \t\n]+\\)" nil t) (setq var (intern (buffer-substring (match-beginning 1) (match-end 1))) localvar (YaTeX-local-table-symbol var)) (goto-char (match-beginning 0)) (setq sexp (buffer-substring (point) (progn (forward-sexp) (point)))) (set-buffer curbuf) (or (assq var (buffer-local-variables)) (make-local-variable var)) (eval (read sexp)) (or (and (boundp localvar) (symbol-value localvar) (not forcetoread)) (set localvar (symbol-value var))) (set-buffer localbuf)) (kill-buffer localbuf))) (set-buffer curbuf))) ;;;###autoload (defun YaTeX-reload-dictionary () "Reload local dictionary. Use this function after editing ./.yatexrc." (interactive) (let ((YaTeX-user-table-is-read nil)) (YaTeX-read-user-completion-table t))) ;;;###autoload (defun YaTeX-lookup-table (word type) "Lookup WORD in completion table whose type is TYPE. This function refers the symbol tmp-TYPE-table, user-TYPE-table, TYPE-table. Typically, TYPE is one of 'env, 'section, 'fontsize, 'singlecmd." (if (symbolp type) (setq type (symbol-name type))) (or (assoc word (symbol-value (intern (concat "tmp-" type "-table")))) (assoc word (symbol-value (intern (concat "user-" type "-table")))) (assoc word (symbol-value (intern (concat type "-table")))))) ;;;###autoload (defun YaTeX-update-table (vallist default-table user-table local-table) "Update completion table if the car of VALLIST is not in current tables. Second argument DEFAULT-TABLE is the quoted symbol of default completion table, third argument USER-TABLE is user table which will be saved in YaTeX-user-completion-table, fourth argument LOCAL-TABLE should have the completion which is valid during current Emacs's session. If you want to make LOCAL-TABLE valid longer span (but restrict in this directory) create the file in current directory which has the same name with YaTeX-user-completion-table." (let ((car-v (car vallist)) key answer (file (file-name-nondirectory YaTeX-user-completion-table))) (cond ((assoc car-v (symbol-value default-table)) nil) ;Nothing to do ((setq key (assoc car-v (symbol-value user-table))) (if (equal (cdr vallist) (cdr key)) nil ;; if association hits, but contents differ. (message "%s's attributes turned into %s" (car vallist) (cdr vallist)) (set user-table (delq key (symbol-value user-table))) (set user-table (cons vallist (symbol-value user-table))) (YaTeX-update-dictionary YaTeX-user-completion-table user-table "user"))) ((setq key (assoc car-v (symbol-value local-table))) (if (equal (cdr vallist) (cdr key)) nil (message "%s's attributes turned into %s" (car vallist) (cdr vallist)) (set local-table (delq key (symbol-value local-table))) (set local-table (cons vallist (symbol-value local-table))) (set (YaTeX-local-table-symbol local-table) (symbol-value local-table)) (YaTeX-update-dictionary file local-table))) ;; All of above cases, there are some completion in tables. ;; Then update tables. (t (if (not YaTeX-nervous) (setq answer "u") (message (cond (YaTeX-japan "`%s'の登録先: U)ユーザ辞書 L)ローカル辞書 N)メモリ D)しない") (t "Register `%s' into: U)serDic L)ocalDic N)one D)iscard")) (if (> (length car-v) 23) (concat (substring car-v 0 10) "..." (substring car-v -9)) car-v)) (setq answer (char-to-string (read-char)))) (cond ((string-match answer "uy") (set user-table (cons vallist (symbol-value user-table))) (YaTeX-update-dictionary YaTeX-user-completion-table user-table "user") ) ((string-match answer "tl") (set local-table (cons vallist (symbol-value local-table))) (set (YaTeX-local-table-symbol local-table) (symbol-value local-table)) (YaTeX-update-dictionary file local-table)) ((string-match answer "d") nil) ;discard it (t (set default-table (cons vallist (symbol-value default-table))))))))) ;;;###autoload (defun YaTeX-cplread-with-learning (prom default-table user-table local-table &optional pred reqmatch init hsym) "Completing read with learning. Do a completing read with prompt PROM. Completion table is what DEFAULT-TABLE, USER-TABLE, LOCAL table are appended in reverse order. Note that these tables are passed by the symbol. Optional arguments PRED, REQMATH and INIT are passed to completing-read as its arguments PREDICATE, REQUIRE-MATCH and INITIAL-INPUT respectively. If optional 8th argument HSYM, history symbol, is passed, use it as history list variable." (YaTeX-sync-local-table local-table) (let*((table (append (symbol-value local-table) (symbol-value user-table) (symbol-value default-table))) (word (completing-read-with-history prom table pred reqmatch init hsym))) (if (and (string< "" word) (not (assoc word table))) (YaTeX-update-table (list word) default-table user-table local-table)) word)) ;;;###autoload (defun YaTeX-update-dictionary (file symbol &optional type) (let ((local-table-buf (find-file-noselect file)) (name (symbol-name symbol)) (value (symbol-value symbol))) (save-excursion (message "Updating %s dictionary..." (or type "local")) (set-buffer local-table-buf) (goto-char (point-max)) (search-backward (concat "(setq " name) nil t) (delete-region (point) (progn (forward-sexp) (point))) (delete-blank-lines) (insert "(setq " name " '(\n") (mapcar '(lambda (s) (insert (format "%s\n" (prin1-to-string s)))) value) (insert "))\n\n") (delete-blank-lines) (basic-save-buffer) (kill-buffer local-table-buf) (message "Updating %s dictionary...Done" (or type "local"))))) ;;;###autoload (defun YaTeX-define-begend-key-normal (key env &optional map) "Define short cut YaTeX-make-begin-end key." (YaTeX-define-key key (list 'lambda '(arg) '(interactive "P") (list 'YaTeX-insert-begin-end env 'arg)) map)) ;;;###autoload (defun YaTeX-define-begend-region-key (key env &optional map) "Define short cut YaTeX-make-begin-end-region key." (YaTeX-define-key key (list 'lambda nil '(interactive) (list 'YaTeX-insert-begin-end env t)) map)) ;;;###autoload (defun YaTeX-define-begend-key (key env &optional map) "Define short cut key for begin type completion. Define both strokes for normal and region mode. To customize YaTeX, user should use this function." (YaTeX-define-begend-key-normal key env map) (if YaTeX-inhibit-prefix-letter nil (YaTeX-define-begend-region-key (concat (upcase (substring key 0 1)) (substring key 1)) env))) ;;;###autoload (defun YaTeX-search-active-forward (string cmntrx &optional bound err cnt func) "Search STRING which is not commented out by CMNTRX. Optional arguments after BOUND, ERR, CNT are passed literally to search-forward or search-backward. Optional sixth argument FUNC changes search-function." (let ((sfunc (or func 'search-forward)) found md) (while (and (prog1 (setq found (funcall sfunc string bound err cnt)) (setq md (match-data))) (or (and (eq major-mode 'yatex-mode) (YaTeX-in-verb-p (match-beginning 0))) (save-excursion (goto-char (match-beginning 0)) (beginning-of-line) (re-search-forward cmntrx (match-beginning 0) t))))) (store-match-data md) found)) (defun YaTeX-re-search-active-forward (regexp cmntrx &optional bound err cnt) "Search REGEXP backward which is not commented out by regexp CMNTRX. See also YaTeX-search-active-forward." (YaTeX-search-active-forward regexp cmntrx bound err cnt 're-search-forward)) (defun YaTeX-search-active-backward (string cmntrx &optional bound err cnt) "Search STRING backward which is not commented out by regexp CMNTRX. See also YaTeX-search-active-forward." (YaTeX-search-active-forward string cmntrx bound err cnt 'search-backward)) (defun YaTeX-re-search-active-backward (regexp cmntrx &optional bound err cnt) "Search REGEXP backward which is not commented out by regexp CMNTRX. See also YaTeX-search-active-forward." (YaTeX-search-active-forward regexp cmntrx bound err cnt 're-search-backward)) (defun YaTeX-relative-path-p (path) "Return non-nil if PATH is not absolute one." (let ((md (match-data))) (unwind-protect (not (string-match "^\\(/\\|[a-z]:\\|\\\\\\).*/" file)) (store-match-data md)))) ;;;###autoload (defun YaTeX-switch-to-buffer (file &optional setbuf) "Switch to buffer if buffer exists, find file if not. Optional second arg SETBUF t make use set-buffer instead of switch-to-buffer." (interactive "Fswitch to file: ") (if (bufferp file) (setq file (buffer-file-name file)) (and (YaTeX-relative-path-p file) (eq major-mode 'yatex-mode) YaTeX-search-file-from-top-directory (save-excursion (YaTeX-visit-main t) (setq file (expand-file-name file))))) (let (buf (hilit-auto-highlight (not setbuf))) (cond ((setq buf (get-file-buffer file)) (funcall (if setbuf 'set-buffer 'switch-to-buffer) (get-file-buffer file)) buf) ((or YaTeX-create-file-prefix-g (file-exists-p file)) (or ;find-file returns nil but set current-buffer... (if setbuf (set-buffer (find-file-noselect file)) (find-file file)) (current-buffer))) (t (message "%s was not found in this directory." file) nil)))) ;;;###autoload (defun YaTeX-switch-to-buffer-other-window (file) "Switch to buffer if buffer exists, find file if not." (interactive "Fswitch to file: ") (and (eq major-mode 'yatex-mode) (stringp file) (YaTeX-relative-path-p file) YaTeX-search-file-from-top-directory (save-excursion (YaTeX-visit-main t) (setq file (expand-file-name file)))) (if (bufferp file) (setq file (buffer-file-name file))) (cond ((get-file-buffer file) (switch-to-buffer-other-window (get-file-buffer file)) t) ((or YaTeX-create-file-prefix-g (file-exists-p file)) (find-file-other-window file) t) (t (message "%s was not found in this directory." file) nil))) (defun YaTeX-get-file-buffer (file) "Return the FILE's buffer. Base directory is that of main file or current directory." (let (dir main (cdir default-directory)) (or (and (eq major-mode 'yatex-mode) YaTeX-search-file-from-top-directory (save-excursion (YaTeX-visit-main t) (get-file-buffer file))) (get-file-buffer file)))) (defun YaTeX-replace-format-sub (string format repl) (let ((beg (or (string-match (concat "^\\(%" format "\\)") string) (string-match (concat "[^%]\\(%" format "\\)") string))) (len (length format))) (if (null beg) string ;no conversion (concat (substring string 0 (match-beginning 1)) (or repl "") (substring string (match-end 1)))))) ;;;###autoload (defun YaTeX-replace-format (string format repl) "In STRING, replace first appearance of FORMAT to REPL as if function `format' does. FORMAT does not contain `%'" (let ((ans string) (case-fold-search nil)) (while (not (string= ans (setq string (YaTeX-replace-format-sub ans format repl)))) (setq ans string)) string)) ;;;###autoload (defun YaTeX-replace-formats (string replace-list) (let ((list replace-list)) (while list (setq string (YaTeX-replace-format string (car (car list)) (cdr (car list))) list (cdr list))) string)) ;;;###autoload (defun YaTeX-replace-format-args (string &rest args) "Translate the argument mark #1, #2, ... #n in the STRING into the corresponding real arguments ARGS." (let ((argp 1)) (while args (setq string (YaTeX-replace-format string (int-to-string argp) (car args))) (setq args (cdr args) argp (1+ argp)))) string) ;;;###autoload (defun rindex (string char) "Return the last position of STRING where character CHAR found." (let ((pos (1- (length string)))(index -1)) (catch 'rindex (while (>= pos 0) (cond ((= (aref string pos) char) (throw 'rindex pos)) (t (setq pos (1- pos)))))))) ;;;###autoload (defun point-beginning-of-line () (save-excursion (beginning-of-line)(point))) ;;;###autoload (defun point-end-of-line () (save-excursion (end-of-line)(point))) ;;;###autoload (defun YaTeX-showup-buffer (buffer &optional func select) "Make BUFFER show up in certain window (but current window) that gives the maximum value by the FUNC. FUNC should take an argument of its window object. Non-nil for optional third argument SELECT selects that window. This function never selects minibuffer window." (or (and (if (and YaTeX-emacs-19 select window-system) (get-buffer-window buffer t) (get-buffer-window buffer)) (progn (if select (goto-buffer-window buffer)) t)) (let ((window (selected-window)) (wlist (YaTeX-window-list)) win w (x 0)) (cond ((> (length wlist) 2) (if func (while wlist (setq w (car wlist)) (if (and (not (eq window w)) (> (funcall func w) x)) (setq win w x (funcall func w))) (setq wlist (cdr wlist))) (setq win (get-lru-window))) (select-window win) (switch-to-buffer buffer) (or select (select-window window))) ((= (length wlist) 2) ;(other-window 1);This does not work properly on Emacs-19 (select-window (get-lru-window)) (switch-to-buffer buffer) (or select (select-window window))) (t ;if one-window (cond ((and YaTeX-emacs-19 window-system (get-buffer-window buffer t)) nil) ;if found in other frame (YaTeX-default-pop-window-height (split-window-calculate-height YaTeX-default-pop-window-height) ;;(pop-to-buffer buffer) ;damn! emacs-19.30 (select-window (next-window nil 1)) (switch-to-buffer (get-buffer-create buffer)) (or select (select-window window))) (t nil))) )))) (cond ((fboundp 'screen-height) (fset 'YaTeX-screen-height 'screen-height) (fset 'YaTeX-screen-width 'screen-width) (fset 'YaTeX-set-screen-height 'set-screen-height) (fset 'YaTeX-set-screen-width 'set-screen-width)) ((fboundp 'frame-height) (fset 'YaTeX-screen-height 'frame-height) (fset 'YaTeX-screen-width 'frame-width) (fset 'YaTeX-set-screen-height 'set-frame-height) (fset 'YaTeX-set-screen-width 'set-frame-width)) (t (error "I don't know how to run YaTeX on this Emacs..."))) ;;;###autoload (defun split-window-calculate-height (height) "Split current window wight specified HEIGHT. If HEIGHT is number, make a new window that has HEIGHT lines. If HEIGHT is string, make a new window that occupies HEIGT % of screen height. Otherwise split window conventionally." (if (one-window-p t) (split-window (selected-window) (max (min (- (YaTeX-screen-height) (if (numberp height) (+ height 2) (/ (* (YaTeX-screen-height) (string-to-int height)) 100))) (- (YaTeX-screen-height) window-min-height 1)) window-min-height)))) ;;;###autoload (defun YaTeX-window-list () (let*((curw (selected-window)) (win curw) (wlist (list curw))) (while (not (eq curw (setq win (next-window win)))) (or (eq win (minibuffer-window)) (setq wlist (cons win wlist)))) wlist)) (if YaTeX-emacs-21 ;; Emacs-21's next-window returns other frame's window even if called ;; with argument ALL-FRAMES nil, when called from minibuffer context. ;; Therefore, check frame identity here. (defun YaTeX-window-list () (let*((curw (selected-window)) (win curw) (wlist (list curw)) (curf (window-frame curw))) (while (and (not (eq curw (setq win (next-window win)))) (eq curf (window-frame win))) (or (eq win (minibuffer-window)) (setq wlist (cons win wlist)))) wlist))) ;;;###autoload (defun substitute-all-key-definition (olddef newdef keymap) "Replace recursively OLDDEF with NEWDEF for any keys in KEYMAP now defined as OLDDEF. In other words, OLDDEF is replaced with NEWDEF where ever it appears." (if YaTeX-emacs-19 (substitute-key-definition olddef newdef keymap global-map) (mapcar (function (lambda (key) (define-key keymap key newdef))) (where-is-internal olddef keymap)))) ;;;###autoload (defun YaTeX-match-string (n &optional m) "Return (buffer-substring (match-beginning n) (match-beginning m))." (if (match-beginning n) (YaTeX-buffer-substring (match-beginning n) (match-end (or m n))))) ;;;###autoload (defun YaTeX-minibuffer-complete () "Complete in minibuffer. If the symbol 'delim is bound and is string, its value is assumed to be the character class of delimiters. Completion will be performed on the last field separated by those delimiters. If the symbol 'quick is bound and is 't, when the try-completion results in t, exit minibuffer immediately." (interactive) (save-restriction (narrow-to-region (if (fboundp 'field-beginning) (field-beginning (point-max)) (point-min)) (point-max)) (let ((md (match-data)) beg word compl (quick (and (boundp 'quick) (eq quick t))) (displist ;function to display completion-list (function (lambda () (with-output-to-temp-buffer "*Completions*" (display-completion-list (all-completions word minibuffer-completion-table))))))) (setq beg (if (and (boundp 'delim) (stringp delim)) (save-excursion (skip-chars-backward (concat "^" delim)) (point)) (point-min)) word (buffer-substring beg (point-max)) compl (try-completion word minibuffer-completion-table)) (cond ((eq compl t) (if quick (exit-minibuffer) (let ((p (point)) (max (point-max))) (unwind-protect (progn (goto-char max) (insert " [Sole completion]") (goto-char p) (sit-for 1)) (delete-region max (point-max)) (goto-char p))))) ((eq compl nil) (ding) (save-excursion (let (p) (unwind-protect (progn (goto-char (setq p (point-max))) (insert " [No match]") (goto-char p) (sit-for 2)) (delete-region p (point-max)))))) ((string= compl word) (funcall displist)) (t (delete-region beg (point-max)) (insert compl) (if quick (if (eq (try-completion compl minibuffer-completion-table) t) (exit-minibuffer) (funcall displist))))) (store-match-data md)))) (defun YaTeX-minibuffer-quick-complete () "Set 'quick to 't and call YaTeX-minibuffer-complete. See documentation of YaTeX-minibuffer-complete." (interactive) (let ((quick t)) (self-insert-command 1) (YaTeX-minibuffer-complete))) (defun YaTeX-yatex-buffer-list () (save-excursion (delq nil (mapcar (function (lambda (buf) (set-buffer buf) (if (eq major-mode 'yatex-mode) buf))) (buffer-list))))) (defun foreach-buffers (pattern job) "For each buffer which matches with PATTERN, do JOB." (let ((list (buffer-list))) (save-excursion (while list (set-buffer (car list)) (if (or (and (stringp pattern) (buffer-file-name) (string-match pattern (buffer-file-name))) (and (symbolp pattern) major-mode (eq major-mode pattern))) (eval job)) (setq list (cdr list)))))) (defun goto-buffer-window (buffer) "Select window which is bound to BUFFER. If no such window exist, switch to buffer BUFFER." (interactive "BGoto buffer: ") (if (stringp buffer) (setq buffer (or (get-file-buffer buffer) (get-buffer buffer)))) (if (get-buffer buffer) (cond ((get-buffer-window buffer) (select-window (get-buffer-window buffer))) ((and YaTeX-emacs-19 (get-buffer-window buffer t)) (let*((win (get-buffer-window buffer t)) (frame (window-frame win))) (select-frame frame) (raise-frame frame) (focus-frame frame) (select-window win) (set-mouse-position frame 0 0) (and (featurep 'windows) (fboundp 'win:adjust-window) (win:adjust-window)))) ((and (featurep 'windows) (fboundp 'win:get-buffer-window) (let ((w (win:get-buffer-window buffer))) (and w (win:switch-window w)))) (select-window (get-buffer-window buffer))) (t (switch-to-buffer buffer))))) ;; Here starts the functions which support gmhist-vs-Emacs19 compatible ;; reading with history. ;;;###autoload (defun completing-read-with-history (prompt table &optional predicate must-match initial hsym) "Completing read with general history: gmhist, Emacs-19." (let ((minibuffer-history (or (symbol-value hsym) (and (boundp 'minibuffer-history) minibuffer-history))) (minibuffer-history-symbol (or hsym 'minibuffer-history))) (prog1 (if (fboundp 'completing-read-with-history-in) (completing-read-with-history-in minibuffer-history-symbol prompt table predicate must-match initial) (completing-read prompt table predicate must-match initial)) (if (and YaTeX-emacs-19 hsym) (set hsym minibuffer-history))))) ;;;###autoload (defun read-from-minibuffer-with-history (prompt &optional init map read hsym) "Read from minibuffer with general history: gmhist, Emacs-19." (cond (YaTeX-emacs-19 (read-from-minibuffer prompt init map read hsym)) (t (let ((minibuffer-history-symbol hsym)) (read-from-minibuffer prompt init map read))))) ;;;###autoload (defun read-string-with-history (prompt &optional init hsym) "Read string with history: gmhist(Emacs-18) and Emacs-19." (cond (YaTeX-emacs-19 (read-from-minibuffer prompt init minibuffer-local-map nil hsym)) ((featurep 'gmhist-mh) (read-with-history-in hsym prompt init)) (t (read-string prompt init)))) (defvar YaTeX-skip-next-reader-char ?\C-j) (defun YaTeX-read-string-or-skip (&rest args) "Read string, or skip if last input char is \C-j." (if (equal (if (boundp 'last-input-event) last-input-event last-input-char) YaTeX-skip-next-reader-char) "" (apply 'read-string args))) (defun YaTeX-completing-read-or-skip (&rest args) "Do completing-read, or skip if last input char is \C-j." (if (equal (if (boundp 'last-input-event) last-input-event last-input-char) YaTeX-skip-next-reader-char) "" (apply 'completing-read args))) ;;;###autoload (fset 'YaTeX-rassoc (if (and nil (fboundp 'rassoc) (subrp (symbol-function 'rassoc))) (symbol-function 'rassoc) (function (lambda (key list) (let ((l list)) (catch 'found (while l (if (equal key (cdr (car l))) (throw 'found (car l))) (setq l (cdr l))))))))) (defun YaTeX-insert-file-contents (file visit &optional beg end) (cond ((and (string< "19" emacs-version) (not (featurep 'xemacs))) (insert-file-contents file visit beg end)) ((string-match "unix\\|linux" (symbol-name system-type)) (let ((default-process-coding-system (and (boundp '*noconv*) (list '*noconv*))) (file-coding-system (and (boundp '*noconv*) '*noconv*)) kanji-fileio-code (default-process-kanji-code 0)) (call-process shell-file-name file (current-buffer) nil (or (and (boundp 'shell-command-option) shell-command-option) "-c") (format "dd bs=1 count=%d | tail -c +%d" end beg)))) (t (insert-file-contents file)))) (defun YaTeX-split-string (str &optional sep null) "Split string STR by every occurrence of SEP(regexp). If the optional second argument SEP is nil, it defaults to \"[ \f\t\n\r\v]+\". Do not include null string by default. Non-nil for optional third argument NULL includes null string in a list." (let ((sep (or sep "[ \f\t\n\r\v]+")) list m) (while str (if (setq m (string-match sep str)) (progn (if (or (> m 0) null) (setq list (cons (substring str 0 m) list))) (setq str (substring str (match-end 0)))) (if (or null (string< "" str)) (setq list (cons str list))) (setq str nil))) (nreverse list))) ;;;###autoload (defun YaTeX-delete1 (elt list) "Delete" (let (e) (while (setq e (YaTeX-member elt list)) (setq list (delq (car e) list)))) list) (if (fboundp 'delete) (fset 'YaTeX-delete (symbol-function 'delete)) (fset 'YaTeX-delete (symbol-function 'YaTeX-delete1))) (defun YaTeX-member1 (elt list) (catch 'found (while list (if (equal elt (car list)) (throw 'found list)) (setq list (cdr list))))) (if (and (fboundp 'member) (subrp (symbol-function 'member))) (fset 'YaTeX-member (symbol-function 'member)) (fset 'YaTeX-member (symbol-function 'YaTeX-member1))) ;;; ;; Interface function for windows.el ;;; ;;;###autoload (fset 'YaTeX-last-key (if (fboundp 'win:last-key) 'win:last-key '(lambda () (if (boundp 'last-command-char) last-command-char last-command-event)))) (defun YaTeX-switch-to-window () "Switch to windows.el's window decided by last pressed key." (interactive) (or (featurep 'windows) (error "Why don't you use `windows.el'?")) (win-switch-to-window 1 (- (YaTeX-last-key) win:base-key))) ;;;###autoload (defun YaTeX-command-to-string (cmd) (if (fboundp 'shell-command-to-string) (funcall 'shell-command-to-string cmd) (let ((tbuf " *tmpout*")) (if (get-buffer-create tbuf) (kill-buffer tbuf)) (let ((standard-output (get-buffer-create tbuf))) (unwind-protect (save-excursion (call-process shell-file-name nil tbuf nil YaTeX-shell-command-option cmd) (set-buffer tbuf) (buffer-string)) (kill-buffer tbuf)))))) ;;;###autoload (defun YaTeX-reindent (col) "Remove current indentation and reindento to COL column." (save-excursion (beginning-of-line) (skip-chars-forward " \t") (if (/= col (current-column)) (progn (delete-region (point) (progn (beginning-of-line) (point))) (indent-to col)))) (skip-chars-forward " \t" (point-end-of-line))) (defun YaTeX-inner-environment (&optional quick) "Return current inner-most environment. Non-nil for optional argument QUICK restricts search bound to most recent sectioning command. Matching point is stored to property 'point of 'YaTeX-inner-environment, which can be referred by (get 'YaTeX-inner-environment 'point)." (put 'YaTeX-inner-environment 'point (point-min)) (put 'YaTeX-inner-environment 'indent 0) (let*((nest 0) (beg (YaTeX-replace-format-args (regexp-quote YaTeX-struct-begin) ;YaTeX-struct-begin ;=== TENTATIVE!! == YaTeX-struct-name-regexp (if (eq major-mode 'yahtml-mode) "\\s *.*" "") "")) (end (YaTeX-replace-format-args (regexp-quote YaTeX-struct-end) YaTeX-struct-name-regexp "" "")) (begend (concat "\\(" beg "\\)\\|\\(" end "\\)")) bound m0 (htmlp (eq major-mode 'yahtml-mode)) (open (concat "^" (or (cdr (assq major-mode '((yahtml-mode . "<")))) "{"))) (close (concat "^" (or (cdr(assq major-mode '((yahtml-mode . "\n\t >")))) "}")))) (save-excursion (if quick (setq bound (save-excursion (if htmlp ;;(re-search-backward YaTeX-sectioning-regexp nil 1) ;;(goto-char (point-min)) ;Is this enough? 97/6/26 (re-search-backward yahtml-indentation-boundary nil 1) (YaTeX-re-search-active-backward (concat YaTeX-ec-regexp "\\(" YaTeX-sectioning-regexp "\\)\\*?{") YaTeX-comment-prefix nil 1)) (or (bobp) (end-of-line)) (point)))) (if (catch 'begin (if (and (numberp bound) (< (point) bound)) (throw 'begin nil)) (while (YaTeX-re-search-active-backward begend YaTeX-comment-prefix bound t) (setq m0 (match-beginning 0)) (if (looking-at end) ;;(match-beginning 2) (setq nest (1+ nest)) (setq nest (1- nest))) (if (< nest 0) (progn (put 'YaTeX-inner-environment 'point m0) (goto-char m0) (put 'YaTeX-inner-environment 'indent (current-column)) (throw 'begin t))))) (YaTeX-buffer-substring (progn (skip-chars-forward open) (1+ (point))) (progn (skip-chars-forward close) (point))))))) (defun YaTeX-goto-corresponding-environment (&optional allow-mismatch noerr) "Go to corresponding begin/end enclosure. Optional argument ALLOW-MISMATCH allows mismatch open/clese. Use this for \left(, \right). Optional third argument NOERR causes no error for unballanced environment." (interactive) (if (not (YaTeX-on-begin-end-p)) nil (let ((p (match-end 0)) b0 b1 env (nest 0) regexp re-s (op (point)) (m0 (match-beginning 0)) ;whole matching (m1 (match-beginning 1)) ;environment in \begin{} (m2 (match-beginning 2)) ;environment in \end{} (m3 (match-beginning 3))) ;environment in \[ \] \( \) ;(setq env (regexp-quote (buffer-substring p (match-beginning 0)))) (if (cond (m1 ;if begin{xxx} (setq env (if allow-mismatch YaTeX-struct-name-regexp (regexp-quote (buffer-substring m1 (match-end 1))))) ; (setq regexp (concat "\\(\\\\end{" env "}\\)\\|" ; "\\(\\\\begin{" env "}\\)")) (setq regexp (concat "\\(" (YaTeX-replace-format-args (regexp-quote YaTeX-struct-end) env "" "") "\\)\\|\\(" (YaTeX-replace-format-args (regexp-quote YaTeX-struct-begin) env "" "") "\\)")) (setq re-s 're-search-forward)) (m2 ;if end{xxx} (setq env (if allow-mismatch YaTeX-struct-name-regexp (regexp-quote (buffer-substring m2 (match-end 2))))) ; (setq regexp (concat "\\(\\\\begin{" env "}\\)\\|" ; "\\(\\\\end{" env "}\\)")) (setq regexp (concat "\\(" (YaTeX-replace-format-args (regexp-quote YaTeX-struct-begin) env "" "") "\\)\\|\\(" (YaTeX-replace-format-args (regexp-quote YaTeX-struct-end) env "" "") "\\)")) (setq re-s 're-search-backward)) (m3 ;math environment (setq env (char-after (1+ m3)) regexp (format "\\(%s%s\\)\\|\\(%s%s\\)" YaTeX-ec-regexp (regexp-quote (cdr (assq env '((?( . ")") (?) . "(") (?[ . "]") (?] . "["))))) YaTeX-ec-regexp (regexp-quote (char-to-string env))) re-s (if (memq env '(?\( ?\[)) 're-search-forward 're-search-backward))) (t (if noerr nil (error "Corresponding environment not found.")))) (progn (while (and (>= nest 0) (funcall re-s regexp nil t)) (setq b0 (match-beginning 0) b1 (match-beginning 1)) (if (or (equal b0 m0) (YaTeX-literal-p b0)) nil (setq nest (if (equal b0 b1) (1- nest) (1+ nest))))) (if (< nest 0) (goto-char (match-beginning 0)) ;found. (goto-char op) (funcall (if noerr 'message 'error) "Corresponding environment `%s' not found." env) (sit-for 1) nil)))))) (defun YaTeX-end-environment () "Close opening environment" (interactive) (let ((env (YaTeX-inner-environment))) (if (not env) (error "No premature environment") (save-excursion (if (and (YaTeX-re-search-active-forward (concat "\\(" (YaTeX-replace-format-args YaTeX-struct-end env "" "") "\\)\\|\\(" (YaTeX-replace-format-args YaTeX-struct-begin env "" "") "\\)") YaTeX-comment-prefix nil t) (match-beginning 1)) ;is closing struc. (if (y-or-n-p (concat "Environment `" env "' may be already closed. Force close?")) nil (error "end environment aborted.")))) (message "") ;Erase (y or n) message. (YaTeX-insert-struc 'end env) (save-excursion (goto-char (or (get 'YaTeX-inner-environment 'point) (match-end 0))) (if (pos-visible-in-window-p) (sit-for (if YaTeX-dos 2 1)) (message "Matches with %s at line %d" (YaTeX-replace-format-args YaTeX-struct-begin env "" "") (count-lines (point-min) (point)))))))) (defun YaTeX-beginning-of-environment (&optional limit-search-bound end) "Goto the beginning of the current environment. Optional argument LIMIT-SEARCH-BOUND non-nil limits the search bound to most recent sectioning command. Non-nil for optional third argument END goes to end of environment." (interactive) (let ((op (point))) (if (YaTeX-inner-environment limit-search-bound) (progn (goto-char (get 'YaTeX-inner-environment 'point)) (and end (YaTeX-goto-corresponding-environment)) (if (interactive-p) (push-mark op)) (point))))) (defun YaTeX-end-of-environment (&optional limit-search-bound) "Goto the end of the current environment. Optional argument LIMIT-SEARCH-BOUND non-nil limits the search bound to most recent sectioning command." (interactive) (YaTeX-beginning-of-environment limit-search-bound t)) (defun YaTeX-mark-environment () "Mark current position and move point to end of environment." (interactive) (require 'yatexmth) (let ((curp (point))) (if (YaTeX-in-math-mode-p) (YaTeX-mark-mathenv) (if (and (YaTeX-on-begin-end-p) (match-beginning 1)) ;if on \\begin (progn (goto-char (match-end 0))) (if (= (char-after (point)) ?\\) nil ;if on \\end (skip-chars-backward "^\n\\\\") (or (bolp) (forward-char -1)))) (if (not (YaTeX-end-of-environment)) ;arg1 turns to match-beginning 1 (progn (goto-char curp) (error "Cannot found the end of current environment.")) (YaTeX-goto-corresponding-environment) (beginning-of-line) ;for confirmation (if (< curp (point)) (progn (message "Mark this environment?(y or n): ") (if (= (read-char) ?y) nil (goto-char curp) (error "Abort. Please call again at more proper position.")))) (set-mark-command nil) (YaTeX-goto-corresponding-environment) (end-of-line) (if (eobp) nil (forward-char 1)))))) (defun YaTeX-kill-buffer (buffer) "Make effort to show parent buffer after kill." (interactive "bKill buffer: ") (or (get-buffer buffer) (error "No such buffer %s" buffer)) (let ((pf YaTeX-parent-file)) (kill-buffer buffer) (and pf (get-file-buffer pf) (switch-to-buffer (get-file-buffer pf))))) (defun YaTeX-getset-builtin (key &optional value) "Read source built-in command of %# usage." (catch 'builtin (let*((bl (delq nil (list (current-buffer) (and YaTeX-parent-file (get-file-buffer YaTeX-parent-file))))) (tuple (cdr (assq major-mode '((yatex-mode "%#" . "\n") (yahtml-mode "\\|\n"))))) (leader (or (car tuple) "")) (closer (or (cdr tuple) "")) (prompt (format "Built-in for %s: " key))) (save-excursion (while bl (set-buffer (car bl)) (save-excursion (goto-char (point-min)) (if (and (re-search-forward (concat "^" (regexp-quote (concat leader key))) nil t) (not (eolp))) (throw 'builtin (let (b e w) (skip-chars-forward " \t" (point-end-of-line)) (setq b (point) e (if (re-search-forward closer nil t) (match-beginning 0) (point-end-of-line)) w (YaTeX-buffer-substring b e)) (if (null value) w (delete-region b e) (goto-char b) (if (symbolp value) (setq value (read-string prompt w))) (insert value) value))))) (setq bl (cdr bl))) ; not found (if (null value) nil ;not set mode, return simply nil (if (symbolp value) (setq value (read-string prompt))) (save-excursion (goto-char (point-min)) (insert leader key " " value "\n") value)))))) ;on set mode, return set value (defun YaTeX-get-builtin (key) "Read source built-in command of %# usage." (YaTeX-getset-builtin key)) ;;;VER2 (defun YaTeX-insert-struc (what env) (cond ((eq what 'begin) (insert (YaTeX-replace-format-args YaTeX-struct-begin env (YaTeX-addin env)))) ((eq what 'end) (insert (YaTeX-replace-format-args YaTeX-struct-end env))) (t nil))) (defun YaTeX-string-width (str) "Return the display width of string." (if (fboundp 'string-width) (string-width str) (length str))) (defun YaTeX-truncate-string-width (str width) (cond ((fboundp 'truncate-string-to-width) (truncate-string-to-width str width)) ((fboundp 'truncate-string) (truncate-string str width)) (t (substring str 0 width)))) (defun YaTeX-hex (str) "Return int expressed by hexadecimal string STR." (if (string< "20" emacs-version) (string-to-number str 16) (let ((md (match-data))) (unwind-protect (if (string-match "[^0-9a-f]" str) (error "Non hexadecimal character in %s" str) (let ((i 0) d) (setq str (downcase str)) (while (string< "" str) (setq d (+ 0 (string-to-char str)) ; + 0 for XEmacs i (+ (* 16 i) (- d (if (<= d ?9) ?0 (- ?a 10)))) str (substring str 1))) i)) (store-match-data md))))) ;;; Function for menu support (defun YaTeX-define-menu (keymap bindlist) "Define KEYMAP(symbol)'s menu-bindings according to BINDLIST. KEYMAP should be a quoted symbol of newly allocated keymap. BINDLIST consists of binding list. Each element is as follows. '(menusymbol DOC_String . contents) CONTENTS is one of lambda-form, interactive function, or other keymap. See yatex19.el for example." (cond ((featurep 'xemacs) (let (name) (if (keymapp (symbol-value keymap)) (progn (setq name (keymap-name (symbol-value keymap))) (set keymap nil)) (setq name (car (symbol-value keymap))) (set keymap (cdr (symbol-value keymap)))) (mapcar (function (lambda (bind) (setq bind (cdr bind)) (if (eq (car-safe (cdr bind)) 'lambda) (setcar (cdr bind) 'progn)) (if (stringp (car-safe (cdr bind))) (set keymap (cons (cdr bind) (symbol-value keymap))) (set keymap (cons (vector (car bind) (cdr bind) t) (symbol-value keymap)))))) bindlist) (set keymap (cons name (symbol-value keymap))))) (t (mapcar (function (lambda (bind) (define-key (symbol-value keymap) (vector (car bind)) (cdr bind)))) bindlist)))) ;;; ;; Emacs 21 compensational wrapper ;;; (defun YaTeX-minibuffer-begin () (if (fboundp 'field-beginning) (field-beginning (point-max)) (point-min))) (defun YaTeX-minibuffer-end () (if (fboundp 'field-end) (field-end (point-max)) (point-max))) (defun YaTeX-minibuffer-string () (buffer-substring (YaTeX-minibuffer-begin) (YaTeX-minibuffer-end))) (defun YaTeX-minibuffer-erase () (if (eq (selected-window) (minibuffer-window)) (if (fboundp 'delete-field) (delete-field) (erase-buffer)))) (fset 'YaTeX-buffer-substring (if (fboundp 'buffer-substring-no-properties) 'buffer-substring-no-properties 'buffer-substring)) ;;; ;; hilit19 vs. font-lock ;;; (defvar YaTeX-19-functions-font-lock-direct '(YaTeX-19-re-search-in-env)) (defun YaTeX-convert-pattern-hilit2fontlock (h19pa) "Convert hilit19's H19PA patterns alist to font-lock's one. This function is a makeshift for YaTeX and yahtml." (let ((ignorecase (not (null (car h19pa)))) (palist (cdr h19pa)) flpa i newface (mapping '((bold . YaTeX-font-lock-bold-face) (italic . YaTeX-font-lock-italic-face) (defun . font-lock-function-name-face) (define . font-lock-variable-name-face) (keyword . font-lock-keyword-face) (decl . YaTeX-font-lock-declaration-face) (label . YaTeX-font-lock-label-face) (crossref . YaTeX-font-lock-crossref-face) (include . YaTeX-font-lock-include-face) (formula . YaTeX-font-lock-formula-face) (delimiter . YaTeX-font-lock-delimiter-face) (string . ignore) (comment . ignore) ))) (while (setq i (car palist)) (setq newface (nth 2 i) newface (or (cdr (assq newface mapping)) newface)) (cond ((eq newface 'ignore) nil) ;no translation ((stringp (car i)) ;hiliting by regexp (setq flpa (cons (if (numberp (car (cdr i))) (list (car i) ;regexp (car (cdr i)) ;matching group number newface nil) ;'keep) ;keep is hilit19 taste (list (concat (car i) ;original regexp and.. ;;"[^" ;;(regexp-quote (substring (car (cdr i)) 0 1)) ;;"]+" ;for shortest match ".*" (car (cdr i))) 0 (list 'quote newface) nil)) ;;'keep)) flpa))) ((and (symbolp (car i)) (fboundp (car i))) (if (memq (car i) YaTeX-19-functions-font-lock-direct) ;; Put direct function call for it. ;; When calling this function, fontify entire matched string. (setq flpa (cons (list (list 'lambda (list 'dummy) ;dummy should be boundary (list (car i) (list 'quote (car (cdr i))))) (list 0 newface)) flpa)) (setq flpa (cons (list (car (cdr i)) ;regexp (list (list 'lambda (list 'dummy) '(goto-char (match-beginning 0)) (if (eq (nth 3 i) 'overwrite) nil '(remove-text-properties (point) (min (point-max) (1+ (point))) '(face nil font-lock-multiline nil))) (list 'let (list '(e (match-end 0)) (list 'm (list (car i) (car (cdr i))))) (list 'if 'm (list 'YaTeX-font-lock-fillin (list 'car 'm) (list 'cdr 'm) (list 'quote 'face) (list 'quote 'font-lock) (list 'quote newface)) '(goto-char e) )) nil) ;retun nil to cheat font-lock nil nil)) ;pre-match, post-match both nil flpa))))) (setq palist (cdr palist)));while (if (featurep 'xemacsp) (nreverse flpa) flpa))) (if (and (boundp 'YaTeX-use-font-lock) YaTeX-use-font-lock) (require 'font-lock)) (cond ((and (featurep 'font-lock) (fboundp 'defface)) ;; In each defface, '(class static-color) is for Emacs-21 -nw ;; '(class tty) is for XEmacs-21 -nw (defface YaTeX-font-lock-label-face '((((class static-color)) (:foreground "yellow" :underline t)) (((type tty)) (:foreground "yellow" :underline t)) (((class color) (background dark)) (:foreground "pink" :underline t)) (((class color) (background light)) (:foreground "red" :underline t)) (t (:bold t :underline t))) "Font Lock mode face used to highlight labels." :group 'font-lock-faces) (defvar YaTeX-font-lock-label-face 'YaTeX-font-lock-label-face) (defface YaTeX-font-lock-declaration-face '((((class color) (background dark)) (:foreground "cyan")) (((class color) (background light)) (:foreground "RoyalBlue")) (t (:bold t :underline t))) "Font Lock mode face used to highlight some declarations." :group 'font-lock-faces) (defvar YaTeX-font-lock-declaration-face 'YaTeX-font-lock-declaration-face) (defface YaTeX-font-lock-include-face '((((class color) (background dark)) (:foreground "Plum1")) (((class color) (background light)) (:foreground "purple")) (t (:bold t :underline t))) "Font Lock mode face used to highlight expression for including." :group 'font-lock-faces) (defvar YaTeX-font-lock-include-face 'YaTeX-font-lock-include-face) (defface YaTeX-font-lock-formula-face '((((class static-color)) (:bold t)) (((type tty)) (:bold t)) (((class color) (background dark)) (:foreground "khaki" :bold t)) (((class color) (background light)) (:foreground "Goldenrod")) (t (:bold t :underline t))) "Font Lock mode face used to highlight formula." :group 'font-lock-faces) (defvar YaTeX-font-lock-formula-face 'YaTeX-font-lock-formula-face) (defface YaTeX-font-lock-delimiter-face '((((class static-color)) (:bold t)) (((type tty)) (:bold t)) (((class color) (background dark)) (:foreground "saddlebrown" :background "ivory" :bold t)) (((class color) (background light)) (:foreground "red")) (t (:bold t :underline t))) "Font Lock mode face used to highlight delimiters." :group 'font-lock-faces) (defvar YaTeX-font-lock-delimiter-face 'YaTeX-font-lock-delimiter-face) (defface YaTeX-font-lock-math-sub-face '((((class static-color)) (:bold t)) (((type tty)) (:bold t)) (((class color) (background dark)) (:foreground "khaki" :bold t :underline t)) (((class color) (background light)) (:foreground "Goldenrod" :underline t)) (t (:bold t :underline t))) "Font Lock mode face used to highlight subscripts in formula." :group 'font-lock-faces) (defvar YaTeX-font-lock-math-sub-face 'YaTeX-font-lock-math-sub-face) (defface YaTeX-font-lock-math-sup-face '((((class static-color)) (:bold t)) (((type tty)) (:bold t)) (((class color) (background dark)) (:bold nil :foreground "ivory" :background "lightyellow4")) (((class color) (background light)) (:underline t :foreground "gold")) (t (:bold t :underline t))) "Font Lock mode face used to highlight superscripts in formula." :group 'font-lock-faces) (defvar YaTeX-font-lock-math-sup-face 'YaTeX-font-lock-math-sup-face) (defface YaTeX-font-lock-crossref-face '((((class color) (background dark)) (:foreground "lightgoldenrod")) (((class color) (background light)) (:foreground "DarkGoldenrod")) (t (:bold t :underline t))) "Font Lock mode face used to highlight cross references." :group 'font-lock-faces) (defvar YaTeX-font-lock-crossref-face 'YaTeX-font-lock-crossref-face) (defface YaTeX-font-lock-bold-face '((t (:bold t))) "Font Lock mode face used to express bold itself." :group 'font-lock-faces) (defvar YaTeX-font-lock-bold-face 'YaTeX-font-lock-bold-face) (defface YaTeX-font-lock-italic-face '((t (:italic t))) "Font Lock mode face used to express italic itself." :group 'font-lock-faces) (defvar YaTeX-font-lock-italic-face 'YaTeX-font-lock-italic-face) ;; Make sure the 'YaTeX-font-lock-{italic,bold}-face is bound with ;; italic/bold fontsets (if (and (fboundp 'fontset-list) YaTeX-use-italic-bold) (let ((flist (fontset-list)) fnt italic bold (df (or (and (fboundp 'face-font-name) (face-font-name 'default)) (face-font 'default) (face-font 'italic) (face-font 'bold) "giveup!")) sz medium-i bold-r) (string-match "^-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-\\(\\([0-9]+\\)\\)" df) (setq sz (or (match-string 1 df) "16")) (setq medium-i (format "-medium-i-[^-]+--%s" sz) bold-r (format "-bold-r-[^-]+--%s" sz)) (while flist (setq fnt (car flist)) (condition-case err (cond ((and (string-match medium-i fnt) (null italic)) (set-face-font 'YaTeX-font-lock-italic-face (setq italic fnt))) ((and (string-match bold-r fnt) (null bold)) (set-face-font 'YaTeX-font-lock-bold-face (setq bold fnt)))) (error nil)) (setq flist (cdr flist))))) ;;Borrowed from XEmacs's font-lock.el (defsubst YaTeX-font-lock-fillin (start end setprop markprop value &optional object) "Fill in one property of the text from START to END. Arguments PROP and VALUE specify the property and value to put where none are already in place. Therefore existing property values are not overwritten. Optional argument OBJECT is the string or buffer containing the text." (let ((start (text-property-any start end markprop nil object)) next (putfunc (if (fboundp 'put-nonduplicable-text-property) 'put-nonduplicable-text-property 'put-text-property))) (if (eq putfunc 'put-text-property) (setq markprop setprop)) (while start (setq next (next-single-property-change start markprop object end)) (funcall putfunc start next setprop value object) (funcall putfunc start next markprop value object) (setq start (text-property-any next end markprop nil object))))) (defun YaTeX-warning-font-lock (mode) (let ((sw (selected-window))) ;;(pop-to-buffer (format " *%s warning*" mode)) ;;(erase-buffer) (momentary-string-display (cond (YaTeX-japan (concat mode " は、既に font-lock に対応しました。\n" "~/.emacs などにある\n" "\t(put 'yatex-mode 'font-lock-keywords 'tex-mode)\n" "\t(put 'yahtml-mode 'font-lock-keywords 'html-mode)\n" "などの間に合わせの記述はもはや不要です。")) (t (concat mode " now supports the font-lock by itself.\n" "So you can remove the descriptions such as\n" "\t(put 'yatex-mode 'font-lock-keywords 'tex-mode)\n" "\t(put 'yahtml-mode 'font-lock-keywords 'html-mode)\n" "in your ~/.emacs file. Thank you."))) (point)) (select-window sw))) )) (defun YaTeX-assoc-regexp (elt alist) "Like assoc, return a list of whose car match with ELT. Search from ALIST. Note that each car of cons-cell is regexp. ELT is a plain text to be compared by regexp." (let (x) (catch 'found (while alist (setq x (car (car alist))) (if (string-match x elt) (throw 'found (car alist))) (setq alist (cdr alist)))))) (defun YaTeX-push-to-kill-ring (string) "Push STRING to kill-ring, then show guidance message." (and (stringp string) (string< "" string) (let ((key (key-description (where-is-internal 'yank nil t))) (msg (if YaTeX-japan " をkill-ringに入れました。次のyank(%s)で貼付できます" " is stored into kill-ring. Paste it by yank(%s)."))) (kill-new string) (message (concat "`%s'" msg) string key)))) (defun YaTeX-elapsed-time (before after) "Get elapsed time from BEFORE and AFTER, which are given from currente-time." (if (fboundp 'float) ;Then, current-time function should be. (let ((mil (float 1000000))) ;To protect parse error before 19 (+ (* (- (nth 0 after) (nth 0 before)) 65536) (- (nth 1 after) (nth 1 before)) (- (/ (nth 2 after) mil) (/ (nth 2 before) mil)))))) ;;; ;; Functions for the Installation time ;;; (defun bcf-and-exit () "Byte compile rest of argument and kill-emacs." (if command-line-args-left (let ((load-path (cons "." load-path))) (and (fboundp 'set-language-environment) (featurep 'mule) (set-language-environment "Japanese")) (mapcar 'byte-compile-file command-line-args-left) (kill-emacs)))) (defun tfb-and-exit () "Texinfo-format-buffer and kill-emacs." (if command-line-args-left (let ((load-path (cons ".." load-path))) (and (fboundp 'set-language-environment) (featurep 'mule) (set-language-environment "Japanese")) (mapcar (function (lambda (arg) (find-file arg) (texinfo-format-buffer) (cond ((fboundp 'set-buffer-file-coding-system) (set-buffer-file-coding-system 'sjis-dos)) ((fboundp 'set-file-coding-system) (set-file-coding-system '*sjis*dos)) ((boundp 'NEMACS) (set (make-local-variable 'kanji-fileio-code) 1))) (let ((coding-system-for-write buffer-file-coding-system)) (basic-save-buffer)))) command-line-args-left) (kill-emacs)))) (provide 'yatexlib) ; Local variables: ; fill-prefix: ";;; " ; paragraph-start: "^$\\| \\|;;;$" ; paragraph-separate: "^$\\| \\|;;;$" ; coding: sjis ; End: yatex_1.77+dfsg1/makefile0000644000175000017500000001370512126310417014055 0ustar kurakura# # Makefile for YaTeX/yahtml # # Edit these variables to be suitable for your site PREFIX = /usr/local ## mule2 #EMACS = mule #EMACSDIR= ${PREFIX}/lib/${EMACS} ## emacs20 or later EMACS = emacs EMACSDIR= ${PREFIX}/share/${EMACS} ## XEmacs #EMACS = xemacs #EMACSDIR= ${PREFIX}/lib/${EMACS} ## Meadow (Sample) #EMACS = meadow #EMACSDIR = c:/usr/local/meadow ## CarbonEmacs on Darwin (Sample) #EMACS = /Applications/Emacs.app/Contents/MacOS/Emacs #PREFIX = /Applications/Emacs.app/Contents/Resources #EMACSDIR = ${PREFIX} LISPDIR = ${EMACSDIR}/site-lisp/yatex # LISPDIR = ${EMACSDIR}/site-packages/lisp/yatex DOCDIR = ${LISPDIR}/docs HELPDIR = ${EMACSDIR}/site-lisp INFODIR = ${PREFIX}/info TAR = tar INSTALL = install -c -m 444 MKDIR = mkdir -p INSTINFO= install-info # Comment out below if you are using Emacs Windows(meadow, etc) GEO = -geometry 80x20+0+0 ################### # Do not edit below ################### # make install to install YaTeX into public space # make install-nw same as above, but -nw mode, or Emacs18(Nemacs) # make ajimi to feel taste # make ajimi-nw same as above, but -nw mode # make package to create package for relase # make yahtmlpack to create package for relase # make clean to delete all producted files # make ci to check in all # make co to check out all MVER = 1.77 LISP = ${LISP18} ${LISP19} YAHTML = yahtml.el COMMON = yatexlib.el yatexprc.el LISP18 = comment.el yatex.el yatexadd.el yatexgen.el yatexenv.el \ ${COMMON} \ yatexmth.el yatexhks.el yatexhlp.el \ yatexm-o.el yatexsec.el yatexhie.el yatexpkg.el ${YAHTML} LISP19 = yatex19.el DOCS = ${DOCSRC} ${DOCOBJ} ${NEWS} NEWS = yatex.new DOCHTML = docs/htmlqa docs/htmlqa.eng docs/yahtmlj.tex docs/yahtmle.tex DOCSRC = docs/yatexj.tex docs/yatexe.tex \ docs/yatex.ref docs/yatexref.eng \ docs/yatexadd.doc docs/yatexgen.doc \ docs/qanda docs/qanda.eng ${DOCHTML} DOCOBJ = docs/yatexj docs/yatexe docs/yahtmlj docs/yahtmle HELP = help/YATEXHLP.jp help/YATEXHLP.eng MANIFEST= manifest EXTRA = dir install 00readme makefile readme.meadow.j newpage.rb DISTRIB = ${EXTRA} ${LISP} ${DOCS} ${MANIFEST} ${HELP} RCSFILE = ${LISP} ${NEWS} ${DOCSRC} ${HELP} YAHTMLLISP = ${YAHTML} ${COMMON} YAHTMLDIST = ${YAHTMLLISP} install 00readme makefile newpage.rb PACK = `ls ${DISTRIB}` TMPDIR = /tmp VERSION = `head -20 yatex.el|awk -F'"' '/revision/{print $$2}'` PACKDIR = ${TMPDIR}/yatex${VERSION} all: @echo "Edit this makefile first." @echo 'Type "make install" to install YaTeX.' @echo 'Type "make install-yahtml" to install yahtml.' @echo 'If you cling to elc files. type "make elc" before make install' # @echo "If you don't use X-clinet of Emacs," # @echo 'type "make install-nw" instead.' install: install-real #install-yahtml: bytecompile-yahtml install-yahtml: [ -d ${LISPDIR} ] || mkdir ${LISPDIR} for f in *.el; do \ rm -f ${LISPDIR}/$${f}c; \ done ${INSTALL} *.el* ${LISPDIR} install-real: if [ ! -d ${LISPDIR} ]; then ${MKDIR} ${LISPDIR}; fi if [ ! -d ${DOCDIR} ]; then ${MKDIR} ${DOCDIR}; fi if [ ! -d ${INFODIR} ]; then ${MKDIR} ${INFODIR}; fi for f in *.el; do \ rm -f ${LISPDIR}/$${f}c; \ done ${INSTALL} *.el* ${NEWS} ${LISPDIR} ${INSTALL} ${DOCSRC} ${DOCDIR} ${INSTALL} ${DOCOBJ} ${INFODIR} ${INSTALL} ${HELP} ${HELPDIR} @echo "--------------------------------" @echo "If you have install-info command, type 'make install-info'." @echo "If not, add next lines into your site's info dir manually." @cat dir install-info: for f in ${DOCOBJ}; do \ b=`basename $$f | sed 's,/.*,,'`; \ ${INSTINFO} --entry="`grep $$b dir`" --section=TeX \ --section=Emacs $${f} ${INFODIR}/dir; \ done install-nw: bytecompile-nw install-real elc: bytecompile bytecompile: lp if [ "$$DISPLAY"x = ""x ]; then \ echo "Set DISPLAY environment variable!!"; exit 1; fi ${EMACS} -q ${GEO} -l ./yatexlib.el -e bcf-and-exit ${LISP} bytecompile-nw: lp1 ${EMACS} -batch -l ./yatexlib.el -e batch-byte-compile ${LISP18} bytecompile-yahtml: if [ "$$DISPLAY"x = ""x ]; then \ echo "Set DISPLAY environment variable!!"; exit 1; fi ${EMACS} -q -g 80x20+0+0 -l ./yatexlib.el -e bcf-and-exit ${YAHTMLLISP} lp: echo '(setq load-path (cons "." load-path))' > lp.el echo '(load-file "./yatexlib.el")' >>lp.el lp1: lp echo '(load-file "./yatex.el")' >>lp.el echo '(load-file "./comment.el")' >>lp.el lp2: echo '(setq load-path (cons "'`pwd`'" load-path))' >>lp.el echo '(setq auto-mode-alist' >>lp.el echo '(cons (cons "\\.tex" '"'yatex-mode) auto-mode-alist))" >>lp.el echo '(load-library "yatex")' >>lp.el ajimi: lp lp2 ${EMACS} -l ./lp.el -e yatex-mode ajimi-nw: lp lp2 ${EMACS} -nw -l ./lp.el -e yatex-mode clean: rm -f *.elc *~ lp.el info: docs/yatexj docs/yatexe docs/yahtmlj docs/yahtmle docs/yatexj: docs/yatexj.tex (cd docs; ${EMACS} -batch -l ../yatexlib.el -e tfb-and-exit yatexj.tex) docs/yatexe: docs/yatexe.tex (cd docs; ${EMACS} -batch -l ../yatexlib.el -e tfb-and-exit yatexe.tex) docs/yahtmlj: docs/yahtmlj.tex (cd docs;${EMACS} -batch -l ../yatexlib.el -e tfb-and-exit yahtmlj.tex) docs/yahtmle: docs/yahtmle.tex (cd docs;${EMACS} -batch -l ../yatexlib.el -e tfb-and-exit yahtmle.tex) package: info @-mkdir ${PACKDIR} @tar cf - ${PACK} | (cd ${PACKDIR}; tar xf -) ( version=${VERSION}; cd ${TMPDIR}; \ ${TAR} vzcf ${TMPDIR}/yatex$$version.tar.gz yatex$$version) yahtmlpack: @-mkdir ${PACKDIR} @tar cf - ${YAHTMLDIST} | (cd ${PACKDIR}; tar xf -) ( version=${VERSION}; cd ${TMPDIR}; \ ${TAR} vzcf ${TMPDIR}/yahtml$$version.tar.gz yatex$$version) ci: ci -r${VERSION} -sRel -f ${RCSFILE} ci -u${VERSION} makefile 00readme co: co ${RCSFILE} co-l: co -l ${RCSFILE} tci: ci -l${VERSION}.0 -Ncurrent ${RCSFILE} makefile dostci: ci -l${MVER}.0 -Ncurrent @rcsfile gohome: zip -u -r /com/okoma/yuuji/tmp/dosconv/yatex.zip . \ -x '*RCS/*' -x 'texinfo/*' RSYNCDIR = ${HOME}/http/yatex/rsync/yatex #sync: # @-mkdir ${PACKDIR} # @tar cf - ${PACK} | (cd ${PACKDIR}; tar xf -) # syncdir -A -x CVS ${PACKDIR} ${RSYNCDIR} # (cd ${RSYNCDIR}; cvs ci -m '') # rm -rf ${PACKDIR} yatex_1.77+dfsg1/yatexpkg.el0000444000175000017500000001635512126310636014540 0ustar kurakura;;; yatexpkg.el --- YaTeX package manager ;;; ;;; (c)2003-2013 by HIROSE, Yuuji [yuuji@yatex.org] ;;; Last modified Mon Apr 1 22:44:31 2013 on firestorm ;;; $Id: yatexpkg.el,v 1.77 2013/04/01 13:53:45 yuuji Rel $ ;;; Code: (defvar YaTeX-package-ams-envs (mapcar 'car YaTeX-ams-env-table)) (defvar YaTeX-package-alist-default '(("version" (env "comment") ;by tsuchiyapine.kuee.kyoto-u.ac.jp (section "includeversion" "excludeversion")) ("plext" (section "bou")) ;by yas.axisma.mni.ne.jp ("url" (section "url")) ;by fujiedajaist.ac.jp ("fancybox" (section "shadowbox" "doublebox" "ovalbox" "Ovalbox")) ("slashbox" (section "slashbox" "backslashbox")) ("pifont" (section "ding")) ("longtable" (env "longtable")) ("ascmac" (env "screen" "boxnote" "shadebox" "itembox") (maketitle "return" "Return" "yen") (section "keytop") ("mask") ("maskbox")) ("bm" (section "bm")) ;by aoyamale.chiba-u.ac.jp ("alltt" (env "alltt")) ("misc" (section "verbfile" "listing")) ("eclbkbox" (env "breakbox")) ("supertabular" (env "supertabular")) ("amsmath" (env . YaTeX-package-ams-envs) (section "tag" "tag*")) ("amssymb" (maketitle "leqq" "geqq" "mathbb" "mathfrak" "fallingdotseq" "lll" "ggg")) ;very few. Please tell us! ("graphicx" (section "includegraphics" "rotatebox" "scalebox" "resizebox" "reflectbox") (option . YaTeX-package-graphics-driver-alist)) ("color" (section "textcolor" "colorbox" "pagecolor" "color") (option . YaTeX-package-graphics-driver-alist)) ("ulem" (section "uline" "uuline" "uwave") (option ("normalem"))) ("multicol" (env "multicols"))) "Default package vs. macro list. Alists contains '(PACKAGENAME . MACROLIST) PACKAGENAME Basename of package(String). MACROLIST List of '(TYPE . MACROS) TYPE One of 'env, 'section or 'maketitle according to completion-type MACROS List of macros If TYPE is 'option, its cdr is alist of completion candidates for that package. Its cdr can be a symbol whose value is alist. An good example is the value of YaTeX-package-alist-default.") (defvar YaTeX-package-graphics-driver-alist '(("dvips") ("xdvi") ("dvipdf") ("pdftex") ("dvipsone") ("dviwindo") ("emtex") ("dviwin") ("oztex") ("textures") ("pctexps") ("pctexwin") ("pctexhp") ("pctex32") ("truetex") ("tcidvi") ("vtex")) "Drivers alist of graphics/color stylefile's supporting deveces. This list is taken from %% graphics.dtx Copyright (C) 1994 David Carlisle Sebastian Rahtz %% Copyright (C) 1995 1996 1997 1998 David Carlisle as of 2004/1/19. Thanks.") (defvar YaTeX-package-alist-private nil "*User defined package vs. macro list. See also YaTeX-package-alist-default") (defun YaTeX-package-lookup (macro &optional type) "Look up a package which contains a definition of MACRO. Optional second argument TYPE limits the macro type. TYPE is a symbol, one of 'env, 'section, 'maketitle." (let ((list (append YaTeX-package-alist-private YaTeX-package-alist-default)) element x val pkg pkglist r) (while list (setq element (car list) pkg (car element) element (cdr element)) (if (setq r (catch 'found (while element (setq x (car element) val (cdr x)) (if (symbolp val) (setq val (symbol-value val))) (and (or (null type) (eq type (car x))) (YaTeX-member macro val) (throw 'found (car x))) ;car x is type (setq element (cdr element))))) (setq pkglist (cons (cons pkg r) pkglist))) (setq list (cdr list))) pkglist)) (defun YaTeX-package-option-lookup (pkg) "Look up options for specified pkg and returne them in alist form. Just only accocing against the alist of YaTeX-package-alist-*" (let ((l (cdr (assq 'option (assoc pkg (append YaTeX-package-alist-private YaTeX-package-alist-default)))))) (if (symbolp l) (symbol-value l) l))) (defvar YaTeX-package-resolved-list nil "List of macros whose package is confirmed to be loaded.") (defun YaTeX-package-auto-usepackage (macro type) "(Semi)Automatically add the \\usepackage line to main-file. Search the usepackage for MACRO of the TYPE." (let ((cb (current-buffer)) (wc (current-window-configuration)) (usepackage (concat YaTeX-ec "usepackage")) (pkglist (YaTeX-package-lookup macro type)) (usepkgrx (concat YaTeX-ec-regexp "\\(usepackage\\|include\\)\\b")) (register '(lambda () (set-buffer cb) (set (make-local-variable 'YaTeX-package-resolved-list) (cons macro YaTeX-package-resolved-list)))) (begdoc (concat YaTeX-ec "begin{document}")) pb pkg optlist (option "") mb0 uspkgargs) (if (or (YaTeX-member macro YaTeX-package-resolved-list) (null pkglist)) nil ;nothing to do ;; Search `usepackage' into main-file (YaTeX-visit-main t) ;set buffer to parent file (setq pb (current-buffer)) (save-excursion (save-restriction (if (catch 'found (goto-char (point-min)) (YaTeX-search-active-forward ;if search fails, goto eob begdoc YaTeX-comment-prefix nil 1) (while ;(YaTeX-re-search-active-backward ;usepkgrx YaTeX-comment-prefix nil t) ;;allow commented out \usepackages 2004/3/16 (re-search-backward usepkgrx nil t) (setq mb0 (match-beginning 0)) (skip-chars-forward "^{") (setq uspkgargs (YaTeX-buffer-substring (point) (progn ;;(forward-list 1) is more precise, ;; but higher risk. (skip-chars-forward "^}\n")(point)))) (let ((pl pkglist)) (while pl ;(car pl)'s car is package, cdr is type (if (string-match (concat "[{,]\\s *" (regexp-quote (car (car pl))) "\\>") uspkgargs) (throw 'found t)) (setq pl (cdr pl))) (goto-char mb0)))) ;;corresponding \usepackage found (funcall register) ;; not found, insert it. (if (y-or-n-p (format "`%s' requires package. Put \\usepackage now?" macro)) (progn (require 'yatexadd) (setq pkg (completing-read "Load which package?(TAB for list): " pkglist nil nil ;;initial input (if (= (length pkglist) 1) (let ((w (car (car pkglist)))) (if YaTeX-emacs-19 (cons w 0) w)))) optlist (YaTeX-package-option-lookup pkg)) (if optlist (let ((minibuffer-completion-table optlist) (delim ",") (w (car (car optlist)))) (setq option (read-from-minibuffer (format "Any option for {%s}?: " pkg) (if (= (length optlist) 1) (if YaTeX-emacs-19 (cons w 0) w)) YaTeX-minibuffer-completion-map) option (if (string< "" option) (concat "[" option "]") "")))) (set-buffer pb) (goto-char (point-min)) (if (YaTeX-re-search-active-forward (concat YaTeX-ec-regexp "document\\(style\\|class\\){") YaTeX-comment-prefix nil t) (forward-line 1)) (if (YaTeX-search-active-forward begdoc YaTeX-comment-prefix nil t) (goto-char (match-beginning 0))) (insert usepackage (format "%s{%s}\t%% required for `\\%s' (yatex added)\n" option pkg macro)) (funcall register)) (funcall register) (message "Don't forget to put \\usepackage{%s} yourself later" (car (car pkglist)))) ;doing car car is negligence... )))))) yatex_1.77+dfsg1/yatexenv.el0000444000175000017500000003052612126310635014542 0ustar kurakura;;; yatexenv.el --- YaTeX environment-specific functions ;;; (c) 1994-2013 by HIROSE Yuuji.[yuuji@yatex.org] ;;; Last modified Mon Apr 1 22:43:10 2013 on firestorm ;;; $Id: yatexenv.el,v 1.77 2013/04/01 13:53:45 yuuji Rel $ ;;; Code: ;;; ;; Functions for tabular environment ;;; ;; Showing the matching column of tabular environment. (defun YaTeX-array-what-column-internal () "Return the cons of matching column and its title of array environment. When calling from a program, make sure to be in array/tabular environment." (let ((p (point)) beg eot bor (nlptn "\\\\\\\\") (andptn "[^\\]&") (n 0) j (firsterr "This line might be the first row.")) (save-excursion (YaTeX-beginning-of-environment) (search-forward "{" p) (up-list 1) (search-forward "{" p) (up-list 1) ;;(re-search-forward andptn p) (while (progn (search-forward "&" p) (equal (char-after (1- (match-beginning 0))) ?\\ ))) (setq beg (1- (point))) ;beg is the point of the first & (or (re-search-forward nlptn p t) (error firsterr)) (setq eot (point)) ;eot is the point of the first \\ (goto-char p) (or (re-search-backward nlptn beg t) (error firsterr)) (setq bor (point)) ;bor is the beginning of this row. (while (< (1- (point)) p) (if (equal (following-char) ?&) (forward-char 1) (re-search-forward andptn nil 1)) (setq n (1+ n))) ;Check current column number (goto-char p) (cond ;Start searching \multicolumn{N} ((> n 1) (re-search-backward andptn) ;Sure to find! (while (re-search-backward "\\\\multicolumn{\\([0-9]+\\)}" bor t) (setq n (+ n (string-to-int (buffer-substring (match-beginning 1) (match-end 1))) -1))))) (message "%s" n) (goto-char (1- beg)) (beginning-of-line) (setq j n) (while (> j 1) (or (re-search-forward andptn p nil) (error "This column exceeds the limit.")) (setq j (1- j))) (skip-chars-forward "\\s ") (list n (buffer-substring (point) (progn (re-search-forward (concat andptn "\\|" nlptn) eot) (goto-char (match-beginning 0)) (if (looking-at andptn) (forward-char 1)) (skip-chars-backward "\\s ") (point))))))) (defun YaTeX-array-what-column () "Show matching column title of array environment. When calling from a program, make sure to be in array/tabular environment." (apply 'message "This is the column(#%d) of: %s" (YaTeX-array-what-column-internal))) ;;;###autoload (defun YaTeX-what-column () "Show which kind of column the current position is belonging to." (interactive) (cond ((YaTeX-quick-in-environment-p '("tabular" "tabular*" "array" "array*")) (YaTeX-array-what-column)) (t (message "Not in array/tabular environment.")))) (defun YaTeX-tabular-parse-format-count-cols (beg end) (goto-char beg) (let (elt (cols 0)) (while (< (point) end) (setq elt (following-char)) (cond ((string-match (char-to-string elt) "clr") ;normal indicators. (setq cols (1+ cols)) (forward-char 1)) ((equal elt ?|) ;vertical (forward-char 1)) ((string-match (char-to-string elt) "p@") ;p or @ expression (setq cols (+ (if (eq elt ?p) 1 0) cols)) ;;(skip-chars-forward "^{" p) (skip-chars-forward "^{" end) (forward-list 1)) ((equal elt ?*) ;*{N}{EXP} -> Repeat EXP N times (skip-chars-forward "^{" end) (setq cols (* (string-to-int (buffer-substring (1+ (point)) (progn (forward-list 1) (1- (point))))) (YaTeX-tabular-parse-format-count-cols (progn (skip-chars-forward "^{" end) (1+ (point))) (progn (forward-list 1) (1- (point))))))) (t (forward-char 1)) ;unknown char )) cols)) (defun YaTeX-tabular-parse-format (&optional type) "Parse `tabular' format. Return the list of (No.ofCols PointEndofFormat)" (let ((p (point)) boform eoform (cols 0)) (save-excursion (if (null (YaTeX-beginning-of-environment t)) (error "Beginning of tabular not found.")) (skip-chars-forward "^{") (forward-list 1) (cond ((eq type 'tabular*) (skip-chars-forward "^{") (forward-list 1))) (skip-chars-forward "^{" p) (if (/= (following-char) ?\{) (error "Tabular format not found.")) (setq boform (1+ (point)) eoform (progn (forward-list 1) (1- (point)))) (if (> eoform p) (error "Non-terminated tabular format.")) (goto-char boform) (setq cols (cond ((eq type 'alignat) (max 1 (* 2 (string-to-int (buffer-substring (point) (progn (up-list -1) (forward-list 1) (1- (point)))))))) (t (YaTeX-tabular-parse-format-count-cols (point) eoform)))) (list cols (1+ eoform))))) ;; Insert & (defun YaTeX-intelligent-newline-tabular (&optional type) "Parse current tabular format and insert that many `&'s." (let*((p (point)) (format (YaTeX-tabular-parse-format type)) (cols (car format)) (beg (car (cdr format))) space hline) (cond ((search-backward "&" beg t) (goto-char p) (setq hline (search-backward "\\hline" beg t)) (setq space (if (search-backward "\t&" beg t) "\t" " ")) (goto-char p)) (t ;;(insert "\\hline\n") (setq space " "))) (goto-char p) (while (> (1- cols) 0) (insert "&" space) (setq cols (1- cols))) (insert "\\\\") (if hline (insert " \\hline")) (goto-char p) (YaTeX-indent-line))) (defun YaTeX-intelligent-newline-tabular* () "Parse current tabular* format and insert that many `&'s." (YaTeX-intelligent-newline-tabular 'tabular*)) (fset 'YaTeX-intelligent-newline-array 'YaTeX-intelligent-newline-tabular) (fset 'YaTeX-intelligent-newline-supertabular 'YaTeX-intelligent-newline-tabular) (defun YaTeX-intelligent-newline-align () "Intelligent newline function for align. Count the number of & in the first align line and insert that many &s." (let*((p (point)) (amps 0)) (if (string-match "alignat" env) (setq amps (1- (car (YaTeX-tabular-parse-format 'alignat)))) (save-excursion (YaTeX-beginning-of-environment) (catch 'done (while (YaTeX-re-search-active-forward "\\(&\\)\\|\\(\\\\\\\\\\)" YaTeX-comment-prefix p t) (if (match-beginning 1) (setq amps (1+ amps)) (throw 'done t)))))) (save-excursion (forward-line -1) (skip-chars-forward " \t") (or (prog1 (looking-at "\\\\begin{") (end-of-line)) (save-excursion (skip-chars-backward " \t") (and (= (preceding-char) ?\\) (= (char-after (- (point) 2)) ?\\))) (insert "\\\\"))) (save-excursion (while (>= (setq amps (1- amps)) 0) (insert "& "))) (YaTeX-indent-line))) (mapcar '(lambda (s) (fset (intern (concat "YaTeX-intelligent-newline-" (symbol-name s))) 'YaTeX-intelligent-newline-align)) '(align* flalign flalign* matrix pmatrix bmatrix Bmatrix vmatrix Vmatrix cases eqnarray eqnarray* alignat alignat*)) ;;; ;; Functions for tabbing environment ;;; (defun YaTeX-intelligent-newline-tabbing () "Check the number of \\= in the first line and insert that many \\>." (let ((p (point)) begenv tabcount) (save-excursion (YaTeX-beginning-of-environment) (setq begenv (point-end-of-line)) (if (YaTeX-search-active-forward "\\\\" YaTeX-comment-prefix p t) (progn (setq tabcount 0) (while (> (point) begenv) (if (search-backward "\\=" begenv 1) (setq tabcount (1+ tabcount))))))) (YaTeX-indent-line) (if tabcount (progn (save-excursion (while (> tabcount 0) (insert "\\>\t") (setq tabcount (1- tabcount)))) (forward-char 2)) (insert "\\= \\\\") (forward-char -5)))) ;;; ;; Functions for itemize/enumerate/list environments ;;; (defun YaTeX-intelligent-newline-itemize () "Insert '\\item '." (insert "\\item ") (YaTeX-indent-line)) (fset 'YaTeX-intelligent-newline-enumerate 'YaTeX-intelligent-newline-itemize) (fset 'YaTeX-intelligent-newline-list 'YaTeX-intelligent-newline-itemize) (defun YaTeX-intelligent-newline-description () (insert "\\item[] ") (forward-char -2) (YaTeX-indent-line)) (defun YaTeX-intelligent-newline-thebibliography () "Insert '\\bibitem '." (YaTeX-indent-line) (YaTeX-make-section nil nil nil "bibitem") (YaTeX-indent-line)) ;;; ;; For document environment ;;; (defun YaTeX-intelligent-newline-document () "New paragraph by null line or `\\par'." (if (< (count-lines (or (get 'YaTeX-inner-environment 'point) (max 1 (- (point) 17))) ;"\begin{document}\n" == 17 (point)) 2) nil (if (save-excursion (re-search-backward "\\\\par\\>" nil t)) (progn (YaTeX-indent-line) (insert "\\par"))) (newline)) (YaTeX-indent-line)) ;;; ;; Intelligent newline ;;; ;;;###autoload (defun YaTeX-intelligent-newline (arg) "Insert newline and environment-specific entry. `\\item' for some itemizing environment, `\\> \\> \\' for tabbing environemnt, `& & \\ \hline' for tabular environment." (interactive "P") (let*(env func) (end-of-line) (setq env (YaTeX-inner-environment)) (if arg (setq env (YaTeX-read-environment "For what environment? "))) (setq func (intern-soft (concat "YaTeX-intelligent-newline-" env))) (end-of-line) (newline) (undo-boundary) (if (and env func (fboundp func)) (funcall func)))) ;;; ;; Environment-specific line indenting functions ;;; ;;;###autoload (defun YaTeX-indent-line-equation () "Indent a line in equation family." (let ((p (point)) (l-r 0) right-p peol depth (mp YaTeX-environment-indent)) (if (save-excursion (beginning-of-line) (skip-chars-forward " \t") (looking-at "\\\\right\\b")) (progn (YaTeX-reindent (save-excursion (YaTeX-goto-corresponding-leftright) (- (current-column) 0)))) (save-excursion (forward-line -1) (while (and (not (bobp)) (YaTeX-on-comment-p)) (forward-line -1)) ;;(beginning-of-line) ;must be unnecessary (skip-chars-forward " \t") (if (eolp) (error "Math-environment can't have a null line!!")) (setq depth (current-column) peol (point-end-of-line)) (while (re-search-forward "\\\\\\(\\(left\\)\\|\\(right\\)\\)\\b" peol t) (setq l-r (+ l-r (if (match-beginning 2) 1 -1)))) (cond ((progn (beginning-of-line) (re-search-forward "\\\\\\\\\\s *$" (point-end-of-line) t)) ;;If previous line has `\\', this indentation is always normal. (setq depth (+ (YaTeX-current-indentation) mp))) ((> l-r 0) (beginning-of-line) (search-forward "\\left" peol nil l-r) (goto-char (1+ (match-beginning 0))) (setq depth (current-column))) ((< l-r 0) (goto-char (match-beginning 0)) ;should be \right (YaTeX-goto-corresponding-leftright) (beginning-of-line) (skip-chars-forward " \t") ;(setq depth (+ (current-column) mp)) ;+mp is good? (setq depth (current-column))) (t ;if \left - \right = 0 (cond ((re-search-forward "\\\\\\\\\\s *$" peol t) (setq depth (+ (YaTeX-current-indentation) mp))) ((re-search-forward "\\\\end{" peol t) nil) ;same indentation as previous line's ((re-search-forward "\\\\begin{" peol t) (setq depth (+ depth mp))) (t (or (bobp) (forward-line -1)) (cond ((re-search-forward "\\\\\\\\\\s *$\\|\\\\begin{" (point-end-of-line) t) (setq depth (+ depth mp))) ))))) (goto-char p)) (YaTeX-reindent depth)))) ;;;###autoload (defun YaTeX-goto-corresponding-leftright () "Go to corresponding \left or \right." (let ((YaTeX-struct-begin "\\left%1") (YaTeX-struct-end "\\right%1") (YaTeX-struct-name-regexp "[][(){}\\.|]") (in-leftright-p t)) (YaTeX-goto-corresponding-environment t))) ;;; ;; Functions for formatting region being enclosed with environment ;;; ; These functions must take two argument; region-beginning, region-end. (defun YaTeX-enclose-equation (beg end) (goto-char beg) (save-restriction (let (m0 bsl) (narrow-to-region beg end) (while (YaTeX-re-search-active-forward "\\(\\$\\)" YaTeX-comment-prefix nil t) (goto-char (setq m0 (match-beginning 0))) (setq bsl 0) (if (and (not (bobp)) (= (char-after (1- (point))) ?\\ )) (while (progn (forward-char -1) (= (char-after (point)) ?\\ )) (setq bsl (1+ bsl)))) (goto-char m0) (if (= 0 (% bsl 2)) (delete-char 1) (forward-char 1)))))) (fset 'YaTeX-enclose-eqnarray 'YaTeX-enclose-equation) (fset 'YaTeX-enclose-eqnarray* 'YaTeX-enclose-equation) (defun YaTeX-enclose-verbatim (beg end)) ;do nothing when enclose verbatim (fset 'YaTeX-enclose-verbatim* 'YaTeX-enclose-verbatim) (provide 'yatexenv) yatex_1.77+dfsg1/yatexsec.el0000444000175000017500000004461012126310635014523 0ustar kurakura;;; yatexsec.el --- YaTeX sectioning browser ;;; ;;; (c) 1994-2013 by HIROSE Yuuji [yuuji@yatex.org] ;;; Last modified Mon Apr 1 22:46:28 2013 on firestorm ;;; $Id: yatexsec.el,v 1.77 2013/04/01 13:53:45 yuuji Rel $ ;;; Code: (defvar YaTeX-sectioning-level '(("part" . 0) ("chapter" . 1) ("section" . 2) ("subsection" . 3) ("subsubsection" . 4) ("paragraph" . 5) ("subparagraph" . 6)) "*Alist of LaTeX's sectioning command and its level. This value must be written in numerically ascending order and consecutive. Needn't define the level of `*' commands such as `section*'.") (defvar YaTeX-sectioning-max-level (cdr (nth (1- (length YaTeX-sectioning-level)) YaTeX-sectioning-level)) "*The heighest(numerically) level of sectioning command. This must be the heighest number in YaTeX-sectioning-level.") (defun YaTeX-sectioning-map-hide (map) (let ((ch ?0)) (while (<= ch ?9) (define-key map (char-to-string ch) 'YaTeX-sectioning-hide) (setq ch (1+ ch)))) ) (defvar YaTeX-sectioning-minibuffer-map nil "Key map used in minibuffer for sectioning.") (if YaTeX-sectioning-minibuffer-map nil (setq YaTeX-sectioning-minibuffer-map (copy-keymap minibuffer-local-completion-map)) (define-key YaTeX-sectioning-minibuffer-map "\C-p" 'YaTeX-sectioning-up) (define-key YaTeX-sectioning-minibuffer-map "\C-e" 'YaTeX-sectioning-up) (define-key YaTeX-sectioning-minibuffer-map "\C-i" 'YaTeX-minibuffer-complete) (define-key YaTeX-sectioning-minibuffer-map " " 'YaTeX-minibuffer-complete) (define-key YaTeX-sectioning-minibuffer-map "\C-n" 'YaTeX-sectioning-down) (define-key YaTeX-sectioning-minibuffer-map "\C-x" 'YaTeX-sectioning-down) (define-key YaTeX-sectioning-minibuffer-map "\C-v" 'YaTeX-sectioning-scroll-up) (define-key YaTeX-sectioning-minibuffer-map "\C-c" 'YaTeX-sectioning-scroll-up) (define-key YaTeX-sectioning-minibuffer-map "\M-v" 'YaTeX-sectioning-scroll-down) (define-key YaTeX-sectioning-minibuffer-map "\C-r" 'YaTeX-sectioning-scroll-down) (define-key YaTeX-sectioning-minibuffer-map "\C-w" '(lambda () (interactive) (YaTeX-sectioning-scroll-down 1))) (define-key YaTeX-sectioning-minibuffer-map "\C-z" '(lambda () (interactive) (YaTeX-sectioning-scroll-up 1))) (define-key YaTeX-sectioning-minibuffer-map "\C-l" 'YaTeX-sectioning-recenter) (define-key YaTeX-sectioning-minibuffer-map "?" 'YaTeX-sectioning-help) (YaTeX-sectioning-map-hide YaTeX-sectioning-minibuffer-map) ) (defvar YaTeX-sectioning-buffer-map nil "Key map used in YaTeX-sectioning-buffer.") (if YaTeX-sectioning-buffer-map nil (setq YaTeX-sectioning-buffer-map (make-sparse-keymap)) (define-key YaTeX-sectioning-buffer-map " " 'YaTeX-sectioning-buffer-jump) (define-key YaTeX-sectioning-buffer-map "." 'YaTeX-sectioning-buffer-show) (define-key YaTeX-sectioning-buffer-map (concat YaTeX-prefix "\C-c") 'YaTeX-sectioning-buffer-jump) (define-key YaTeX-sectioning-buffer-map "u" 'YaTeX-shift-section-up) (define-key YaTeX-sectioning-buffer-map "d" 'YaTeX-shift-section-down) (define-key YaTeX-sectioning-buffer-map "U" 'YaTeX-shift-section-up-region) (define-key YaTeX-sectioning-buffer-map "D" 'YaTeX-shift-section-down-region) (define-key YaTeX-sectioning-buffer-map "s" 'YaTeX-sync-section-buffer) (define-key YaTeX-sectioning-buffer-map "n" 'YaTeX-sectioning-buffer-next-line) (define-key YaTeX-sectioning-buffer-map "p" 'YaTeX-sectioning-buffer-prev-line) (define-key YaTeX-sectioning-buffer-map "h" 'describe-mode) (define-key YaTeX-sectioning-buffer-map "o" 'other-window) (define-key YaTeX-sectioning-buffer-map "-" 'shrink-window) (define-key YaTeX-sectioning-buffer-map "+" 'enlarge-window) (define-key YaTeX-sectioning-buffer-map "q" 'delete-window) (define-key YaTeX-sectioning-buffer-map "\C-_" 'YaTeX-shift-section-undo) (and YaTeX-emacs-19 (boundp 'window-system) (eq window-system 'x) (define-key YaTeX-sectioning-buffer-map [?\C-/] 'YaTeX-shift-section-undo)) (YaTeX-sectioning-map-hide YaTeX-sectioning-buffer-map) ) (defun YaTeX-sectioning-mode () "Mode for browsing document's sectioning structure. \\[YaTeX-shift-section-up] Shift up a sectioning command \\[YaTeX-shift-section-down] Shift down a sectioning command \\[YaTeX-shift-section-up-region] Shift up sectioning commands in region \\[YaTeX-shift-section-down-region] Shift down sectioning commands in region \\[YaTeX-shift-section-undo] Undo changes of shifting \\[YaTeX-sync-section-buffer] Synchronize sectioning buffer with source \\[YaTeX-sectioning-buffer-next-line] Next line \\[YaTeX-sectioning-buffer-prev-line] Previous line \\[YaTeX-sectioning-buffer-jump] Previous line \\[YaTeX-sectioning-buffer-show] Show curresponding source line " (interactive) (setq major-mode 'YaTeX-sectioning-mode mode-name "sectioning") (use-local-map YaTeX-sectioning-buffer-map) ) (defvar YaTeX-sectioning-buffer-parent nil) (defun YaTeX-sectioning-buffer-jump-internal (&optional keep) (let ((p (point)) ;save-excursion is NG because ptn ln) ;this function should switch buffer (beginning-of-line) (if (re-search-forward YaTeX-sectioning-regexp) (progn (save-restriction (narrow-to-region (point-beginning-of-line) (point-end-of-line)) (setq ptn (buffer-substring (1- (match-beginning 0)) (progn (skip-chars-forward "^}") (1+ (point)))) ln (buffer-substring (progn (search-forward "line:") (match-end 0)) (progn (skip-chars-forward "0-9") (point))))) (goto-char p) (YaTeX-showup-buffer YaTeX-sectioning-buffer-parent nil t) (or (and ln (string< "" ln) (progn (goto-char (point-min)) (forward-line (max 0 (- (string-to-int ln) 2))) (and (search-forward ptn nil t) (goto-char (match-beginning 0))))) (progn (goto-char (point-max)) (search-backward ptn))) (if keep (goto-buffer-window YaTeX-sectioning-buffer)) (current-buffer)) nil))) (defun YaTeX-sectioning-buffer-jump (&optional keep) "Goto corresponding sectioning unit with current line in the next window. If optional argument KEEP is non-nil, only shows the line." (interactive) (if (and YaTeX-sectioning-buffer-parent (get-buffer YaTeX-sectioning-buffer-parent)) (YaTeX-sectioning-buffer-jump-internal keep) (message "No line number expression.")) ) (defun YaTeX-sectioning-buffer-show () "Show corresponding sectioning unit with current line." (interactive) (YaTeX-sectioning-buffer-jump-internal t) ) (defun YaTeX-sectioning-hide-under (n) "Hide sectioning commands under level N." (let ((cw (selected-window))) (YaTeX-showup-buffer YaTeX-sectioning-buffer nil t) (if (>= n YaTeX-sectioning-max-level) (progn (set-selective-display nil) (message "Show all.")) (set-selective-display (1+ n)) (if (rassq n YaTeX-sectioning-level) (message "Hide lower than %s" (car (rassq n YaTeX-sectioning-level))) (message ""))) (if (numberp selective-display) (setq mode-name (format "level %d" (1- selective-display))) (setq mode-name (format "all"))) (select-window cw)) ) (defun YaTeX-sectioning-hide () "Call YaTeX-sectioning-hide-under with argument according to pressed key." (interactive) (YaTeX-sectioning-hide-under (- (YaTeX-last-key) ?0))) (defun YaTeX-sectioning-help () "Show help of sectioning." (interactive) (let ((cw (selected-window)) sb (hb (get-buffer-create "*Help*"))) (unwind-protect (progn (other-window 1) (setq sb (current-buffer)) (switch-to-buffer hb) (erase-buffer) (insert "===== View sectioning ===== C-p Up sectioning level. 0 Show only \\part, C-n Down sectioning level. 1 and \\chapter, C-v Scroll up *Sectioning line* buffer. 2 and \\section, M-v Scroll down *Sectioning line* buffer. 3 and \\subsection, C-z Scroll up by 1 line. 4 and \\subsubsection, C-w Scroll down by 1 line. 5 and \\paragraph. SPC Complete word. 6 Show all. TAB Complete word. C-l Recenter recent line. RET Select. ==== End of HELP ===== ") (set-buffer-modified-p nil) (goto-char (point-min)) (momentary-string-display "" (point-min))) (bury-buffer hb) (switch-to-buffer sb) (select-window cw))) ) (defun YaTeX-sectioning-up (n) "Up section level. Refers the YaTeX-read-section-in-minibuffer's local variable minibuffer-start." (interactive "p") (if (eq (selected-window) (minibuffer-window)) (let*((command (YaTeX-minibuffer-string)) (aster (and (string< "" command) (equal (substring command -1) "*"))) (command (if aster (substring command 0 -1) command)) (alist YaTeX-sectioning-level) (level 0)) (or (assoc command alist) (error "No such sectioning command.")) (while (not (string= (car (nth level alist)) command)) (setq level (1+ level))) ;I want to use `member'.... (setq level (- level n)) (if (or (< level 0) (>= level (length alist))) (ding) (YaTeX-minibuffer-erase) (insert (concat (car (nth level alist)) (if aster "*" "")))))) ) (defun YaTeX-sectioning-down (n) "Down section level." (interactive "p") (YaTeX-sectioning-up (- n)) ) (defun YaTeX-sectioning-scroll-up (n) (interactive "P") (let ((section-buffer YaTeX-sectioning-buffer) (cw (selected-window))) (YaTeX-showup-buffer section-buffer nil t) (unwind-protect (scroll-up (or n (- (window-height) 2))) (select-window cw))) ) (defun YaTeX-sectioning-scroll-down (n) (interactive "P") (let ((section-buffer YaTeX-sectioning-buffer) (cw (selected-window))) (YaTeX-showup-buffer section-buffer nil t) (unwind-protect (scroll-down (or n (- (window-height) 2))) (select-window cw))) ) (defun YaTeX-sectioning-recenter (arg) "Recenter `<<--' line" (interactive "P") (let ((cw (selected-window))) (unwind-protect (progn (YaTeX-showup-buffer YaTeX-sectioning-buffer nil t) (or (search-forward "<<--" nil t) (search-backward "<<--" nil)) (recenter (or arg (/ (window-height) 2)))) (select-window cw))) ) (defvar YaTeX-sectioning-minibuffer " *sectioning*" "Miniuffer used for sectioning") ;;;###autoload (defun YaTeX-read-section-in-minibuffer (prompt table &optional default delim) (interactive) (let ((minibuffer-completion-table table)) (read-from-minibuffer prompt default YaTeX-sectioning-minibuffer-map)) ) (defun YaTeX-get-sectioning-level () "Get section-level on the cursor." (cdr-safe (assoc (buffer-substring (point) (progn (skip-chars-forward "a-z") (point))) YaTeX-sectioning-level)) ) (defvar YaTeX-sectioning-buffer "*Sectioning lines*") (defvar YaTeX-sectioning-indent 1) (defun YaTeX-collect-sections () "Collect all the lines which contains sectioning command." (let ((cw (selected-window)) level indent begp (prevp 1) (prevl 1) (pattern (concat YaTeX-ec-regexp "\\(" YaTeX-sectioning-regexp "\\)\\*?{")) (cb (current-buffer))) (save-excursion (set-buffer (get-buffer-create YaTeX-sectioning-buffer)) (setq buffer-read-only nil) (erase-buffer) (set-buffer cb) (YaTeX-showup-buffer YaTeX-sectioning-buffer) ;show buffer (goto-char (point-min)) (let ((standard-output (get-buffer YaTeX-sectioning-buffer))) (while (re-search-forward pattern nil t) (goto-char (1+ (match-beginning 0))) (setq level (YaTeX-get-sectioning-level) begp (match-beginning 0)) ;;(beginning-of-line) ;;(skip-chars-forward " \t") (setq indent (format "%%%ds" (* level YaTeX-sectioning-indent))) (princ (format indent "")) (if (YaTeX-on-comment-p) (princ "%")) (princ (buffer-substring begp (progn (forward-list 1) (point)))) (setq prevl (+ prevl (count-lines prevp (point)) -1) prevp (point)) (princ (format " (line:%d)" prevl)) (princ "\n"))) (set-buffer YaTeX-sectioning-buffer) (make-local-variable 'YaTeX-sectioning-buffer-parent) (YaTeX-sectioning-mode) (use-local-map YaTeX-sectioning-buffer-map) (setq YaTeX-sectioning-buffer-parent cb) (if (numberp selective-display) (setq mode-name (format "level %d" (1- selective-display)))) YaTeX-sectioning-buffer)) ) (defvar YaTeX-pending-undo nil) (defun YaTeX-section-overview () "Show section overview. Return the nearest sectioning command." (interactive) (let ((cw (selected-window)) (ln (count-lines (point-min) (point))) (pattern "(line:\\([0-9]+\\))") secbuf (command "")) (save-excursion (setq secbuf (YaTeX-collect-sections)) (YaTeX-showup-buffer secbuf nil t) (set-buffer secbuf) (goto-char (point-max)) (while (re-search-backward pattern nil t) (if (< ln (string-to-int (YaTeX-match-string 1))) nil (beginning-of-line) (search-forward YaTeX-ec) (looking-at YaTeX-TeX-token-regexp) (setq command (YaTeX-match-string 0)) (end-of-line) (insert " <<--") (setq pattern (concat "HackyRegexp" "ForFailure")))) (set-buffer-modified-p nil) (setq buffer-read-only t buffer-undo-list nil) (make-local-variable 'YaTeX-pending-undo) (forward-line 1) (if (eobp) (recenter -1) (recenter -3)) (select-window cw) command)) ) ;;;###autoload (defun YaTeX-make-section-with-overview () "Input sectining command with previous overview." (interactive) (insert YaTeX-ec (YaTeX-read-section-in-minibuffer "Sectioning(Up=C-p, Down=C-n, Help=?): " YaTeX-sectioning-level (YaTeX-section-overview)) "{}") (forward-char -1) ) (defun YaTeX-shifted-section (sc n) "Get SC's N-shifted sectioning command." (let (lv) (setq lv (- (cdr (assoc sc YaTeX-sectioning-level)) n) lv (max (min YaTeX-sectioning-max-level lv) 0)) (car (nth lv YaTeX-sectioning-level))) ) (defun YaTeX-shift-section-up (n) "Shift sectioning command down by level N." (interactive "p") (let ((cb (current-buffer)) sc nsc lv) (if (and YaTeX-sectioning-buffer-parent (get-buffer YaTeX-sectioning-buffer-parent) (save-excursion (beginning-of-line) (skip-chars-forward "^\\\\" (point-end-of-line)) (YaTeX-on-section-command-p YaTeX-sectioning-regexp))) (save-excursion (or (buffer-name (get-buffer YaTeX-sectioning-buffer-parent)) (error "This buffer is obsolete.")) (setq nsc (YaTeX-shifted-section (YaTeX-match-string 1) n)) (YaTeX-sectioning-buffer-jump-internal) (undo-boundary) (goto-char (match-beginning 0)) (skip-chars-forward "\\\\") (delete-region (point) (progn (skip-chars-forward "^*{") (point))) (insert nsc) (undo-boundary) ;; Return to *Sectioning Lines* buffer (select-window (get-buffer-window cb)) (beginning-of-line) (let (buffer-read-only) (delete-region (point) (progn (skip-chars-forward " \t") (point))) (indent-to-column (* (cdr (assoc nsc YaTeX-sectioning-level)) YaTeX-sectioning-indent)) (skip-chars-forward "^\\\\") (delete-region (1+ (point)) (progn (skip-chars-forward "^*{") (point))) (insert nsc) (undo-boundary)) (set-buffer-modified-p nil) (setq YaTeX-pending-undo pending-undo-list) ))) ) (defun YaTeX-shift-section-down (n) "Shift sectioning command down by level N." (interactive "p") (YaTeX-shift-section-up (- n)) ) (defun YaTeX-shift-section-undo (arg) "Undo YaTeX-shift-section-up/down." (interactive "p") (and YaTeX-sectioning-buffer-parent (get-buffer YaTeX-sectioning-buffer-parent) (equal (current-buffer) (get-buffer YaTeX-sectioning-buffer)) (let ((cb (current-buffer)) (lc (if (eq last-command 'YaTeX-shift-section-undo) 'undo t))) (let ((pending-undo-list YaTeX-pending-undo) buffer-read-only (last-command lc)) (undo arg) (setq YaTeX-pending-undo pending-undo-list)) (YaTeX-showup-buffer YaTeX-sectioning-buffer-parent) (goto-buffer-window YaTeX-sectioning-buffer-parent) (undo-boundary) (let ((last-command lc) (pending-undo-list (if (eq lc 'undo) YaTeX-pending-undo pending-undo-list))) (undo arg) (setq YaTeX-pending-undo pending-undo-list)) (goto-buffer-window cb) (setq this-command 'YaTeX-shift-section-undo))) ) (defun YaTeX-sync-section-buffer () "Synchronize *Sectioning Lines* buffer with parent buffer." (interactive) (if (and YaTeX-sectioning-buffer-parent (get-buffer YaTeX-sectioning-buffer-parent)) (let ((cb (current-buffer)) (p (point))) (set-buffer (get-buffer YaTeX-sectioning-buffer-parent)) (YaTeX-section-overview) (switch-to-buffer cb) (goto-char p))) ) (defun YaTeX-shift-section-up-region (beg end n) "Shift sectioning commands in region down by level N." (interactive "r\np") (or YaTeX-sectioning-buffer-parent (get-buffer YaTeX-sectioning-buffer-parent) (error "Can't find corresponding LaTeX buffer")) (save-excursion (goto-char beg) (let ((cb (current-buffer)) nsc from to repllist (e (make-marker))) (set-marker e end) (while (progn (skip-chars-forward "^\\\\") (< (point) e)) (YaTeX-on-section-command-p YaTeX-sectioning-regexp) (setq from (YaTeX-match-string 0) nsc (YaTeX-shifted-section (YaTeX-match-string 1) n)) (goto-char (match-beginning 0)) (let (buffer-read-only) ;(delete-region (point) (progn (beginning-of-line) (point))) (delete-region (progn (beginning-of-line) (point)) (progn (skip-chars-forward " \t") (point))) (indent-to-column (cdr (assoc nsc YaTeX-sectioning-level))) (delete-region (progn (skip-chars-forward "%\\\\") (point)) (progn (skip-chars-forward "^*{") (point))) (insert nsc)) (YaTeX-on-section-command-p YaTeX-sectioning-regexp) (setq to (YaTeX-match-string 0) repllist (cons (cons from to) repllist)) (forward-line 1)) (YaTeX-showup-buffer YaTeX-sectioning-buffer-parent) (goto-buffer-window YaTeX-sectioning-buffer-parent) (save-excursion (goto-char (point-max)) (undo-boundary) (while repllist (if (search-backward (car (car repllist)) nil t) (progn (goto-char (match-beginning 0)) ;confirm (delete-region (point) (match-end 0)) (insert (cdr (car repllist))) (goto-char (match-beginning 0)))) (setq repllist (cdr repllist)))) (goto-buffer-window cb))) ) (defun YaTeX-shift-section-down-region (beg end n) "Shift sectioning commands in region down by level N." (interactive "r\np") (YaTeX-shift-section-up-region beg end (- n)) ) (defun YaTeX-sectioning-buffer-next-line (n) "Move to next line in *Sectioning Lines* buffer." (interactive "p") (forward-line n) (skip-chars-forward " \t%") ) (defun YaTeX-sectioning-buffer-prev-line (n) "Move to previous line in *Sectioning Lines* buffer." (interactive "p") (YaTeX-sectioning-buffer-next-line (- n)) ) (provide 'yatexsec) yatex_1.77+dfsg1/yatexm-o.el0000444000175000017500000000277312126310635014445 0ustar kurakura;;; yatexm-o.el --- Sample to invoke yatex-mode with outline-minor mode ;;; (c)1993 by HIROSE Yuuji [yuuji@yatex.org] ;;; Last modified Sat Sep 1 08:12:40 2012 on firestorm ;;; Code: ;;; ;; outline-minor-mode(使用しない場合は不要です) ;;; (autoload 'outline-minor-mode "min-out" t) (make-variable-buffer-local 'outline-prefix-char) (make-variable-buffer-local 'outline-regexp) (setq default-outline-regexp "[*\^l]+") (make-variable-buffer-local 'outline-level-function) (setq-default outline-level-function 'outline-level-default) (setq LaTeX-outline-regexp (concat "[ \t]*" (regexp-quote "\\") "\\(appendix\\|documentstyle\\|part\\|chapter\\|section\\|" "subsection\\|subsubsection\\|paragraph\\|subparagraph\\)" "\\*?[ \t]*[[{]")) ;;; ;; yatex-mode ;;; (setq auto-mode-alist (cons '("\\.tex$" . yatex-mode) auto-mode-alist)) (autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t) ;;↓min-outを使用しない場合、;;@ の行は不要です。 (defvar yatex-mode-hook '(lambda () (setq outline-regexp LaTeX-outline-regexp) ;;@ (outline-minor-mode 1) ;;@ )) (defvar yatex-mode-load-hook '(lambda () (setq-default outline-prefix-char (concat YaTeX-prefix "\C-o"));;@ (require 'min-out) ;;@ ;;auctex 付属の min-out.el の場合これ↓ ;(define-key outline-minor-keymap "\C-?" 'hide-subtree) ;;@ ;;Emacs 付属の outline.el の場合これ↓ (define-key outline-mode-prefix-map "\C-?" 'hide-subtree) (YaTeX-define-begend-key "ba" "abstract") )) yatex_1.77+dfsg1/yatexgen.el0000444000175000017500000004734012126310635014525 0ustar kurakura;;; yatexgen.el --- YaTeX add-in function generator(rev.5) ;;; (c)1991-1995,1999,2000 by HIROSE Yuuji.[yuuji@yatex.org] ;;; Last modified Sat Sep 1 08:10:36 2012 on firestorm ;;; $Id: yatexgen.el,v 1.77 2013/04/01 13:53:45 yuuji Rel $ ;;; Code: (require 'yatex) (defmacro YaTeX-setq (var japanese english) (list 'setq var (if YaTeX-japan japanese english))) (put 'YaTeX-setq 'lisp-indent-hook 1) (YaTeX-setq YaTeX-generate-initial-message " 自動生成モードへようこそ!! 初めてやる人はこのバッファの例にしたがって指示通りにやって練習してね。 本番の時もこのバッファに出るメッセージを *よく読んで* 操作しないとう まく関数が作れないよ!! ではリターンキーを押して下さい。" " Welcome to auto-generation mode!! If this is your first trial, exercise this according to example and following my messages. Then, at making actual function, operate reading my messages *carefully*, or you'll fail to generate appropriate function. Hit return key!") (YaTeX-setq YaTeX-generate-start-message "さぁはじめるよ.\n1.登録したい補完をやってみて. たとえば section 型補完の \\documentstyle だったら \\documentstyle{} だけをいれてみてね. ちゃんと『〜型補完』を使わないとダメよ!。 で、おわったらりたーん!!" "Let's begin completion for which you want to make add-in function. If you want to make add-in function for \\documentstyle input only `\\documentstyle{}' *with* completion of yatex-mode. If you finish this, please press RET.") (YaTeX-setq YaTeX-generate-abort-message "やめた、やめた〜いめんどくせ〜" "Aborted.") (YaTeX-setq YaTeX-generate-same-message "それじゃ、なにも変わってねぇだろーが! やめた。" "I found no difference between them. So I'm quitting.") (YaTeX-setq YaTeX-generate-invalid-message "それは、ちと無理というものじゃ." "It's impossible.") (YaTeX-setq YaTeX-generate-idontknow-message "う〜ん、難しくてよくわからないなぁ。ばかでごめんねェ〜" "Sorry I can't tell your adding method.") (YaTeX-setq YaTeX-generate-confirm-message "ということは、付け足したい部分はこれでいいのね" "Is it additional string of add-in function?") (YaTeX-setq YaTeX-generate-output-message "2.じゃ、それにくっつけたいものを *カーソルの位置に* 足してみて. さっきの \\documentstyle{} の例だと \\documentstyle[12pt]{} とかにするの。 しつこいようだけど、今の位置からカーソル動かしちゃダメよ!! で、またおわったらりたーん!!" "2.Then input additional string *at CURSOR POSITION* According to last example \\documentstyle{}, modify it \\documentstyle[12pt]{}. RET to finish.") (YaTeX-setq YaTeX-generate-put-arg-message "3.このうち、キーボードから読み込んで欲しい文字列を順に入れて。 さっきの \\documentstyle[12pt]{} だったら、付加する文字は[12pt]だけど 手で入れたいのは 12pt の部分だけですね。 で、全部入れ終ったら、りたーんだけうってね!!" "3.In this string, extract string which you want to input from key board with quiry afterwards. For example, though additional string is \\documentstyle[12pt]{}, but you want enter only `12pt' by hand. RET to finish!") (YaTeX-setq YaTeX-generate-read-prompt-message "4.では、あとでこれらの文字列を読み込む時に、どういうプロンプトを 出したいですか? 順に入れて下さい。面倒なら単にリターンを打ってね。 さっきの 12pt の部分だったら、『サイズは』とかがおすすめ。" "4.When you use this add-in function afterwards, what message do you like to be prompted with to enter these values. In last example `12pt', typical prompt string may be `Size?: '.") (YaTeX-setq YaTeX-generate-done-message "よし! これが、君の作りたかった関数だ。~/.emacs にでも入れてせいぜい 楽してくれ。このバッファ(*ご案内*)を yatex-mode にしておくから できた関数が本当にお望みの動作をするか確かめてみるといいかもね。 ところで、この関数こんなに簡単だろう? そろそろ自分で書いたらどう? " "OK! This is the definition of function you want to make! Add this description to your ~/.emacs or so. Use this buffer(*Guide*) for testing of this function please. But you can see this function quite easy, can't you? You had better write your most favorite add-in function yourself! ") (YaTeX-setq YaTeX-generate-nomatch-message "こらこら、そんな文字列どこにもねーぞ!!" "No such string in additional string.") (YaTeX-setq YaTeX-generate-buffer "*付加関数生成バッファ*" "*Generate-add-in-function*") (YaTeX-setq YaTeX-generate-message-buffer "*ご案内*" "*Guide*") (YaTeX-setq YaTeX-generate-bug-message "ごめ〜ん!! ちょっと、このアドイン関数つくるの失敗しちゃったみたい!! 作者まで連絡してくださ〜〜〜い!" "Sorry I failed to make add-in function for you... Send bug report to me.") (YaTeX-setq YaTeX-generate-narrow-message "画面がせますぎるような気がします。" "Too narrow screen height.") (defvar YaTeX-generate-message-height 10 "Window height of YaTeX-generate-message-buffer") ;; Do you need learning for generated function? ;; If you need, please tell me (yuuji@yatex.org) ;;(defvar YaTeX-generate-variables-for-learning nil) ;;(defvar YaTeX-generate-current-completion-table nil) ;;; ;Generate mode. ;;; (defun YaTeX-generate () "Genarate YaTeX add-in function with enquiry." (interactive) (if (< (YaTeX-screen-height) (+ YaTeX-generate-message-height 10)) (error YaTeX-generate-narrow-message)) (put 'YaTeX-generate 'disabled t) (save-window-excursion (unwind-protect (let (input output (i 0) (beg 0) end add-in map map1 si str slist (from (make-marker)) (to (make-marker))) (delete-other-windows) (switch-to-buffer YaTeX-generate-message-buffer) (yatex-mode) (erase-buffer) (insert YaTeX-generate-initial-message) (read-string (if YaTeX-japan "リターンキーを押して下さい." "Press RETURN.")) (erase-buffer) (insert YaTeX-generate-start-message) (pop-to-buffer (get-buffer-create YaTeX-generate-buffer)) (enlarge-window (- (window-height) YaTeX-generate-message-height 1)) (erase-buffer) (yatex-mode) (use-local-map (setq map (copy-keymap YaTeX-mode-map))) (define-key (current-local-map) "\n" 'exit-recursive-edit) (define-key (current-local-map) "\r" 'exit-recursive-edit) (define-key (current-local-map) "\C-g" 'abort-recursive-edit) (setq map1 (copy-keymap map)) (YaTeX-suppress-sparse-keymap map) ;;First get input form. (recursive-edit) (setq input (YaTeX-minibuffer-string) end (1- (length input))) (if (string= "" input) (error YaTeX-generate-abort-message)) (YaTeX-generate-move-to-add-in-position) (set-marker from (1- (point))) ;;Can't write before `from' (set-marker to (1+ (point))) ;;Can't write after `to' ;;Second get output form. (setq beg (1- (point)));;Cheat begin point! (YaTeX-generate-display-message YaTeX-generate-output-message) (use-local-map map1) (fset 'si (symbol-function 'self-insert-command)) (defun self-insert-command (arg) (interactive "p") (if (or (not (equal (buffer-name) YaTeX-generate-buffer)) (and (> (point) (marker-position from)) (< (point) (marker-position to)))) (insert (this-command-keys)) (ding))) (unwind-protect (recursive-edit) (fset 'self-insert-command (symbol-function 'si))) (setq output (YaTeX-minibuffer-string)) (cond ((string= "" output) (error YaTeX-generate-abort-message)) ((string= input output) (error YaTeX-generate-same-message)) ((< (length output) (length input)) (error YaTeX-generate-invalid-message))) ;;(while (and (< beg end) (= (aref input beg) (aref output i))) ;; (setq beg (1+ beg) i (1+ i))) ;;for universal use. (setq i (1- (length output))) (while (and (>= end beg) (= (aref output i) (aref input end))) (setq end (1- end) i (1- i))) (setq add-in (substring output beg (if (= i (1- (length output))) nil (1+ i)))) (erase-buffer) (insert add-in) (if (not (y-or-n-p YaTeX-generate-confirm-message)) (error YaTeX-generate-idontknow-message)) ;;Extract arguments. (YaTeX-generate-display-message YaTeX-generate-put-arg-message) (setq i 1) (while (not (string= "" (setq str (read-string (format "Arg %d: " i))))) (if (not (string-match (regexp-quote str) add-in)) (progn (ding) (YaTeX-generate-display-message YaTeX-generate-nomatch-message -1)) (setq slist (append slist (list (list str))) i (1+ i))) );input all of arguments. ;;Compare with output string. (set-buffer YaTeX-generate-buffer) ;;for safety (emacs-lisp-mode) (if (> i 1) (YaTeX-generate-parse-add-in slist add-in) (erase-buffer) (insert "(defun " (YaTeX-generate-function-name) " ()\n") (insert "\"" (YaTeX-generate-lisp-quote add-in) "\")\n") (indent-region (point-min) (point-max) nil) (message (if YaTeX-japan "このくらいの関数手で書け!!" "You don't need me to make such easy function."))) );let (put 'YaTeX-generate 'disabled nil) (put 'YaTeX-addin 'disabled nil) )) (YaTeX-generate-display-message YaTeX-generate-done-message) (switch-to-buffer YaTeX-generate-buffer) (condition-case error (eval-current-buffer) (error (insert YaTeX-generate-bug-message))) (pop-to-buffer YaTeX-generate-message-buffer)) (defun YaTeX-generate-parse-add-in (args add-in) "Parse add-in string and extract argument for it. Variable add-in is referred in parent function." (let ((i 1) j (case-fold-search nil) ;i holds argument number (prompt (make-vector (length args) "")) (used (make-vector (length add-in) nil)) func-name (string "")) ;;Phase 1. extract argument from add-in string. (mapcar '(lambda (arg) (let ((index 0) (match 0) beg end (carg (car arg))) (YaTeX-generate-display-message YaTeX-generate-read-prompt-message) (aset prompt (1- i) (read-string (format (if YaTeX-japan "%d番目(%s)を読む時?: " "When reading argument #%d(%s)?: ") i (car arg)))) (while (string-match (regexp-quote carg) (substring add-in index)) (setq beg (+ index (match-beginning 0)) end (+ index (match-end 0))) (if (aref used beg) nil (setq match (1+ match)) (cond ((= match 1) ;;(setq arg (append arg (list (list beg end)))) (YaTeX-generate-register-match)) ((YaTeX-generate-ask-match-position) (YaTeX-generate-register-match)))) (setq index end)) (setq i (1+ i)))) args) ;;Phase 2. Generate function!! (setq i 0) (setq func-name (YaTeX-generate-function-name)) (while (< i (length add-in)) (setq beg i j (aref used i)) (while (and (< i (length add-in)) (equal j (aref used i))) (setq i (1+ i))) (if j ;If it is argument. (setq string (concat string (format " arg%d" j))) (setq string (concat string " \"" (YaTeX-generate-quote-quote (substring add-in beg i)) "\"")) )) (erase-buffer) (setq i 1) (insert "(defun " func-name " ()\n" " (let (") (mapcar '(lambda (arg) (insert (format "(arg%d (read-string \"%s: \"))\n" i (aref prompt (1- i)))) (setq i (1+ i))) args) (delete-region (point) (progn (forward-line -1) (end-of-line) (point))) (insert ")\n(concat " (YaTeX-generate-lisp-quote string) ")))\n") (indent-region (point-min) (point) nil) used)) (defun YaTeX-generate-ask-match-position () "Ask user whether match-position is in his expectation, Referencing variables in parent function YaTeX-generate-parse-add-in." (pop-to-buffer YaTeX-generate-message-buffer) (goto-char (point-max)) (insert "\n\n" (format (if YaTeX-japan "%d 番目の引数 %s って" "Is argument #%d's value `%s' also corresponding to") i carg) "\n" add-in "\n") (indent-to-column beg) (let ((c beg)) (while (< c end) (insert "^") (setq c (1+ c)))) (insert "\n" (if YaTeX-japan "ここにも対応してるの?" "this underlined part too?")) (other-window -1) (y-or-n-p (if YaTeX-japan "下線部はあってますか" "Is underline right"))) (defun YaTeX-generate-register-match () (nconc arg (list (list beg end))) (let ((x beg)) (while (< x end) (aset used x i)(setq x (1+ x))))) (defun YaTeX-generate-display-message (mes &optional bottom) "Display message to generation buffer." (pop-to-buffer YaTeX-generate-message-buffer) (goto-char (point-max)) (insert "\n\n") (if bottom (recenter (1- bottom)) (recenter 0)) (insert mes) (other-window -1)) (defun YaTeX-generate-move-to-add-in-position () "Move cursor where add-in function should insert string." (cond ((eq YaTeX-current-completion-type 'begin) (goto-char (point-min)) (skip-chars-forward "^{") (setq YaTeX-env-name (buffer-substring (1+ (point)) (progn (skip-chars-forward "^}") (point)))) (forward-char 1)) ((eq YaTeX-current-completion-type 'section) (goto-char (point-min)) (skip-chars-forward "^{")) ((eq YaTeX-current-completion-type 'maketitle) (goto-char (point-max)) (if (= (preceding-char) ? ) (forward-char -1))))) (defun YaTeX-generate-function-name () (concat "YaTeX:" (cond ((eq YaTeX-current-completion-type 'begin) YaTeX-env-name) ((eq YaTeX-current-completion-type 'section) YaTeX-section-name) ((eq YaTeX-current-completion-type 'maketitle) YaTeX-single-command)))) (defun YaTeX-generate-lisp-quote (str) (let ((len (length str))(i 0) (quote "")) (while (< i len) (if (= (aref str i) ?\\) (setq quote (concat quote "\\"))) (if (= (aref str i) 127) (setq quote (concat quote "\"")) (setq quote (concat quote (substring str i (1+ i))))) (setq i (1+ i))) quote)) (defun YaTeX-generate-quote-quote (str) (let ((len (length str))(i 0) (quote "")) (while (< i len) (if (= (aref str i) ?\") (setq quote (concat quote (char-to-string 127)))) (setq quote (concat quote (substring str i (1+ i)))) (setq i (1+ i))) quote)) (defun YaTeX-suppress-sparse-keymap (map) (let ((i ? )) (while (< i 127) (define-key map (char-to-string i) 'undefined) (setq i (1+ i))))) ;;; ;; Auto-generate Function for Lispers. ;;; (defun YaTeX-generate-read-completion-type (nth) (message "Read type(%d): (S)tring (C)omplete (F)ile ([)option (P)osition co(O)rd. (q)uit" nth) (let ((c (read-char))) (cond ((= c ?s) 'string) ((= c ?c) 'completion) ((= c ?f) 'file) ((= c ?\[) 'option) ((= c ?p) 'oneof) ((= c ?o) 'coord) ;;((= c ?m) 'macro) (t 'quit)))) (defun YaTeX-generate-read-completion-table () (let ((i 1) cand (cands "(") (cb (current-buffer)) (buf (get-buffer-create " *Candidates*"))) (save-window-excursion (save-excursion (YaTeX-showup-buffer buf nil) (set-buffer buf) (erase-buffer) (while (string< "" (setq cand (read-string (format "Item[%d](RET to exit): " i)))) (setq cands (concat cands (format "(\"%s\")\n" cand)) i (1+ i)) (insert cand "\n")) (kill-buffer buf))) ;;(set-buffer cb) (setq YaTeX-generate-current-completion-table (concat cands ")")))) (defun YaTeX-generate-corresponding-paren (left) (cond ((equal left "{") "}") ((equal left "[") "]") ((equal left "(") ")") ((equal left "<") ">") ((equal left "\\begin{") "}") (t left))) (defun YaTeX-generate-create-read-string (&optional nth) (concat "(read-string \"" (read-string (if nth (format "Prompt for argument#%d: " nth) "Prompt: ")) ": \"\n" "\"" (read-string "Default: ") "\"" ")\n")) (defun YaTeX-generate-create-completing-read (&optional nth) (prog1 (concat "(completing-read \"" (read-string (if nth (format "Prompt for argument#%d: " nth) "Prompt: ")) ": \"\n" (format "'%s\n" (YaTeX-generate-read-completion-table)) "nil " (format "%s)" (y-or-n-p "Require match? "))) (if nil ;;;(y-or-n-p "Do you need learning for this completion?") (setq YaTeX-generate-variables-for-learning (cons (cons (format "YaTeX-%s-%d" command (or nth 0)) YaTeX-generate-current-completion-table) YaTeX-generate-variables-for-learning))))) (defun YaTeX-generate-create-read-file-name (&optional nth) (concat "(read-file-name \"" (read-string (if nth (format "Prompt for argument#%d: " nth) "Prompt: ")) ": \" "" \"\" t \"\")\n")) (defun YaTeX-generate-create-read-oneof (&optional nth readpos) (concat (if readpos "(YaTeX:read-position \"" "(YaTeX:read-oneof \"") (read-string "Acceptable characters: " "lcr") "\")\n")) (defun YaTeX-generate-option-type (command) (let ((func (format "YaTeX:%s" command)) leftp (buf (get-buffer-create YaTeX-generate-buffer)) type (n 1)) (set-buffer buf) (erase-buffer) (insert "(defun " func " ()\n (concat\n") (catch 'done (while t (setq type (YaTeX-generate-read-completion-type n)) (insert (cond ;;Read string ((eq type 'string) (concat "\"" (setq leftp (read-string "Left parenthesis: " "(")) "\"\n" (YaTeX-generate-create-read-string) "\"" (YaTeX-generate-corresponding-paren leftp) "\"") ) ;;Completing-read ((eq type 'completion) (concat "\"" (setq leftp (read-string "Left parenthesis: " "{")) "\"\n" (YaTeX-generate-create-completing-read) "\"" (YaTeX-generate-corresponding-paren leftp) "\"") ) ((eq type 'file) (concat "\"" (setq leftp (read-string "Left parenthesis: " "(")) "\"\n" (YaTeX-generate-create-read-file-name) "\"" (YaTeX-generate-corresponding-paren leftp) "\"") ) ((eq type 'oneof) (YaTeX-generate-create-read-oneof nil t) ) ((eq type 'option) (concat "(let ((op (read-string \"" (read-string "Prompt: ") ": \")))\n" "(if (string< \"\" op)\n" " (concat \"[\" op \"]\")\n" " \"\"))\n") ) ((eq type 'coord) (concat "(YaTeX:read-coordinates \"" (read-string "Prompt for coordinates: ") ": \")\n") ) ((eq type 'macro) (error "not yet supported") ) (t (throw 'done t)))) (setq n (1+ n)))) (insert "))\n") ;close defun (goto-char (point-min)) (while (not (eobp)) (lisp-indent-line) (forward-line 1)) (eval-current-buffer) buf)) (defun YaTeX-generate-argument-type (command argc) "Create an argument-type add-in function." (interactive) (let ((func (format "YaTeX::%s" command)) (argp 1) (cb (current-buffer)) (buf (get-buffer-create YaTeX-generate-buffer))) (set-buffer buf) (erase-buffer) (insert "(defun " func " (&optional argp)\n(cond\n") (while (<= argp argc) (insert (format "((equal argp %d)\n" argp)) (setq type (YaTeX-generate-read-completion-type argp)) (insert (cond ((eq type 'string) (concat (YaTeX-generate-create-read-string argp))) ((eq type 'completion) (concat (YaTeX-generate-create-completing-read argp))) ((eq type 'oneof) (YaTeX-generate-create-read-oneof)) ((eq type 'file) (concat (YaTeX-generate-create-read-file-name argp))) (t "")) ")\n") (setq argp (1+ argp))) (insert "))\n") (goto-char (point-min)) (while (not (eobp)) (lisp-indent-line) (forward-line 1)) (eval-current-buffer) (set-buffer cb) (YaTeX-update-table (if (> argc 1) (list command argc) (list command)) 'section-table 'user-section-table 'tmp-section-table) buf)) (defun YaTeX-generate-simple (&optional command) "Simple but requiring some elisp knowledge add-in generator." (interactive) (setq YaTeX-generate-variables-for-learning nil) (or command (setq command (completing-read (format "Making add-in function for (default %s): " YaTeX-section-name) (append section-table user-section-table tmp-section-table env-table user-env-table tmp-env-table singlecmd-table user-singlecmd-table tmp-singlecmd-table) nil nil) command (if (string= "" command) YaTeX-section-name command))) (message (cond (YaTeX-japan "(o)追加型? (a)引数型? (yatexadd.docを参照のこと) :") (t "(O)ption? (A)rgument?"))) (YaTeX-showup-buffer (if (= (read-char) ?o) (YaTeX-generate-option-type command) (YaTeX-generate-argument-type command (string-to-int (read-string "How many arguments?: ")))) nil)) (provide 'yatexgen) yatex_1.77+dfsg1/yatexprc.el0000444000175000017500000011466012126310635014540 0ustar kurakura;;; yatexprc.el --- YaTeX process handler ;;; ;;; (c)1993-2013 by HIROSE Yuuji.[yuuji@yatex.org] ;;; Last modified Mon Apr 1 22:44:38 2013 on firestorm ;;; $Id: yatexprc.el,v 1.77 2013/04/01 13:53:45 yuuji Rel $ ;;; Code: ;(require 'yatex) (require 'yatexlib) (defvar YaTeX-typeset-process nil "Process identifier for jlatex") (defvar YaTeX-typeset-buffer "*YaTeX-typesetting*" "Process buffer for jlatex") (defvar YaTeX-typeset-buffer-syntax nil "*Syntax table for typesetting buffer") (defvar YaTeX-current-TeX-buffer nil "Keeps the buffer on which recently typeset run.") (defvar YaTeX-shell-command-option (or (and (boundp 'shell-command-option) shell-command-option) (and (boundp 'shell-command-switch) shell-command-switch) (if YaTeX-dos "/c" "-c")) "Shell option for command execution.") (defvar YaTeX-latex-message-code ;; (cond ;; (YaTeX-dos (cdr (assq 1 YaTeX-kanji-code-alist))) ;; ((and YaTeX-emacs-20 (member 'undecided (coding-system-list)) ;; 'undecided)) ;; ((featurep 'mule) ;; (or (and (boundp '*autoconv*) *autoconv*) ;; (and (fboundp 'coding-system-list) 'automatic-conversion))) ;; ((boundp 'NEMACS) ;; (cdr (assq (if YaTeX-dos 1 2) YaTeX-kanji-code-alist)))) (cond (YaTeX-dos (cdr (assq 1 YaTeX-kanji-code-alist))) (YaTeX-emacs-20 (cdr (assoc latex-message-kanji-code YaTeX-kanji-code-alist))) ((boundp 'MULE) (symbol-value (cdr (assoc latex-message-kanji-code YaTeX-kanji-code-alist)))) ((boundp 'NEMACS) latex-message-kanji-code)) "Process coding system for LaTeX.") (if YaTeX-typeset-buffer-syntax nil (setq YaTeX-typeset-buffer-syntax (make-syntax-table (standard-syntax-table))) (modify-syntax-entry ?\{ "w" YaTeX-typeset-buffer-syntax) (modify-syntax-entry ?\} "w" YaTeX-typeset-buffer-syntax) (modify-syntax-entry ?\[ "w" YaTeX-typeset-buffer-syntax) (modify-syntax-entry ?\] "w" YaTeX-typeset-buffer-syntax)) (defvar YaTeX-typeset-marker nil) (defvar YaTeX-typeset-consumption nil) (make-variable-buffer-local 'YaTeX-typeset-consumption) (defun YaTeX-typeset (command buffer &optional prcname modename ppcmd) "Execute jlatex (or other) to LaTeX typeset." (interactive) (save-excursion (let ((p (point)) (window (selected-window)) execdir (cb (current-buffer)) (map YaTeX-typesetting-mode-map) (outcode (cond ((eq major-mode 'yatex-mode) YaTeX-coding-system) ((eq major-mode 'yahtml-mode) yahtml-kanji-code)))) (if (and YaTeX-typeset-process (eq (process-status YaTeX-typeset-process) 'run)) ;; if tex command is halting. (YaTeX-kill-typeset-process YaTeX-typeset-process)) (YaTeX-put-nonstopmode) (setq prcname (or prcname "LaTeX") modename (or modename "typeset")) (if (eq major-mode 'yatex-mode) (YaTeX-visit-main t)) ;;execution dir (setq execdir default-directory) ;;Select lower-most window if there are more than 2 windows and ;;typeset buffer not seen. (YaTeX-showup-buffer buffer (function (lambda (x) (nth 3 (window-edges x))))) (set-buffer (get-buffer-create buffer)) (setq default-directory execdir) (cd execdir) (erase-buffer) (cond ((not (fboundp 'start-process)) ;YaTeX-dos;if MS-DOS (call-process shell-file-name nil buffer nil YaTeX-shell-command-option command)) (t ;if UNIX (set-process-buffer (setq YaTeX-typeset-process (start-process prcname buffer shell-file-name YaTeX-shell-command-option command)) (get-buffer buffer)) (set-process-sentinel YaTeX-typeset-process 'YaTeX-typeset-sentinel) (put 'YaTeX-typeset-process 'thiscmd command) (put 'YaTeX-typeset-process 'name prcname) (if (fboundp 'current-time) (setq YaTeX-typeset-consumption (cons (cons 'time (current-time)) (delq 'time YaTeX-typeset-consumption)))) (let ((ppprop (get 'YaTeX-typeset-process 'ppcmd))) (setq ppprop (delq (assq YaTeX-typeset-process ppprop) ppprop)) (if ppcmd (setq ppprop (cons (cons YaTeX-typeset-process ppcmd) ppprop))) (put 'YaTeX-typeset-process 'ppcmd ppprop)) (if (and (boundp 'bibcmd) bibcmd) (let ((bcprop (get 'YaTeX-typeset-process 'bibcmd))) (setq bcprop (cons (cons YaTeX-typeset-process bibcmd) (delq (assq YaTeX-typeset-process bcprop) bcprop))) (put 'YaTeX-typeset-process 'bibcmd bcprop))))) (message (format "Calling `%s'..." command)) (setq YaTeX-current-TeX-buffer (buffer-name)) (use-local-map map) ;map may be localized (set-syntax-table YaTeX-typeset-buffer-syntax) (setq mode-name modename) (if YaTeX-typeset-process ;if process is running (maybe on UNIX) (cond ((fboundp 'set-current-process-coding-system) (set-current-process-coding-system YaTeX-latex-message-code outcode)) ((fboundp 'set-process-coding-system) (set-process-coding-system YaTeX-typeset-process YaTeX-latex-message-code outcode)) (YaTeX-emacs-20 (set-buffer-process-coding-system YaTeX-latex-message-code outcode)) ((boundp 'NEMACS) (set-kanji-process-code YaTeX-latex-message-code)))) (set-marker (or YaTeX-typeset-marker (setq YaTeX-typeset-marker (make-marker))) (point)) (insert (format "Call `%s'\n" command)) (if YaTeX-dos (message "Done.") (insert " ") (set-marker (process-mark YaTeX-typeset-process) (1- (point)))) (if (bolp) (forward-line -1)) ;what for? (if (and YaTeX-emacs-19 window-system) (let ((win (get-buffer-window buffer t)) owin) (select-frame (window-frame win)) (setq owin (selected-window)) (select-window win) (goto-char (point-max)) (recenter -1) (select-window owin)) (select-window (get-buffer-window buffer)) (goto-char (point-max)) (recenter -1)) (select-window window) (switch-to-buffer cb) (YaTeX-remove-nonstopmode)))) (defvar YaTeX-typeset-auto-rerun t "*Non-nil automatically reruns typesetter when cross-refs update found. This is a toy mechanism. DO NOT RELY ON THIS MECHANISM. You SHOULD check the integrity of cross-references with your eyes!! Supplying an integer to this variable inhibit compulsory call of bibtex, thus, it call bibtex only if warning messages about citation are seen.") (defvar YaTeX-typeset-rerun-msg "Rerun to get cross-references right.") (defvar YaTeX-typeset-citation-msg "Warning: Citation \`") (defun YaTeX-typeset-sentinel (proc mes) (cond ((null (buffer-name (process-buffer proc))) ;; buffer killed (set-process-buffer proc nil)) ((memq (process-status proc) '(signal exit)) (let* ((obuf (current-buffer)) (pbuf (process-buffer proc)) (pwin (get-buffer-window pbuf)) (owin (selected-window)) win tobecalled shortname (thiscmd (get 'YaTeX-typeset-process 'thiscmd)) (ppprop (get 'YaTeX-typeset-process 'ppcmd)) (ppcmd (cdr (assq proc ppprop))) (bcprop (get 'YaTeX-typeset-process 'bibcmd)) (bibcmd (cdr (assq proc bcprop)))) (put 'YaTeX-typeset-process 'ppcmd ;erase ppcmd (delq (assq proc ppprop) ppprop)) (put 'YaTeX-typeset-process 'bibcmd ;erase bibcmd (delq (assq proc bcprop) bcprop)) ;; save-excursion isn't the right thing if ;; process-buffer is current-buffer (unwind-protect (progn ;; Write something in *typesetting* and hack its mode line (if pwin (select-window pwin) (set-buffer pbuf)) ;;(YaTeX-showup-buffer pbuf nil t) (goto-char (point-max)) (if pwin (recenter -3)) (insert ?\n mode-name " " mes) (forward-char -1) (insert (format " at %s%s\n" (substring (current-time-string) 0 -5) (if (and (fboundp 'current-time) (fboundp 'float) (assq 'time YaTeX-typeset-consumption)) (format " (%.2f secs)" (YaTeX-elapsed-time (cdr (assq 'time YaTeX-typeset-consumption)) (current-time)))))) (setq mode-line-process (concat ": " (symbol-name (process-status proc)))) (message "%s %s" mode-name (if (eq (process-status proc) 'exit) "done" "ceased")) ;; If buffer and mode line shows that the process ;; is dead, we can delete it now. Otherwise it ;; will stay around until M-x list-processes. (delete-process proc) (if (cond ((or (not YaTeX-typeset-auto-rerun) (string-match "latexmk" thiscmd)) nil) ((and bibcmd ;Call bibtex if bibcmd defined && (or ; (1st call || warning found) (and (not (numberp YaTeX-typeset-auto-rerun)) ; cancel call at 1st, if value is a number. (not (string-match "bibtex" mode-name))) (re-search-backward YaTeX-typeset-citation-msg YaTeX-typeset-marker t)) (save-excursion ; && using .bbl files. (search-backward ".bbl" YaTeX-typeset-marker t))) ;; Always call bibtex after the first typesetting, ;; because bibtex doesn't warn disappeared \cite. ;; (Suggested by ryseto. 2012) ;; It is more efficient to call bibtex directly than ;; to call it after deep inspection on the balance ;; of \cite vs. \bib*'s referring all *.aux files. (insert "\n" YaTeX-typeset-rerun-msg "\n") (setq tobecalled bibcmd shortname "+bibtex")) ((or (save-excursion (search-backward YaTeX-typeset-rerun-msg YaTeX-typeset-marker t)) (save-excursion (re-search-backward "natbib.*Rerun to get citations correct" YaTeX-typeset-marker t))) (if bibcmd (put 'YaTeX-typeset-process 'bibcmd (cons (cons (get-buffer-process pbuf) bibcmd) bcprop))) (setq tobecalled thiscmd shortname "+typeset")) (t nil)) ;no need to call any process (progn (insert (format "===!!! %s !!!===\n" (message "Rerun `%s' to get cross-references right" tobecalled))) (if (equal tobecalled thiscmd) (set-marker YaTeX-typeset-marker (point))) (set-process-sentinel (start-process (setq mode-name (concat mode-name shortname)) pbuf shell-file-name YaTeX-shell-command-option tobecalled) 'YaTeX-typeset-sentinel) (if ppcmd (put 'YaTeX-typeset-process 'ppcmd (cons (cons (get-buffer-process pbuf) ppcmd) ppprop))) (if thiscmd (put 'YaTeX-typeset-process 'thiscmd thiscmd))) ;; If ppcmd is active, call it. (cond ((and ppcmd (string-match "finish" mes)) (insert (format "=======> Success! Calling %s\n" ppcmd)) (setq mode-name ; set process name (concat mode-name "+" (substring ppcmd 0 (string-match " " ppcmd)))) ; to reach here, 'start-process exists on this emacsen (set-process-sentinel (start-process mode-name pbuf ; Use this buffer twice. shell-file-name YaTeX-shell-command-option ppcmd) 'YaTeX-typeset-sentinel)) (t ;pull back original mode-name (setq mode-name "typeset")))) (forward-char 1)) (setq YaTeX-typeset-process nil) ;; Force mode line redisplay soon (set-buffer-modified-p (buffer-modified-p)) ) (select-window owin) (set-buffer obuf))))) (defvar YaTeX-texput-file "texput.tex" "*File name for temporary file of typeset-region.") (defun YaTeX-typeset-region () "Paste the region to the file `texput.tex' and execute typesetter. The region is specified by the rule: (1)If keyword `%#BEGIN' is found in the upper direction from (point). (1-1)if the keyword `%#END' is found after `%#BEGIN', ->Assume the text between `%#BEGIN' and `%#END' as region. (1-2)if the keyword `%#END' is not found anywhere after `%#BEGIN', ->Assume the text after `%#BEGIN' as region. (2)If no `%#BEGIN' usage is found before the (point), ->Assume the text between current (point) and (mark) as region. DON'T forget to eliminate the `%#BEGIN/%#END' notation after editing operation to the region." (interactive) (save-excursion (let* ((end "") typeout ;Type out message that tells the method of cutting. (texput YaTeX-texput-file) (cmd (concat (YaTeX-get-latex-command nil) " " texput)) (buffer (current-buffer)) opoint preamble (subpreamble "") main (hilit-auto-highlight nil) ;for Emacs19 with hilit19 reg-begin reg-end lineinfo) (save-excursion (if (search-backward "%#BEGIN" nil t) (progn (setq typeout "--- Region from BEGIN to " end "the end of the buffer ---" reg-begin (match-end 0)) (if (search-forward "%#END" nil t) (setq reg-end (match-beginning 0) end "END ---") (setq reg-end (point-max)))) (setq typeout "=== Region from (point) to (mark) ===" reg-begin (point) reg-end (mark))) (goto-char (min reg-begin reg-end)) (setq lineinfo (count-lines (point-min) (point-end-of-line))) (goto-char (point-min)) (while (search-forward "%#REQUIRE" nil t) (setq subpreamble (concat subpreamble (cond ((eolp) (buffer-substring (match-beginning 0) (point-beginning-of-line))) (t (buffer-substring (match-end 0) (point-end-of-line)))) "\n")) (goto-char (match-end 0)))) (YaTeX-visit-main t) (setq main (current-buffer)) (setq opoint (point)) (goto-char (point-min)) (setq preamble (if (re-search-forward "^[ ]*\\\\begin.*{document}" nil t) (buffer-substring (point-min) (match-end 0)) (concat (if YaTeX-use-LaTeX2e "\\documentclass{" "\\documentstyle{") YaTeX-default-document-style "}\n" "\\begin{document}"))) (goto-char opoint) ;;(set-buffer buffer) ;for clarity (let ((hilit-auto-highlight nil) (auto-mode-alist nil) (magic-mode-alist nil)) ;Do not activate yatex-mode here (set-buffer (find-file-noselect texput))) ;;(find-file YaTeX-texput-file) (erase-buffer) (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop) (insert "\\nonstopmode{}\n")) (insert preamble "\n" subpreamble "\n") (setq lineinfo (list (count-lines 1 (point-end-of-line)) lineinfo)) (insert-buffer-substring buffer reg-begin reg-end) (insert "\\typeout{" typeout end "}\n") ;Notice the selected method. (insert "\n\\end{document}\n") (basic-save-buffer) (kill-buffer (current-buffer)) (set-buffer main) ;return to parent file or itself. (YaTeX-typeset cmd YaTeX-typeset-buffer) (switch-to-buffer buffer) ;for Emacs-19 (put 'dvi2-command 'region t) (put 'dvi2-command 'file buffer) (put 'dvi2-command 'offset lineinfo)))) (defun YaTeX-typeset-environment () "Typeset current math environment" (interactive) (save-excursion (YaTeX-mark-environment) (YaTeX-typeset-region))) (defun YaTeX-typeset-buffer (&optional pp) "Typeset whole buffer. If %#! usage says other buffer is main text, visit main buffer to confirm if its includeonly list contains current buffer's file. And if it doesn't contain editing text, ask user which action wants to be done, A:Add list, R:Replace list, %:comment-out list. If optional argument PP given as string, PP is considered as post-process command and call it with the same command argument as typesetter without last extension. eg. if PP is \"dvipdfmx\", called commands as follows. platex foo.tex dvipdfmx foo PP command will be called iff typeset command exit successfully" (interactive) (YaTeX-save-buffers) (let*((me (substring (buffer-name) 0 (rindex (buffer-name) ?.))) (mydir (file-name-directory (buffer-file-name))) (cmd (YaTeX-get-latex-command t)) pparg ppcmd bibcmd (cb (current-buffer))) (setq pparg (substring cmd 0 (string-match "[;&]" cmd)) ;rm multistmt pparg (substring pparg (rindex pparg ? )) ;get last arg pparg (substring pparg 0 (rindex pparg ?.)) ;rm ext bibcmd (or (YaTeX-get-builtin "BIBTEX") bibtex-command)) (or (string-match "\\s " bibcmd) ;if bibcmd has no spaces, (setq bibcmd (concat bibcmd pparg))) ;append argument(== %#!) (and pp (stringp pp) (setq ppcmd (concat pp pparg))) (if (YaTeX-main-file-p) nil (save-excursion (YaTeX-visit-main t) ;search into main buffer (save-excursion (push-mark (point) t) (goto-char (point-min)) (if (and (re-search-forward "^[ ]*\\\\begin{document}" nil t) (re-search-backward "^[ ]*\\\\includeonly{" nil t)) (let* ((b (progn (skip-chars-forward "^{") (point))) (e (progn (skip-chars-forward "^}") (1+ (point)))) (s (buffer-substring b e)) c (pardir (file-name-directory (buffer-file-name)))) (if (string-match (concat "[{,/]" me "[,}]") s) nil ; Nothing to do when it's already in includeonly. (ding) (switch-to-buffer (current-buffer));Display this buffer. (setq me ;;Rewrite my name(me) to contain sub directory name. (concat (if (string-match pardir mydir) ;if mydir is child of main (substring mydir (length pardir)) ;cut absolute path mydir) ;else concat absolute path name. me)) (message "`%s' is not in \\includeonly. A)dd R)eplace %%)comment? " me) (setq c (read-char)) (cond ((= c ?a) (goto-char (1+ b)) (insert me (if (string= s "{}") "" ","))) ((= c ?r) (delete-region (1+ b) (1- e)) (insert me)) ((= c ?%) (beginning-of-line) (insert "%")) (t nil)) (basic-save-buffer)))) (exchange-point-and-mark))) (switch-to-buffer cb)) ;for 19 (YaTeX-typeset cmd YaTeX-typeset-buffer nil nil ppcmd) (put 'dvi2-command 'region nil))) (defvar YaTeX-call-command-history nil "Holds history list of YaTeX-call-command-on-file.") (put 'YaTeX-call-command-history 'no-default t) (defun YaTeX-call-command-on-file (base-cmd buffer &optional file) "Call external command BASE-CMD in the BUFFER. By default, pass the basename of current file. Optional 3rd argument FILE changes the default file name." (YaTeX-save-buffers) (let ((default (concat base-cmd " " (let ((me (file-name-nondirectory (or file buffer-file-name)))) (if (string-match "\\.tex" me) (substring me 0 (match-beginning 0)) me))))) (or YaTeX-call-command-history (setq YaTeX-call-command-history (list default))) (YaTeX-typeset (read-string-with-history "Call command: " (car YaTeX-call-command-history) 'YaTeX-call-command-history) buffer))) (defvar YaTeX-call-builtin-on-file) (make-variable-buffer-local 'YaTeX-call-builtin-on-file) (defun YaTeX-call-builtin-on-file (builtin-type &optional default update) "Call command on file specified by BUILTIN-TYPE." (YaTeX-save-buffers) (let*((main (or YaTeX-parent-file (save-excursion (YaTeX-visit-main t) buffer-file-name))) (mainroot (file-name-nondirectory (substring main 0 (rindex main ?.)))) (alist YaTeX-call-builtin-on-file) (b-in (or (YaTeX-get-builtin builtin-type) (cdr (assoc builtin-type alist)))) (command b-in)) (if (or update (null b-in)) (progn (setq command (read-string-with-history (format "%s command: " builtin-type) (or b-in (format "%s %s" default mainroot)) 'YaTeX-call-command-history)) (if (or update (null b-in)) (if (y-or-n-p "Use this command line in the future? ") (YaTeX-getset-builtin builtin-type command) ;keep in a file (setq YaTeX-call-builtin-on-file ;keep in memory (cons (cons builtin-type command) (delete (assoc builtin-type alist) alist))))))) (YaTeX-typeset command (format " *YaTeX-%s*" (downcase builtin-type))))) (defun YaTeX-kill-typeset-process (proc) "Kill process PROC after sending signal to PROC. PROC should be process identifier." (cond ((not (fboundp 'start-process)) (error "This system can't have concurrent process.")) ((or (null proc) (not (eq (process-status proc) 'run))) (message "Typesetting process is not running.")) (t (save-excursion (set-buffer (process-buffer proc)) (save-excursion (goto-char (point-max)) (beginning-of-line) (if (looking-at "\\? +$") (let ((mp (point-max))) (process-send-string proc "x\n") (while (= mp (point-max)) (sit-for 1)))))) (if (eq (process-status proc) 'run) (progn (interrupt-process proc) (delete-process proc)))))) (defun YaTeX-system (command buffer) "Execute some command on buffer. Not a official function." (save-excursion (YaTeX-showup-buffer buffer (function (lambda (x) (nth 3 (window-edges x))))) (let ((df default-directory)) ;preserve current buf's pwd (set-buffer (get-buffer-create buffer)) ;1.61.3 (setq default-directory df) (cd df)) (erase-buffer) (if (not (fboundp 'start-process)) (call-process shell-file-name nil buffer nil YaTeX-shell-command-option command) (if (and (get-buffer-process buffer) (eq (process-status (get-buffer-process buffer)) 'run) (not (y-or-n-p (format "Process %s is running. Continue?" buffer)))) nil (set-process-buffer (start-process "system" buffer shell-file-name YaTeX-shell-command-option command) (get-buffer buffer)))))) (defvar YaTeX-default-paper-type "a4" "*Default paper type.") (defconst YaTeX-paper-type-alist '(("a4paper" . "a4") ("a5paper" . "a5") ("b4paper" . "b4") ("b5paper" . "b5")) "Holds map of options and paper types.") (defconst YaTeX-dvips-paper-option-alist '(("a4" . "-t a4") ("a5" . "-t a5") ("b4" . "-t b4") ("b5" . "-t b5") ("a4r" . "-t landscape"); Can't specify options, `-t a4' and `-t landscape', at the same time. ("a5r" . "-t landscape") ("b4r" . "-t landscape") ("b5r" . "-t landscape")) "Holds map of dvips options and paper types.") (defun YaTeX-get-paper-type () "Search options in header and return a paper type, such as \"a4\", \"a4r\", etc." (save-excursion (YaTeX-visit-main t) (goto-char (point-min)) (let ((opts (if (re-search-forward "^[ \t]*\\\\document\\(style\\|class\\)[ \t]*\\[\\([^]]*\\)\\]" nil t) (YaTeX-split-string (YaTeX-match-string 2) "[ \t]*,[ \t]*")))) (concat (catch 'found-paper (mapcar (lambda (pair) (if (YaTeX-member (car pair) opts) (throw 'found-paper (cdr pair)))) YaTeX-paper-type-alist) YaTeX-default-paper-type) (if (YaTeX-member "landscape" opts) (if YaTeX-dos "L" "r") ""))))) (defvar YaTeX-preview-command-history nil "Holds minibuffer history of preview command.") (put 'YaTeX-preview-command-history 'no-default t) (defvar YaTeX-preview-file-history nil "Holds minibuffer history of file to preview.") (put 'YaTeX-preview-file-history 'no-default t) (defun YaTeX-preview (preview-command preview-file) "Execute xdvi (or other) to tex-preview." (interactive (let* ((command (read-string-with-history "Preview command: " (YaTeX-replace-format (or (YaTeX-get-builtin "PREVIEW") dvi2-command) "p" (format (cond (YaTeX-dos "-y:%s") (t "-paper %s")) (YaTeX-get-paper-type))) 'YaTeX-preview-command-history)) (file (read-string-with-history "Preview file: " (if (get 'dvi2-command 'region) (substring YaTeX-texput-file 0 (rindex YaTeX-texput-file ?.)) (YaTeX-get-preview-file-name command)) 'YaTeX-preview-file-history))) (list command file))) (setq dvi2-command preview-command) ;`dvi2command' is buffer local (save-excursion (YaTeX-visit-main t) (if YaTeX-dos (setq preview-file (expand-file-name preview-file))) (let ((pbuffer "*dvi-preview*") (dir default-directory)) (YaTeX-showup-buffer pbuffer (function (lambda (x) (nth 3 (window-edges x))))) (set-buffer (get-buffer-create pbuffer)) (erase-buffer) (setq default-directory dir) ;for 18 (cd dir) ;for 19 (cond ((not (fboundp 'start-process)) ;if MS-DOS (send-string-to-terminal "\e[2J\e[>5h") ;CLS & hide cursor (call-process shell-file-name "con" "*dvi-preview*" nil YaTeX-shell-command-option (concat preview-command " " preview-file)) (send-string-to-terminal "\e[>5l") ;show cursor (redraw-display)) ((and (string-match "dviout" preview-command) ;maybe on `kon' (stringp (getenv "TERM")) (string-match "^kon" (getenv "TERM"))) (call-process shell-file-name "con" "*dvi-preview*" nil YaTeX-shell-command-option (concat preview-command " " preview-file))) (t ;if UNIX (set-process-buffer (let ((process-connection-type nil)) (start-process "preview" "*dvi-preview*" shell-file-name YaTeX-shell-command-option (concat preview-command " " preview-file))) (get-buffer pbuffer)) (message (concat "Starting " preview-command " to preview " preview-file))))))) (defvar YaTeX-xdvi-remote-program "xdvi") (defun YaTeX-xdvi-remote-search (&optional region-mode) "Search string at the point on xdvi -remote window. Non-nil for optional argument REGION-MODE specifies the search string by region." (interactive "P") (let ((pb " *xdvi*") str proc) (save-excursion (if region-mode (setq str (buffer-substring (region-beginning) (region-end))) (setq str (buffer-substring (point) (progn (skip-chars-forward "^\n\\\\}") (point))))) (message "Searching `%s'..." str) (if (boundp 'MULE) (define-program-coding-system (regexp-quote pb) (regexp-quote YaTeX-xdvi-remote-program) *euc-japan*)) (setq proc (start-process "xdvi" pb YaTeX-xdvi-remote-program "-remote" (format "SloppySearch(%s) " str) (concat (YaTeX-get-preview-file-name) ".dvi"))) (message "Searching `%s'...Done" str)))) (defun YaTeX-set-virtual-error-position (file-sym line-sym) "Replace the value of FILE-SYM, LINE-SYM by virtual error position." (cond ((and (get 'dvi2-command 'region) (> (symbol-value line-sym) (car (get 'dvi2-command 'offset)))) (set file-sym (get 'dvi2-command 'file)) (set line-sym (+ (- (apply '- (get 'dvi2-command 'offset))) (symbol-value line-sym) -1))))) (defun YaTeX-prev-error () "Visit position of previous typeset error or warning. To avoid making confliction of line numbers by editing, jump to error or warning lines in reverse order." (interactive) (let ((cur-buf (save-excursion (YaTeX-visit-main t) (buffer-name))) (cur-win (selected-window)) b0 bound errorp error-line typeset-win error-buffer error-win) (if (null (get-buffer YaTeX-typeset-buffer)) (error "There is no typesetting buffer.")) (YaTeX-showup-buffer YaTeX-typeset-buffer nil t) (if (and (markerp YaTeX-typeset-marker) (eq (marker-buffer YaTeX-typeset-marker) (current-buffer))) (setq bound YaTeX-typeset-marker)) (setq typeset-win (selected-window)) (if (re-search-backward (concat "\\(" latex-error-regexp "\\)\\|\\(" latex-warning-regexp "\\)") bound t) (setq errorp (match-beginning 1)) (select-window cur-win) (error "No more errors on %s" cur-buf)) (goto-char (setq b0 (match-beginning 0))) (skip-chars-forward "^0-9" (match-end 0)) (setq error-line (string-to-int (buffer-substring (point) (progn (skip-chars-forward "0-9" (match-end 0)) (point)))) error-buffer (expand-file-name (YaTeX-get-error-file cur-buf))) (if (or (null error-line) (equal 0 error-line)) (error "Can't detect error position.")) (YaTeX-set-virtual-error-position 'error-buffer 'error-line) (setq error-win (get-buffer-window error-buffer)) (select-window cur-win) (cond (error-win (select-window error-win)) ((eq (get-lru-window) typeset-win) (YaTeX-switch-to-buffer error-buffer)) (t (select-window (get-lru-window)) (YaTeX-switch-to-buffer error-buffer))) (setq error-win (selected-window)) (goto-line error-line) (message "LaTeX %s in `%s' on line: %d." (if errorp "error" "warning") error-buffer error-line) (select-window typeset-win) (skip-chars-backward "0-9") (recenter (/ (window-height) 2)) (sit-for 1) (goto-char b0) (select-window error-win))) (defun YaTeX-jump-error-line () "Jump to corresponding line on latex command's error message." (interactive) (let (error-line error-file error-buf) (save-excursion (beginning-of-line) (setq error-line (re-search-forward "l[ ines]*\\.?\\([1-9][0-9]*\\)" (point-end-of-line) t))) (if (null error-line) (if (eobp) (insert (this-command-keys)) (error "No line number expression.")) (goto-char (match-beginning 0)) (setq error-line (string-to-int (buffer-substring (match-beginning 1) (match-end 1))) error-file (expand-file-name (YaTeX-get-error-file YaTeX-current-TeX-buffer))) (YaTeX-set-virtual-error-position 'error-file 'error-line) (setq error-buf (YaTeX-switch-to-buffer error-file t))) (if (null error-buf) (error "`%s' is not found in this directory." error-file)) (YaTeX-showup-buffer error-buf nil t) (goto-line error-line))) (defun YaTeX-send-string () "Send string to current typeset process." (interactive) (if (and (eq (process-status YaTeX-typeset-process) 'run) (>= (point) (process-mark YaTeX-typeset-process))) (let ((b (process-mark YaTeX-typeset-process)) (e (point-end-of-line))) (goto-char b) (skip-chars-forward " \t" e) (setq b (point)) (process-send-string YaTeX-typeset-process (concat (buffer-substring b e) "\n")) (goto-char e) (insert "\n") (set-marker (process-mark YaTeX-typeset-process) (point)) (insert " ")) (ding))) (defun YaTeX-view-error () (interactive) (if (null (get-buffer YaTeX-typeset-buffer)) (message "No typeset buffer found.") (let ((win (selected-window))) (YaTeX-showup-buffer YaTeX-typeset-buffer nil t) ;; Next 3 lines are obsolete because YaTeX-typesetting-buffer is ;; automatically scrolled up at typesetting. ;;(goto-char (point-max)) ;;(forward-line -1) ;;(recenter -1) (select-window win)))) (defun YaTeX-get-error-file (default) "Get current processing file from typesetting log." (save-excursion (let(s) (condition-case () (up-list -1) (error (let ((list 0) found) (while (and (<= list 0) (not found) (re-search-backward "\\((\\)\\|\\()\\)" nil t)) (if (equal (match-beginning 0) (match-beginning 2)) ;close paren. (setq list (1- list)) ;open paren (setq list (1+ list)) (if (= list 1) (if (looking-at "\\([^,{}%]+\.\\)tex\\|sty") (setq found t) (setq list (1- list))))))))) (setq s (buffer-substring (progn (forward-char 1) (point)) (progn (skip-chars-forward "^ \n" (point-end-of-line)) (point)))) (if (string= "" s) default s)))) (defun YaTeX-put-nonstopmode () (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop) (if (re-search-backward "\\\\nonstopmode{}" (point-min) t) nil ;if already written in text then do nothing (save-excursion (YaTeX-visit-main t) (goto-char (point-min)) (insert "\\nonstopmode{}%_YaTeX_%\n") (if (buffer-file-name) (basic-save-buffer)))))) (defun YaTeX-remove-nonstopmode () (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop) ;for speed (save-excursion (YaTeX-visit-main t) (goto-char (point-min)) (forward-line 1) (narrow-to-region (point-min) (point)) (goto-char (point-min)) (delete-matching-lines "^\\\\nonstopmode\\{\\}%_YaTeX_%$") (widen)))) (defvar YaTeX-dvi2-command-ext-alist '(("[agx]dvi\\|dviout" . ".dvi") ("ghostview\\|gv" . ".ps") ("acroread\\|xpdf\\|pdfopen\\|Preview\\|TeXShop\\|Skim\\|evince\\|mupdf\\|zathura\\|okular" . ".pdf"))) (defun YaTeX-get-preview-file-name (&optional preview-command) "Get file name to preview by inquiring YaTeX-get-latex-command" (if (null preview-command) (setq preview-command dvi2-command)) (let* ((latex-cmd (YaTeX-get-latex-command t)) (rin (rindex latex-cmd ? )) (fname (if rin (substring latex-cmd (1+ rin)) "")) (r (YaTeX-assoc-regexp preview-command YaTeX-dvi2-command-ext-alist)) (ext (if r (cdr r) ""))) (concat (if (string= fname "") (setq fname (substring (file-name-nondirectory (buffer-file-name)) 0 -4)) (setq fname (substring fname 0 (rindex fname ?.)))) ext))) (defun YaTeX-get-latex-command (&optional switch) "Specify the latex-command name and its argument. If there is a line which begins with string: \"%#!\", the following strings are assumed to be the latex-command and arguments. The default value of latex-command is: tex-command FileName and if you write \"%#!jlatex\" in the beginning of certain line. \"jlatex \" FileName will be the latex-command, and you write \"%#!jlatex main.tex\" on some line and argument SWITCH is non-nil, then \"jlatex main.tex\" will be given to the shell." (let (parent tparent magic) (setq parent (cond (YaTeX-parent-file (if YaTeX-dos (expand-file-name YaTeX-parent-file) YaTeX-parent-file)) (t (save-excursion (YaTeX-visit-main t) (file-name-nondirectory (buffer-file-name))))) magic (YaTeX-get-builtin "!") tparent (file-name-nondirectory parent)) (YaTeX-replace-formats (cond (magic (cond (switch (if (string-match "\\s " magic) magic (concat magic " " parent))) (t (concat (substring magic 0 (string-match "\\s " magic)) " ")))) (t (concat tex-command " " (if switch parent)))) (list (cons "f" tparent) (cons "r" (substring tparent 0 (rindex tparent ?.))))))) (defvar YaTeX-lpr-command-history nil "Holds command line history of YaTeX-lpr.") (put 'YaTeX-lpr-command-history 'no-default t) (defvar YaTeX-lpr-ask-page-range-default t) (defun YaTeX-lpr (arg) "Print out. If prefix arg ARG is non nil, call print driver without page range description." (interactive "P") (or YaTeX-lpr-ask-page-range-default (setq arg (not arg))) (let*((cmd (or (YaTeX-get-builtin "LPR") dviprint-command-format)) from to (lbuffer "*dvi-printing*") dir) (setq cmd (YaTeX-replace-format cmd "f" (if (or arg (not (string-match "%f" cmd))) "" (YaTeX-replace-format dviprint-from-format "b" (if (string= (setq from (read-string "From page(default 1): ")) "") "1" from)))) ) (setq cmd (YaTeX-replace-format cmd "t" (if (or arg (not (string-match "%t" cmd)) (string= (setq to (read-string "To page(default none): ")) "")) "" (YaTeX-replace-format dviprint-to-format "e" to))) ) (setq cmd (YaTeX-replace-format cmd "p" (cdr (assoc (YaTeX-get-paper-type) YaTeX-dvips-paper-option-alist)))) (setq cmd (read-string-with-history "Edit command line: " (format cmd (if (get 'dvi2-command 'region) (substring YaTeX-texput-file 0 (rindex YaTeX-texput-file ?.)) (YaTeX-get-preview-file-name))) 'YaTeX-lpr-command-history)) (save-excursion (YaTeX-visit-main t) ;;change execution directory (setq dir default-directory) (YaTeX-showup-buffer lbuffer (function (lambda (x) (nth 3 (window-edges x))))) (set-buffer (get-buffer-create lbuffer)) (erase-buffer) (cd dir) ;for 19 (cond ((not (fboundp 'start-process)) (call-process shell-file-name "con" "*dvi-printing*" nil YaTeX-shell-command-option cmd)) (t (set-process-buffer (let ((process-connection-type nil)) (start-process "print" "*dvi-printing*" shell-file-name YaTeX-shell-command-option cmd)) (get-buffer lbuffer)) (message "Starting printing command: %s..." cmd)))))) (defun YaTeX-main-file-p () "Return if current buffer is main LaTeX source." (cond (YaTeX-parent-file (eq (get-file-buffer YaTeX-parent-file) (current-buffer))) ((YaTeX-get-builtin "!") (string-match (concat "^" (YaTeX-guess-parent (YaTeX-get-builtin "!"))) (buffer-name))) (t (save-excursion (let ((latex-main-id (concat "^\\s *" YaTeX-ec-regexp "document\\(style\\|class\\)"))) (or (re-search-backward latex-main-id nil t) (re-search-forward latex-main-id nil t))))))) (defun YaTeX-visit-main (&optional setbuf) "Switch buffer to main LaTeX source. Use set-buffer instead of switch-to-buffer if the optional argument SETBUF is t(Use it only from Emacs-Lisp program)." (interactive "P") (if (and (interactive-p) setbuf) (setq YaTeX-parent-file nil)) (let ((ff (function (lambda (f) (if setbuf (set-buffer (find-file-noselect f)) (find-file f))))) b-in main-file YaTeX-create-file-prefix-g (hilit-auto-highlight (not setbuf))) (if (setq b-in (YaTeX-get-builtin "!")) (setq main-file (YaTeX-guess-parent b-in))) (if YaTeX-parent-file (setq main-file ;;(get-file-buffer YaTeX-parent-file) YaTeX-parent-file)) (if (YaTeX-main-file-p) (if (interactive-p) (message "I think this is main LaTeX source.") nil) (cond ((and ;;(interactive-p) main-file (cond ((get-file-buffer main-file) (cond (setbuf (set-buffer (get-file-buffer main-file))) ((get-buffer-window (get-file-buffer main-file)) (select-window (get-buffer-window (get-file-buffer main-file)))) (t (switch-to-buffer (get-file-buffer main-file))))) ((file-exists-p main-file) (funcall ff main-file))))) ;;((and main-file (YaTeX-switch-to-buffer main-file setbuf))) ((and main-file (file-exists-p (setq main-file (concat "../" main-file))) (or b-in (y-or-n-p (concat (expand-file-name main-file) " is main file?:")))) (setq YaTeX-parent-file main-file) ;(YaTeX-switch-to-buffer main-file setbuf) (funcall ff main-file) ) (t (setq main-file (read-file-name "Enter your main text: " nil nil 1)) (setq YaTeX-parent-file main-file) ; (YaTeX-switch-to-buffer main-file setbuf)) (funcall ff main-file)) ))) nil) (defun YaTeX-guess-parent (command-line) (setq command-line (if (string-match ".*\\s " command-line) (substring command-line (match-end 0)) (file-name-nondirectory (buffer-file-name))) command-line (concat (if (string-match "\\(.*\\)\\." command-line) (substring command-line (match-beginning 1) (match-end 1)) command-line) ".tex"))) (defun YaTeX-visit-main-other-window () "Switch to buffer main LaTeX source in other window." (interactive) (if (YaTeX-main-file-p) (message "I think this is main LaTeX source.") (YaTeX-switch-to-buffer-other-window (concat (YaTeX-get-preview-file-name) ".tex")))) (defun YaTeX-save-buffers () "Save buffers whose major-mode is equal to current major-mode." (basic-save-buffer) (let ((cmm major-mode)) (save-excursion (mapcar '(lambda (buf) (set-buffer buf) (if (and (buffer-file-name buf) (eq major-mode cmm) (buffer-modified-p buf) (y-or-n-p (format "Save %s" (buffer-name buf)))) (save-buffer buf))) (buffer-list))))) (provide 'yatexprc) yatex_1.77+dfsg1/newpage.rb0000755000175000017500000000603611703451323014334 0ustar kurakura#!/usr/bin/env ruby # THIS is very very tentative. Insufficient examination of function. # Create new HTML file referring other HTML file in the same directory. # (C)2010 by HIROSE Yuuji [yuuji@yatex.org] # Last modified Mon Sep 6 16:16:33 2010 on firestorm # $Id: newpage.rb,v 33c8875f52f9 2012-01-12 12:26 +0900 yuuji $ # http://www.yatex.org # Example: # newpage.rb Create new index.html by copying template. # newpage.rb foo.html Create new foo.html whose by copying header # and footer from index.html. # newpage.rb d/sub.html Create new directory d (if necessary) and # d/sub.html by copying header/footer from # index.html in a same directory or parent # directory rewriting href to css file # considering relative path. # newpage.rb -o [file] Forcibly overwrite existing file. # newpage.rb -c cssfile Set `cssfile' as defualt css. # newpage.rb -t template Set `template' as HTML template. require 'fileutils' mydir=File.dirname($0) myname=File.basename($0, ".rb") index = 'index.html' cssdefault = nil overwrite = nil template = __FILE__ #File.expand_path(myname+".html", mydir) def guesscss(dir) end while ARGV[0] && /^-/ =~ (a0=ARGV[0].dup) && ARGV.shift break if /^--$/ =~ a0 while /^-[A-Za-z]/ =~ a0 case a0 when "-c" # css ARGV.shift; cssdefault = ARGV[0] when "-t" # template ARGV.shift; cssdefault = ARGV[0] when "-o" # overwrite overwrite = true end a0.sub!(/-.(.*)/, '-\\1') end end outfile = ARGV[0]||index if !overwrite && test(?s, outfile) then STDERR.printf("File \`%s' exists. Use -o option to overwrite.\n", outfile) exit 1 end # set css default file dots = 0 of = outfile dots+=1 while "." != (of=File.dirname(of)) cssdir = "../"*dots # set copy source outdir = File.dirname(outfile) if "index.html" == File.basename(outfile) src = (dots == 0 ? template : "index.html") elsif test(?s, outdir+"/index.html") src = outdir+"/index.html" else src = template end FileUtils.mkdir_p(outdir) cssfile = cssdir+"main.css" name = File.basename(outfile, ".html") begin open(outfile, "w") do |out| #IO.foreach(src) do |line| if src == __FILE__ input = DATA else input = open(src, "r") end begin html = input.readlines.join html.sub!(%r|^|i, sprintf("

%s

\n", name)) if !html.gsub!("__CSSFILE__", cssfile) html.gsub!(/href=(['\"])(.*\.css)\1/, 'href="'+cssdir+'\2"') end html.gsub!("__TITLE__", name) out.print html ensure input.close end end printf(<<_EOS_, outfile, name) %s _EOS_ rescue p $! STDERR.printf(<<'_EOS_', outfile, outfile) Cannot output to [%s]. Do chmod +w %s or chmod +w . or change output directory. _EOS_ exit 1 end __END__ __TITLE__

__TITLE__

yatex_1.77+dfsg1/yatexadd.el0000444000175000017500000021052412126310635014500 0ustar kurakura;;; yatexadd.el --- YaTeX add-in functions ;;; yatexadd.el rev.20 ;;; (c)1991-2013 by HIROSE Yuuji.[yuuji@yatex.org] ;;; Last modified Mon Apr 1 22:43:00 2013 on firestorm ;;; $Id: yatexadd.el,v 1.77 2013/04/01 13:53:45 yuuji Rel $ ;;; Code: ;;; ;;Sample functions for LaTeX environment. ;;; (defvar YaTeX:tabular-default-rule "@{\\vrule width 1pt\\ }c|c|c@{\\ \\vrule width 1pt}" "*Your favorite default rule format.") (defvar YaTeX:tabular-thick-vrule "\\vrule width %s" "*Vertical thick line format (without @{}). %s'll be replaced by its width.") (defvar YaTeX:tabular-thick-hrule "\\noalign{\\hrule height %s}" "*Horizontal thick line format. %s will be replaced by its width.") (defun YaTeX:tabular () "YaTeX add-in function for tabular environment. Notice that this function refers the let-variable `env' in YaTeX-make-begin-end." (let ((width "") bars (rule "") (and "") (j 1) loc ans (hline "\\hline")) (if (string= YaTeX-env-name "tabular*") (setq width (concat "{" (read-string "Width: ") "}"))) (setq loc (YaTeX:read-position "tb") bars (string-to-int (read-string "Number of columns(0 for default format): " "3"))) (if (<= bars 0) (setq ;if 0, simple format rule YaTeX:tabular-default-rule and "& &") (while (< j bars) ;repeat bars-1 times (setq rule (concat rule "c|") and (concat and "& ") j (1+ j))) (setq rule (concat rule "c")) (message "(N)ormal-frame or (T)hick frame? [nt]") (setq ans (read-char)) (cond ((or (equal ans ?t) (equal ans ?T)) (setq ans (read-string "Rule width: " "1pt") rule (concat "@{" (format YaTeX:tabular-thick-vrule ans) "}" rule "@{\\ " (format YaTeX:tabular-thick-vrule ans) "}") hline (format YaTeX:tabular-thick-hrule ans))) (t (setq rule (concat "|" rule "|") hline "\\hline")))) (setq rule (read-string "rule format: " rule)) (setq YaTeX-single-command "hline") (format "%s%s{%s}" width loc rule))) (fset 'YaTeX:tabular* 'YaTeX:tabular) (fset 'YaTeX:supertabular 'YaTeX:tabular) (defun YaTeX:alignat () (concat "{" (read-string "Number of columns: ") "}")) (defun YaTeX:array () (concat (YaTeX:read-position "tb") "{" (read-string "Column format: ") "}")) (defun YaTeX:subequations () (message (if YaTeX-japan "分かりやすいコメントに変えるとref補完が楽よ" "Changing comment string reduces effort at `ref' completion")) (concat " " YaTeX-comment-prefix (YaTeX::ref-default-label "%H:%M") (if YaTeX-japan "の式群" "equations"))) (defun YaTeX:read-oneof (oneof &optional quick allow-dup) (let ((pos "") loc (guide "")) (and (boundp 'name) name (setq guide (format "%s " name))) (catch 'quick (while (not (string-match (setq loc (read-key-sequence (format "%s position (`%s') [%s]: " guide oneof pos));name is in YaTeX-addin loc (if (fboundp 'events-to-keys) (events-to-keys loc) loc)) "\r\^g\n")) (cond ((string-match loc oneof) (if (or allow-dup (not (string-match loc pos))) (setq pos (concat pos loc))) (if quick (throw 'quick t))) ((and (string-match loc "\C-h\C-?") (> (length pos) 0)) (setq pos (substring pos 0 (1- (length pos))))) (t (ding) (message "Please input one of `%s'." oneof) (sit-for 3))))) (message "") pos)) (defun YaTeX:read-position (oneof) "Read a LaTeX (optional) position format such as `[htbp]'." (let ((pos (YaTeX:read-oneof oneof))) (if (string= pos "") "" (concat "[" pos "]")))) ;;; ;; Functions for figure environemnt ;;; (defvar YaTeX:figure-caption-first nil "Non-nil indicates put caption before figure.") (defun YaTeX:figure (&optional type firstp) "YaTeX add-in function for figure(*) environment." (setq YaTeX-section-name (if YaTeX:figure-caption-first "caption" "includegraphics") YaTeX-env-name "center") (YaTeX:read-position "htbp")) (fset 'YaTeX:figure* 'YaTeX:figure) ;;; ;; Functions for table environemnt ;;; (defvar YaTeX:table-caption-first t "*Non-nil indicates put caption before tabular.") (defun YaTeX:table () "YaTeX add-in function for table environment." (cond ((eq major-mode 'yatex-mode) (setq YaTeX-section-name (if YaTeX:table-caption-first "caption" "label") YaTeX-env-name "tabular") (YaTeX:read-position "htbp")) ((eq major-mode 'texinfo-mode) (concat " " (completing-read "Highlights with: " '(("@samp")("@kbd")("@code")("@asis")("@file")("@var")) nil nil "@"))))) (fset 'YaTeX:table* 'YaTeX:table) (defun YaTeX:description () "Truly poor service:-)" (setq YaTeX-single-command "item[]") "") (defun YaTeX:itemize () "It's also poor service." (setq YaTeX-single-command "item") "") (defun YaTeX:enumerate () (setq YaTeX-single-command "item" YaTeX-section-name "label") "") (defun YaTeX:picture () "Ask the size of coordinates of picture environment." (concat (YaTeX:read-coordinates "Picture size") (YaTeX:read-coordinates "Initial position"))) (defun YaTeX:equation () (YaTeX-jmode-off) (if (fboundp 'YaTeX-toggle-math-mode) (YaTeX-toggle-math-mode t))) ;force math-mode ON. (mapcar '(lambda (f) (fset f 'YaTeX:equation)) '(YaTeX:eqnarray YaTeX:eqnarray* YaTeX:align YaTeX:align* YaTeX:split YaTeX:multline YaTeX:multline* YaTeX:gather YaTeX:gather* YaTeX:aligned* YaTeX:gathered YaTeX:gathered* YaTeX:alignat YaTeX:alignat* YaTeX:xalignat YaTeX:xalignat* YaTeX:xxalignat YaTeX:xxalignat*)) (defun YaTeX:alignat () (YaTeX:equation) (concat "{" (read-string "Number of cols: ") "}")) (defun YaTeX:list () "%\n{} %default label\n{} %formatting parameter") (defun YaTeX:minipage () (concat (YaTeX:read-position "cbt") "{" (read-string "Width: ") "}")) (defun YaTeX:thebibliography () (setq YaTeX-section-name "bibitem") (concat "{" (read-string "Longest label: ") "}")) (defun YaTeX:multicols () (concat "{" (read-string "Number of columns: ") "}")) ;;; ;;Sample functions for section-type command. ;;; (defun YaTeX:multiput () (concat (YaTeX:read-coordinates "Pos") (YaTeX:read-coordinates "Step") "{" (read-string "How many times: ") "}")) (defun YaTeX:put () (YaTeX:read-coordinates "Pos")) (defun YaTeX:makebox () (cond ((YaTeX-in-environment-p "picture") (concat (YaTeX:read-coordinates "Dimension") (YaTeX:read-position "lsrtb"))) (t (let ((width (read-string "Width: "))) (if (string< "" width) (progn (or (equal (aref width 0) ?\[) (setq width (concat "[" width "]"))) (concat width (YaTeX:read-position (if YaTeX-use-LaTeX2e "lrs" "lr"))))))))) ;; (defun YaTeX:framebox () ;; (if (YaTeX-quick-in-environment-p "picture") ;; (YaTeX:makebox))) (fset 'YaTeX:framebox 'YaTeX:makebox) (defun YaTeX:parbox () (YaTeX:read-position "tbc")) (defun YaTeX::parbox (argp) (cond ((= argp 1) (read-string "Width: ")) ((= argp 2) (read-string "Text: ")))) (defun YaTeX::dashbox () (concat "{" (read-string "Dash dimension: ") "}" (YaTeX:read-coordinates "Dimension"))) (defun YaTeX::savebox (argp) (cond ((= argp 1) (read-string "Saved into name: " "\\")) ((= argp 2) (read-string "Text: ")))) (defvar YaTeX-minibuffer-quick-map nil) (if YaTeX-minibuffer-quick-map nil (setq YaTeX-minibuffer-quick-map (copy-keymap minibuffer-local-completion-map)) (let ((ch (1+ ? ))) (while (< ch 127) (define-key YaTeX-minibuffer-quick-map (char-to-string ch) 'YaTeX-minibuffer-quick-complete) (setq ch (1+ ch))))) (defvar YaTeX:left-right-delimiters '(("(" . ")") (")" . "(") ("[" . "]") ("]" . "[") ("\\{" . "\\}") ("\\}" . "\\{") ("|") ("\\|") ("\\lfloor" . "\\rfloor") ("\\lceil" . "\\rceil") ("\\langle" . "\\rangle") ("/") (".") ("\\rfloor" . "\\rfloor") ("\\rceil" . "\\lceil") ("\\rangle" . "\\langle") ("\\backslash") ("\\uparrow") ("\\downarrow") ("\\updownarrow") ("\\Updownarrow")) "TeX math delimiter, which can be completed after \\right or \\left.") (defvar YaTeX:left-right-default nil "Default string of YaTeX:right.") (defun YaTeX:left () (let ((minibuffer-completion-table YaTeX:left-right-delimiters) delimiter (leftp (string= YaTeX-single-command "left"))) (setq delimiter (read-from-minibuffer (format "Delimiter%s: " (if YaTeX:left-right-default (format "(default=`%s')" YaTeX:left-right-default) "(SPC for menu)")) nil YaTeX-minibuffer-quick-map)) (if (string= "" delimiter) (setq delimiter YaTeX:left-right-default)) (setq YaTeX-single-command (if leftp "right" "left") YaTeX:left-right-default (or (cdr (assoc delimiter YaTeX:left-right-delimiters)) delimiter)) delimiter)) (fset 'YaTeX:right 'YaTeX:left) (defun YaTeX:langle () (setq YaTeX-single-command "rangle") nil) (defun YaTeX:read-coordinates (&optional mes varX varY) (concat "(" (read-string (format "%s %s: " (or mes "Dimension") (or varX "X"))) "," (read-string (format "%s %s: " (or mes "Dimension") (or varY "Y"))) ")")) (defun YaTeX:itembox () (concat "{" (read-string "Item heading string: ") "}")) ;;; ;;Sample functions for maketitle-type command. ;;; (defun YaTeX:sum () "Read range of summation." (YaTeX:check-completion-type 'maketitle) (concat (YaTeX:read-boundary "_") (YaTeX:read-boundary "^"))) (fset 'YaTeX:int 'YaTeX:sum) (defun YaTeX:lim () "Insert limit notation of \\lim." (YaTeX:check-completion-type 'maketitle) (let ((var (read-string "Variable: ")) limit) (if (string= "" var) "" (setq limit (read-string "Limit ($ means infinity): ")) (if (string= "$" limit) (setq limit "\\infty")) (concat "_{" var " \\rightarrow " limit "}")))) (defun YaTeX:gcd () "Add-in function for \\gcd(m,n)." (YaTeX:check-completion-type 'maketitle) (YaTeX:read-coordinates "\\gcd" "(?,)" "(,?)")) (defun YaTeX:read-boundary (ULchar) "Read boundary usage by _ or ^. _ or ^ is indicated by argument ULchar." (let ((bndry (read-string (concat ULchar "{???} ($ for infinity): ")))) (if (string= bndry "") "" (if (string= bndry "$") (setq bndry "\\infty")) (concat ULchar "{" bndry "}")))) (defun YaTeX:verb () "Enclose \\verb's contents with the same characters." (let ((quote-char (read-string "Quoting char: " "|")) (contents (read-string "Quoted contents: "))) (concat quote-char contents quote-char))) (fset 'YaTeX:verb* 'YaTeX:verb) (defun YaTeX:footnotemark () (setq YaTeX-section-name "footnotetext") nil) (defun YaTeX:cite () (let ((comment (read-string "Comment for citation: "))) (if (string= comment "") "" (concat "[" comment "]")))) (defun YaTeX:bibitem () (let ((label (read-string "Citation label for bibitem: "))) (if (string= label "") "" (concat "[" label "]")))) (defun YaTeX:item () (cond ((eq major-mode 'yatex-mode) (YaTeX-indent-line) (setq YaTeX-section-name "label")) ((eq major-mode 'texinfo-mode) (setq YaTeX-section-name "dots"))) ;?? " ") (fset 'YaTeX:item\[\] 'YaTeX:item) (fset 'YaTeX:subitem 'YaTeX:item) (fset 'YaTeX:subsubitem 'YaTeX:item) (defun YaTeX:linebreak () (let (obl) (message "Break strength 0,1,2,3,4 (default: 4): ") (setq obl (char-to-string (read-char))) (if (string-match "[0-4]" obl) (concat "[" obl "]") ""))) (fset 'YaTeX:pagebreak 'YaTeX:linebreak) ;;; ;;Subroutine ;;; (defun YaTeX:check-completion-type (type) "Check valid completion type." (if (not (eq type YaTeX-current-completion-type)) (error "This should be completed with %s-type completion." type))) ;;; ;;; [[Add-in functions for reading section arguments]] ;;; ;; All of add-in functions for reading sections arguments should ;; take an argument ARGP that specify the argument position. ;; If argument position is out of range, nil should be returned, ;; else nil should NOT be returned. ;; ; Label selection ;; (defvar YaTeX-label-menu-other (if YaTeX-japan "':他のバッファのラベル\n" "':LABEL IN OTHER BUFFER.\n")) (defvar YaTeX-label-menu-repeat (if YaTeX-japan ".:直前の\\refと同じ\n" "/:REPEAT LAST \ref{}\n")) (defvar YaTeX-label-menu-any (if YaTeX-japan "*:任意の文字列\n" "*:ANY STRING.\n")) (defvar YaTeX-label-buffer "*Label completions*") (defvar YaTeX-label-guide-msg "Select label and hit RETURN.") (defvar YaTeX-label-select-map nil "Key map used in label selection buffer.") (defun YaTeX::label-setup-key-map () (if YaTeX-label-select-map nil (message "Setting up label selection mode map...") ;(setq YaTeX-label-select-map (copy-keymap global-map)) (setq YaTeX-label-select-map (make-keymap)) (suppress-keymap YaTeX-label-select-map) (substitute-all-key-definition 'previous-line 'YaTeX::label-previous YaTeX-label-select-map) (substitute-all-key-definition 'next-line 'YaTeX::label-next YaTeX-label-select-map) (define-key YaTeX-label-select-map "\C-n" 'YaTeX::label-next) (define-key YaTeX-label-select-map "\C-p" 'YaTeX::label-previous) (define-key YaTeX-label-select-map "<" 'beginning-of-buffer) (define-key YaTeX-label-select-map ">" 'end-of-buffer) (define-key YaTeX-label-select-map "\C-m" 'exit-recursive-edit) (define-key YaTeX-label-select-map "\C-j" 'exit-recursive-edit) (define-key YaTeX-label-select-map " " 'exit-recursive-edit) (define-key YaTeX-label-select-map "\C-g" 'abort-recursive-edit) (define-key YaTeX-label-select-map "/" 'isearch-forward) (define-key YaTeX-label-select-map "?" 'isearch-backward) (define-key YaTeX-label-select-map "'" 'YaTeX::label-search-tag) (define-key YaTeX-label-select-map "." 'YaTeX::label-search-tag) (define-key YaTeX-label-select-map "*" 'YaTeX::label-search-tag) (message "Setting up label selection mode map...Done") (let ((key ?A)) (while (<= key ?Z) (define-key YaTeX-label-select-map (char-to-string key) 'YaTeX::label-search-tag) (define-key YaTeX-label-select-map (char-to-string (+ key (- ?a ?A))) 'YaTeX::label-search-tag) (setq key (1+ key)))))) (defun YaTeX::label-next () (interactive) (forward-line 1) (message YaTeX-label-guide-msg)) (defun YaTeX::label-previous () (interactive) (forward-line -1) (message YaTeX-label-guide-msg)) (defun YaTeX::label-search-tag () (interactive) (let ((case-fold-search t) (tag (regexp-quote (char-to-string (YaTeX-last-key))))) (cond ((save-excursion (forward-char 1) (re-search-forward (concat "^" tag) nil t)) (goto-char (match-beginning 0))) ((save-excursion (goto-char (point-min)) (re-search-forward (concat "^" tag) nil t)) (goto-char (match-beginning 0)))) (message YaTeX-label-guide-msg))) ; (defun YaTeX::ref (argp &optional labelcmd refcmd) ; (cond ; ((= argp 1) ; (let ((lnum 0) e0 label label-list (buf (current-buffer)) ; (labelcmd (or labelcmd "label")) (refcmd (or refcmd "ref")) ; (p (point)) initl line cf) ; (message "Collecting labels...") ; (save-window-excursion ; (YaTeX-showup-buffer ; YaTeX-label-buffer (function (lambda (x) (window-width x)))) ; (if (fboundp 'select-frame) (setq cf (selected-frame))) ; (if (eq (window-buffer (minibuffer-window)) buf) ; (progn ; (other-window 1) ; (setq buf (current-buffer)) ; (set-buffer buf) ; ;(message "cb=%s" buf)(sit-for 3) ; )) ; (save-excursion ; (set-buffer (get-buffer-create YaTeX-label-buffer)) ; (setq buffer-read-only nil) ; (erase-buffer)) ; (save-excursion ; (goto-char (point-min)) ; (let ((standard-output (get-buffer YaTeX-label-buffer))) ; (princ (format "=== LABELS in [%s] ===\n" (buffer-name buf))) ; (while (YaTeX-re-search-active-forward ; (concat "\\\\" labelcmd "\\b") ; (regexp-quote YaTeX-comment-prefix) nil t) ; (goto-char (match-beginning 0)) ; (skip-chars-forward "^{") ; (setq label ; (buffer-substring ; (1+ (point)) ; (prog2 (forward-list 1) (setq e0 (1- (point))))) ; label-list (cons label label-list)) ; (or initl ; (if (< p (point)) (setq initl lnum))) ; (beginning-of-line) ; (skip-chars-forward " \t\n" nil) ; (princ (format "%c:{%s}\t<<%s>>\n" (+ (% lnum 26) ?A) label ; (buffer-substring (point) (point-end-of-line)))) ; (setq lnum (1+ lnum)) ; (message "Collecting \\%s{}... %d" labelcmd lnum) ; (goto-char e0)) ; (princ YaTeX-label-menu-other) ; (princ YaTeX-label-menu-repeat) ; (princ YaTeX-label-menu-any) ; );standard-output ; (goto-char p) ; (or initl (setq initl lnum)) ; (message "Collecting %s...Done" labelcmd) ; (if (fboundp 'select-frame) (select-frame cf)) ; (YaTeX-showup-buffer YaTeX-label-buffer nil t) ; (YaTeX::label-setup-key-map) ; (setq truncate-lines t) ; (setq buffer-read-only t) ; (use-local-map YaTeX-label-select-map) ; (message YaTeX-label-guide-msg) ; (goto-line (1+ initl)) ;goto recently defined label line ; (switch-to-buffer (current-buffer)) ; (unwind-protect ; (progn ; (recursive-edit) ; (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion ; (beginning-of-line) ; (setq line (1- (count-lines (point-min)(point)))) ; (cond ; ((= line -1) (setq label "")) ; ((= line lnum) (setq label (YaTeX-label-other))) ; ((= line (1+ lnum)) ; (save-excursion ; (switch-to-buffer buf) ; (goto-char p) ; (if (re-search-backward ; (concat "\\\\" refcmd "{\\([^}]+\\)}") nil t) ; (setq label (YaTeX-match-string 1)) ; (setq label "")))) ; ((>= line (+ lnum 2)) ; (setq label (read-string (format "\\%s{???}: " refcmd)))) ; (t (setq label (nth (- lnum line 1) label-list))))) ; (bury-buffer YaTeX-label-buffer))) ; label))))) (defvar YaTeX-ref-default-label-string "%H%M%S_%d%b%y" "*Default \\ref time string format. This format is like strftime(3) but allowed conversion char are as follows; %y -> Last 2 digit of year, %b -> Month name, %m -> Monthe number(1-12), %d -> Day, %H -> Hour, %M -> Minute, %S -> Second, %qx -> alphabetical-decimal conversion of yymmdd. %qX -> alphabetical-decimal conversion of HHMMSS. Beware defualt label-string should be always unique. So this format string should have both time part (%H+%M+%S or %qX) and date part (%y+(%b|%m)+%d or %qx).") (defun YaTeX::ref-alphabex (n) (let ((alphabex "")) (while (> n 0) (setq alphabex (concat (char-to-string (+ ?a (% n 26))) alphabex) n (/ n 26))) alphabex)) (defun YaTeX::ref-default-label (&optional format) "Default auto-genarated label string." ;; We do not use (format-time-string) for emacs-19 (let*((ts (substring (current-time-string) 4)) (y (substring ts -2)) (b (substring ts 0 3)) (d (format "%d" (string-to-int (substring ts 4 6)))) (H (substring ts 7 9)) (M (substring ts 10 12)) (S (substring ts 13 15)) (HMS (+ (* 10000 (string-to-int H)) (* 100 (string-to-int M)) (string-to-int S))) (talphabex (YaTeX::ref-alphabex HMS)) (mnames "JanFebMarAprMayJunJulAugSepOctNovDec") (m (format "%02d" (/ (string-match b mnames) 3))) (ymd (+ (* 10000 (string-to-int y)) (* 100 (string-to-int m)) (string-to-int d))) (dalphabex (YaTeX::ref-alphabex ymd))) (YaTeX-replace-formats (or format YaTeX-ref-default-label-string) (list (cons "y" y) (cons "b" b) (cons "m" m) (cons "d" d) (cons "H" H) (cons "M" M) (cons "S" S) (cons "qX" talphabex) (cons "qx" dalphabex))))) (defvar YaTeX-ref-generate-label-function 'YaTeX::ref-generate-label "*Function to generate default label for unnamed \\label{}s. The function pointed to this value should take two arguments. First argument is LaTeX macro's name, second is macro's argument.") (defun YaTeX::ref-generate-label (command arg) "Generate a label string which is unique in current buffer." (let ((default (condition-case nil (YaTeX::ref-default-label) (error (substring (current-time-string) 4))))) (read-string "Give a label for this line: " (if YaTeX-emacs-19 (cons default 1) default)))) (defun YaTeX::ref-getset-label (buffer point &optional noset) "Get label string in the BUFFER near the POINT. Make \\label{xx} if no label. If optional third argument NOSET is non-nil, do not generate new label." ;;Here, we rewrite the LaTeX source. Therefore we should be careful ;;to decide the location suitable for \label. Do straightforward! (let (boundary inspoint cc newlabel (labelholder "label") mathp exp1 env (r-escape (regexp-quote YaTeX-comment-prefix)) command arg alreadysought foundpoint) (set-buffer buffer) (save-excursion (goto-char point) (setq cc (current-column)) (if (= (char-after (point)) ?\\) (forward-char 1)) (cond ;; In each codition, 'inspoint and 'boundary should be set ((looking-at YaTeX-sectioning-regexp) (setq command (YaTeX-match-string 0)) (skip-chars-forward "^{") (setq arg (buffer-substring (1+ (point)) (progn (forward-list 1) (1- (point))))) (skip-chars-forward " \t\n") ;(setq boundary "[^\\]") (setq inspoint (point)) (setq boundary (save-excursion (if (YaTeX-re-search-active-forward (concat YaTeX-ec-regexp "\\(" YaTeX-sectioning-regexp "\\|" "begin\\|item\\)") r-escape nil 1) (match-beginning 0) (1- (point)))))) ((looking-at "item\\s ") (setq command "item" cc (+ cc 6)) ;(setq boundary (concat YaTeX-ec-regexp "\\(item\\|begin\\|end\\)\\b")) (setq boundary (save-excursion (if (YaTeX-re-search-active-forward (concat YaTeX-ec-regexp "\\(item\\|begin\\|end\\)\\b") r-escape nil 1) (match-beginning 0) (1- (point)))) inspoint boundary)) ((looking-at "bibitem") (setq labelholder "bibitem" ; label holder is bibitem itself command "bibitem") (setq boundary (save-excursion (if (YaTeX-re-search-active-forward (concat YaTeX-ec-regexp "\\(bibitem\\|end\\)\\b") r-escape nil 1) (match-beginning 0) (1- (point)))) inspoint boundary)) ((string-match YaTeX::ref-nestable-counter-regexp (setq env (or (YaTeX-inner-environment t) "document"))) (let ((curtop (get 'YaTeX-inner-environment 'point)) (end (point-max)) label) (skip-chars-forward " \t\n") (setq inspoint (point) ;initial candidate cc (current-column) command env alreadysought t) (if (condition-case nil (progn (goto-char curtop) (YaTeX-goto-corresponding-environment)) (error nil)) (setq end (point))) (goto-char inspoint) (while (YaTeX-re-search-active-forward (concat YaTeX-ec-regexp "label{\\([^}]+\\)}" ) r-escape end t) (setq label (YaTeX-match-string 1)) (if (and (equal env (YaTeX-inner-environment t)) (= curtop (get 'YaTeX-inner-environment 'point))) ;;I found the label (setq alreadysought label foundpoint (match-end 0)))) )) ((string-match YaTeX::ref-mathenv-regexp env) ;env is set in above case (setq command env mathp t exp1 (string-match YaTeX::ref-mathenv-exp1-regexp env)) ;;(setq boundary (concat YaTeX-ec-regexp "\\(\\\\\\|end{" env "}\\)")) (setq boundary (save-excursion (or (catch 'bndry (while (YaTeX-re-search-active-forward (concat YaTeX-ec-regexp "\\(" (if exp1 "" "\\\\\\|") "\\(end{" env "\\)}\\)") r-escape nil 1) (setq foundpoint (match-beginning 0)) (if (or (match-beginning 2) ;end of outer math-env (equal env (YaTeX-inner-environment t))) ;; YaTeX-inner-environment destroys match-data (throw 'bndry foundpoint)))) (1- (point)))) inspoint boundary)) ((looking-at "footnote\\s *{") (setq command "footnote") (skip-chars-forward "^{") ;move onto `{' (setq boundary (save-excursion (condition-case err (forward-list 1) (error (error "\\\\footnote at point %s's brace not closed" (point)))) (1- (point))) inspoint boundary)) ((looking-at "caption\\|\\(begin\\)") (setq command (YaTeX-match-string 0)) (skip-chars-forward "^{") ;;;;;;(if (match-beginning 1) (forward-list 1)) ;; caption can be treated as mathenv, is it right?? (setq arg (buffer-substring (1+ (point)) (progn (forward-list 1) (1- (point))))) ;;(setq boundary (concat YaTeX-ec-regexp "\\(begin\\|end\\)\\b")) (setq inspoint (point)) (setq boundary (save-excursion (if (YaTeX-re-search-active-forward (concat YaTeX-ec-regexp "\\(begin\\|end\\)\\b") r-escape nil 1) (match-beginning 0) (1- (point)))))) (t )) ;;cond by kind of labeling ends here. (if (save-excursion (skip-chars-forward " \t") (looking-at "%")) (forward-line 1)) (cond ((stringp alreadysought) (put 'YaTeX::ref-getset-label 'foundpoint foundpoint) ;ugly... alreadysought) ((and (null alreadysought) (> boundary (point)) (save-excursion (YaTeX-re-search-active-forward ;;(concat "\\(" labelholder "\\)\\|\\(" boundary "\\)") labelholder (regexp-quote YaTeX-comment-prefix) boundary 1)) (match-beginning 0)) ;; if \label{hoge} found, return it (put 'YaTeX::ref-getset-label 'foundpoint (1- (match-beginning 0))) (buffer-substring (progn (goto-char (match-end 0)) (skip-chars-forward "^{") (1+ (point))) (progn (forward-sexp 1) (1- (point))))) ;;else make a label ;(goto-char (match-beginning 0)) (noset nil) ;do not set label if noset (t (goto-char inspoint) (skip-chars-backward " \t\n") (save-excursion (setq newlabel (funcall YaTeX-ref-generate-label-function command arg))) (delete-region (point) (progn (skip-chars-backward " \t") (point))) (if mathp nil (insert "\n") (YaTeX-reindent cc)) (put 'YaTeX::ref-getset-label 'foundpoint (point)) (insert (format "\\label{%s}" newlabel)) newlabel))))) (defvar YaTeX::ref-labeling-regexp-alist-default '(("\\\\begin{\\(java\\|program\\)}{\\([^}]+\\)}" . 2) ("\\\\label{\\([^}]+\\)}" . 1)) "Alist of labeling regexp vs. its group number points to label string. This alist is used in \\ref's argument's completion.") (defvar YaTeX::ref-labeling-regexp-alist-private nil "*Private extension to YaTeX::ref-labeling-regexp-alist. See the documetation of YaTeX::ref-labeling-regexp-alist.") (defvar YaTeX::ref-labeling-regexp-alist (append YaTeX::ref-labeling-regexp-alist-default YaTeX::ref-labeling-regexp-alist-private)) (defvar YaTeX::ref-labeling-regexp (mapconcat 'car YaTeX::ref-labeling-regexp-alist "\\|")) (defvar YaTeX::ref-mathenv-regexp ;; See also YaTeX-ams-math-begin-alist in yatex.el ;; Define only envs which has counter.(without *) "equation\\|eqnarray\\|align\\(at\\)?\\|flalign\\|gather\\|xx?alignat\\|multline") (defvar YaTeX::ref-mathenv-exp1-regexp "\\(equation\\|multline\\)\\b" "*Regexp of math-envname which has only one math-expression.") (defvar YaTeX::ref-enumerateenv-regexp "enumerate") (defvar YaTeX::ref-nestable-counter-regexp "subequations") (defvar YaTeX::ref-labeling-section-level 2 "*ref補完で収集するセクショニングコマンドの下限レベル YaTeX-sectioning-levelの数値で指定.") (defun YaTeX::ref (argp &optional labelcmd refcmd predf) (setplist 'YaTeX::ref-labeling-regexp nil) ;erase memory cache (require 'yatexsec) (cond ((= argp 1) (let*((lnum 0) m0 e0 x cmd label match-point point-list boundary (buf (current-buffer)) (llv YaTeX::ref-labeling-section-level) (mathenvs YaTeX::ref-mathenv-regexp) envname endrx (enums YaTeX::ref-enumerateenv-regexp) (counter (or labelcmd (concat YaTeX-ec-regexp "\\(\\(" (mapconcat 'concat (delq nil (mapcar (function (lambda (s) (if (>= llv (cdr s)) (car s)))) YaTeX-sectioning-level)) "\\|") "\\|caption\\(\\[[^]]+\\]\\)?\\|footnote\\){" "\\|\\(begin{\\(" mathenvs "\\|" enums "\\)}\\)" (if YaTeX-use-AMS-LaTeX (concat "\\|\\(begin{" YaTeX::ref-nestable-counter-regexp "}\\)")) "\\)"))) (regexp (concat "\\(" counter "\\)\\|\\(" YaTeX::ref-labeling-regexp "\\)")) (itemsep (concat YaTeX-ec-regexp "\\(\\(bib\\)?item\\|begin\\|end\\)")) (refcmd (or refcmd "\\(page\\)?ref")) (p (point)) initl line cf (percent (regexp-quote YaTeX-comment-prefix)) (output (function (lambda (label p) (while (setq x (string-match "[\n\t]" label)) (aset label x ? )) (while (setq x (string-match " +" label)) (setq label (concat (substring label 0 (1+ (match-beginning 0))) (substring label (match-end 0))))) (princ (format "%c: <<%s>>\n" (+ (% lnum 26) ?A) label)) (setq point-list (cons p point-list)) (message "Collecting labels... %d" lnum) (setq lnum (1+ lnum))))) (me (if (boundp 'me) me 'YaTeX::ref)) ) (message "Collecting labels...") (save-window-excursion (YaTeX-showup-buffer YaTeX-label-buffer (function (lambda (x) (window-width x)))) (if (fboundp 'select-frame) (setq cf (selected-frame))) (if (eq (window-buffer (minibuffer-window)) buf) (progn (other-window 1) (setq buf (current-buffer)) (set-buffer buf))) (save-excursion (set-buffer (get-buffer-create YaTeX-label-buffer)) (condition-case () (if (and YaTeX-use-font-lock (fboundp 'font-lock-mode)) (font-lock-mode 1)) (error nil)) (setq buffer-read-only nil) (erase-buffer)) (save-excursion (set-buffer buf) (goto-char (point-min)) (let ((standard-output (get-buffer YaTeX-label-buffer)) existlabel) (princ (format "=== LABELS in [%s] ===\n" (buffer-name buf))) (while (YaTeX-re-search-active-forward regexp ;;counter percent nil t) ;(goto-char (match-beginning 0)) (setq e0 (match-end 0)) (cond ;; ;;2005/10/21 Skip it if predicate function returns nil ((and predf (let ((md (match-data))) (prog1 (condition-case nil (not (funcall predf)) (error nil)) (store-match-data md))))) ((YaTeX-literal-p) nil) ((YaTeX-match-string 1) ;;if standard counter commands found (setq cmd (YaTeX-match-string 2) m0 (match-beginning 0)) (setq match-point (match-beginning 0)) (or initl (if (< p (point)) (setq initl lnum))) (cond ;; In any case, variables e0 should be set ((and YaTeX-use-AMS-LaTeX (string-match YaTeX::ref-nestable-counter-regexp cmd)) (let (label) (skip-chars-forward "}") (setq label (buffer-substring (point) (min (+ 80 (point)) (point-max)))) ;; to skip (maybe)auto-generated comment (skip-chars-forward " \t") (if (looking-at YaTeX-comment-prefix) (forward-line 1)) (setq e0 (point)) (skip-chars-forward " \t\n") (if (looking-at "\\\\label{\\([^}]+\\)}") (setq label (format "(labe:%s)" (YaTeX-match-string 1)) e0 (match-end 1))) (funcall output (format "--subequation--%s" label) e0))) ((string-match mathenvs cmd) ;;if matches mathematical env (skip-chars-forward "}") (setq x (point) envname (substring cmd (match-beginning 0) (match-end 0))) (save-restriction (narrow-to-region m0 (save-excursion (YaTeX-re-search-active-forward (setq endrx (format "%send{%s}" YaTeX-ec-regexp (regexp-quote envname))) percent nil t))) (catch 'scan (while (YaTeX-re-search-active-forward (concat "\\\\end{\\(" (regexp-quote envname) "\\)";;(1) "\\|\\\\\\(notag\\)" ;;2 (if (string-match YaTeX::ref-mathenv-exp1-regexp cmd) "" "\\|\\(\\\\\\\\\\)$") ;;3 ) percent nil t) (let*((quit (match-beginning 1)) (notag (match-beginning 2)) (newln (match-beginning 3)) (label ".......................") l2 (e (point)) (m0 (match-beginning 0)) (ln (YaTeX-string-width label))) (cond (notag (YaTeX-re-search-active-forward "\\\\\\\\" percent nil 1) (setq x (point))) ;use x as \label search bound ((and newln ; `\\' found (not (equal (YaTeX-inner-environment) envname))) (YaTeX-end-of-environment) (goto-char (match-end 0))) (t (if (YaTeX-re-search-active-backward YaTeX::ref-labeling-regexp percent x t) ;; if \label{x} in math-expression, display it ;; because formula source is hard to recognize (progn (goto-char (match-end 0)) (setq l2 (format "\"label:%s\"" (buffer-substring (1- (point)) (progn (forward-sexp -1) (1+ (point)))))) (setq label (if (< (YaTeX-string-width l2) ln) (concat l2 (substring label 0 (- ln (YaTeX-string-width l2)))) l2)) (goto-char e))) (funcall output (concat label " " (buffer-substring x m0)) x) (cond ((YaTeX-quick-in-environment-p YaTeX-math-gathering-list) ;; if here is inner split/cases/gathered env., ;; counter for here is only one. ;; Go out this environment and, (YaTeX-end-of-environment) ;; search next expression unit boundary. (YaTeX-re-search-active-forward (concat endrx "\\|\\\\begin{") percent nil 1) (end-of-line))) (if quit (throw 'scan t))))) (setq x (point))))) (setq e0 (point))) ((string-match enums cmd) ;(skip-chars-forward "} \t\n") (save-restriction (narrow-to-region (point) (save-excursion (YaTeX-goto-corresponding-environment) (point))) (forward-line 1) (while (YaTeX-re-search-active-forward (concat YaTeX-ec-regexp "item\\s ") percent nil t) (setq x (match-beginning 0)) (funcall output (concat existlabel (buffer-substring (match-beginning 0) (if (re-search-forward itemsep nil t) (progn (goto-char (match-beginning 0)) (skip-chars-backward " \t") (1- (point))) (point-end-of-line)))) x)) (setq e0 (point-max)))) ((string-match "bibitem" cmd) ;maybe generated by myself (setq label "") (skip-chars-forward " \t") (if (looking-at "{") ;sure to be true!! (forward-list 1)) (let ((list '(30 10 65)) (delim ";") q lim len l str) (save-excursion (setq lim (if (re-search-forward itemsep nil 1) (match-beginning 0) (point)))) (while list (skip-chars-forward " \t\n\\") (setq q (looking-at "[\"'{]") len (car list) str (buffer-substring (point) (progn (if q (forward-sexp 1) (search-forward delim lim 1) (forward-char -1)) (point)))) (if (> (setq l (YaTeX-string-width str)) len) (setq str (concat (YaTeX-truncate-string-width str (- len (if q 5 4))) "... " (if q (substring str -1))))) (if (< (setq l (YaTeX-string-width str)) len) (setq str (concat str (make-string (- len l) ? )))) (if (looking-at delim) (goto-char (match-end 0))) (setq label (concat label " " str) list (cdr list))) (funcall output label match-point))) ;;else, simple section-type counter ((= (char-after (1- (point))) ?{) (setq label (buffer-substring (match-beginning 0) (progn (forward-char -1) (forward-list 1) (point)))) (funcall output label match-point) ;; Skip preceding label if exists (if (YaTeX::ref-getset-label (current-buffer) match-point t) (goto-char (get 'YaTeX::ref-getset-label 'foundpoint))) (if (save-excursion (skip-chars-forward "\t \n") (looking-at YaTeX::ref-labeling-regexp)) (setq e0 (match-end 0)))) (t (skip-chars-forward " \t") (setq label (buffer-substring (match-beginning 0) (if (re-search-forward itemsep nil t) (progn (goto-char (match-beginning 0)) (skip-chars-backward " \t") (1- (point))) (point-end-of-line)))) (funcall output label match-point) (if (save-excursion (skip-chars-forward "\t \n") (looking-at YaTeX::ref-labeling-regexp)) (setq e0 (match-end 0))))) ) ;;put label buffer ;; ;; if user defined label found (t ;; memorize line number and label into property (goto-char (match-beginning 0)) (let ((list YaTeX::ref-labeling-regexp-alist) (cache (symbol-plist 'YaTeX::ref-labeling-regexp))) (while list (if (looking-at (car (car list))) (progn (setq label (YaTeX-match-string 0)) (put 'YaTeX::ref-labeling-regexp lnum (YaTeX-match-string (cdr (car list)))) (funcall output label 0) ;;0 is dummy, never used (setq list nil))) (setq list (cdr list)))) )) (goto-char e0)) (princ YaTeX-label-menu-other) (princ YaTeX-label-menu-repeat) (princ YaTeX-label-menu-any) );standard-output (goto-char p) (or initl (setq initl lnum)) (message "Collecting labels...Done") (if (fboundp 'select-frame) (select-frame cf)) (YaTeX-showup-buffer YaTeX-label-buffer nil t) (YaTeX::label-setup-key-map) (setq truncate-lines t) (setq buffer-read-only t) (use-local-map YaTeX-label-select-map) (message YaTeX-label-guide-msg) (goto-line (1+ initl)) ;goto recently defined label line (switch-to-buffer (current-buffer)) (unwind-protect (progn (recursive-edit) (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion (beginning-of-line) (setq line (1- (count-lines (point-min)(point)))) (cond ((= line -1) (setq label "")) ((= line lnum) (setq label (YaTeX-label-other))) ((= line (1+ lnum)) (save-excursion (switch-to-buffer buf) (goto-char p) (if (re-search-backward (concat "\\\\" refcmd "{") nil t) (setq label (YaTeX-buffer-substring (progn (goto-char (1- (match-end 0))) (1+ (point))) (progn (forward-list 1) (1- (point))))) (setq label "")))) ((>= line (+ lnum 2)) (setq label (read-string (format "\\%s{???}: " refcmd)))) (t ;(setq label (nth (- lnum line 1) label-list)) (setq label (or (get 'YaTeX::ref-labeling-regexp line) (YaTeX::ref-getset-label buf (nth (- lnum line 1) point-list)))) ))) (bury-buffer YaTeX-label-buffer))) label))))) (defun YaTeX::label-rename-refs (old new &optional def ref) "Rename reference tag from OLD to NEW. Optional arguments DEF and REF specify defining command and referring command respectively. --------------------------------------------------------- CONTROL KEYS - キーの説明 y Replace 置換する n Do not replace 置換しない ! Replace All w/o query 残る全部を確認なしで置換 r Enter Recursive-edit 再帰編集モードへ q Quit from replacing ここまでで置換をやめる Don't forget to exit from recursive edit by typing \\[exit-recursive-edit] 再帰編集に入ったら \\[exit-recursive-edit] で抜け忘れなきよう。" (save-window-excursion (catch 'exit (let*((bufs (YaTeX-yatex-buffer-list)) buf b e (oldptn (regexp-quote old)) (sw (selected-window)) (ptn (concat "\\(" YaTeX-refcommand-ref-regexp "\\)" "\\s *{" oldptn "}")) (repface (and (fboundp 'make-overlay) (fboundp 'internal-find-face) (if (internal-find-face 'isearch) 'isearch 'region))) ov (qmsg "Replace to `%s'? [yn!rq?]") continue ch) (while bufs (set-buffer (setq buf (car bufs))) (save-excursion (goto-char (point-min)) (while (re-search-forward ptn nil t) (goto-char (match-end 1)) (skip-chars-forward " \t\n{") (unwind-protect (if (and (looking-at oldptn) (setq b (match-beginning 0) e (match-end 0)) (or continue (catch 'query (if repface (if ov (move-overlay ov b e) (overlay-put (setq ov (make-overlay b e)) 'face repface))) (switch-to-buffer buf) (while t (message qmsg new) (setq ch (read-char)) (cond ((= ch ?q) (throw 'exit t)) ((= ch ?r) (message "Don't forget to exit recursive-edit by `%s'" (key-description (where-is-internal 'exit-recursive-edit '(keymap) t))) (sleep-for 2) (recursive-edit)) ((memq ch '(?y ?\ )) (throw 'query t)) ((= ch ?!) (throw 'query (setq continue t))) ((= ch ??) (describe-function 'YaTeX::label-rename-refs) (select-window (get-buffer-window "*Help*")) (search-forward "----") (forward-line 1) (set-window-start (selected-window) (point)) (sit-for 0) (select-window sw)) ((= ch ?n) (throw 'query nil))))))) (replace-match new t)) (and ov (delete-overlay ov))))) (setq bufs (cdr bufs))))))) (defun YaTeX::label (argp &optional labname refname) "Read label name and return it with copying \\ref{LABEL-NAME} to kill-ring." (cond ((= argp 1) (let*((chmode (boundp (intern-soft "old"))) (dlab (if chmode old ;if called via YaTeX-change-section (tricky...) (YaTeX::ref-default-label))) (label (read-string (format "New %s name: " (or labname "label")) (cons dlab 1)))) (if (string< "" label) (let ((refstr (format "\\%s{%s}" (or refname "ref") label))) (YaTeX-push-to-kill-ring refstr) (and chmode (not (equal old label)) (YaTeX::label-rename-refs old label)))) label)))) (fset 'YaTeX::pageref 'YaTeX::ref) (defun YaTeX::tabref (argp) ; For the style file of IPSJ journal (YaTeX::ref argp nil nil (function (lambda () (YaTeX-quick-in-environment-p "table"))))) (defun YaTeX::figref (argp) ; For the style file of IPSJ journal (YaTeX::ref argp nil nil (function (lambda () (YaTeX-quick-in-environment-p "figure"))))) (defun YaTeX::eqref (argp) (YaTeX::ref argp nil nil (function (lambda () (YaTeX-in-math-mode-p))))) (defun YaTeX::cite-collect-bibs-external (bibptn &rest files) "Collect bibentry from FILES(variable length argument) ; and print them to standard output." ;;Thanks; http://icarus.ilcs.hokudai.ac.jp/comp/biblio.html (let*((tb (get-buffer-create " *bibtmp*")) (bibitemsep "^\\s *@[A-Za-z]") (target (if (string< "" bibptn) bibptn bibitemsep)) (checkrx (concat "\\(" bibptn "\\)\\|" bibitemsep)) beg (searchnext (if (string< "" bibptn) (function (lambda() (setq beg (point)) (and (prog1 (re-search-forward target nil t) (end-of-line)) (re-search-backward bibitemsep beg t)))) (function (lambda() (re-search-forward target nil t))))) ) (save-excursion (set-buffer tb) (princ (format "%sbegin{thebibliography}\n" YaTeX-ec)) (while files (erase-buffer) (cond ((file-exists-p (car files)) (insert-file-contents (car files))) ((file-exists-p (concat (car files) ".bib")) (insert-file-contents (concat (car files) ".bib")))) (save-excursion (goto-char (point-min)) (while (funcall searchnext) (skip-chars-forward "^{,") (setq beg (point)) (if (= (char-after (point)) ?{) (princ (format "%sbibitem{%s}%s\n" YaTeX-ec (buffer-substring (1+ (point)) (progn (skip-chars-forward "^,\n") (point))) (mapconcat (function (lambda (kwd) (goto-char beg) (if (re-search-forward (concat kwd "\\s *=") nil t) (buffer-substring (progn (goto-char (match-end 0)) (skip-chars-forward " \t\n") (point)) (progn (if (looking-at "[{\"]") (forward-sexp 1) (forward-char 1) (skip-chars-forward "^,}")) (point)))))) '("author" "year" "title" ) ";")))) (and (re-search-forward bibitemsep nil t) (forward-line -1)))) (setq files (cdr files))) (princ (format "%sbegin{thebibliography}\n" YaTeX-ec))))) (defvar YaTeX::cite-bibitem-macro-regexp "bibitem\\|harvarditem" "*Regexp of macro name of bibitem definition") (defun YaTeX::cite-collect-bibs-internal (bibptn) "Collect bibentry in the current buffer and print them to standard output." (let ((ptn (concat YaTeX-ec-regexp "\\(" YaTeX::cite-bibitem-macro-regexp "\\)\\b")) (lim (concat YaTeX-ec-regexp "\\(" YaTeX::cite-bibitem-macro-regexp "\\b\\)" "\\|\\(end{\\)")) (pcnt (regexp-quote YaTeX-comment-prefix))) ;; Using bibptn not yet implemented. ;; Do you need it?? 2005/11/22 (save-excursion (while (YaTeX-re-search-active-forward ptn pcnt nil t) (skip-chars-forward "^{\n") (or (eolp) (princ (format "%sbibitem%s %s\n" YaTeX-ec (buffer-substring (point) (progn (forward-sexp 1) (point))) (buffer-substring (progn (skip-chars-forward "\n \t") (point)) (save-excursion (if (YaTeX-re-search-active-forward lim pcnt nil t) (progn (goto-char (match-beginning 0)) (skip-chars-backward "\n \t") (point)) (point-end-of-line))))))))))) (defun YaTeX::cite (argp &rest dummy) (cond ((eq argp 1) (let* ((cb (current-buffer)) (f (file-name-nondirectory buffer-file-name)) (d default-directory) (hilit-auto-highlight nil) (pcnt (regexp-quote YaTeX-comment-prefix)) (bibrx (concat YaTeX-ec-regexp "bibliography{\\([^}]+\\)}")) (bibptn (read-string "Pattern: ")) (bbuf (get-buffer-create " *bibitems*")) (standard-output bbuf) (me 'YaTeX::cite) ;shuld set this for using YaTeX::ref bibs files) (set-buffer bbuf)(erase-buffer)(set-buffer cb) (save-excursion (goto-char (point-min)) ;;(1)search external bibdata (while (YaTeX-re-search-active-forward bibrx pcnt nil t) (apply 'YaTeX::cite-collect-bibs-external bibptn (YaTeX-split-string (YaTeX-match-string 1) ","))) ;;(2)search direct \bibitem usage (YaTeX::cite-collect-bibs-internal bibptn) (if (progn (YaTeX-visit-main t) (not (eq (current-buffer) cb))) (save-excursion (goto-char (point-min)) ;;(1)search external bibdata (while (YaTeX-re-search-active-forward bibrx pcnt nil t) (apply 'YaTeX::cite-collect-bibs-external bibptn (YaTeX-split-string (YaTeX-match-string 1) ","))) ;;(2)search internal (YaTeX::cite-collect-bibs-internal bibptn))) ;;Now bbuf holds the list of bibitem (set-buffer bbuf) ;;;(switch-to-buffer bbuf) (if (fboundp 'font-lock-fontify-buffer) (font-lock-fontify-buffer)) (YaTeX::ref argp (concat "\\\\\\(" YaTeX::cite-bibitem-macro-regexp "\\)\\(\\[.*\\]\\)?") "cite")))) (t nil))) (defun YaTeX::bibitem (argp) "Add-in function to insert argument of \\bibitem." (YaTeX::label argp "label" "cite")) ;;; for Harvard citation style (fset 'YaTeX::citeasnoun 'YaTeX::cite) (fset 'YaTeX::possessivecite 'YaTeX::cite) (fset 'YaTeX::citeyear 'YaTeX::cite) (fset 'YaTeX::citename 'YaTeX::cite) (fset 'YaTeX::citep 'YaTeX::cite) (fset 'YaTeX::citet 'YaTeX::cite) (defun YaTeX-select-other-yatex-buffer () "Select buffer from all yatex-mode's buffers interactivelly." (interactive) (let ((lbuf "*YaTeX mode buffers*") (blist (YaTeX-yatex-buffer-list)) (lnum -1) buf rv (ff "**find-file**")) (YaTeX-showup-buffer lbuf (function (lambda (x) 1))) ;;Select next window surely. (save-excursion (set-buffer (get-buffer lbuf)) (setq buffer-read-only nil) (erase-buffer)) (let ((standard-output (get-buffer lbuf))) (while blist (princ (format "%c:{%s}\n" (+ (% (setq lnum (1+ lnum)) 26) ?A) (buffer-name (car blist)))) (setq blist (cdr blist))) (princ (format "':{%s}" ff))) (YaTeX-showup-buffer lbuf nil t) (YaTeX::label-setup-key-map) (setq buffer-read-only t) (use-local-map YaTeX-label-select-map) (message YaTeX-label-guide-msg) (unwind-protect (progn (recursive-edit) (set-buffer lbuf) (beginning-of-line) (setq rv (if (re-search-forward "{\\([^\\}]+\\)}" (point-end-of-line) t) (buffer-substring (match-beginning 1) (match-end 1)) nil))) (kill-buffer lbuf)) (if (string= rv ff) (progn (call-interactively 'find-file) (current-buffer)) rv))) (defun YaTeX-label-other () (let ((rv (YaTeX-select-other-yatex-buffer))) (cond ((null rv) "") (t (set-buffer rv) (funcall me argp labelcmd refcmd))))) ;; ; completion for the arguments of \newcommand ;; (defun YaTeX::newcommand (&optional argp) (cond ((= argp 1) (let ((command (read-string "Define newcommand: " "\\"))) (put 'YaTeX::newcommand 'command (substring command 1)) command)) ((= argp 2) (let ((argc (string-to-int (read-string "Number of arguments(Default 0): "))) (def (read-string "Definition: ")) (command (get 'YaTeX::newcommand 'command))) ;;!!! It's illegal to insert string in the add-in function !!! (if (> argc 0) (insert (format "[%d]" argc))) (if (and (stringp command) (string< "" command) (y-or-n-p "Update dictionary?")) (cond ((= argc 0) (YaTeX-update-table (list command) 'singlecmd-table 'user-singlecmd-table 'tmp-singlecmd-table)) ((= argc 1) (YaTeX-update-table (list command) 'section-table 'user-section-table 'tmp-section-table)) (t (YaTeX-update-table (list command argc) 'section-table 'user-section-table 'tmp-section-table)))) (message "") def ;return command name )) (t ""))) (defun YaTeX::newcounter (&optional argp) (cond ((= argp 1) (read-string "New counter name: ")) (t ""))) ;; ; completion for the arguments of \pagestyle ;; (defun YaTeX::pagestyle (&optional argp) "Read the pagestyle with completion." (completing-read "Page style: " '(("plain") ("empty") ("headings") ("myheadings") ("normal") nil))) (fset 'YaTeX::thispagestyle 'YaTeX::pagestyle) ;; ; completion for the arguments of \pagenumbering ;; (defun YaTeX::pagenumbering (&optional argp) "Read the numbering style." (completing-read "Page numbering style: " '(("arabic") ("Alpha") ("alpha") ("Roman") ("roman")))) ;; ; Length ;; (defvar YaTeX:style-parameters-default '(("\\arraycolsep") ("\\arrayrulewidth") ("\\baselineskip") ("\\columnsep") ("\\columnseprule") ("\\doublerulesep") ("\\evensidemargin") ("\\footheight") ("\\footskip") ("\\headheight") ("\\headsep") ("\\itemindent") ("\\itemsep") ("\\labelsep") ("\\labelwidth") ("\\leftmargin") ("\\linewidth") ("\\listparindent") ("\\marginparsep") ("\\marginparwidth") ("\\mathindent") ("\\oddsidemargin") ("\\parindent") ("\\parsep") ("\\parskip") ("\\partopsep") ("\\rightmargin") ("\\tabcolsep") ("\\textheight") ("\\textwidth") ("\\topmargin") ("\\topsep") ("\\topskip") ) "Alist of LaTeX style parameters.") (defvar YaTeX:style-parameters-private nil "*User definable alist of style parameters.") (defvar YaTeX:style-parameters-local nil "*User definable alist of local style parameters.") (defvar YaTeX:length-history nil "Holds history of length.") (put 'YaTeX:length-history 'no-default t) (defun YaTeX::setlength (&optional argp) "YaTeX add-in function for arguments of \\setlength." (cond ((equal 1 argp) ;;(completing-read "Length variable: " YaTeX:style-parameters nil nil "\\") (YaTeX-cplread-with-learning "Length variable: " 'YaTeX:style-parameters-default 'YaTeX:style-parameters-private 'YaTeX:style-parameters-local nil nil "\\") ) ((equal 2 argp) (read-string-with-history "Length: " nil 'YaTeX:length-history)))) (fset 'YaTeX::addtolength 'YaTeX::setlength) (defun YaTeX::settowidth (&optional argp) "YaTeX add-in function for arguments of \\settowidth." (cond ((equal 1 argp) (YaTeX-cplread-with-learning "Length variable: " 'YaTeX:style-parameters-default 'YaTeX:style-parameters-private 'YaTeX:style-parameters-local nil nil "\\")) ((equal 2 argp) (read-string "Text: ")))) (defun YaTeX::newlength (&optional argp) "YaTeX add-in function for arguments of \\newlength" (cond ((equal argp 1) (let ((length (read-string "Length variable: " "\\"))) (if (string< "" length) (YaTeX-update-table (list length) 'YaTeX:style-parameters-default 'YaTeX:style-parameters-private 'YaTeX:style-parameters-local)) length)))) ;; \multicolumn's arguments (defun YaTeX::multicolumn (&optional argp) "YaTeX add-in function for arguments of \\multicolumn." (cond ((equal 1 argp) (read-string "Number of columns: ")) ((equal 2 argp) (YaTeX:read-oneof "|lrc" nil t)) ((equal 3 argp) (read-string "Item: ")))) (defvar YaTeX:documentstyles-default '(("article") ("jarticle") ("j-article") ("book") ("jbook") ("j-book") ("report") ("jreport") ("j-report") ("letter") ("ascjletter")) "List of LaTeX documentstyles.") (defvar YaTeX:documentstyles-private nil "*User defined list of LaTeX documentstyles.") (defvar YaTeX:documentstyles-local nil "*User defined list of local LaTeX documentstyles.") (defvar YaTeX:documentstyle-options-default '(("a4j") ("a5j") ("b4j") ("b5j") ("twocolumn") ("jtwocolumn") ("epsf") ("epsfig") ("epsbox") ("nfig")) "List of LaTeX documentstyle options.") (defvar YaTeX:documentstyle-options-private nil "*User defined list of LaTeX documentstyle options.") (defvar YaTeX:documentstyle-options-local nil "List of LaTeX local documentstyle options.") (defun YaTeX:documentstyle () (let*((delim ",") (dt (append YaTeX:documentstyle-options-local YaTeX:documentstyle-options-private YaTeX:documentstyle-options-default)) (minibuffer-completion-table dt) (opt (read-from-minibuffer "Style options ([opt1,opt2,...]): " nil YaTeX-minibuffer-completion-map nil)) (substr opt) o) (if (string< "" opt) (progn (while substr (setq o (substring substr 0 (string-match delim substr))) (or (assoc o dt) (YaTeX-update-table (list o) 'YaTeX:documentstyle-options-default 'YaTeX:documentstyle-options-private 'YaTeX:documentstyle-options-local)) (setq substr (if (string-match delim substr) (substring substr (1+ (string-match delim substr)))))) (concat "[" opt "]")) ""))) (defun YaTeX::documentstyle (&optional argp) "YaTeX add-in function for arguments of \\documentstyle." (cond ((equal argp 1) (setq YaTeX-env-name "document") (let ((sname (YaTeX-cplread-with-learning (format "Documentstyle (default %s): " YaTeX-default-document-style) 'YaTeX:documentstyles-default 'YaTeX:documentstyles-private 'YaTeX:documentstyles-local))) (if (string= "" sname) (setq sname YaTeX-default-document-style)) (setq YaTeX-default-document-style sname))))) (defun YaTeX::include (argp &optional prompt) "Read file name setting default directory to that of main file." (cond ((= argp 1) (save-excursion (YaTeX-visit-main t) (let*((insert-default-directory) (file (read-file-name (or prompt "Input file: ") ""))) (setq file (substring file 0 (string-match "\\.tex$" file)))))))) (fset 'YaTeX::input 'YaTeX::include) ;;; -------------------- LaTeX2e stuff -------------------- (defvar YaTeX:documentclass-options-default '(("a4paper") ("a5paper") ("b4paper") ("b5paper") ("10pt") ("11pt") ("12pt") ("latterpaper") ("legalpaper") ("executivepaper") ("landscape") ("oneside") ("twoside") ("draft") ("final") ("leqno") ("fleqn") ("openbib") ("tombow") ("titlepage") ("notitlepage") ("dvips") ("mingoth") ;for jsarticle ("clock") ;for slides class only ) "Default options list for documentclass") (defvar YaTeX:documentclass-options-private nil "*User defined options list for documentclass") (defvar YaTeX:documentclass-options-local nil "*User defined options list for local documentclass") (defun YaTeX:documentclass () (let*((delim ",") (dt (append YaTeX:documentclass-options-local YaTeX:documentclass-options-private YaTeX:documentclass-options-default)) (minibuffer-completion-table dt) (opt (read-from-minibuffer "Documentclass options ([opt1,opt2,...]): " nil YaTeX-minibuffer-completion-map nil)) (substr opt) o) (if (string< "" opt) (progn (while substr (setq o (substring substr 0 (string-match delim substr))) (or (assoc o dt) (YaTeX-update-table (list o) 'YaTeX:documentclass-options-default 'YaTeX:documentclass-options-private 'YaTeX:documentclass-options-local)) (setq substr (if (string-match delim substr) (substring substr (1+ (string-match delim substr)))))) (concat "[" opt "]")) ""))) (defvar YaTeX:documentclasses-default '(("article") ("jarticle") ("report") ("jreport") ("book") ("jbook") ("jsarticle") ("jsbook") ("j-article") ("j-report") ("j-book") ("letter") ("slides") ("ltxdoc") ("ltxguide") ("ltnews") ("proc")) "Default documentclass alist") (defvar YaTeX:documentclasses-private nil "*User defined documentclass alist") (defvar YaTeX:documentclasses-local nil "*User defined local documentclass alist") (defvar YaTeX-default-documentclass (if YaTeX-japan "jarticle" "article") "*Default documentclass") (defun YaTeX::documentclass (&optional argp) (cond ((equal argp 1) (setq YaTeX-env-name "document") (let ((sname (YaTeX-cplread-with-learning (format "Documentclass (default %s): " YaTeX-default-documentclass) 'YaTeX:documentclasses-default 'YaTeX:documentclasses-private 'YaTeX:documentclasses-local))) (if (string= "" sname) (setq sname YaTeX-default-documentclass)) (setq YaTeX-section-name "title" YaTeX-default-documentclass sname))))) (defun YaTeX::title (&optional argp) (prog1 (read-string "Document Title: ") (setq YaTeX-section-name "author" YaTeX-single-command "maketitle"))) (defun YaTeX::author (&optional argp) (prog1 (read-string "Document Author: ") (setq YaTeX-section-name "date" YaTeX-single-command "maketitle"))) (defun YaTeX:document () (setq YaTeX-section-name (if (string-match "book\\|bk" YaTeX-default-documentclass) "chapter" "section")) "") (defvar YaTeX:latex2e-named-color-alist '(("GreenYellow") ("Yellow") ("Goldenrod") ("Dandelion") ("Apricot") ("Peach") ("Melon") ("YellowOrange") ("Orange") ("BurntOrange") ("Bittersweet") ("RedOrange") ("Mahogany") ("Maroon") ("BrickRed") ("Red") ("OrangeRed") ("RubineRed") ("WildStrawberry") ("Salmon") ("CarnationPink") ("Magenta") ("VioletRed") ("Rhodamine") ("Mulberry") ("RedViolet") ("Fuchsia") ("Lavender") ("Thistle") ("Orchid")("DarkOrchid") ("Purple") ("Plum") ("Violet") ("RoyalPurple") ("BlueViolet") ("Periwinkle") ("CadetBlue") ("CornflowerBlue") ("MidnightBlue") ("NavyBlue") ("RoyalBlue") ("Blue") ("Cerulean") ("Cyan") ("ProcessBlue") ("SkyBlue") ("Turquoise") ("TealBlue") ("Aquamarine") ("BlueGreen") ("Emerald") ("JungleGreen") ("SeaGreen") ("Green") ("ForestGreen") ("PineGreen") ("LimeGreen") ("YellowGreen") ("SpringGreen") ("OliveGreen") ("RawSienna") ("Sepia") ("Brown") ("Tan") ("Gray") ("Black") ("White")) "Colors defined in $TEXMF/tex/plain/dvips/colordvi.tex") (defvar YaTeX:latex2e-basic-color-alist '(("black") ("white") ("red") ("blue") ("yellow") ("green") ("cyan") ("magenta")) "Basic colors") (defun YaTeX:textcolor () "Add-in for \\color's option" (if (y-or-n-p "Use `named' color? ") "[named]")) (defun YaTeX::color-completing-read (prompt) (let ((completion-ignore-case t) (namedp (save-excursion (skip-chars-backward "^\n\\[\\\\") (looking-at "named")))) (completing-read prompt (if namedp YaTeX:latex2e-named-color-alist YaTeX:latex2e-basic-color-alist) nil t))) (defun YaTeX::textcolor (argp) "Add-in for \\color's argument" (cond ((= argp 1) (YaTeX::color-completing-read "Color: ")) ((= argp 2) (read-string "Colored string: ")))) (fset 'YaTeX:color 'YaTeX:textcolor) (fset 'YaTeX::color 'YaTeX::textcolor) (fset 'YaTeX:colorbox 'YaTeX:textcolor) (fset 'YaTeX::colorbox 'YaTeX::textcolor) (fset 'YaTeX:fcolorbox 'YaTeX:textcolor) (fset 'YaTeX:pagecolor 'YaTeX:textcolor) (fset 'YaTeX::pagecolor 'YaTeX::textcolor) (defun YaTeX::fcolorbox (argp) (cond ((= argp 1) (YaTeX::color-completing-read "Frame color: ")) ((= argp 2) (YaTeX::color-completing-read "Inner color: ")) ((= argp 3) (read-string "Colored string: ")))) (defun YaTeX:scalebox () "Add-in for \\scalebox" (let ((vmag (read-string (if YaTeX-japan "倍率(負で反転): " "Magnification(Negative for flipped): "))) (hmag (read-string (if YaTeX-japan "縦倍率(省略可): " "Vertical magnification(Optional): ")))) (if (and hmag (string< "" hmag)) (format "{%s}[%s]" vmag hmag) (format "{%s}" vmag)))) (defun YaTeX:rotatebox () "Optional argument add-in for \\rotatebox" (message "Rotate origin? (N)one (O)rigin (X)-Y: ") (let ((c (read-char)) r (defx "x=mm") x (defy "y=mm") y something) (cond ((memq c '(?O ?o)) (if (string< "" (setq r (YaTeX:read-oneof "htbpB"))) (concat "[origin=" r "]"))) ((memq c '(?X ?x ?Y ?y)) (setq r (read-string "" (if YaTeX-emacs-19 (cons defx 3) defx)) x (if (string< "x=" r) r) r (read-string "" (if YaTeX-emacs-19 (cons defy 3) defy)) y (if (string< "y=" r) r) something (or x y)) (format "%s%s%s%s%s" (if something "[" "") (if x x "") (if (and x y) "," "") (if y y "") (if something "]" "")))))) (defun YaTeX::rotatebox (argp) "Argument add-in for \\rotatebox" (cond ((= argp 1) (read-string (if YaTeX-japan "回転角(度; 左回り): " "Angle in degree(unclockwise): "))) ((= argp 2) (read-string (if YaTeX-japan "テキスト: " "Text: "))))) (defun YaTeX:includegraphics () "Add-in for \\includegraphics's option" (let (width height (scale "") angle str) (setq width (YaTeX-read-string-or-skip "Width: ") height (YaTeX-read-string-or-skip "Height: ")) (or (string< "" width) (string< "" height) (setq scale (YaTeX-read-string-or-skip "Scale: "))) (setq angle (YaTeX-read-string-or-skip "Angle(0-359): ")) (setq str (mapconcat 'concat (delq nil (mapcar '(lambda (s) (and (stringp (symbol-value s)) (string< "" (symbol-value s)) (format "%s=%s" s (symbol-value s)))) '(width height scale angle))) ",")) (if (string= "" str) "" (concat "[" str "]")))) (defun YaTeX::includegraphics (argp) "Add-in for \\includegraphics" (let ((imgfile (YaTeX::include argp "Image File: ")) (case-fold-search t) info bb noupdate needclose c) (and (string-match "\\.\\(jpe?g\\|png\\|gif\\|bmp\\)$" imgfile) (file-exists-p imgfile) (or (fboundp 'yahtml-get-image-info) (progn (load "yahtml" t) (featurep 'yahtml))) ;(require 'yahtml nil t) (setq info (yahtml-get-image-info imgfile)) (car info) ;if has width value (car (cdr info)) ;if has height value (setq bb (format "bb=%d %d %d %d" 0 0 (car info) (car (cdr info)))) (save-excursion (cond ((and (save-excursion (YaTeX-re-search-active-backward "\\\\\\(includegraphics\\)\\|\\(bb=[-+ \t0-9]+\\)" YaTeX-comment-prefix nil t)) (match-beginning 2) (not (setq noupdate (equal (YaTeX-match-string 2) bb))) (y-or-n-p (format "Update `bb=' line to `%s'?: " bb))) (message "") (replace-match bb)) (noupdate nil) ((and (match-beginning 1) (prog2 (message "Insert `%s'? Y)es N)o C)yes+`clip': " bb) (memq (setq c (read-char)) '(?y ?Y ?\ ?c ?C)) (message ""))) (goto-char (match-end 0)) (message "") (if (looking-at "\\[") (forward-char 1) (insert-before-markers "[") (setq needclose t)) (insert-before-markers bb) (if (memq c '(?c ?C)) (insert-before-markers ",clip")) (if needclose (insert-before-markers "]") (or (looking-at "\\]") (insert-before-markers ",")))) (t (YaTeX-push-to-kill-ring bb))))) (setq YaTeX-section-name "caption") imgfile)) (defun YaTeX::verbfile (argp) "Add-in for \\verbfile" (YaTeX::include argp "Virbatim File: ")) (defun YaTeX:caption () (setq YaTeX-section-name "label") nil) (defvar YaTeX::usepackage-alist-default '(("version") ("plext") ("url") ("fancybox") ("pifont") ("longtable") ("ascmac") ("bm") ("graphics") ("graphicx") ("alltt") ("misc") ("eclbkbox") ("amsmath") ("amssymb") ("xymtex") ("chemist") ("a4j") ("array") ("epsf") ("color") ("epsfig") ("floatfig") ("landscape") ("path") ("supertabular") ("twocolumn") ("latexsym") ("times") ("makeidx")) "Default completion table for arguments of \\usepackage") (defvar YaTeX::usepackage-alist-private nil "*Private completion list of the argument for usepackage") (defvar YaTeX::usepackage-alist-local nil "Directory local completion list of the argument for usepackage") (defun YaTeX::usepackage (&optional argp) (cond ((equal argp 1) (setq YaTeX-env-name "document") (let ((minibuffer-local-completion-map YaTeX-minibuffer-completion-map) (delim ",")) (YaTeX-cplread-with-learning (if YaTeX-japan "Use package(カンマで区切ってOK): " "Use package(delimitable by comma): ") 'YaTeX::usepackage-alist-default 'YaTeX::usepackage-alist-private 'YaTeX::usepackage-alist-local))))) (defun YaTeX::mask (argp) (cond ((equal argp 1) (read-string "String: ")) ((equal argp 2) (let (c) (while (not (memq c '(?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K))) (message "Mask type(A..K): ") (setq c (upcase (read-char)))) (format "%c" c))))) (defun YaTeX::maskbox (argp) (cond ((equal argp 1) (read-string "Width: ")) ((equal argp 2) (read-string "Height: ")) ((equal argp 3) (let (c) (while (not (memq c '(?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K))) (message "Mask type(A..K): ") (setq c (upcase (read-char)))) (format "%c" c))) ((equal argp 4) (YaTeX:read-oneof "lcr" 'quick)) ((equal argp 5) (read-string "String: ")))) (defun YaTeX::textcircled (argp) (cond ((equal argp 1) (let ((char (read-string "Circled char: ")) (left "") (right "") c) (setq c (read-char "Enclose also with (s)mall (t)iny s(C)riptsize (N)one:")) (cond ((memq c '(?s ?S)) (setq left "{\\small " right "}")) ((memq c '(?t ?T)) (setq left "{\\tiny " right "}")) ((memq c '(?c ?C)) (setq left "{\\scriptsize " right "}"))) (format "%s%s%s" left char right))))) ;;; -------------------- math-mode stuff -------------------- (defun YaTeX::tilde (&optional pos) "For accent macros in mathmode" (cond ((equal pos 1) (message "Put accent on variable: ") (let ((v (char-to-string (read-char))) (case-fold-search nil)) (message "") (cond ((string-match "i\\|j" v) (concat "\\" v "math")) ((string-match "[\r\n\t ]" v) "") (t v)))) (nil ""))) (fset 'YaTeX::hat 'YaTeX::tilde) (fset 'YaTeX::check 'YaTeX::tilde) (fset 'YaTeX::bar 'YaTeX::tilde) (fset 'YaTeX::dot 'YaTeX::tilde) (fset 'YaTeX::ddot 'YaTeX::tilde) (fset 'YaTeX::vec 'YaTeX::tilde) (defun YaTeX::widetilde (&optional pos) "For multichar accent macros in mathmode" (cond ((equal pos 1) (let ((m "Put over chars[%s ]: ") v v2) (message m " ") (setq v (char-to-string (read-char))) (message "") (if (string-match "[\r\n\t ]" v) "" (message m v) (setq v2 (char-to-string (read-char))) (message "") (if (string-match "[\r\n\t ]" v2) v (concat v v2))))) (nil ""))) (fset 'YaTeX::widehat 'YaTeX::widetilde) (fset 'YaTeX::overline 'YaTeX::widetilde) (fset 'YaTeX::overrightarrow 'YaTeX::widetilde) ; ; for \frac{}{} region (defun YaTeX::frac-region (beg end) (if (catch 'done (while (re-search-forward "\\s *\\(\\\\over\\|/\\)\\s *" end t) (goto-char (match-beginning 0)) (if (y-or-n-p (format "Replace this `%s' with `}{'" (YaTeX-match-string 0))) (throw 'done t)) (goto-char (match-end 0)))) (let (p (b0 (match-beginning 0)) e0) (replace-match "}{") (setq e0 (point)) (save-restriction (narrow-to-region beg end) (goto-char e0) (skip-chars-forward " \t") (setq p (point)) (YaTeX-goto-corresponding-paren) (forward-char 1) (skip-chars-forward " \t\r\n") (if (= end (1+ (point))) (progn (goto-char p) (if (looking-at "\\\\") (forward-char 1)) (YaTeX-kill-paren nil))) (goto-char beg) (skip-chars-forward " \t") (setq p (point)) (YaTeX-goto-corresponding-paren) (forward-char 1) (skip-chars-forward " \t\r\n") (if (>= (point) b0) (progn (goto-char p) (if (looking-at "\\\\") (forward-char 1)) (YaTeX-kill-paren nil)))))) (message "")) (defun YaTeX::DeclareMathOperator (argp) (cond ((equal argp 1) (read-string "Operator: " "\\")))) ;;; ;; Add-in functions for large-type command. ;;; (defun YaTeX:em () (cond ((eq YaTeX-current-completion-type 'large) "\\/") (t nil))) (fset 'YaTeX:it 'YaTeX:em) ;;; -------------------- End of yatexadd -------------------- (provide 'yatexadd) ; Local variables: ; fill-prefix: ";;; " ; paragraph-start: "^$\\| \\|;;;$" ; paragraph-separate: "^$\\| \\|;;;$" ; coding: sjis ; End: yatex_1.77+dfsg1/yatexhks.el0000444000175000017500000000447412126310635014542 0ustar kurakura;;; -*- Emacs-Lisp -*- ;;; Hooks for YaTeX ;;; 野鳥に関連する記述(たとえばアドイン関数)は yatexhks.el という名前の ;;; ファイルに入れてください。起動時に自動的にロードします。 ;;; All the private definitions for YaTeX can be stuffed into the file ;;; named `yatexhks.el'. The file `yatexhks.el' will be automatically ;;; loaded at the end of loading `yatex.el'. ;Private definitions begin from here. ;;97/1/27 (define-key YaTeX-user-extensional-map "v" 'YaTeX-section-overview) ;;initial version (define-key YaTeX-user-extensional-map "0" '(lambda () (interactive) (YaTeX-make-section nil nil nil "part"))) (define-key YaTeX-user-extensional-map "1" '(lambda () (interactive) (YaTeX-make-section nil nil nil "chapter"))) (define-key YaTeX-user-extensional-map "2" '(lambda () (interactive) (YaTeX-make-section nil nil nil "section"))) (define-key YaTeX-user-extensional-map "3" '(lambda () (interactive) (YaTeX-make-section nil nil nil "subsection"))) (define-key YaTeX-user-extensional-map "4" '(lambda () (interactive) (YaTeX-make-section nil nil nil "subsubsection"))) (define-key YaTeX-user-extensional-map "5" '(lambda () (interactive) (YaTeX-make-section nil nil nil "paragraph"))) (define-key YaTeX-user-extensional-map "6" '(lambda () (interactive) (YaTeX-make-section nil nil nil "subparagraph"))) (define-key YaTeX-user-extensional-map "r" '(lambda () (interactive) (YaTeX-make-section nil nil nil "ref"))) (define-key YaTeX-user-extensional-map "i" '(lambda () (interactive) (YaTeX-make-singlecmd "item"))) (define-key YaTeX-user-extensional-map "\C-b" '(lambda () (interactive) (YaTeX-make-singlecmd "leftarrow"))) (define-key YaTeX-user-extensional-map "l" '(lambda () (interactive) (YaTeX-make-section nil nil nil "label"))) (define-key YaTeX-user-extensional-map "f" '(lambda () (interactive) (YaTeX-make-section nil nil nil "frac"))) (define-key YaTeX-user-extensional-map "S" '(lambda () (interactive) (YaTeX-make-section nil nil nil "setlength"))) (define-key YaTeX-user-extensional-map "b" '(lambda () (interactive) (YaTeX-make-fontsize nil "bf"))) (define-key YaTeX-user-extensional-map "I" 'YaTeX-browse-info) (defun YaTeX-browse-info () "Browse YaTeX's info" (interactive) (require 'info) (Info-goto-node (if YaTeX-japan "(yatexj)Top" "(yatexe)Top"))) ; ;;; End of yatexhks.el (provide 'yatexhks) yatex_1.77+dfsg1/yatexhie.el0000444000175000017500000003571612126310635014525 0ustar kurakura;;; yatexhie.el --- YaTeX hierarchy browser ;;; ;;; (c)1995-2013 by HIROSE Yuuji [yuuji@yatex.org] ;;; Last modified Mon Apr 1 22:43:34 2013 on firestorm ;;; $Id: yatexhie.el,v 1.77 2013/04/01 13:53:45 yuuji Rel $ ;;; Code: ;; ----- Customizable variables ----- (defvar YaTeX-hierarchy-ignore-heading-regexp "\\$[A-Z][a-z]+: .* \\$\\|-\\*- .* -\\*-" "*Regexp of lines to ignore as files' headline.") ;; ----- General variables ----- (defvar YaTeX-default-TeX-extensions "\\.\\(tex\\|sty\\)") (defvar YaTeX-hierarchy-current-main nil) (defvar YaTeX-hierarchy-buffer-message (concat "n)ext p)rev N)extsame P)revsame u)p K)illbuf RET)select" (if (and YaTeX-emacs-19 window-system) " Mouse2)select" "") " ?)help")) (defvar YaTeX-hierarchy-saved-wc nil "Saved window configuration.") ;; ----- Functions for parsing hierarchy ----- (defun YaTeX-all-included-files (&optional file) "Return all included files from FILE as a list. If FILE is nil, use current buffer." (save-excursion (let ((include-regex (concat YaTeX-ec-regexp "\\(\\(input\\)\\|" ;match#2 "\\(include\\)\\)\\b")) ;match#3 list file (cb (current-buffer))) (if file (set-buffer (YaTeX-switch-to-buffer file t))) (goto-char (point-min)) (while (YaTeX-re-search-active-forward include-regex YaTeX-comment-prefix nil t) (cond ((match-beginning 2) ;\input, {} is optional, 1 argument (skip-chars-forward " {") (setq file (buffer-substring (point) (progn (skip-chars-forward (concat "^ \t\n\r" YaTeX-ec-regexp "{}")) (point))))) ((and (match-beginning 3) (looking-at "{")) (skip-chars-forward "{") (setq file (buffer-substring (point) (progn (forward-char -1) (forward-list 1) (1- (point))))))) (or (string-match YaTeX-default-TeX-extensions file) (setq file (concat file ".tex"))) (setq list (cons file list))) (set-buffer cb) (nreverse list)))) (defun YaTeX-document-hierarchy (&optional file basedir) "Return the document hierarchy beginning from FILE as a list. If FILE is nil, beginning with current buffer's file." (setq file (or file buffer-file-name)) (and YaTeX-search-file-from-top-directory (not (file-exists-p file)) (string-match "^[^/].*/" file) (setq file (expand-file-name file basedir))) (message "Parsing [%s]..." (file-name-nondirectory file)) (prog1 (save-excursion (if (or (file-exists-p file) (null file)) (progn (if file (let ((parent buffer-file-name)) (YaTeX-switch-to-buffer file t) ;set buffer to file (or YaTeX-parent-file (YaTeX-get-builtin "!") (setq YaTeX-parent-file parent)))) (cons (buffer-file-name (current-buffer)) (mapcar '(lambda (f) ;return value (YaTeX-document-hierarchy f basedir)) (YaTeX-all-included-files)))))) (message "Parsing [%s]...done" (file-name-nondirectory file)))) ;; ----- Functions for displaying hierarchy ----- (defun YaTeX-hierarchy-get-file-heading (file) "Get a FILE's heading." (save-excursion (set-buffer (find-file-noselect file)) (save-excursion (let (p) (goto-char (point-min)) (cond ((re-search-forward (concat YaTeX-ec-regexp YaTeX-sectioning-regexp) nil t) (search-forward "{") (forward-char -1) (setq p (condition-case nil (progn (forward-list 1) (1- (point))) (error (point-end-of-line)))) (goto-char (1+ (match-beginning 0))) (skip-chars-forward " \t\n") (buffer-substring (point) (min (point-end-of-line) p))) ((catch 'found (while (re-search-forward "^ *%\\([^#]\\)" nil t) (or (re-search-forward YaTeX-hierarchy-ignore-heading-regexp (point-end-of-line) t) (throw 'found t)))) (beginning-of-line) (search-forward "%") (skip-chars-forward "% \t") (buffer-substring (point) (point-end-of-line))) (t "")))))) (defun YaTeX-display-a-hierachy (hier level) "Put a HIER of document hierarchy. LEVEL is including depth." (message "Formatting hierarchy buffer...") (let ((lastatomcol 0) list i p) (cond ((listp hier) (setq list hier) (while list (YaTeX-display-a-hierachy (car list) (1+ level)) (setq list (cdr list)))) ((stringp hier) ;is an atom (insert " ") (setq i level) (while (> i 2) (insert "| ") (setq i (1- i))) (if (> level 1) (insert "+---")) (setq p (point)) (insert (or (buffer-name (get-file-buffer hier)) (file-name-nondirectory hier))) (if (and window-system YaTeX-emacs-19) (put-text-property p (point) 'mouse-face 'underline)) (insert " ") (indent-to-column (1- (/ (window-width) 2))) (insert "% " (YaTeX-hierarchy-get-file-heading hier)) (insert "\n")))) (message "Formatting hierarchy buffer...")) (defun YaTeX-display-hierarchy (file &optional use-default) "Display document hierarchy that is beginning from FILE." (interactive "P") (setq YaTeX-hierarchy-saved-wc (list (current-window-configuration) (and (featurep 'windows) (boundp 'win:current-config) win:current-config))) (let*((b-in (YaTeX-get-builtin "!")) default) ;;$B$`!<$s"-$3$N$X$s$N;EMM$I$&$7$?$i$$$$$+NI$/J,$+$i$s(B... (if default (setq default (expand-file-name default))) (YaTeX-visit-main t) ;move to parent file (setq default buffer-file-name) (setq file (or (if use-default default file) (read-file-name (format "Main .tex file%s: " (if default (format "(default %s)"(file-name-nondirectory default)) "")) "" default 1)))) (setq file (expand-file-name file)) (setq YaTeX-hierarchy-current-main file) (let ((dbuf "*document hierarchy*") (topdir default-directory)) (YaTeX-showup-buffer dbuf nil t) (set-buffer (get-buffer dbuf)) (setq truncate-lines t) (let ((buffer-read-only nil)) (erase-buffer) (YaTeX-display-a-hierachy (YaTeX-document-hierarchy file topdir) 0)) (goto-char (point-min)) (YaTeX-hierarchy-next 0) (set-buffer-modified-p nil) (YaTeX-hierarchy-mode) )) (defun YaTeX-display-hierarchy-directly () "Same as YaTeX-display-hierarchy. Call from mouse." (interactive) (YaTeX-display-hierarchy nil t)) (defun YaTeX-hierarchy-mode () "Major mode to browse and select document hierarchy. \\[YaTeX-hierarchy-next] next line \\[YaTeX-hierarchy-prev] previous line \\[YaTeX-hierarchy-forward] move forward in the same level \\[YaTeX-hierarchy-backward] move backward in the same level \\[YaTeX-hierarchy-up-document] move to parent file \\[delete-other-windows] delete other windows \\[other-window] other window \\[shrink-window] shrink window \\[enlarge-window] enlarge window \\[YaTeX-hierarchy-show] show file contents in the next window \\[YaTeX-hierarchy-scroll-up] scroll up file contents buffer \\[YaTeX-hierarchy-scroll-down] scroll down file contents buffer \\[YaTeX-hierarchy-top] show the top of file contents \\[YaTeX-hierarchy-bottom] show the bottom of file contents \\[YaTeX-hierarchy-lastpos] return to the previous position \\[YaTeX-hierarchy-select] select file \\[YaTeX-hierarchy-mouse-select] select " (setq major-mode 'YaTeX-hierarchy-mode mode-name "YaTeX hier") (use-local-map YaTeX-hierarchy-mode-map) (setq buffer-read-only t) (message YaTeX-hierarchy-buffer-message)) ;; ----- Subfunctions for interactive functions ----- (defun YaTeX-hierarchy-get-current-file-buffer () "Return the buffer associated with current line's file." (let ((file (buffer-substring (point) (save-excursion (skip-chars-forward "^ \t" (point-end-of-line)) (point)))) (hilit-auto-highlight) buffer) (set-buffer (find-file-noselect YaTeX-hierarchy-current-main)) (if (get-buffer file) ;buffer is active (setq buffer (get-buffer file)) ;may contain `<2>' (if (string-match "<[2-9]>$" file) (setq file (substring file 0 -3))) (save-excursion (setq buffer (YaTeX-switch-to-buffer file t)))))) ; open it! ;; ----- Interactive functions ----- (defun YaTeX-hierarchy-next (arg &optional quiet) "Move to next line's file in YaTeX document hierarchy buffer." (interactive "p") (forward-line arg) (skip-chars-forward "- +\\|") (if (and (/= arg 0) (not quiet)) (YaTeX-hierarchy-select t)) (message YaTeX-hierarchy-buffer-message)) (defun YaTeX-hierarchy-prev (arg) "Move to previous line's file in YaTeX document hierarchy buffer." (interactive "p") (YaTeX-hierarchy-next (- arg))) (defun YaTeX-hierarchy-next-line (arg) (interactive "p") (YaTeX-hierarchy-next arg t)) (defun YaTeX-hierarchy-prev-line (arg) (interactive "p") (YaTeX-hierarchy-next (- arg) t)) (defun YaTeX-hierarchy-forward (arg) "Move to forward file in same hierarchy level." (interactive "p") (YaTeX-hierarchy-next 0) (let ((p (point))(column (current-column)) (i (if (> arg 0) arg (- arg)))) (if (= column 0) (error "Not on file line.")) (while (> i 0) (if (catch 'found (while (and (not (eobp)) (not (bobp))) (forward-line (if (> arg 0) 1 -1)) (move-to-column column) (if (looking-at "[- +\\|]") nil (YaTeX-hierarchy-next 0) (if (= (current-column) column) (throw 'found t))) (beginning-of-line))) nil (goto-char p) (error "No same level file.")) (setq i (1- i))))) (defun YaTeX-hierarchy-backward (arg) "Move to backward file in same hierarchy level." (interactive "p") (YaTeX-hierarchy-forward (- arg))) (defun YaTeX-hierarchy-up-document () "Up level, that is, move to parent file position." (interactive) (YaTeX-hierarchy-next 0) ;adjust column (let ((p (point)) (line (count-lines (point-min) (point))) column) (if (or (<= line 1) (< (current-column) 6)) (message "No more parent") (backward-char 1) (or (= (char-after (point)) ?-) (error "Unexpected hierarchy buffer")) (setq column (current-column)) (while (and (> line 1) (looking-at "[- +\\|]")) (forward-line -1) (move-to-column column)) (YaTeX-hierarchy-next 0) (push-mark p t) (message "Mark set to last position")))) (defun YaTeX-hierarchy-kill-buffer (arg) "Kill buffer associated with current line's file." (interactive "p") (YaTeX-hierarchy-next 0) ;move to file name column (if (bolp) (error "Not on file name line")) (let ((file (buffer-substring (point) (progn (skip-chars-forward "^ \t") (point))))) (YaTeX-hierarchy-next arg) (cond ((get-buffer file) (kill-buffer (get-buffer file)) (message "Buffer [%s] was killed" file)) (t (message "Buffer [%s] is not active." file))))) (defun YaTeX-hierarchy-select (arg) "Select current line's file in YaTeX document hierarchy buffer. If ARG is non-nil, show the buffer in the next window." (interactive "P") (beginning-of-line) (skip-chars-forward "- +\\|") (or (eolp) (let ((buffer (YaTeX-hierarchy-get-current-file-buffer))) (if buffer ;if file was found (if arg (YaTeX-showup-buffer buffer nil) (if (and YaTeX-emacs-19 window-system (get-buffer-window buffer t)) (goto-buffer-window buffer) ;select currently displaying (YaTeX-switch-to-buffer-other-window buffer))))))) (defun YaTeX-hierarchy-show () "Show current line's file in the next window." (interactive) (YaTeX-hierarchy-select t)) (defun YaTeX-hierarchy-mouse-select (event) (interactive "e") (mouse-set-point event) (YaTeX-hierarchy-select nil)) (defun YaTeX-hierarchy-quit () "Quit from YaTeX-hierarchy buffer and restore window configuration." (interactive) (if (or (not (featurep 'windows)) (car YaTeX-hierarchy-saved-wc) (and (= (car (cdr YaTeX-hierarchy-saved-wc)) win:current-config))) (set-window-configuration (car YaTeX-hierarchy-saved-wc)) (bury-buffer nil))) (defun YaTeX-hierarchy-scroll-up (arg &optional action) "Scroll up file contents of YaTeX-hierarchy." (interactive "P") (YaTeX-hierarchy-next 0 t) (let*((bufname (buffer-substring (point) (save-excursion (skip-chars-forward "^ \t") (point)))) (buf (get-buffer bufname)) (cw (selected-window))) (cond ((and buf (get-buffer-window buf)) (select-window (get-buffer-window buf))) ((and buf (YaTeX-showup-buffer buf nil t)) t) (t (YaTeX-hierarchy-select nil))) (unwind-protect (cond ((eq action 'down) (scroll-down arg)) ((eq action 'top) (beginning-of-buffer)) ((eq action 'bottom) (end-of-buffer)) ((eq action 'last) (exchange-point-and-mark)) (t (scroll-up arg))) (select-window cw)))) (defun YaTeX-hierarchy-scroll-down (arg) "Scroll down file contents of YaTeX-hierarchy." (interactive "P") (YaTeX-hierarchy-scroll-up arg 'down)) (defun YaTeX-hierarchy-top () "Show the top of YaTeX-hierarchy inspection buffer's." (interactive) (YaTeX-hierarchy-scroll-up nil 'top) ) (defun YaTeX-hierarchy-bottom () "Show the top of YaTeX-hierarchy inspection buffer's." (interactive) (YaTeX-hierarchy-scroll-up nil 'bottom) ) (defun YaTeX-hierarchy-lastpos () "Go to last position in YaTeX-hierarchy buffer." (interactive) (YaTeX-hierarchy-scroll-up nil 'last) ) ;; ----- Setting up keymap ----- (defvar YaTeX-hierarchy-mode-map nil "Keymap used in YaTeX-hierarchy-mode.") (if YaTeX-hierarchy-mode-map nil (setq YaTeX-hierarchy-mode-map (make-sparse-keymap)) (define-key YaTeX-hierarchy-mode-map "n" 'YaTeX-hierarchy-next) (define-key YaTeX-hierarchy-mode-map "p" 'YaTeX-hierarchy-prev) (define-key YaTeX-hierarchy-mode-map "j" 'YaTeX-hierarchy-next-line) (define-key YaTeX-hierarchy-mode-map "k" 'YaTeX-hierarchy-prev-line) (substitute-all-key-definition 'next-line 'YaTeX-hierarchy-next-line YaTeX-hierarchy-mode-map) (substitute-all-key-definition 'previous-line 'YaTeX-hierarchy-prev-line YaTeX-hierarchy-mode-map) (define-key YaTeX-hierarchy-mode-map "N" 'YaTeX-hierarchy-forward) (define-key YaTeX-hierarchy-mode-map "P" 'YaTeX-hierarchy-backward) (define-key YaTeX-hierarchy-mode-map "u" 'YaTeX-hierarchy-up-document) (define-key YaTeX-hierarchy-mode-map "K" 'YaTeX-hierarchy-kill-buffer) (define-key YaTeX-hierarchy-mode-map "1" 'delete-other-windows) (define-key YaTeX-hierarchy-mode-map "o" 'other-window) (define-key YaTeX-hierarchy-mode-map "-" 'shrink-window) (define-key YaTeX-hierarchy-mode-map "+" 'enlarge-window) (define-key YaTeX-hierarchy-mode-map "." 'YaTeX-hierarchy-show) (define-key YaTeX-hierarchy-mode-map " " 'YaTeX-hierarchy-scroll-up) (define-key YaTeX-hierarchy-mode-map "b" 'YaTeX-hierarchy-scroll-down) (define-key YaTeX-hierarchy-mode-map "\C-?" 'YaTeX-hierarchy-scroll-down) (define-key YaTeX-hierarchy-mode-map "\C-m" 'YaTeX-hierarchy-select) (define-key YaTeX-hierarchy-mode-map "<" 'YaTeX-hierarchy-top) (define-key YaTeX-hierarchy-mode-map ">" 'YaTeX-hierarchy-bottom) (define-key YaTeX-hierarchy-mode-map "'" 'YaTeX-hierarchy-lastpos) (define-key YaTeX-hierarchy-mode-map "g" 'YaTeX-hierarchy-select) (define-key YaTeX-hierarchy-mode-map "q" 'YaTeX-hierarchy-quit) (define-key YaTeX-hierarchy-mode-map "?" 'describe-mode) (if (and YaTeX-emacs-19 window-system) (define-key YaTeX-hierarchy-mode-map [mouse-2] 'YaTeX-hierarchy-mouse-select)) ) (provide 'yatexhie) ;;end of yatexhie.el yatex_1.77+dfsg1/help/0000755000175000017500000000000012143407303013277 5ustar kurakurayatex_1.77+dfsg1/install0000644000175000017500000001076511703451275013761 0ustar kurakura# (This file is encoded with MS-KANJI(Shift JIS) coding system) Installation of YaTeX / 野鳥のインストール ****************************************** Put these expressions into your ~/.emacs まず ~/.emacsに下の2項目を加えます。 (setq auto-mode-alist (cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist)) (autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t) Then, add certain path name where you put files of YaTeX to your load-path. If you want to put them in `~/src/emacs', write 次に野鳥の emacs-lisp ファイル群を置くディレクトリを load-path に加えます。 たとえば、`~/src/emacs/yatex'に置くのであれば、 (setq load-path (cons (expand-file-name "~/src/emacs/yatex") load-path)) in your ~/.emacs. などとします。 Then edit makefile and set your environment variable `DISPLAY' correctly, exec the next. 続いて makefile を編集し、環境変数 DISPLAY の値を正しくセットしてから % make install でインストールを行ってください。 If `make install' fails, do as follows; もし `make install' でうまく行かない時は下記のように手動でインストール を行ってください。 First, copy `*.el' to suitable directory. 最初に、野鳥の emacs-lisp ファイル群を適当なディレクトリにコピーします。 Then copy `help/YATEXHLP.eng' to $EMACS/etc directory, which is displayed by typin `exec-directory C-j' in the *scratch* buffer (on Emacs19, $exec-directory/../../site-lisp). つぎに、help/YATEXHLP.jp を Emacs の etc ディレクトリに入れます。 (*scratch* バッファで「exec-directory C-j」とうって示されるところです Emacs19以降の場合 doc-directory の ../../site-lisp) Finally, copy `docs/yatexe' and `docs/yahtmle' to Info directory and append the contents of `dir' in this directory to `dir' of Info directory. 最後に、info ディレクトリに docs/yatexj, docs/yatexe, docs/yahtmlj, docs/yahtmle をコピーし、info ディレクトリの dir というファイルにこのディ レクトリの dir ファイルの中身を追加します。 Note that when you byte-compile yatex19.el, do it on window system. This file cannot be compiled on terminal Emacs because it requires hilit19.el, which cannot be loaded on terminal Emacs. But you don't have to byte-compile it. 注意: yatex19.el をバイトコンパイルする時はウィンドウシステム上の emacs で行って下さい。emacs -nw では、hilit19.el がロードできず、正常にコンパ イルできません。うまくいかない場合はバイトコンパイルしなくて構いません。 About yahtml / yahtmlについて ***************************** Yahtml is a different package for writing HTML files with Emacs. It is very far from html-mode, html-helper-mode or other existing HTML modes. It is a good successor of YaTeX in HTML world. Do not want it to behave as modes you used. Yahtml doesn't lessen the number of initial typing not so much. But it lessens your effort of polishing/debugging your source, tracing links between file or URL, and browsing the result with browsers. If you had not used YaTeX, the concept of `C-c g', `C-c k', and `C-c c' are very new to you. If you are interested in the philosophy of YaTeX, please take a look at the info file of YaTeX. yahtml.el は html-mode とか html-helper-mode とかとはじぇえ〜〜んじぇん 違います。「html-helper-mode でいうところのあの機能はないの〜」とかそう いう気持で使うと、すげー調子悪いです。逆に、野鳥のインタフェースを知って 使っているとかなり調子良いです。 Installation of yahtml / yahtmlのインストール ********************************************* Follow the guidance in the beginning of yahtml.el. yahtml.el の先頭部分にある [Installation] にしたがって下さい。 Then the set some variables correctly. Here are the major of them. Parenthesized values are default. 以下の変数を環境に合わせて設定して下さい(括弧内はデフォルト値)。 * yahtml-kanji-code HTML文書のデフォルト漢字コード 1=SJIS, 2=JIS, 3=EUC, 4=UTF-8 * yahtml-image-viewer Image viewer / 画像ヴューア * yahtml-www-browser WWW browser / WWWブラウザ * yahtml-path-url-alist List of unix path name vs. its URL name within the WWW world. See the definition of it (in yahtml.el) as an example. UNIXパス名と、そのWWWでのURL名の対応リス ト。yahtml.el のこの変数の定義を参考にあ なた自身のサイトの対応リストを設定して下 さい。 * yahtml-directory-index Directory index file, which is a file to be opened when URL is ended with directory name. If you're not sure of this, ask it to WWW administrator. Typically `index.html' if your site is running apache, or `Welcome.html' if CERN httpd. URLでファイル名を省略した時にオープンさ れるファイル。WWW管理者に聞いて下さい。 たいてい index.html でしょう。 yatex_1.77+dfsg1/00readme0000444000175000017500000000205211260026713013665 0ustar kurakura・Mercurialリポジトリでも公開しています(1.74以降)。 % hg clone http://www.yatex.org/hgrepos/yatex yatex でコピーし、その後は yatex/ ディレクトリ内で hg pull -u して下さい。 ・yatex-1.69 よりバイトコンパイルしないのをデフォルトとしました。 動作速度が(認識できない程度に)遅くなりますが、インストールしてある全ての Emacsで利用できます。ほんの少し速くなるだけでもいい、Emacsの種類毎に 何回もインストールしてもいい、と思う場合は make elc してから make install を行なって下さい。 ・makefile の先頭部分を編集し、 mule2(emacs-19), emacs20, XEmacs を使う場合は make install それ以外の場合は make install-nw にてLispディレクトリへのインストールが行われます。 詳細は、install ファイルを御覧下さい。 Meadow を使う人は readme.meadow.j も御覧下さい。 ・「野鳥」およびその Vz への移植版である「雷鳥」、Wzへの移植版である「白 鳥」、Hidemaruへの移植版である「飛鳥」、xyzzyへの移植版である「花鳥」 に関する情報交換のためのメイリングリスト「fj野鳥の会」に是非御参加ください。 詳しくは docs/qanda ファイル、または http://www.yatex.org/ を御覧ください。 yatex_1.77+dfsg1/docs/0000755000175000017500000000000012126311540013275 5ustar kurakurayatex_1.77+dfsg1/docs/htmlqa0000444000175000017500000001466212126310642014517 0ustar kurakura%% %% Q and A on yahtml %% %% C-u C-x $ とすると質問項目だけ表示されます。C-x $ で元に戻ります。 %% (新項目: ・font-lockって使えますか?) ■インストール関連 ・LaTeX使わないんだけど野鳥も入れなきゃダメですか? や、別にええっす。 http://www.yatex.org/ のソースアーカイブリンク のなかに、"yahtml" で始まるファイルがあるので次からはそれを持っ て来ればよござんす。 ■カスタマイズ関連 ・font-lockって使えますか? はい。yahtml-1.69から使えます。あらかじめ font-lock をロードしてお きましょう。以前、yahtml が font-lock に対応する前に (put 'yahtml-mode 'font-lock-defaults 'another-html-mode) などを ~/.emacs に書いた人は、その設定を削除して下さい。 ・いつもは EUC にしてたまに JIS コードのファイルを作りたいんだけど。 ~/.emacs で (setq yahtml-kanji-code 3) ;3はEUC しておけば普段のhtmlコードはEUCになります。で局所的に変える方法。 サーバーはApacheですね? ならそのディレクトリに .htaccess という ファイルを用意して、 AddType "text/html; charset=iso-2020-jp" .html という行を書きましょう。するとApache君はそのディレクトリのhtmlファ イルを「iso-2022-jp(いわゆるJIS)だよー」とお客さんにあらかじめ伝 えるようになります。yahtmlもこれに従い、そのディレクトリ以下のファ イルは漢字コードをJISに設定します。 なに、apacheではないとな。なら明示的にhtmlソースのお尻に、 と書いておけばそのファイルだけJISになります。 ただし、Emacs-20 や XEmacs の場合、漢字コードのシンボルの両端の* は付きません。 ・を 認識して漢字コードを設定して欲しいなー。 文書の中にファイルのエンコード法を書いてもそもそもそのMETAなんちゃ らを読めない可能性があるので charset をMETAで指定するのは本当に 期待した通りには機能しません。たとえば、多国語文書を書く必要が出 たとします。すると今のところUTF-7でエンコードするのが一番無難で しょう。NetscapeでもIEでもUTF-7はちゃんと読むことができます。と ういことで、ファイルを開いてブラウザがちゃんとUTF-7と認識するよ うに、HTML文書の先頭に次のように書きました。 このように書いたものが http://www.yatex.org/charset/hello-meta.file にあります。 NetscapeとIEならUTF-7は読めるはずなので、どちらかでアクセスして みましょう。読めますか? 読めませんね。IEの場合はUTF-7の部分を自 動判別するので、一見読めてるように見えますがtext/html とは解釈さ れておらず、結局METAが判別できなかったことが分かります。つまり、 違うエンコード法を利用する場合、 の部分さえもサーバに解 釈不能な状態になり得るので、文書の中にcharset指定を埋め込むのは 賢い方法ではありません。 かわりに、上記で説明した .htaccess を利用しましょう。*.utf7 とい う拡張子を持つファイルは、UTF-7 でエンコードしたHTML文書である、 という定義は、以下のように書けます。 AddType "text/html; charset=utf-7" .utf7 .htaccess ファイルにこのように定義しておけば、無駄ななど綴らなくてもしっかりとサーバがエンコーディングを理 解できます。このようにして書かれた UTF-7 のHTML文書が http://www.yatex.org/charset/hello.utf7 にありますので、同じくNetscapeかIEで読んでみましょう。 AddTypeは~/public_html などに置けばそれ以下の *.utf7 という拡張 子全てに適用できます。一個だけAddTypeを書くだけでいいのです。 HTML屋では、気休め程度にしかならないMETAによるcharset指定を推奨 しない事を選びました。かわりに、もっと確実で簡単な .htaccess に よるエンコーディング指定を推奨するために、そちらをサポートします。 関係ありませんが今(2000年現在)では x-sjisじゃなくて、Shift_JIS と綴ることになってます:-p ・
  • の直後に空白入るとhtmllintに怒られるから空白なしにしたいんだけど… それ、htmllintがやりすぎなんです。タグ直後の空白に対して文句いう のは http://www.cre.canon.co.uk/%7Eneilb/weblint/www5-paper.html によると、空白があることで変なレイアウトになってしまうへぼブラウ ザへの配慮によるものなのでHTML的にはまるで問題ないんです。とかく htmllintを使うとhtmllintに怒られないこと自体が目的となりがちです が、わたしはそれは本末転倒であると思います。 ・の途中で auto-fill されちゃうと悲しい 使っているのがMule2(Emacs-19)以降なら auto-fill-inhibit-regexp という変数でコントロールできます。 yahtml-mode-hook を使って以下 のように設定しましょう。 (add-hook 'yahtml-mode-hook '(lambda () (setq auto-fill-inhibit-regexp "^[ ]*\\( *Uncomment the region/environment [prefix] < If the point is on a line with \begin{} or \end{}, everything within the environment will be (un)commented. Otherwise, everything between the mark and point will be (un)commented. *Comment out a paragraph or environment declaration [prefix] . *Uncomment out a paragraph or environment declaration [prefix] , If the point is on a line with \begin{} or \end, the two lines with it will be (un)commented. Otherwise the paragraph that the point is in will be (un)commented. [ETC] *Align and fill item [prefix] i Available only in an environment. Will do a hanging indent on the \item. *Change LaTeX command [prefix] c On a line with \begin{} or \end{}, will change the name of the environment. On a section-type command, will change the command name, and also change arguments if invoked on the argument. For large-type command, will change font/size definitions. On a math mode command entered using image-type completion, will return to the completion operation. *Kill commands [prefix] k For \begin{}/\end{}, %#BEGIN/%#END, and parenthesis, will delete them in pairs. For section-type commands, font/size definition, will delete the command ant parenthesis surrounding them. *Enclose region with () [prefix] ) *Enclose region with {} [prefix] } *Enclose region with [] [prefix] ] *Enclose region with $$ [prefix] $ *Toggle modes [prefix] w Will toggle between modify mode and math mode. *%# editing [prefix] % *Show columns in tabular/array [prefix] & *Online help [prefix] h *Online apropos [prefix] / *Intelligent return ESC RET Intelligent return can be used in tabular, array, itemize, enumerate, list and description environments. *Browse included structure [prefix] d HIROSE Yuuji yuuji@yatex.org Local variables: mode: text fill-prefix: " " End: yatex_1.77+dfsg1/docs/yatexe0000644000175000017500000023121012126311417014521 0ustar kurakuraInfo file: yatexe, -*-Text-*- produced by `texinfo-format-buffer' from file `yatexe.tex' using `texinfmt.el' version 2.38 of 3 July 1998. START-INFO-DIR-ENTRY * YaTeX-e: (yatexe). Yet Another tex-mode for Emacs (English). END-INFO-DIR-ENTRY  File: yatexe, Node: Top, Next: What is YaTeX?, Prev: (dir), Up: (dir) * Menu: * What is YaTeX?:: * Main features:: What YaTeX can do * Installation:: Guide to install * Typesetting:: Call typesetting processes * %#notation:: Meta-keyword `%#' * Completion:: Input LaTeX commands with completion * Local dictionaries:: Directory dependent completion * Commenting out:: Commenting/uncommenting text * Cursor jump:: Jumping to related position * Changing and Deleting:: Changing/deleting certain unit of text * Filling:: Filling an item or paragraph * Updation of includeonly:: Free from maintaining includeonly * What column:: Check what table-column the cursor belong * Intelligent newline:: Guess requisites of new line * Usepackage checker:: Selecting correct \usepackage is YaTeX's job * Online help:: On-line documentation of LaTeX * Browsing file hierarchy:: Walking through file hierarchy * Cooperation with other packages:: Work well with gmhist, min-out * Customizations:: How to breed `Wild Bird' * Etcetera:: YaTeX is acquisitive. * Copying:: Redistribution  File: yatexe, Node: What is YaTeX?, Next: Main features, Prev: Top, Up: Top What is YaTeX? ************** YaTeX automates typesetting and previewing of LaTeX and enables completing input of LaTeX mark-up command such as `\begin{}'..`\end{}'. YaTeX also supports Demacs which runs on MS-DOS(386), Mule (Multi Language Enhancement to GNU Emacs), and latex on DOS.  File: yatexe, Node: Main features, Next: Installation, Prev: What is YaTeX?, Up: Top Main features ************* * Invocation of typesetter, previewer and related programs(`C-c t') * Typesetting on static region which is independent from point * Semiautomatic replacing of `\includeonly' * Jumping to error line(`C-c '') * Completing-read of LaTeX commands such as `\begin{}', `\section' etc. (`C-c b', `C-c s', `C-c l', `C-c m') * Enclosing text into LaTeX environments or commands (`C-u' ABOVEKEYSTROKES) * Displaying the structure of text at entering sectioning commands * Lump shifting of sectioning commands (*Note view-sectioning::) * Learning unknown/new LaTeX commands for the next completion * Argument reading with a guide for complicated LaTeX commands * Generating argument-readers for new/unsupported commands(`yatexgen') * Quick changing or deleting of LaTeX commands(`C-c c', `C-c k') * Jumping from and to inter-file, begin<->end, ref<->label(`C-c g') * Blanket commenting out or uncommenting (`C-c >', `C-c <', `C-c ,', `C-c .') * Easy input of accent mark, math-mode's commands and Greek letters (`C-c a', `;', `:') * Online help for the popular LaTeX commands (`C-c ?', `C-c /') * Document files hierarchy browser (`C-c d') * Adding automatically \usepackage corresponding to inputting LaTeX macro with completion * Allow you to forget creating \label{}s, \ref{} or \cite{} completion automatically generate labels.  File: yatexe, Node: Installation, Next: Typesetting, Prev: Main features, Up: Top Installation ************ Put next two expressions into your `~/.emacs'. (setq auto-mode-alist (cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist)) (autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t) Next, add certain path name where you put files of YaTeX to your load-path. If you want to put them in `~/src/emacs', write (setq load-path (cons (expand-file-name "~/src/emacs") load-path)) in your `~/.emacs' Then, yatex-mode will be automatically loaded when you visit a file which has extension `.tex'. If yatex-mode is successfully loaded, mode string on mode line will be turned to "YaTeX".  File: yatexe, Node: Typesetting, Next: %#notation, Prev: Installation, Up: Top Typesetting *********** The prefix key stroke of yatex-mode is `C-c' (Press 'C' with Control key) by default. If you don't intend to change the prefix key stroke, assume all `[prefix]' as `C-c' in this document. These key strokes execute typeset or preview command. `[prefix] t j' ... invoke latex `[prefix] t r' ... invoke latex on region `[prefix] t e' ... invoke latex on current environment or whole portion of current formulas in math-mode. `[prefix] t d' ... invoke dvipdfmx after successful typesetting `[prefix] t k' ... kill current typesetting process `[prefix] t b' ... invoke bibtex `[prefix] t i' ... invoke makeindex `[prefix] t d' ... invoke latex && dvipdfmx `[prefix] t p' ... preview `[prefix] t l' ... lpr dvi-file `[prefix] t s' ... search current string on xdvi-remote * Menu: * Calling typesetter:: * Calling previewer:: * Printing out::  File: yatexe, Node: Calling typesetter, Next: Calling previewer, Prev: Typesetting, Up: Typesetting Calling typesetter ================== Typing `[prefix] t j', the current editing window will be divided horizontally when you invoke latex command, and log message of LaTeX typesetting will be displayed in the other window; called typesetting buffer. The typesetting buffer automatically scrolls up and traces LaTeX warnings and error messages. If you see latex stopping by an error, you can send string to latex in the typesetting buffer. If an error stops the LaTeX typesetting, this key stroke will move the cursor to the line where LaTeX error is detected. `[prefix] '' `([prefix]+single quotation)' ... jump to the previous error or warning If you find a noticeable error, move to the typesetting buffer and move the cursor on the line of error message and type `SPACE' key. This makes the cursor move to corresponding source line. YaTeX-typeset-region invoked by `[prefix] tr' call typesetter for region. The region is specified by standard point and mark, or by `%#BEGIN' and `%#END' marks. Selected region will be copied to the temporary file `texput.tex' with the same preamble as the main file of current editing sources. Be sure to put all local macro settings in preamble, not after `\begin{document}'. The method of specification of the region is shown in the section *Note %#notation::. The documentclass for typeset-region is the same as that of editing file if you edit one file, and is the same as main file's if you edit splitting files. The `[prefix] te' key automatically marks current inner environment or inner math mode and then call typeset-region with marked region. This is convenient to quick view of current tabular environment or current editing formulas. Keeping previewer window for `texput.dvi' is handy for debugging. Since `[prefix] te' selects the inner-most environment as region, it is not suitable for partial typesetting of doubly or more composed environment. If you want to do partial typesetting for a nested environment, use `[prefix] tr' for static-region, which is described in the section *Note %#notation::.  File: yatexe, Node: Calling previewer, Next: Printing out, Prev: Calling typesetter, Up: Typesetting Calling previewer ================= `[prefix] t p' invokes the TeX previewer. And if you are using xdvi-remote, which can be controled from other terminals, `[prefix] t s' enables you to search current string at the cursor on the running xdvi window.  File: yatexe, Node: Printing out, Prev: Calling previewer, Up: Typesetting Printing out ============ When you type `[preifx] t l', YaTeX asks you the range of dvi-printing by default. You can skip this by invoking it with universal-argument as follows: C-u [prefix] tl  File: yatexe, Node: %#notation, Next: Completion, Prev: Typesetting, Up: Top %# notation *********** You can control the typesetting process by describing `%#' notations in the source text. * Menu: * Changing typesetter:: * Splitting input files:: * Static region for typesetting:: * Lpr format:: * Controlling which command to invoke:: * Editing %# notation::  File: yatexe, Node: Changing typesetter, Next: Splitting input files, Prev: %#notation, Up: %#notation To change the `latex' command or to split a source text. ======================================================== To change the typesetting command, write %#!latex-big anywhere in the source text. This is useful for changing typesetter.  File: yatexe, Node: Splitting input files, Next: Static region for typesetting, Prev: Changing typesetter, Up: %#notation Splitting input files ===================== And if you split the source text and edit subfile that should be included from main text. %#!latex main.tex will be helpful to execute latex on main file from sub text buffer. Since this command line after `%#!' will be sent to shell literally, next description makes it convenient to use ghostview as dvi-previewer. %#!latex main && dvi2ps main.dvi > main Note that YaTeX assumes the component before the last period of the last word in this line as base name of the main LaTeX source. The `%f' notation in this line is replaced by main file name, and `%r' replaced by root name of main file name. If you specify `%f' or `%r', YaTeX always ask you the name of main file at the first typesetting. To make best use of the feature of inter-file jumping by `[prefix] g' (see *Note Cursor jump::), take described below into consideration. * You can put split texts in sub directory, but not in sub directory of sub directory. * In the main text, specify the child file name with relative path name such as \include{chap1/sub}, when you include the file in a sub-directory. * In a sub-text, write `%#!latex main.tex' even if `main.tex' is in the parent directory(not %#!latex ../main.tex).  File: yatexe, Node: Static region for typesetting, Next: Lpr format, Prev: Splitting input files, Up: %#notation Static region ============= Typeset-region by `[prefix] tr' passes the region between point and mark to typesetting command by default. But when you want to typeset static region, enclose the region by `%#BEGIN' and `%#END' as follows. %#BEGIN TheRegionYouWantToTypesetManyTimes %#END This is the rule of deciding the region. 1. If there exists %#BEGIN before point, 1. If there exists %#END after %#BEGIN, * From %#BEGIN to %#END. 2. If %#END does not exist after %#BEGIN, * From %#BEGIN to the end of buffer. 2. If there does not exist %#BEGIN before point, * Between point and mark(standard method of Emacs). It is useful to write `%#BEGIN' in the previous line of \begin and `%#END' in the next line of \`end' when you try complex environment such as `tabular' many times. It is also useful to put only `%#BEGIN' alone at the middle of very long text. Do not forget to erase `%#BEGIN' `%#END' pair.  File: yatexe, Node: Lpr format, Next: Controlling which command to invoke, Prev: Static region for typesetting, Up: %#notation Lpr format ========== Lpr format is specified by three Lisp variables. Here are the default values of them. `(1)dviprint-command-format' `"dvi2ps %f %t %s | lpr"' `(2)dviprint-from-format' `"-f %b"' `(3)dviprint-to-format' `"-t %e"' On YaTeX-lpr, `%s' in (1) is replaced by the file name of main text, `%f' by contents of (2), %t by contents of (3). At these replacements, `%b' in (2) is also replaced by the number of beginning page, `%e' in (3) is replaced by the number of ending page. But `%f' and `%t' are ignored when you omit the range of print-out by `C-u [prefix] tl'. If you want to change this lpr format temporarily, put a command such as follows somewhere in the text: %#LPR dvi2ps %f %t %s | 4up -page 4 | texfix | lpr -Plp2 And if you want YaTeX not to ask you the range of printing out, the next example may be helpful. %#LPR dvi2ps %s | lpr  File: yatexe, Node: Controlling which command to invoke, Next: Editing %# notation, Prev: Lpr format, Up: %#notation Controlling which command to invoke =================================== These %# notation below can control which command to invoke for LaTeX related process. `%#BIBTEX' ... Command line for makeindex ([prefix] t i) `%#MAKEINDEX' ... Command line for bibtex ([prefix] t b) If you want to invoke "makeidx hogehoge" to update index, put the next line some upper place in the source, for example. %#MAKEINDEX makeidx hogehoge  File: yatexe, Node: Editing %# notation, Prev: Controlling which command to invoke, Up: %#notation Editing %# notation =================== To edit `%#' notation described above, type `[prefix] %' ... editing %# notation menu and select one of the entry of the menu as follows. !)Edit-%#! B)EGIN-END-region L)Edit-%#LPR Type `!' to edit `%#!' entry, `b' to enclose the region with `%#BEGIN' and `%#END', and `l' to edit `%#LPR' entry. When you type `b', all `%#BEGIN' and `%#END' are automatically erased.  File: yatexe, Node: Completion, Next: Local dictionaries, Prev: %#notation, Up: Top Completion ********** YaTeX makes it easy to input the LaTeX commands. There are several kinds of completion type, begin-type, section-type, large-type, etc... * Menu: * Begin-type completion:: * Section-type completion:: * Large-type completion:: * Maketitle-type completion:: * Arbitrary completion:: * End completion:: * Accent completion:: * Image completion:: * Greek letters completion::  File: yatexe, Node: Begin-type completion, Next: Section-type completion, Prev: Completion, Up: Completion Begin-type completion ===================== "Begin-type completion" completes commands of `\begin{env}' ... `\end{env}'. All of the begin-type completions begin with this key sequence. `[prefix] b' ... start begin-type completion An additional key stroke immediately completes a frequently used LaTeX `\begin{}'...`\`end'{}' environment. `[prefix] b c' ... `\begin{center}...\end{center}' `[prefix] b d' ... `\begin{document}...\end{document}' `[prefix] b D' ... `\begin{description}...\end{description}' `[prefix] b e' ... `\begin{enumerate}...\end{enumerate}' `[prefix] b E' ... `\begin{equation}...\end{equation}' `[prefix] b i' ... `\begin{itemize}...\end{itemize}' `[prefix] b l' ... `\begin{flushleft}...\end{flushleft}' `[prefix] b m' ... `\begin{minipage}...\end{minipage}' `[prefix] b t' ... `\begin{tabbing}...\end{tabbing}' `[prefix] b T' ... `\begin{tabular}...\end{tabular}' `[prefix] b^T' ... `\begin{table}...\end{table}' `[prefix] b p' ... `\begin{picture}...\end{picture}' `[prefix] b q' ... `\begin{quote}...\end{quote}' `[prefix] b Q' ... `\begin{quotation}...\end{quotation}' `[prefix] b r' ... `\begin{flushright}...\end{flushright}' `[prefix] b v' ... `\begin{verbatim}...\end{verbatim}' `[prefix] b V' ... `\begin{verse}...\end{verse}' Any other LaTeX environments are made by completing-read of the Emacs function. `[prefix] b SPACE' ... begin-type completion The next message will show up in the minibuffer Begin environment(default document): by typing `[prefix] b'. Put the wishing environment with completion in the minibuffer, and `\begin{env}'...\`\end{env}' will be inserted in the LaTeX source text. If the environment you want to put does not exist in the YaTeX completion table, it will be registered in the user completion table. YaTeX automatically saves the user completion table in the user dictionary file at exiting of emacs. At the completion of certain environments, the expected initial entry will automatically inserted such as `\item' for `itemize' environment. If you don't want the entry, it can be removed by undoing. If you want to enclose some paragraphs which have already been written, invoke the begin-type completion with changing the case of `b' of key sequence upper(or invoke it with universal argument by `C-u' prefix). The following example encloses a region with `description' environment. `[prefix] B D' `(or ESC 1 [prefix] b D)' `(or C-u [prefix] b D)' ... begin-type completion for region This enclosing holds good for the completing input by `[prefix] b SPC'. `[prefix] B SPC' enclose a region with the environment selected by completing-read.  File: yatexe, Node: Section-type completion, Next: Large-type completion, Prev: Begin-type completion, Up: Completion Section-type completion ======================= "Section-type completion" completes section-type commands which take an argument or more such as `\section{foo}'. To invoke section-type completion, type `[prefix] s' ... section-type completion then the prompt (C-v for view) \???{} (default documentclass): will show up in the minibuffer. Section-type LaTeX commands are completed by space key, and the default value is selected when you type nothing in the minibuffer. Next, \section{???}: prompts you the argument of section-type LaTeX command. For example, the following inputs \???{} (default documentclass): section \section{???}: Hello world. will insert the string \section{Hello world.} in your LaTeX source. When you neglect argument such as (C-v for view) \???{} (default section): vspace* \vspace*{???}: YaTeX puts \vspace*{} and move the cursor in the braces. In LaTeX command, there are commands which take more than one arguments such as `\addtolength{\topmargin}{8mm}'. To complete these commands, invoke section-type completion with universal argument as, C-u 2 [prefix] s (or ESC 2 [prefix] s) and make answers in minibuffer like this. (C-v for view) \???{} (default vspace*): addtolength \addtolength{???}: \topmargin Argument 2: 8mm `\addtolength' and the first argument `\topmargin' can be typed easily by completing read. Since YaTeX also learns the number of arguments of section-type command and will ask that many arguments in future completion, you had better tell the number of arguments to YaTeX at the first completion of the new word. But you can change the number of arguments by calling the completion with different universal argument again. Invoking section-type completion with `[Prefix] S' (Capital `S') includes the region as the first argument of section-type command. The section/large/maketitle type completion can work at the prompt for the argument of other section-type completion. Nested LaTeX commands are efficiently read with the recursive completion by typing YaTeX's completion key sequence in the minibuffer. * Menu: * view-sectioning::  File: yatexe, Node: view-sectioning, Prev: Section-type completion, Up: Section-type completion view-sectioning --------------- In the minibuffer at the prompt of section-type command completion, typing `C-v' shows a list of sectioning commands in source text(The line with `<<--' mark is the nearest sectioning command). Then, default sectioning command appears in the minibuffer. You can go up/down sectioning command by typing `C-p'/`C-n', can scrolls up/down the listing buffer by `C-v'/`M-v', and can hide sectioning commands under certain level by 0 through 6. Type `?' in the minibuffer of sectioning prompt for more information. You can generate this listing buffer (`*Sectioning Lines*' buffer) by typing `M-x YaTeX-section-overview' ... Generate *Sectioning Lines* buffer from the LaTeX source buffer. In this listing buffer, typing `u' on the sectioning command shifts up the corresponding sectioning command in source text and `d' shifts down. After marking lines in the listing buffer, typing `U' shifts up all sectioning commands in the region, and `U' shifts down. Here are all the key bindings of `*Sectioning Lines*' buffer. `SPC' ... Jump to corresponding source line `.' ... Display corresponding source line `u' ... Shift up a sectioning line `d' ... Shift down a sectioning line `U' ... Shift up sectioning lines in region `D' ... Shift down sectioning lines in region `0...6' ... Hide sectioning commands whose level is lower than n  File: yatexe, Node: Large-type completion, Next: Maketitle-type completion, Prev: Section-type completion, Up: Completion Large-type completion ===================== "Large-type completion" inputs the font or size changing descriptions such as `{\large }'. When you type `[prefix] l' ... large-type completion the message in the minibuffer {\??? } (default large): prompts prompts you large-type command with completing-read. There are TeX commands to change fonts or sizes, `it', `huge' and so on, in the completion table. Region-based completion is also invoked by changing the letter after prefix key stroke as `[prefix] L'. It encloses the region by braces with large-type command.  File: yatexe, Node: Maketitle-type completion, Next: Arbitrary completion, Prev: Large-type completion, Up: Completion Maketitle-type completion ========================= We call it "maketitle-type completion" which completes commands such as `\maketitle'. Take notice that maketitle-type commands take no arguments. Then, typing `[prefix] m' ... maketitle-type completion begins maketitle-completion. Above mentioned method is true for maketitle-completion, and there are LaTeX commands with no arguments in completion table.  File: yatexe, Node: Arbitrary completion, Next: End completion, Prev: Maketitle-type completion, Up: Completion Arbitrary completion ==================== You can complete certain LaTeX command anywhere without typical completing method as described, by typing `[prefix] SPC' ... arbitrary completion after the initial string of LaTeX command that is preceded by `\'.  File: yatexe, Node: End completion, Next: Accent completion, Prev: Arbitrary completion, Up: Completion End completion ============== YaTeX automatically detects the opened environment and close it with \`\end{environment}'. Though proficient YaTeX users never fail to make environment with begin-type completion, some may begin an environment manually. In that case, type `[prefix] e' ... `end' completion at the end of the opened environment.  File: yatexe, Node: Accent completion, Next: Image completion, Prev: End completion, Up: Completion Accent completion ================= When you want to write the European accent marks(like `\`{o}'), `[prefix] a' ... accent completion shows the menu 1:` 2:' 3:^ 4:" 5:~ 6:= 7:. u v H t c d b in the minibuffer. Chose one character or corresponding numeric, and you will see \`{} in the editing buffer with the cursor positioned in braces. Type one more character `o' for example, then \`{o} will be completed, and the cursor gets out from braces.  File: yatexe, Node: Image completion, Next: Greek letters completion, Prev: Accent completion, Up: Completion Image completion of mathematical sign ===================================== Arrow marks, sigma mark and those signs mainly used in the TeX's math environment are completed by key sequences which imitate the corresponding symbols graphically. This completion only works in the math environment. YaTeX automatically detects whether the cursor located in math environment or not, and change the behavior of key strokes `;' and `:'. By the way, we often express the leftarrow mark by `<-' for example. Considering such image, you can write `\leftarrow' by typing `<-' after `;' (semicolon) as a prefix. In the same way, `\longleftarrow' (`<--') is completed by typing `;<--', infinity mark which is imitated by `oo' is completed by typing `;oo'. Here are the sample operations in YaTeX math-mode. INPUT Completed LaTeX commands ; < - `\leftarrow' ; < - - `\longleftarrow' ; < - - > `\longleftrightarrow' ; o `\circ' ; o o `\infty' In any case, you can quit from image completion and can move to the next editing operation if the LaTeX command you want is shown in the buffer. `;' itself in math-environment is inserted by `;;'. Typing `TAB' in the midst of image completion shows all of the LaTeX commands that start with the same name as string you previously typed in. In this menu buffer, press `RET' after moving the cursor (by `n', `p', `b', `f') to insert the LaTeX command. To know all of the completion table, type `TAB' just after `;'. And here is the sample menu by `TAB' after `;<'. KEY LaTeX sequence sign < \leq < ~ << \ll << <- \leftarrow <- <= \Leftarrow <= You can define your favorite key-vs-sequence completion table in the Emacs-Lisp variable `YaTeX-math-sign-alist-private'. See also `yatexmth.el' for the information of the structure of this variable.  File: yatexe, Node: Greek letters completion, Prev: Image completion, Up: Completion Greek letters completion ======================== Math-mode of YaTeX provides another image completion, Greek letters completion in the same method. After prefix `:', typing `a' makes `\alpha', `b' makes `\beta' and `g' makes `\gamma' and so on. First, type `:TAB' to know all the correspondence of alphabets vs. Greek letters. If you will find `;' or `:' doesn't work in correct position of math environment, it may be a bug of YaTeX. Please send me a bug report with the configuration of your text, and avoid it temporarily by typing `;' or `:' after universal-argument(`C-u') which forces `;' and `:' to work as math-prefix.  File: yatexe, Node: Local dictionaries, Next: Commenting out, Prev: Completion, Up: Top Local dictionaries ****************** Tables for completion consist of three dictionaries; `standard dictionary' built in `yatex.el', `user dictionary' for your common private commands, and `local dictionary' that is effective in a certain directory. When you input the command unknown to YaTeX at a completion in the minibuffer, YaTeX asks you with the following prompt; `foo' is not in table. Register into: U)serDic L)ocalDic N)one D)iscard In this menu, typing `u' updates your `user dictionary', `l' updates your local dictionary, `n' updates only on-memory dictionary which go through only current Emacs session, and `d' updates no dictionary and throws the new word away. If you find this switching feature meaningless and bothersome, put the next expression into your `~/.emacs' (setq YaTeX-nervous nil)  File: yatexe, Node: Commenting out, Next: Cursor jump, Prev: Local dictionaries, Up: Top Commenting out ************** You may want to comment out some region. `[prefix] >' ... comment out region by % `[prefix] <' ... uncomment region cause an operation to the region between point and mark. `[prefix] .' ... comment out current paragraph `[prefix] ,' ... uncomment current paragraph comments or uncomments the paragraph where the cursor belongs. This `paragraph' means the region marked by the function mark-paragraph, bound to `ESC h' by default. It is NOT predictable what will happen when you continuously comment out some paragraph many times. You can also comment out an environment between `\begin' and `\end', or a `\begin'-\`\end' pair themselves, by making the following key strokes on the line where `\begin{}' or `\end{}' exists. `[prefix] >' ... comment out from \begin to \`end' `[prefix] <' ... uncomment from \begin to \`end' comment whole the contents of environment. Moreover, `[prefix] .' ... comment out \begin and \`end' `[prefix] ,' ... uncomment \begin and \`end' (un)comments out only environment declaration: `\begin{}' and `\end{}'. NOTE that even if you intend to comment out some region, invoking `[prefix] >' on the `\begin',`\end' line decides to work in `commenting out from `\begin' to `\end'' mode.  File: yatexe, Node: Cursor jump, Next: Changing and Deleting, Prev: Commenting out, Up: Top Cursor jump *********** * Menu: * Jump to corresponding object:: * Invoking image processor:: * Jump to main file:: * Jumping around the environment:: * Jumping to last completion position::  File: yatexe, Node: Jump to corresponding object, Next: Invoking image processor, Prev: Cursor jump, Up: Cursor jump Jump to corresponding object ============================ Typing `[prefix] g' ... go to corresponding object in a certain place move the cursor to the place corresponding to the LaTeX command of last place. YaTeX recognize the followings as pairs that have relation each other. * `\begin{}' <-> `\end{}' * `%#BEGIN' <-> `%#END' * On the image-including line -> corresponding viewer or drawing tool * `\label{}' <-> `\ref{}' * `\include(\input)' -> included file * `\bibitem{}' <-> `\cite{}' On a `\begin',`\end' line, typing `[prefix] g' moves the cursor to the corresponding `\end',`\begin' line, if its partner really exists. The behavior on the line `%#BEGIN' and `%#END' are the same. Note that if the correspondent of `label/ref' or `cite/bibitem' exists in another file, that file have to be opened to make a round trip between references by `[prefix] g'. If you type `[prefix] g' on the line of `\include{chap1}', typically in the main text, YaTeX switches buffer to `chap1.tex'. `[prefix] 4 g' ... go to corresponding object in other window do the same job as `[prefix] g' except it's done in other window. Note that this function doesn't work on `begin/end', `%#BEGIN/%#END' pairs because it is meaningless.  File: yatexe, Node: Invoking image processor, Next: Jump to main file, Prev: Jump to corresponding object, Up: Cursor jump Invoking image processor ======================== `image-including line' described above means such lines as `\epsfile{file=foo.ps}'. If you type `[prefix] g' on that line, YaTeX automatically searches source of `foo.ps' and invokes image viewer or drawing tool correspoinding to it. For example; if you draw an image foo.obj with Tgif and enclose its product named foo.eps by `\epsfile' command. Typing `[prefix] g' on `\epsfile' line make YaTeX invoke `tgif foo.obj'. How a processor is choosen is as follows. 1. If there is an expression matching with one of the pattern defined in `YaTeX-processed-file-regexp-alist', extract file name from regexp group surrounded by \\(\\). (Which group corresponds is written in the cdr part of each list.) If no matches were found, do nothing. 2. If there is a pattern as `%PROCESSOR' which is defined in the variable `YaTeX-file-processor-alist', call that processor giving the file name with corresponding extension. 3. If not, check the existence of each file which is supplied the extension in the cdr part of each list of `YaTeX-file-processor-alist'. If any, call the corresponding image viewer or drawing tool.  File: yatexe, Node: Jump to main file, Next: Jumping around the environment, Prev: Invoking image processor, Up: Cursor jump Jump to main file ================= Typing `[prefix] ^' ... visit main file `[prefix] 4^' ... visit main file in other buffer in a sub text switch the buffer to the main text specified by `%#!' notation.  File: yatexe, Node: Jumping around the environment, Next: Jumping to last completion position, Prev: Jump to main file, Up: Cursor jump Jumping around the environment ============================== And these are the functions which work on the current LaTeX environment: `M-C-a' ... beginning of environment `M-C-e' ... `end' of environment `M-C-@' ... mark environment  File: yatexe, Node: Jumping to last completion position, Prev: Jumping around the environment, Up: Cursor jump Jumping to last completion position =================================== YaTeX always memorize the position of completion into register `3'. So every time you make a trip to any other part of text other than you are writing, you can return to the editing paragraph by calling register-to-point with argument YaTeX-current-position-register, which is achieved by typing `C-x j 3'(by default).  File: yatexe, Node: Changing and Deleting, Next: Filling, Prev: Cursor jump, Up: Top Changing and Deleting ********************* These functions are for change or deletion of LaTeX commands already entered. `[prefix] c' ... change LaTeX command `[prefix] k' ... kill LaTeX command * Menu: * Changing LaTeX commands:: * Killing LaTeX commands::  File: yatexe, Node: Changing LaTeX commands, Next: Killing LaTeX commands, Prev: Changing and Deleting, Up: Changing and Deleting Changing LaTeX commands ======================= `[prefix] c' can change the various (La)TeX commands. This can change the followings. * Environment names * Section-type commands * Argument of section-type commands * Optional parameters (enclosed by []) of section-type commands * Font/size designators * Math-mode's maketitle-type commands that can be inputted with image completion Typing `[prefix] c' on one of above objects you want to change brings a suitable reading function sometimes with completion. Note: If you want to change the argument of section-type command that contains other LaTeX commands, type `[prefix] c' either of surrounding braces of the argument in order to make YaTeX ignore the internal LaTeX sequences as an object of changing. Anyway, it is very difficult to know which argument position the cursor belongs because the LaTeX commands can be nested and braces can freely emerge. So keep it mind to put the cursor on a brace when you are thinking of changing a complicated argument.  File: yatexe, Node: Killing LaTeX commands, Prev: Changing LaTeX commands, Up: Changing and Deleting Killing LaTeX commands ====================== `[prefix] k' kills the LaTeX commands sometimes with their arguments. Following table illustrates the correspondence of the invoking position and what is killed. [Invoking position] [action] \begin, \end line kill \begin,\end pairs %#BEGIN, %#END line kill %#BEGIN,%#END pairs on a Section-type command kill section-type command on a parenthesis kill parentheses Note that when killing `\begin, \end' or `%#BEGIN, %#END' pair, the lines `\begin, \end' or `%#BEGIN, %#END' exist will be killed entirely. So take care not to create any line that contains more than one `\begin' or so. While all operations above are to kill `containers' which surround some text, universal argument (`C-u') for these commands kills not only `containers' but also `contents' of them. See below as a sample. Original text: [prefix] k C-u [prefix] k Main \footnote{note} here. Main note here. Main here. ~(cursor)  File: yatexe, Node: Filling, Next: Updation of includeonly, Prev: Changing and Deleting, Up: Top Filling ******* Filling an item =============== To fill a term (descriptive sentences) of `\item', type `M-q' ... fill item on that item. YaTeX uses the value of the variable `YaTeX-item-regexp' as the regular expression to search item header in itemize environment. If you make a newcommand to itemize terms(e.g. `\underlineitem'), put (setq YaTeX-item-regexp "\\(\\\\\\(sub\\)*item\\)\\|\\(\\\\underlineitem\\)") in your `~/.emacs'. If you are not familiar with regular expression for Emacs-Lisp, name a newcommand for `itemize' beginning with `\item' such as `\itembf', not `\bfitem'. This function reformats the `\item' into `hang-indented' style. For example: itemize, enumerate environment: > >\item[foo] `foo' is the typical word for describing an > arbitrarily written.... description environment: > \item[bar] When the word `for' is used as an arbitrarily > word, `bar' is bound to follow it. Note that the indent depth of an `\item' word and its descriptive paragraph are the same in latter case. If you want to use different depth, invoke fill-paragraph at the beginning of non-whitespace character(see below). Filling paragraph ================= Fill-paragraph is little bit adapted for LaTeX sources. It retains from filling in certain environments where formatting leads to a disaster such as verbatim, tabular, or so. And it protects `\verb' expressions from being folded (The variable `YaTeX-verb-regexp' controls this). Besides, putting cursor on the first occurrence of non-whitespace character on a line changes the fill-prefix temporarily to the depth of the line.  File: yatexe, Node: Updation of includeonly, Next: What column, Prev: Filling, Up: Top Updation of `\includeonly' ************************** When you edit splitting source texts, the notation \includeonly{CurrentEditingFileName} in the main file reduces the time of typesetting. If you want to hack other file a little however, you have to rewrite it to \includeonly{OtherFileNameYouWantToFix} in the main file. YaTeX automatically detects that the current edited text is not in includeonly list and prompts you A)dd R)eplace %)comment? in the minibuffer. Type `a' if you want to add the current file name to `\includeonly' list, `r' to replace \`includeonly' list with the current file, and type `%' to comment out the `\includeonly' line.  File: yatexe, Node: What column, Next: Intelligent newline, Prev: Updation of includeonly, Up: Top What column? ************ We are often get tired of finding the corresponding column in large tabulars. For example, \begin{tabular}{|c|c|c|c|c|c|c|c|}\hline Name&Position&Post No.&Addr.&Phone No.&FAX No.& Home Addr.&Home Phone\\ \hline Thunder Bird & 6 & 223 & LA & xxx-yyy & zzz-www & Japan & 9876-54321 \\ & 2 & \multicolumn{2}{c|}{Unknown} &&&(???) \\ \hline \end{tabular} Suppose you have the cursor located at `(???)' mark, can you tell which column it is belonging at once? Maybe no. In such case, type `[prefix] &' ... What column in that position. YaTeX tells you the column header of the current field. Since YaTeX assumes the first line of tabular environment as a row of column headers, you can create a row of virtual column headers by putting them in the first line and commenting that line with `%'.  File: yatexe, Node: Intelligent newline, Next: Usepackage checker, Prev: What column, Up: Top Intelligent newline ******************* At the end of begin-type completion of tabular[*], array, itemize, enumerate or tabbing environment, or typing `ESC RET' ... Intelligent newline in these environments inserts the contents corresponding to the current environment in the next line. (At the begin-type completion, this contents can be removed by `undo'.) In `tabular' environment, for example, `ESC RET' inserts the certain number of `&' and trailing `\\', and `\hline' if other `\hline' is found in backward. Here are the list of contents vs. environments. * `tabular', `tabular*', `array' Corresponding number of `&' and `\\'. And `\hline' if needed. * `tabbing' The same number of `\>' as `\=' in the first line. * `itemize', `enumerate', `description', `list' `\item' or `item[]'. Note that since this function works seeing the contents of the first line, please call this after the second line if possible. If you want to apply these trick to other environments, `foo' environment for example, define the function named `YaTeX-intelligent-newline-foo' to insert corresponding contents. That function will be called at the beginning of the next line after the newline is inserted to the current line. Since the function `YaTeX-indent-line' is designed to indent the current line properly, calling this function before your code to insert certain contents must be useful. See the definition of the function `YaTeX-intelligent-newline-itemize' as an example.  File: yatexe, Node: Usepackage checker, Next: Online help, Prev: Intelligent newline, Up: Top Usepackage checker ****************** When you input begint-type, section-type, maketitle-type macros with completion, and it requires some LaTeX2e package, YaTeX examines the existence of correct `\usepackage'. If not, YaTeX inserts the `\usepackage{}' declaration corresponding to input macro. To activate the package completion for your favarite package, set the variable `YaTeX-package-alist-private' correctly. Please refere the value of `YaTeX-package-alist-default' as an example.  File: yatexe, Node: Online help, Next: Browsing file hierarchy, Prev: Usepackage checker, Up: Top Online help *********** YaTeX provides you the online help with popular LaTeX commands. Here are the key strokes for the online help. `[prefix] ?' ... Online help `[prefix] /' ... Online apropos Online help =========== `Online help' shows the documentation for the popular LaTeX commands(defaults to the commands on the cursor) in the next buffer. There are two help file, `global help' and `private help'. The former file contains the descriptions on the standard LaTeX command and is specified its name by variable `YaTeX-help-file'. Usually, the global help file should be located in public space (`$EMACSEXECPATH' by default) and should be world writable so that anyone can update it to enrich its contents. The latter file contains descriptions on non-standard or personal command definitions and is specified by `YaTeX-help-file-private'. This file should be put into private directory. Online apropos ============== `Online apropos' is an equivalent of GNU Emacs's apropos. It shows all the documentations that contains the keyword entered by the user. When no descriptions are found... ================================= If there is no description on a command in help files, YaTeX requires you to write a description on that command. If you are willing to do, determine which help file to add and write the description on it referring your manual of (La)TeX. Please send me your additional descriptions if you describe the help on some standard commands. I might want to include it in the next distribution.  File: yatexe, Node: Browsing file hierarchy, Next: Cooperation with other packages, Prev: Online help, Up: Top Browsing file hierarchy *********************** When you are editing multi-file source, typing `[prefix] d' ... browse file hierarchy asks you the parent-most file (which may be defaulted) and displays the documentation hierarchy in the next window. In this buffer, the following commands are available. `n' ... move to the next line and show its contents `p' ... move to the previous line and show its contents `N' ... move to the next file in the same inclusion level `P' ... move to the previous file in the same inclusion level `j' ... move to the next line `k' ... move to the previous line `u' ... move to the parent file `.' ... show the current files contents in the next window `SPC' ... scroll up the current file window `DEL, b' ... scroll down the current file window `<' ... show the beginning of the current file `>' ... show the end of the current file `>' ... return to the previous postion after `<' or `>' `RET, g' ... open the current file in the next window `mouse-2' ... same as RET(available only with window system) `o' ... other window `1' ... delete other windows `-' ... shrink hierarchy buffer window `+' ... enlarge hierarchy buffer window `?' ... describe mode `q' ... quit Note that operations on the file contents in the next window do not work correctly when you close the corresponding file.  File: yatexe, Node: Cooperation with other packages, Next: Customizations, Prev: Browsing file hierarchy, Up: Top Cooperation with other packages ******************************* YaTeX works better with other brilliant packages. gmhist ====== When you are loading `gmhist.el' and `gmhist-mh.el', you can use independent command history list at the prompt of preview command (`[prefix] tp') and print command (`[prefix] tl'). On each prompt, you can enter the previous command line string repeatedly by typing `M-p'. min-out ======= `min-out', the outline minor mode, can be used in yatex-mode buffers. If you want to use it with YaTeX, please refer the file `yatexm-o.el' as an example.  File: yatexe, Node: Customizations, Next: Etcetera, Prev: Cooperation with other packages, Up: Top Customizations ************** You can customize YaTeX by setting Emacs-Lisp variables and by making add-in functions. * Menu: * Lisp variables:: * Add-in functions:: * Add-in generator::  File: yatexe, Node: Lisp variables, Next: Add-in functions, Prev: Customizations, Up: Customizations Lisp variables ============== You can change the key assignments or make completion more comfortable by setting the values of various variables which control the movement of yatex-mode. For example, if you want to change the prefix key stroke from `C-c' to any other sequence, set YaTeX-prefix to whatever you want to use. If you don't want to use the key sequence `C-c letter' which is assumed to be the user reserved sequence in Emacs world, set `YaTeX-inhibit-prefix-letter' to `t', and all of the default key bind of `C-c letter' will turn to the corresponding `C-c C-letter' (but the region based completions that is invoked with `C-c Capital-letter' remain valid, if you want to disable those bindings, set that variable to 1 instead of `t'). * Menu: * All customizable variables:: * Sample definitions:: * Hook variables:: * Hook file::  File: yatexe, Node: All customizable variables, Next: Sample definitions, Prev: Lisp variables, Up: Lisp variables All customizable variables -------------------------- Here are the customizable variables of yatex-mode. Each value setq-ed in `~/.emacs' is preferred and that of defined in `yatex.el' is neglected. Parenthesized contents stands for the default value. When you are to change some of these variables, see more detailed documentation of the variable by `M-x describe-variable'. -- Variable: YaTeX-japan Set this nil to produce all messages in English (`Depends on Japanese feature of Emacs') -- Variable: YaTeX-kanji-code Default buffer-file-coding-system for YaTeX modes' buffer. Set this 0 to no language conversion. Nil to preserve original coding-system. 1=Shift JIS, 2=JIS, 3=EUC, 4=UTF-8 (`1 or 2') -- Variable: YaTeX-prefix Prefix key stroke (`C-c') -- Variable: YaTeX-inhibit-prefix-letter Change key stroke from `C-c letter' to `C-c C-letter' (`nil') -- Variable: YaTeX-fill-prefix Fill-prefix used in yatex-mode (`nil') -- Variable: YaTeX-user-completion-table Name of user dictionary where learned completion table will be stored. (`"~/.yatexrc"') -- Variable: tex-command LaTeX typesetter command (`"latex"') -- Variable: dvi2-command Preview command (`"xdvi -geo +0+0 -s 4"') -- Variable: dviprint-command-format Command format to print dvi file (`"dvi2ps %f %t %s | lpr"') -- Variable: dviprint-from-format Start page format of above %f. %b will turn to start page (`"-f %b"') -- Variable: dviprint-to-format End page format of above %t. %e will turn to `end' page (`"-t %e"') -- Variable: makeindex-command Default makeindex command (`"makeindex"' (`"makeind"' on MS-DOS)) -- Variable: YaTeX-dvipdf-command Default command name to convert .dvi to PDF (`"dvipdfmx"') -- Variable: YaTeX-need-nonstop Put `\nonstopmode{}' or not (`nil') -- Variable: latex-warning-regexp Regular expression of warning message latex command puts out (`"line.* [0-9]*"') -- Variable: latex-error-regexp Regular expression of error message (`"l\\.[1-9][0-9]*"') -- Variable: latex-dos-emergency-message Message latex command running on DOS puts at abort (`"Emergency stop"') -- Variable: YaTeX-item-regexp Regular expression of item command (`"\\\\item"') -- Variable: YaTeX-verb-regexp Regexp of verb family. Omit \\\\. (`"verb\\*?\\|path"') -- Variable: YaTeX-nervous T for using local dictionary (`t') -- Variable: YaTeX-sectioning-regexp Regexp of LaTeX sectioning command (`"\\(part\\|chapter\\*?\\|\\(sub\\)*\\(section\\|paragraph\\)\\*?\\)\\b"') -- Variable: YaTeX-fill-inhibit-environments Inhibit fill in these environments (`'("tabular" "tabular*" "array" "picture" "eqnarray" "eqnarray*" "equation" "math" "displaymath" "verbatim" "verbatim*")') -- Variable: YaTeX-uncomment-once T for deleting all preceding `%' (`nil') -- Variable: YaTeX-close-paren-always T for always close all parenthesis automatically, `nil' for only eol (`t') -- Variable: YaTeX-auto-math-mode Switch math-mode automatically (`t') -- Variable: YaTeX-math-key-list-private User defined alist, math-mode-prefix vs completion alist used in image completion (`nil'). See `yatexmth.el' for the information about how to define a completion alist. -- Variable: YaTeX-default-pop-window-height Initial height of typesetting buffer when one-window. Number for the lines of the buffer, numerical string for the percentage of the screen-height. `nil' for half height (10) -- Variable: YaTeX-help-file Global online help file name (`$doc-directory/../../site-lisp/YATEXHLP.eng') -- Variable: YaTeX-help-file-private Private online help file name (`"~/YATEXHLP.eng"') -- Variable: YaTeX-no-begend-shortcut Disable [prefix] b ?? shortcut (`nil)' -- Variable: YaTeX-hilit-pattern-adjustment-private List of the list that contain the regular expression and the symbol of logical meaning of the string that matches the pattern. See also the value from `(assq 'yatex-mode hilit-patterns-alist)' and the value of `YaTeX-hilit-pattern-adjustment-default' (and even the document of hilit19.el). -- Variable: YaTeX-sectioning-level Alist of LaTeX's sectioning command vs its height. -- Variable: YaTeX-hierarchy-ignore-heading-regexp `YaTeX-display-hierarchy' searches for sectioning command first, and comment line secondary as a file headings. In latter case, ignore lines that match with regular expression of this variable. Default value of this variable is RCS header expressions and mode specifying line `-*- xxxx -*'. -- Variable: YaTeX-skip-default-reader Non-nil for this variable skips the default argument reader of section-type command when add-in function for it is not defined (`nil') -- Variable: YaTeX-create-file-prefix-g When typing `prefix g' on the `\include' line, open the target file even if the file doesn't exist (`nil') -- Variable: YaTeX-simple-messages Simplyfy messages of various completions (`nil') -- Variable: YaTeX-hilit-sectioning-face When hilit19 and yatex19 is active, YaTeX colors the sectioning commands. This variable specifies the foreground and background color of `\part' macro. The default value is `'(yellow/dodgerblue yellow/slateblue)'. The first element of this list is for the screen when `hilit-background-mode' is `'light', and the second element is for `'dark'. You should specify both color as `forecolor/backcolor'. -- Variable: YaTeX-hilit-sectioning-attenuation-rate When color mode, this variable specifies how much attenuate the color density of `\subparagraph' compared with that of `\chapter' (`'(15 40)') See also `YaTeX-hilit-sectioning-face'. -- Variable: YaTeX-use-AMS-LaTeX If you use AMS-LaTeX, set to `t' (`nil') -- Variable: YaTeX-use-LaTeX2e If you use LaTeX2e, set to `t' (`t') -- Variable: YaTeX-template-file File name which is automatically inserted at creation (`~/work/template.tex') -- Variable: YaTeX-search-file-from-top-directory Non-nil means to search input-files from the directory where main file exists (`t') -- Variable: YaTeX-use-font-lock Use font-lock to fontify buffer or not (`(featurep 'font-lock)' -- Variable: YaTeX-use-hilit19 Use hilit19 to highlight buffer or not (`(featurep 'hilit19)' -- Variable: YaTeX-use-italic-bold YaTeX tries to search italic, bold fontsets or not (`t' if Emacs-20 or later). This variable is effective only when font-lock is used. (`(featurep 'hilit19)' -- Variable: YaTeX-singlecmd-suffix Suffix which is always inserted after maketitle-type macros. `"{}"' is recommended. -- Variable: YaTeX-package-alist-private Alist of LaTeX2e-package name vs. lists of macros in it. Set this alist properly and YaTeX automatically check the declaratiion of `usepackage' for corresponding macro, when you input that macro with completion. If required `usepackage' is not found, YaTeX also automatically inserts `\usepackage'. Alist is as follows; '((PackageName1 (completionType ListOfMacro) (completionType ListOfMacro)) (PackageName2 (completionType ListOfMacro) (completionType ListOfMacro...))....) completionType is one of `env, section, maketitle'. Consult the value of `YaTeX-package-alist-default' as an example. -- Variable: YaTeX-tabular-indentation At indentation by `C-i' in tabular or array environment, YaTeX put the additional spaces to the normail indentation depth. The number of additional spaces is the product of YaTeX-tabular-indentation and the number of column position in tabular. -- Variable: YaTeX-noindent-env-regexp Regexp of environment names that should begin with no indentation. All verbatime-like environment name should match with. -- Variable: YaTeX-ref-default-label-string Default \\ref time string format. This format is like strftime(3) but allowed conversion char are as follows; %y -> Last 2 digit of year, %b -> Month name, %m -> Monthe number(1-12), %d -> Day, %H -> Hour, %M -> Minute, %S -> Second, %qx -> alphabetical-decimal conversion of yymmdd. %qX -> alphabetical-decimal conversion of HHMMSS. Beware defualt label-string should be always unique. So this format string should have both time part (%H+%M+%S or %qX) and date part (%y+(%b|%m)+%d or %qx). -- Variable: YaTeX-ref-generate-label-function Function to generate default label string for unnamed \\label{}s. The function pointed to this value should take two arguments. First argument is LaTeX macro's name, second is macro's argument. Here is an example for using this value. (setq YaTeX-ref-generate-label-function 'my-yatex-generate-label) (defun my-yatex-generate-label (command value) (and (string= command "caption") (re-search-backward "\\\\begin{\\(figure\\|table\\)}" nil t) (setq command (match-string 1))) (let ((alist '(("chapter" . "chap") ("section" . "sec") ("subsection" . "subsec") ("figure" . "fig") ("table" . "tbl")))) (if (setq command (cdr (assoc command alist))) (concat command ":" value) (YaTeX::ref-generate-label nil nil))))  File: yatexe, Node: Sample definitions, Next: Hook variables, Prev: All customizable variables, Up: Lisp variables Sample definitions ------------------ For instance, to change the prefix key stroke to `ESC', and name of the user dictionary `~/src/emacs/yatexrc', and set `fill-prefix' to single TAB character, add the following `setq' to `~/.emacs'. (setq YaTeX-prefix "\e" YaTeX-user-completion-table "~/src/emacs/yatexrc" YaTeX-fill-prefix " ")  File: yatexe, Node: Hook variables, Next: Hook file, Prev: Sample definitions, Up: Lisp variables Hook variables -------------- More customizations will be done by the hook-function defined in hook-variable `yatex-mode-hook'. This is useful to define a shortcut key sequence to enter some environments other than `document' and `enumerate' etc. The following statement defines `[prefix] ba' to enter `\begin{abstract}' ... `=end{abstract}' immediately. (setq yatex-mode-hook '(lambda() (YaTeX-define-begend-key "ba" "abstract"))) You should use functions `YaTeX-define-key', or `YaTeX-define-begend-key' to define all the key sequences of yatex-mode.  File: yatexe, Node: Hook file, Prev: Hook variables, Up: Lisp variables Hook file --------- You can stuff all of YaTeX related expressions into a file named `yatexhks.el' if you have a lot of codes. YaTeX automatically load this file at the initialization of itself. Using `yatexhks.el' makes `yatex-mode-load-hook' unnecessary.  File: yatexe, Node: Add-in functions, Next: Add-in generator, Prev: Lisp variables, Up: Customizations Add-in functions ================ You can easily define a function to input detailed arguments with completion according to LaTeX environments or commands. What is add-in functions? ------------------------- When you input `tabular' environment, don't you think "I want YaTeX to complete its argument toward my favorite one such as `{|c|c|c|}'..."? Yes, you can define the function to complete arguments for any environment and any LaTeX commands. Procedure --------- Here is the procedure to define add-in functions. 1. Define the function 2. Put the function into `yatexhks.el' * Menu: * How the add-in function works:: * How the function is called:: * Useful functions for creating add-in:: * Contribution::  File: yatexe, Node: How the add-in function works, Next: How the function is called, Prev: Add-in functions, Up: Add-in functions How the add-in function works ----------------------------- There are three types of add-in. 1. Option add-in 2. argument add-in 3. enclosing add-in "Option add-in" returns the LaTeX's optional parameters such as optional strings after `\begin{ENV}', optional strings between a section-type command and its first argument, and optional strings just after type maketitle-type command. The following illustrates the name of add-in functions, where underlined strings are generated by add-in functions. \begin{table}[ht] (Function name: YaTeX:table) ~~~~ \put(100,200){} (Function name: YaTeX:put) ~~~~~~~~~ \sum_{i=0}^{n} (Function name: YaTeX:sum) ~~~~~~~~~~ Obviously, the function name is decided by concatenating the prefix `YaTeX:' and LaTeX command's name. Another add-in type is "argument add-in", which completes arguments for section-type commands. \newcommand{\foo}{bar} (Function name: YaTeX::newcommand) ~~~~ ~~~ When the section-type command is inputted, the function named by concatenating `YaTeX::' and section-type command, is called automatically with an integer argument which indicates which argument of section-type command is being read. Thus the add-in should determine the job referring the value of its argument. "enclosing add-in" is for modifying and/or checking the region that will be enclosed by section-type commands via `[prefix] S'. An enclosing add-in function will be called with two arguments, beginning of the enclosed region and end of the region. Suppose you want to enclose the existing text `(a+b)/c' by `\frac{}'. a/c | | A B You do set-mark-command at point A and then move to point B. Typing `[prefix] S' and input `frac' enclose the region like this; \frac{a/c} Normally, the expression `a/c' is translated to `\frac{a}{c}'. An enclosing add-in is useful for modifying `/' to `}{'. * Menu: * Defining option-add-in:: * Defining argument-add-in:: * Defining enclosing-add-in::  File: yatexe, Node: Defining option-add-in, Next: Defining argument-add-in, Prev: How the add-in function works, Up: How the add-in function works Defining `option add-in' ........................ If you want `{|c|c|c|}' for all `tabular' environment, (defun YaTeX:tabular () "{|c|c|c|}") is enough. If you want more complicated format, define as below. (defun YaTeX:tabular () "{@{\\vrule width 1pt\\ }|||@{\\ \\vrule width 1pt}}") Note that the character `\' must be described as `\\' in Emacs-Lisp. The next example reads the tabular format from keyboard. (defun YaTeX:tabular () (concat "{" (read-string "Rule: ") "}"))  File: yatexe, Node: Defining argument-add-in, Next: Defining enclosing-add-in, Prev: Defining option-add-in, Up: How the add-in function works Defining `argument add-in' .......................... This section describes how to define the add-in function for `\newcommand'. The first argument of `\newcommand' begins always with `\'. The second argument is usually so complex that we can not edit them in the minibuffer. Here is the created function considering this. (defun YaTeX::newcommand (n) ;n is argument position (cond ((= n 1) ;1st argument is macro name (read-string "Command: " "\\")) ;initial input `\' ((= n 2) "") ;do nothing when reading arg#2 (t nil))) Note that when the `argument add-in' function return `nil', normal argument reader will be called.  File: yatexe, Node: Defining enclosing-add-in, Prev: Defining argument-add-in, Up: How the add-in function works Defining `enclosing add-in' ........................... This section describes how to define the add-in function for text enclosed by `\frac{}'. When enclosing the text `5/3' by `\frac{}', you might want to replace `/' with `}{'. Enclosing function `YaTeX::frac-region' is called with two arguments, beginning of enclosed text and end of enclosed text. The function is expected to replace `/' with `}{'. Here is an example expression. (defun YaTeX::frac-region (beg end) (catch 'done (while (search-forward "/" end t) (goto-char (match-beginning 0)) (if (y-or-n-p "Replace this slash(/) with `}{'") (throw 'done (replace-match "}{"))) (goto-char (match-end 0)))))  File: yatexe, Node: How the function is called, Next: Useful functions for creating add-in, Prev: How the add-in function works, Up: Add-in functions How the function is called -------------------------- YaTeX calls the add-in functions for specified begin-type, section-type, and maketitle-type command, if any. `Option add-in' functions for begin-type are called when `\begin{ENV}' has been inserted, functions for section-type are called just before input of the first argument, and functions for maketitle-type is called after maketitle-type command has been inserted. `Argument add-in' functions are called at each entry of arguments for section-type commands.  File: yatexe, Node: Useful functions for creating add-in, Next: Contribution, Prev: How the function is called, Up: Add-in functions Useful functions for creating add-in ------------------------------------ Many add-in functions for typical LaTeX commands are defined in `yatexadd.el'. Those are also useful as references. Here are the short descriptions on useful functions, where [F] means function, [A] means arguments, [D] means description. `[F]' YaTeX:read-position `[A]' Character list which can show up in the brackets `[D]' Return the location specifier such as `[htb]'. When nothing is entered, omit [] itself. If the possible characters are "htbp", call this function as `(YaTeX:read-position "htbp")' `[F]' YaTeX:read-coordinates `[A]' Base prompt, X-axis prompt, Y-axis prompt (each optional) `[D]' Read the coordinates with the prompt "BasePrompt X-axisPrompt:" for X-axis, "BasePrompt Y-axisPrompt:" for Y-axis, and return it in the form of "(X,Y)". The default prompts are `Dimension', `X', `Y' respectively. `[F]' YaTeX:check-completion-type `[A]' One of the symbols: 'begin, 'section, or 'maketitle `[D]' Check the current completion type is specified one and cause error if not. The variable `YaTeX-current-completion-type' holds the symbol according to the current completion type.  File: yatexe, Node: Contribution, Prev: Useful functions for creating add-in, Up: Add-in functions Contribution ------------ If you make your own pretty function and you let it be in public, please send me the function. I'm going to include it in the next release.  File: yatexe, Node: Add-in generator, Prev: Add-in functions, Up: Customizations Add-in generator ================ First, don't forget to read the section of add-in functions *Note Add-in functions::. If you easily understand how to define them, there's no need to read this section. But being not familiar with Emacs-Lisp, when you don't have clear idea what to do, this section describes how to get YaTeX make add-in function. There are two methods of generation. One is for fully interactive generator for beginners and another requires little knowledge of Emacs-Lisp. Generator for beginners ----------------------- The former generator is called by `M-x YaTeX-generate' strokes. All you have to do is follow the guidances. Defying them may cases the disaster (I wonder what is it???). So when you make some mistake, it is recommendable to type `C-g' and start afresh. Simple generator ---------------- The latter generator is invoked by the next sequence. `M-x YaTeX-generate-simple' This generator can make both "option add-in" and "argument add-in" (*refer the section add-in functions* *Note How the add-in function works::), whereas `YaTeX-generate' cannot make "argument addin". For example, assume you have the LaTeX command as follows. \epsinput[t](250,50){hoge.eps}{plain}{Picture of foo} (A) (B) (1) (2) (3) (A)Optional parameter to specify the position One of t(top), b(bottom), l(left), r(right) (B)Maximum size of frame (1)1st argument is filename of EPS file (2)2nd argument indicates plain do nothing frame make frame around image dframe make double-frame around image for included EPS file. (3)Caption for the picture Now get start with generation. Typing `M-x YaTeX-generate-simple' brings the prompt: (O)ption? (A)rgument? Generating "option add-in" .......................... Since (A), (B) above are optional argument, all we have to do to complete them is define the option add-in for them. Let's generate the function to complete (A). M-x YaTeX-generate-simple RET epsinput RET o Typing as above leads the next prompt. Read type(1): (S)tring (C)omplete (F)ile ([)option (P)osition co(O)rd. (q)uit This asks that "Which type is the completion style of 1st argument?". Here are the possible completion style. `String' read plain string `Complete' read with completion `File' read file name `Option' read optional string (if string omitted, omit [] too) `Position' read positional option (like [htbp]) `Coord.' read coordinates `Quit' quit from generating Since (A) is the optional argument to specify the location of included EPS file, the completion style is `Position', and the possible characters are t, b, l, and r. To tell these information to generator, operate as follows. Read type(1).... p Acceptable characters: tblr RET (B) is coordinate. So its completion style is coOrd. We want a prompt meaning "Maximum size" when completion. Read type(2).... o Prompt for coordinates: Max size RET That's all for optional argument. Select quit. Read type(3).... q Then the generated option add-in function for \epsinput will be shown in the next window. Generating "argument add-in" ............................ Next, create the argument add-in. The arguments for \epsinput are EPS file name, framing style, and caption string in sequence. M-x YaTeX-generate-simple RET epsinput RET a Above key strokes bring the prompt that asks the number of argument. Answer it with 3. How many arguments?: 3 RET Then the generator asks the completion style and prompt for completion. Answer them. `f' for FileName and prompt string. Read type(1).... f Prompt for argument#1 EPS file name RET The second argument is one of selected symbol. So the completion type is `Completion'. Read type(2).... c Prompt for argument#2 Include style RET Then all the candidates ready to be read. Type single RET after entering all. Item[1](RET to exit): plain RET Item[2](RET to exit): frame RET Item[3](RET to exit): dframe RET Item[4](RET to exit): RET The following prompt asks whether the entered string must belong to candidates or not. In this case, since the argument must be one of `plain', `frame', and `dframe', type `y'. Require match? (y or n) y The last argument is the caption string for which any completion is needed. Read type(3).... s Prompt for argument#3 Caption RET default: Figure of RET Finally we'll get the argument add-in in the next window. Contribution ------------ If you get your own pretty function and you let it be in public, please steel yourself in the happy atmosphere and do not send me the function. I do know it is not fine because it is generated by yatexgen:-p.  File: yatexe, Node: Etcetera, Next: Copying, Prev: Customizations, Up: Top Etcetera ******** The standard completion tables provided in `yatex.el' contain a few LaTeX commands I frequently use. This is to lessen the key strokes to complete entire word, because too many candidates rarely used often cause too many hits. Therefore always try to use completion in order to enrich your dictionary, and you will also find `Wild Bird' growing suitable for your LaTeX style. The package name `Wild Bird' is the English translation of Japanese title `Yachou', which is a trick on words of Japanese.  File: yatexe, Node: Copying, Prev: Etcetera, Up: Top Copying ******* This program is distributed as a free software. You can use/copy/modify/redistribute this software freely but with NO warranty to anything as a result of using this software. Adopting code from this program is also free. But I would not do contract act. Any reports and suggestions are welcome as long as I feel interests in this software. My possible e-mail address is `yuuji@yatex.org'. (as of Jan.2004) And there is mailing list for YaTeX. Although the common language is Japanese, questions in English will be welcome. To join the ML, send the mail whose subject is `append' to the address `yatex@yatex.org. If you have some question, please ask to `yatex-admin@yatex.org'. The specification of this software will be surely modified (depending on my feelings) without notice :-p. HIROSE Yuuji  Tag table: Node: Top256 Node: What is YaTeX?1597 Node: Main features1970 Node: Installation3499 Node: Typesetting4276 Node: Calling typesetter5406 Node: Calling previewer7610 Node: Printing out7971 Node: %#notation8263 Node: Changing typesetter8681 Node: Splitting input files9045 Node: Static region for typesetting10470 Node: Lpr format11599 Node: Controlling which command to invoke12672 Node: Editing %# notation13265 Node: Completion13809 Node: Begin-type completion14369 Node: Section-type completion17412 Node: view-sectioning19847 Node: Large-type completion21427 Node: Maketitle-type completion22158 Node: Arbitrary completion22710 Node: End completion23100 Node: Accent completion23570 Node: Image completion24187 Node: Greek letters completion26444 Node: Local dictionaries27171 Node: Commenting out28108 Node: Cursor jump29567 Node: Jump to corresponding object29879 Node: Invoking image processor31280 Node: Jump to main file32623 Node: Jumping around the environment32988 Node: Jumping to last completion position33406 Node: Changing and Deleting33915 Node: Changing LaTeX commands34307 Node: Killing LaTeX commands35484 Node: Filling36669 Node: Updation of includeonly38520 Node: What column39317 Node: Intelligent newline40402 Node: Usepackage checker42056 Node: Online help42647 Node: Browsing file hierarchy44322 Node: Cooperation with other packages46059 Node: Customizations46764 Node: Lisp variables47098 Node: All customizable variables48102 Node: Sample definitions57901 Node: Hook variables58414 Node: Hook file59118 Node: Add-in functions59457 Node: How the add-in function works60317 Node: Defining option-add-in62516 Node: Defining argument-add-in63238 Node: Defining enclosing-add-in64120 Node: How the function is called64974 Node: Useful functions for creating add-in65650 Node: Contribution67055 Node: Add-in generator67329 Node: Etcetera72701 Node: Copying73306  End tag table yatex_1.77+dfsg1/docs/yatexgen.doc0000444000175000017500000001245512126310642015617 0ustar kurakura----------------------------------------------------------------------------- 野鳥用付加関数を自動的に作ろう! ----------------------------------------------------------------------------- 【はじめに】 まず、yatexadd.doc には目を通して下さい。それを読んで、なにか独 自の関数をすぐに作りたくなったあなたには、このドキュメントも、 yatexgen.el も必要有りません。しかし、Emacs-Lisp をよく知らないた め、どのように作ってよいのかピンと来ない方のために、野鳥自身に付加 関数を自動的に作らせる時の説明をするのが、このドキュメントです。 ただ、自動的に作るわけですから、気の利いた関数などは作れません。 \documentstyle{} を入れる時に、オプション([twocolumn,12pt]とか)を 自動的にキーボードから読み込むようにする程度のものだけなので、それ 以上を望む場合は、ちゃんと yatexadd.el を参考にして、すごいのを作 りましょう:-)。 【作り方その1】 Emacs-Lispなんか全然知らないよ〜んという人向け: M-x YaTeX-generate ぺし あとは、画面に出て来る指示通りに操作して下さい。これを無視してい いかげんに操作すると、とんでもないことになります(なんだろう?)。失 敗した、と思ったら、^G して最初からやり直すのが無難です。 【作り方その2】 他の付加関数を見て何をやってるかの想像が付く人、あるいは Emacs-Lisp は知ってるが単に作るのが面倒な人向け: M-x YaTeX-generate-simple RET こっちでは追加型付加関数と引数型付加関数(yatexadd.docもちゃんと 読んでね;-)の両方が作れます(その1は追加型しか作れない)。 では、例として次のような LaTeX コマンドがあったとしましょう。 (実際にはないよー) \epsinput[t](250,50){hoge.eps}{plain}{ほげほげの絵} (A) (B) (1) (2) (3) (A)位置を指定するオプション引数(なくても良い) t(top) b(bottom) l(left) r(right) のどれかが入る (B)枠の最大の大きさ (1)第1引数は取り込むEPSファイル名 (2)第2引数は取り込む時に plain 何もしない frame 枠を付ける dframe 二重枠を付ける のどれかのスタイルを選べたりする (3)絵に付けるキャプションを指定 早速付加関数を作りましょう。M-x YaTeX-generate-simple とすると Making add-in function for (default ???): epsinput RET と聞いて来るので何用の付加関数を作るか答えます。さらに (o)追加型? (a)引数型? と、聞いて来るのでどちらを作るか答えます。ではそれぞれの場合につい て例を追ってみましょう。 (o)追加型付加関数を作る (A),(B)の部分はオプション引数なので、追加型付加関数で補完します。 (1)〜(3)は実際の引数なので引数型付加関数で補完します。では(A)を補 完するための関数を作りましょう。 M-x YaTeX-generate-simple RET epsinput RET o すると次のメニューが出ます。 Read type(1): (S)tring (C)omplete (F)ile ([)option (P)osition co(O)rd. (q)uit 「Read type(1)」というのは「1番目のオプションの補完スタイルはなあ に?」という意味です。補完スタイルには以下のものがあります。 String 普通の文字列を読み込む Complete いくつかの候補の中から読み込む File ファイル名を読み込む Option オプション引数を読む(省略すると[]がつかない) Position 場所指定オプションを読む([htbp] みたいなの) Coord. 座標を読み込む Quit おしまい さて(A)はEPSファイルを配置する場所指定オプションなので補完タイプは Position、さらにその候補は t, b, l, r のどれかなので、以下のように 操作します。 Read type(1).... p Acceptable characters: tblr RET 次の(B)は座標なので補完タイプは coOrd. 最大サイズと言う意味のプロ ンプトを出したいので次のようにします。 Read type(2).... o Prompt for coordinates: Max size RET もうオプション引数はないので、quitを選びます。 Read type(3).... q これで隣のウィンドウに \epsinput 用の追加型付加関数が生成されます。 (a)引数型付加関数を作る さて \epsinput の引数の種別は順に、EPSファイル名、枠付スタイル、 キャプション文字列でした。これらを読み込む(引数型)付加関数を作りま しょう。 M-x YaTeX-generate-simple RET epsinput RET a すると引数の数を聞いて来るのでそれに答えます。 How many arguments?: 3 RET すると第1引数について補完タイプを聞いて来るので、「ファイル名(f)」 を選び、ファイル名を読む時に出したいプロンプト文字列を入れます。 Read type(1).... f Prompt for argument#1 EPS file name RET 第2引数は複数候補から選択するので補完タイプは Completion。 Read type(2).... c Prompt for argument#2 Include style RET すると全候補の入力を促すので、順次入力し最後にRETを空打ちします。 Item[1](RET to exit): plain RET Item[2](RET to exit): frame RET Item[3](RET to exit): dframe RET Item[4](RET to exit): RET さらに補完候補以外の選択を認めるかを聞いて来るので、y か n で答え ます。この場合 plain, frame, dframe 以外は選べないので Require match? (y or n) y のように y と答えます。 最後の引数は単に文字列を読めば良いので、補完タイプは String。 「default:」ではミニバッファで入力する時にデフォルトで入力されてい る文字列を入れます。必要なければRETを空打ちします。 Read type(3).... s Prompt for argument#3 Caption RET default: の絵 RET これで隣のウィンドウに \epsinput 用の引数型付加関数が生成されま す。 【できあがり】 言われた通りに正しく指示を与えると、お望みのお手軽関数が出来上 がります。これを切り取って、~/yatexhks.el にでも放り込みましょう。 本当はこれも自動化しようと思ったのですが、これに失敗すると命がい くつあっても足りないので、やめておきました。第一それも面倒な人は、 野鳥なんか使っていないよね? 【最後に】 快適な関数を定義したなら、そしてそれを公開してもよいと思われたな ら、幸福感に浸るだけにして、決して筆者まで送ったりしないで下さい。 yatexgen が作るんだから、ろくな関数じゃないことは分かってます:-p。 広瀬雄二 yuuji@yatex.org yatex_1.77+dfsg1/docs/qanda.eng0000444000175000017500000004033712126310642015063 0ustar kurakura%% %% Q and A on YaTeX %% %% C-u C-x $ shows only questions. C-x $ shows all. %% (New Item *It is bothering for me to determine I should call bibtex or latex... *Filling a paragraph doesn't work as I expected. [Installation] ============== *Installing the manual Copy yatexe to the info directory where your Emacs is installed, and add the next line to the dir file of the same directory. * YaTeX-e: (yatexe). Yet Another tex-mode for Emacs. (English). (After that, M-x info [RET] m yatex [RET] will give you Wild Bird's manual. Hitting ? will show how to use info) *I'm a Meadow(Emacs on Win32) user. I don't have `make' utility Make program is needed only for byte-compiling. So if you do not care the subtle speed difference, you don't have to byte-compile. You don't have to look for `make' utility. The simplest way to install yatex without `make'. 1 Extract this yatex*tar.gz to your Meadow's site-lisp dir. 2 Add the yatex installed path to your load-path according to `install' file in this package. *I ain't got the privilege to write in the Info directory... Get yourself made root. If you can't, have them install Mule2 and add (setq Info-default-directory-list (cons "YOUR INFO DIRECTORY" Info-default-directory-list)) to your ~/.emacs. Now your personal files will be added to the menu when you invoke info. By the way, Mule1 will not release memories, so processes will pile up and be heavier on the system compared to Mule2. Nemacs has already become obsolete by the developers, so no further comments for usage of Nemacs. Get yourself Mule2 with flying colors :-) *Emacs can't find the help file. The help file is set to be placed in $EMACS/etc/ for Nemacs, Mule1 and $EMACS/site-lisp/ for Mule2. If you don't have the privilege to put them in a public location, copy it to your home directory and set YaTeX-help-file to that file name. *I can't read info on Nemacs The info file was formatted on Mule, so it can't be read correctly on Nemacs (or Demacs based on Nemacs) because the internal Japanese processing is different. Read it on Mule. Use the Emacs-Lisp package in texinfo-3.1.tar.gz to format the Texinfo file. [Operations] ============ *I accidentally learned in a wrong LaTeX command. There should be a line with the wrong command in the .yatexrc file in your home or current directory. Erase or fix that line, and save the results with C-x C-s, then kill buffer with C-x k. Once you make sure the current buffer is your LaTeX source, type M-x YaTeX-reload-dictionary. *I can't comment out the region. Probably the point is on a line withe \begin{} or \end{}. Go up or down a line and do C-c >. *I was asked for a parent file when typesetting, and answered the wrong file. Re-read the child file with C-x C-v RET or re-type the parent file with C-u C-c ^. *The typeset buffer is not shown when I get a typeset buffer on Demacs. This happens on Demacs 1.2.0, when the child process returns an error level of 1 or more. If you are calling jlatex from a batch file, call a dummy command that always returns errorlevel 0 at the end. *How can I enter "\underline{\makebox[4em][l]{x y}{\tt z}}" more easily? Recursive completion can be used for inputting arguments in the mini-buffer of a section type completion. Following is an example showing the command in question. PROMPT KEYs ENTERED C-c s und SPC RET \underline{???}: C-c s makeb SPC RET Width: 4em RET makebox position (`lr'): - l RET \makebox{???}: x y RET \underline{???}: \makebox[4em][l]{x y} C-c l tt RET \underline{???}: \makebox[4em][l]{x y}{\tt } z RET *How can I kill \footnote{} from \footnote{HOGE} Put the point to \footnote and do C-c k. This will kill the \footnote{}. If you want to kill the whole thing including HOGE, do C-u C-c k. *I want to make HONYARA into a footnote. Mark HONYARA and do C-c S footnote RET. (S in uppercase) *I want to make the verbatim environment I have now into verbatim*. Do C-c c on the line with \begin{verbatim} or \end{verbatim}. *I want to enclose a region with \verb. \verb isn't a maketitle-type, so there aren't any quick commands. But you can use C-c $ to do the same thing. v v WHAT YOU NEED to make \verb \verbWHAT YOU NEED to make \verb (insert \verb) ^(C-@) (mark W) \verbWHAT YOU NEED to make \verb ^C-c $ (move point to end enclose with $) \verb$WHAT YOU NEED$ to make \verb (done!) *I want to have commands defined on a upper level file to be read in when doing a typeset-region on a child file. When you are editing child files broken into sections and some macros to be used are defined in upper level files, you'll need them to do typeset-region. The macros needed will be copied to the temporary file if you add %#REQUIRE to the end of the macro's definition. Say you had a grand-child file +-- main.tex --+ +---- sub.tex ----+ +-- subsub.tex --+ | : | |%#jlatex main | |%#jlatex main | |\include{sub} | |\include{macros} | |..... | | : |<-| : |<-|%#BEGIN | | : | | : | |TEXT YOU WANT | | : | +-----------------+ |TYPESET IS | +--------------+ ^ |HERE | +-- macros.tex ---+ |%#END | |\def\foo{bar} | |: | |\def\hoge{hero} | +----------------+ +-----------------+ In this case you change the \include{macros} line in sub.tex to \include{macros} %#REQUIRE and add to subsub.tex %#REQUIRE \include{macros} If %#REQUIRE is at the top of the line, the following will be copied to the temporary file. So, macros.tex will be included only once whether you are typesetting all the files, or doing a typeset-region on sub.tex or subsub.tex. *I want to reuse ARGUMENTS I used in the last \foo{ARGUMENTS} Use the gmhist package. YaTeX works fine with gmhist. When you are asked \foo{???}: in the mini-buffer, hitting M-p (ESC p) will get you a history of what you have inputted in reverse. M-n will go forward in the history. This input history can be used for begin-type completion, section-type completion, evoking the previewer, and print out commands. gmhist can be found at many Emacs-Lisp archive sights. For example, ftp.ae.keio.ac.jp:pub/emacs-lisp/util/gmhist.tar.gz Note that Emacs-19(Mule2) doesn't need gmhist for the feature of minibuffer history. *ref<->label jump doesn't work. C-c g will start a forward search of ref/label. C-u C-c g will start a backward search. If you want to continue searching for \ref, hit C-s (C-r) twice and use the repeated search feature of the incremental search. If the point to jump is in another file, that file must be already opened. YaTeX-display-hierarchy (C-c d) can be used to open all files at once. *I get a % at the end of the line when I do a fill-paragraph or auto-fill. NTT-jTeX will add an unnecessary space in the print out image if the japanese paragraph is written with an indent. To avoid this, you need to put a % at the end of the line. YaTeX will automatically put a % so you can input indented text for NTT-jTeX. But there may be a bug in the routine so please report if you find any %s otherwise than at the end of a line. *Isn't the indentation too deep in itemize environments? Think so too? An alias Mr. K thought this was better and he feels an ultimate ecstacy with hitting the TAB to indent a line. Wasn't my idea! (still have a bit of a grudge) If you also think it's too deep, hit TAB at the end of the line with \begin{itemize} within the environment. Now it's too shallow? Umm... time for me to take a break. *Is it possible to include personal template file template.tex handily? Try Emacs-19's standard package `autoinsert.el' please. Or its upper compatible package auto-insert-tkld might also be good. You can get auto-insert-tkld via anonymous ftp ftp://ftp.ae.keio.ac.jp/pub/emacs-lisp/util/ ftp://archive.cis.ohio-state.edu/pub/gnu/elisp-archive/ *It is bothering for me to determine I should call bibtex or latex... Why don't you try `latexmk' perl script, which is a TeX specific tool as `make'? It detects the dependency among the TeX-related files such as .tex, .bib, and so on, and will execute suitable commands in a suitable sequence. You can find `latexmk' script in a directory of supports/latexmk in some CTAN ftp directory. *Can I inhibit auto-filling against very long line? If you use Emacs-19 or later, Yes. The variable auto-fill-inhibit-regexp controls the filling behaviour. To set this, use yatex-mode-hook as below. (add-hook 'yahtml-mode-hook '(lambda () (setq auto-fill-inhibit-regexp "^[ ]*\\(end, ref<->label(@kbd{C-c g}) @item Blanket commenting out or uncommenting (@kbd{C-c >}, @kbd{C-c <}, @kbd{C-c ,}, @kbd{C-c .}) @item Easy input of accent mark, math-mode's commands and Greek letters (@kbd{C-c a}, @kbd{;}, @kbd{:}) @item Online help for the popular La@TeX{} commands (@kbd{C-c ?}, @kbd{C-c /}) @item Document files hierarchy browser (@kbd{C-c d}) @item Adding automatically \usepackage corresponding to inputting LaTeX macro with completion @item Allow you to forget creating \label@{@}s, \ref@{@} or \cite@{@} completion automatically generate labels. @end itemize @node Installation, Typesetting, Main features, Top @comment node-name, next, previous, up @chapter Installation @cindex installation @cindex .emacs @cindex auto-mode-alist @cindex autoload Put next two expressions into your @file{~/.emacs}. @lisp (setq auto-mode-alist (cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist)) (autoload 'yatex-mode "yatex" "Yet Another La@TeX{} mode" t) @end lisp Next, add certain path name where you put files of YaTeX to your load-path. If you want to put them in @file{~/src/emacs}, write @lisp (setq load-path (cons (expand-file-name "~/src/emacs") load-path)) @end lisp @noindent in your @file{~/.emacs} Then, yatex-mode will be automatically loaded when you visit a file which has extension @file{.tex}. If yatex-mode is successfully loaded, mode string on mode line will be turned to "YaTeX". @node Typesetting, %#notation, Installation, Top @comment node-name, next, previous, up @chapter Typesetting @cindex typesetting @cindex previewer @cindex typesetter @cindex latex @cindex printing out The prefix key stroke of yatex-mode is @kbd{C-c} (Press 'C' with Control key) by default. If you don't intend to change the prefix key stroke, assume all @kbd{[prefix]} as @kbd{C-c} in this document. These key strokes execute typeset or preview command. @table @kbd @item [prefix] t j @dots{} invoke latex @item [prefix] t r @dots{} invoke latex on region @item [prefix] t e @dots{} invoke latex on current environment or whole portion of current formulas in math-mode. @item [prefix] t d @dots{} invoke dvipdfmx after successful typesetting @item [prefix] t k @dots{} kill current typesetting process @item [prefix] t b @dots{} invoke bibtex @item [prefix] t i @dots{} invoke makeindex @item [prefix] t d @dots{} invoke latex && dvipdfmx @item [prefix] t p @dots{} preview @item [prefix] t l @dots{} lpr dvi-file @item [prefix] t s @dots{} search current string on xdvi-remote @end table @menu * Calling typesetter:: * Calling previewer:: * Printing out:: @end menu @node Calling typesetter, Calling previewer, Typesetting, Typesetting @comment node-name, next, previous, up @section Calling typesetter Typing @kbd{[prefix] t j}, the current editing window will be divided horizontally when you invoke latex command, and log message of La@TeX{} typesetting will be displayed in the other window; called typesetting buffer. The typesetting buffer automatically scrolls up and traces La@TeX{} warnings and error messages. If you see latex stopping by an error, you can send string to latex in the typesetting buffer. If an error stops the La@TeX{} typesetting, this key stroke will move the cursor to the line where La@TeX{} error is detected. @table @kbd @item [prefix] ' @itemx ([prefix]+single quotation) @dots{} jump to the previous error or warning @end table If you find a noticeable error, move to the typesetting buffer and move the cursor on the line of error message and type @kbd{SPACE} key. This makes the cursor move to corresponding source line. YaTeX-typeset-region invoked by @kbd{[prefix] tr} call typesetter for region. The region is specified by standard point and mark, or by @code{%#BEGIN} and @code{%#END} marks. Selected region will be copied to the temporary file @file{texput.tex} with the same preamble as the main file of current editing sources. Be sure to put all local macro settings in preamble, not after @code{\begin@{document@}}. The method of specification of the region is shown in the section @xref{%#notation}. The documentclass for typeset-region is the same as that of editing file if you edit one file, and is the same as main file's if you edit splitting files. The @kbd{[prefix] te} key automatically marks current inner environment or inner math mode and then call typeset-region with marked region. This is convenient to quick view of current tabular environment or current editing formulas. Keeping previewer window for @file{texput.dvi} is handy for debugging. Since @kbd{[prefix] te} selects the inner-most environment as region, it is not suitable for partial typesetting of doubly or more composed environment. If you want to do partial typesetting for a nested environment, use @kbd{[prefix] tr} for static-region, which is described in the section @xref{%#notation}. @node Calling previewer, Printing out, Calling typesetter, Typesetting @comment node-name, next, previous, up @section Calling previewer @kbd{[prefix] t p} invokes the TeX previewer. And if you are using xdvi-remote, which can be controled from other terminals, @kbd{[prefix] t s} enables you to search current string at the cursor on the running xdvi window. @node Printing out, , Calling previewer, Typesetting @comment node-name, next, previous, up @section Printing out When you type @code{[preifx] t l}, YaTeX asks you the range of dvi-printing by default. You can skip this by invoking it with universal-argument as follows: @example C-u [prefix] tl @end example @node %#notation, Completion, Typesetting, Top @comment node-name, next, previous, up @chapter %# notation @cindex %# notation You can control the typesetting process by describing @code{%#} notations in the source text. @menu * Changing typesetter:: * Splitting input files:: * Static region for typesetting:: * Lpr format:: * Controlling which command to invoke:: * Editing %# notation:: @end menu @node Changing typesetter, Splitting input files, %#notation, %#notation @comment node-name, next, previous, up @section To change the `latex' command or to split a source text. @cindex typesetter To change the typesetting command, write @example %#!latex-big @end example @noindent anywhere in the source text. This is useful for changing typesetter. @node Splitting input files, Static region for typesetting, Changing typesetter, %#notation @comment node-name, next, previous, up @section Splitting input files And if you split the source text and edit subfile that should be included from main text. @example %#!latex main.tex @end example @noindent will be helpful to execute latex on main file from sub text buffer. Since this command line after @kbd{%#!} will be sent to shell literally, next description makes it convenient to use ghostview as dvi-previewer. @example %#!latex main && dvi2ps main.dvi > main @end example @noindent Note that YaTeX assumes the component before the last period of the last word in this line as base name of the main La@TeX{} source. The @code{%f} notation in this line is replaced by main file name, and @code{%r} replaced by root name of main file name. If you specify @code{%f} or @code{%r}, YaTeX always ask you the name of main file at the first typesetting. To make best use of the feature of inter-file jumping by @kbd{[prefix] g} (see @ref{Cursor jump}), take described below into consideration. @itemize @item You can put split texts in sub directory, but not in sub directory of sub directory. @item In the main text, specify the child file name with relative path name such as \include@{chap1/sub@}, when you include the file in a sub-directory. @item In a sub-text, write @code{%#!latex main.tex} even if @file{main.tex} is in the parent directory(not %#!latex ../main.tex). @end itemize @node Static region for typesetting, Lpr format, Splitting input files, %#notation @comment node-name, next, previous, up @section Static region @cindex static region @cindex Fixed region Typeset-region by @kbd{[prefix] tr} passes the region between point and mark to typesetting command by default. But when you want to typeset static region, enclose the region by @code{%#BEGIN} and @code{%#END} as follows. @example %#BEGIN TheRegionYouWantToTypesetManyTimes %#END @end example This is the rule of deciding the region. @enumerate @item If there exists %#BEGIN before point, @enumerate @item If there exists %#END after %#BEGIN, @itemize @item From %#BEGIN to %#END. @end itemize @item If %#END does not exist after %#BEGIN, @itemize @item From %#BEGIN to the end of buffer. @end itemize @end enumerate @item If there does not exist %#BEGIN before point, @itemize @item Between point and mark(standard method of Emacs). @end itemize @end enumerate It is useful to write @code{%#BEGIN} in the previous line of \begin and @code{%#END} in the next line of \@code{end} when you try complex environment such as `tabular' many times. It is also useful to put only @code{%#BEGIN} alone at the middle of very long text. Do not forget to erase @code{%#BEGIN} @code{%#END} pair. @node Lpr format, Controlling which command to invoke, Static region for typesetting, %#notation @comment node-name, next, previous, up @section Lpr format @cindex lpr format Lpr format is specified by three Lisp variables. Here are the default values of them. @table @code @item (1)dviprint-command-format @code{"dvi2ps %f %t %s | lpr"} @item (2)dviprint-from-format @code{"-f %b"} @item (3)dviprint-to-format @code{"-t %e"} @end table On YaTeX-lpr, @code{%s} in (1) is replaced by the file name of main text, @code{%f} by contents of (2), %t by contents of (3). At these replacements, @code{%b} in (2) is also replaced by the number of beginning page, @code{%e} in (3) is replaced by the number of ending page. But @code{%f} and @code{%t} are ignored when you omit the range of print-out by @kbd{C-u [prefix] tl}. If you want to change this lpr format temporarily, put a command such as follows somewhere in the text: @example %#LPR dvi2ps %f %t %s | 4up -page 4 | texfix | lpr -Plp2 @end example And if you want YaTeX not to ask you the range of printing out, the next example may be helpful. @example %#LPR dvi2ps %s | lpr @end example @node Controlling which command to invoke, Editing %# notation, Lpr format, %#notation @comment node-name, next, previous, up @section Controlling which command to invoke These %# notation below can control which command to invoke for La@TeX{} related process. @table @code @item %#BIBTEX @dots{} Command line for makeindex ([prefix] t i) @item %#MAKEINDEX @dots{} Command line for bibtex ([prefix] t b) @end table If you want to invoke ``makeidx hogehoge'' to update index, put the next line some upper place in the source, for example. @example %#MAKEINDEX makeidx hogehoge @end example @node Editing %# notation, , Controlling which command to invoke, %#notation @comment node-name, next, previous, up @section Editing %# notation To edit @code{%#} notation described above, type @table @kbd @item [prefix] % @dots{} editing %# notation menu @end table @noindent and select one of the entry of the menu as follows. @example !)Edit-%#! B)EGIN-END-region L)Edit-%#LPR @end example @noindent Type @kbd{!} to edit @code{%#!} entry, @code{b} to enclose the region with @code{%#BEGIN} and @code{%#END}, and @code{l} to edit @code{%#LPR} entry. When you type @kbd{b}, all @code{%#BEGIN} and @code{%#END} are automatically erased. @node Completion, Local dictionaries, %#notation, Top @comment node-name, next, previous, up @chapter Completion @cindex completion YaTeX makes it easy to input the La@TeX{} commands. There are several kinds of completion type, begin-type, section-type, large-type, etc... @menu * Begin-type completion:: * Section-type completion:: * Large-type completion:: * Maketitle-type completion:: * Arbitrary completion:: * End completion:: * Accent completion:: * Image completion:: * Greek letters completion:: @end menu @node Begin-type completion, Section-type completion, Completion, Completion @comment node-name, next, previous, up @section Begin-type completion @cindex begin-type completion @cindex environment @cindex prefix b "Begin-type completion" completes commands of @code{\begin@{env@}} ... @code{\end@{env@}}. All of the begin-type completions begin with this key sequence. @table @kbd @item [prefix] b @dots{} start begin-type completion @end table @noindent An additional key stroke immediately completes a frequently used La@TeX{} @code{\begin@{@}}...@code{\@code{end}@{@}} environment. @table @kbd @item [prefix] b c @dots{} @code{\begin@{center@}...\end@{center@}} @item [prefix] b d @dots{} @code{\begin@{document@}...\end@{document@}} @item [prefix] b D @dots{} @code{\begin@{description@}...\end@{description@}} @item [prefix] b e @dots{} @code{\begin@{enumerate@}...\end@{enumerate@}} @item [prefix] b E @dots{} @code{\begin@{equation@}...\end@{equation@}} @item [prefix] b i @dots{} @code{\begin@{itemize@}...\end@{itemize@}} @item [prefix] b l @dots{} @code{\begin@{flushleft@}...\end@{flushleft@}} @item [prefix] b m @dots{} @code{\begin@{minipage@}...\end@{minipage@}} @item [prefix] b t @dots{} @code{\begin@{tabbing@}...\end@{tabbing@}} @item [prefix] b T @dots{} @code{\begin@{tabular@}...\end@{tabular@}} @item [prefix] b^T @dots{} @code{\begin@{table@}...\end@{table@}} @item [prefix] b p @dots{} @code{\begin@{picture@}...\end@{picture@}} @item [prefix] b q @dots{} @code{\begin@{quote@}...\end@{quote@}} @item [prefix] b Q @dots{} @code{\begin@{quotation@}...\end@{quotation@}} @item [prefix] b r @dots{} @code{\begin@{flushright@}...\end@{flushright@}} @item [prefix] b v @dots{} @code{\begin@{verbatim@}...\end@{verbatim@}} @item [prefix] b V @dots{} @code{\begin@{verse@}...\end@{verse@}} @end table Any other La@TeX{} environments are made by completing-read of the Emacs function. @table @kbd @item [prefix] b SPACE @dots{} begin-type completion @end table @noindent The next message will show up in the minibuffer @example Begin environment(default document): @end example @noindent by typing @kbd{[prefix] b}. Put the wishing environment with completion in the minibuffer, and @code{\begin@{env@}}...\@code{\end@{env@}} will be inserted in the La@TeX{} source text. If the environment you want to put does not exist in the YaTeX completion table, it will be registered in the user completion table. YaTeX automatically saves the user completion table in the user dictionary file at exiting of emacs. At the completion of certain environments, the expected initial entry will automatically inserted such as @code{\item} for @code{itemize} environment. If you don't want the entry, it can be removed by undoing. If you want to enclose some paragraphs which have already been written, invoke the begin-type completion with changing the case of @kbd{b} of key sequence upper(or invoke it with universal argument by @kbd{C-u} prefix). @cindex enclose region into environment The following example encloses a region with `description' environment. @table @kbd @item [prefix] B D @itemx (or ESC 1 [prefix] b D) @itemx (or C-u [prefix] b D) @dots{} begin-type completion for region @end table This enclosing holds good for the completing input by @kbd{[prefix] b SPC}. @kbd{[prefix] B SPC} enclose a region with the environment selected by completing-read. @node Section-type completion, Large-type completion, Begin-type completion, Completion @comment node-name, next, previous, up @section Section-type completion @cindex section-type completion @cindex prefix s "Section-type completion" completes section-type commands which take an argument or more such as @code{\section@{foo@}}. To invoke section-type completion, type @table @kbd @item [prefix] s @dots{} section-type completion @end table @noindent then the prompt @example (C-v for view) \???@{@} (default documentclass): @end example @noindent will show up in the minibuffer. Section-type La@TeX{} commands are completed by space key, and the default value is selected when you type nothing in the minibuffer. Next, @example \section@{???@}: @end example @noindent prompts you the argument of section-type La@TeX{} command. For example, the following inputs @example \???@{@} (default documentclass): section \section@{???@}: Hello world. @end example @noindent will insert the string @example \section@{Hello world.@} @end example in your La@TeX{} source. When you neglect argument such as @example (C-v for view) \???@{@} (default section): vspace* \vspace*@{???@}: @end example YaTeX puts @example \vspace*@{@} @end example @noindent and move the cursor in the braces. In La@TeX{} command, there are commands which take more than one arguments such as @code{\addtolength@{\topmargin@}@{8mm@}}. To complete these commands, invoke section-type completion with universal argument as, @cindex number of argument @example C-u 2 [prefix] s (or ESC 2 [prefix] s) @end example @noindent and make answers in minibuffer like this. @example (C-v for view) \???@{@} (default vspace*): addtolength \addtolength@{???@}: \topmargin Argument 2: 8mm @end example @code{\addtolength} and the first argument @code{\topmargin} can be typed easily by completing read. Since YaTeX also learns the number of arguments of section-type command and will ask that many arguments in future completion, you had better tell the number of arguments to YaTeX at the first completion of the new word. But you can change the number of arguments by calling the completion with different universal argument again. Invoking section-type completion with @code{[Prefix] S} (Capital `S') includes the region as the first argument of section-type command. The section/large/maketitle type completion can work at the prompt for the argument of other section-type completion. Nested La@TeX{} commands are efficiently read with the recursive completion by typing YaTeX's completion key sequence in the minibuffer. @menu * view-sectioning:: @end menu @node view-sectioning, , Section-type completion, Section-type completion @comment node-name, next, previous, up @subsection view-sectioning @cindex view sectioning @cindex outline In the minibuffer at the prompt of section-type command completion, typing @kbd{C-v} shows a list of sectioning commands in source text(The line with @code{<<--} mark is the nearest sectioning command). Then, default sectioning command appears in the minibuffer. You can go up/down sectioning command by typing @kbd{C-p}/@kbd{C-n}, can scrolls up/down the listing buffer by @kbd{C-v}/@kbd{M-v}, and can hide sectioning commands under certain level by 0 through 6. Type @kbd{?} in the minibuffer of sectioning prompt for more information. You can generate this listing buffer (@code{*Sectioning Lines*} buffer) by typing @table @kbd @item M-x YaTeX-section-overview @dots{} Generate *Sectioning Lines* buffer @end table @cindex{Generate the listing of sectioning units} from the LaTeX source buffer. In this listing buffer, typing @kbd{u} on the sectioning command shifts up the corresponding sectioning command in source text and @kbd{d} shifts down. After marking lines in the listing buffer, typing @kbd{U} shifts up all sectioning commands in the region, and @kbd{U} shifts down. Here are all the key bindings of @code{*Sectioning Lines*} buffer. @table @kbd @item SPC @dots{} Jump to corresponding source line @item . @dots{} Display corresponding source line @item u @dots{} Shift up a sectioning line @item d @dots{} Shift down a sectioning line @item U @dots{} Shift up sectioning lines in region @item D @dots{} Shift down sectioning lines in region @item 0@dots{}6 @dots{} Hide sectioning commands whose level is lower than n @end table @node Large-type completion, Maketitle-type completion, Section-type completion, Completion @comment node-name, next, previous, up @section Large-type completion "Large-type completion" inputs the font or size changing descriptions such as @code{@{\large @}}. When you type @table @kbd @item [prefix] l @dots{} large-type completion @end table @noindent the message in the minibuffer @example @{\??? @} (default large): @end example prompts prompts you large-type command with completing-read. There are TeX commands to change fonts or sizes, @code{it}, @code{huge} and so on, in the completion table. Region-based completion is also invoked by changing the letter after prefix key stroke as @kbd{[prefix] L}. It encloses the region by braces with large-type command. @node Maketitle-type completion, Arbitrary completion, Large-type completion, Completion @comment node-name, next, previous, up @section Maketitle-type completion @cindex maketitle-type completion We call it "maketitle-type completion" which completes commands such as @code{\maketitle}. Take notice that maketitle-type commands take no arguments. Then, typing @table @kbd @item [prefix] m @dots{} maketitle-type completion @end table @noindent begins maketitle-completion. Above mentioned method is true for maketitle-completion, and there are La@TeX{} commands with no arguments in completion table. @node Arbitrary completion, End completion, Maketitle-type completion, Completion @comment node-name, next, previous, up @section Arbitrary completion @cindex arbitrary completion @noindent You can complete certain La@TeX{} command anywhere without typical completing method as described, by typing @table @kbd @item [prefix] SPC @dots{} arbitrary completion @end table @noindent after the initial string of La@TeX{} command that is preceded by @code{\}. @node End completion, Accent completion, Arbitrary completion, Completion @comment node-name, next, previous, up @section End completion @cindex end completion @noindent YaTeX automatically detects the opened environment and close it with \@code{\end@{environment@}}. Though proficient YaTeX users never fail to make environment with begin-type completion, some may begin an environment manually. In that case, type @table @kbd @item [prefix] e @dots{} @code{end} completion @end table @noindent at the end of the opened environment. @node Accent completion, Image completion, End completion, Completion @comment node-name, next, previous, up @section Accent completion @cindex accent completion When you want to write the European accent marks(like @code{\`@{o@}}), @table @kbd @item [prefix] a @dots{} accent completion @end table @noindent shows the menu @example 1:` 2:' 3:^ 4:" 5:~ 6:= 7:. u v H t c d b @end example @noindent in the minibuffer. Chose one character or corresponding numeric, and you will see @example \`@{@} @end example @noindent in the editing buffer with the cursor positioned in braces. Type one more character `o' for example, then @example \`@{o@} @end example @noindent will be completed, and the cursor gets out from braces. @node Image completion, Greek letters completion, Accent completion, Completion @comment node-name, next, previous, up @section Image completion of mathematical sign @cindex image completion @cindex math-mode @cindex sigma @cindex leftarrow @cindex ; Arrow marks, sigma mark and those signs mainly used in the TeX's math environment are completed by key sequences which imitate the corresponding symbols graphically. This completion only works in the math environment. YaTeX automatically detects whether the cursor located in math environment or not, and change the behavior of key strokes @kbd{;} and @kbd{:}. By the way, we often express the leftarrow mark by `<-' for example. Considering such image, you can write @code{\leftarrow} by typing @kbd{<-} after @kbd{;} (semicolon) as a prefix. In the same way, @code{\longleftarrow} (@code{<--}) is completed by typing @kbd{;<--}, infinity mark which is imitated by @code{oo} is completed by typing @kbd{;oo}. Here are the sample operations in YaTeX math-mode. @example INPUT Completed La@TeX{} commands ; < - @code{\leftarrow} ; < - - @code{\longleftarrow} ; < - - > @code{\longleftrightarrow} ; o @code{\circ} ; o o @code{\infty} @end example In any case, you can quit from image completion and can move to the next editing operation if the La@TeX{} command you want is shown in the buffer. @code{;} itself in math-environment is inserted by @kbd{;;}. Typing @kbd{TAB} in the midst of image completion shows all of the La@TeX{} commands that start with the same name as string you previously typed in. In this menu buffer, press @kbd{RET} after moving the cursor (by @kbd{n}, @kbd{p}, @kbd{b}, @kbd{f}) to insert the La@TeX{} command. To know all of the completion table, type @kbd{TAB} just after @kbd{;}. And here is the sample menu by @kbd{TAB} after @kbd{;<}. @example KEY LaTeX sequence sign < \leq < ~ << \ll << <- \leftarrow <- <= \Leftarrow <= @end example You can define your favorite key-vs-sequence completion table in the Emacs-Lisp variable @code{YaTeX-math-sign-alist-private}. See also @file{yatexmth.el} for the information of the structure of this variable. @node Greek letters completion, , Image completion, Completion @comment node-name, next, previous, up @section Greek letters completion @cindex Greek letters completion @cindex : Math-mode of YaTeX provides another image completion, Greek letters completion in the same method. After prefix @kbd{:}, typing @kbd{a} makes @code{\alpha}, @kbd{b} makes @code{\beta} and @kbd{g} makes @code{\gamma} and so on. First, type @kbd{:TAB} to know all the correspondence of alphabets vs. Greek letters. If you will find @kbd{;} or @kbd{:} doesn't work in correct position of math environment, it may be a bug of YaTeX. Please send me a bug report with the configuration of your text, and avoid it temporarily by typing @kbd{;} or @kbd{:} after universal-argument(@kbd{C-u}) which forces @kbd{;} and @kbd{:} to work as math-prefix. @node Local dictionaries, Commenting out, Completion, Top @comment node-name, next, previous, up @chapter Local dictionaries @cindex local dictionaries @cindex nervous users Tables for completion consist of three dictionaries; `standard dictionary' built in @file{yatex.el}, `user dictionary' for your common private commands, and `local dictionary' that is effective in a certain directory. When you input the command unknown to YaTeX at a completion in the minibuffer, YaTeX asks you with the following prompt; @example `foo' is not in table. Register into: U)serDic L)ocalDic N)one D)iscard @end example @noindent In this menu, typing @kbd{u} updates your `user dictionary', @kbd{l} updates your local dictionary, @kbd{n} updates only on-memory dictionary which go through only current Emacs session, and @kbd{d} updates no dictionary and throws the new word away. If you find this switching feature meaningless and bothersome, put the next expression into your @file{~/.emacs} @lisp (setq YaTeX-nervous nil) @end lisp @node Commenting out, Cursor jump, Local dictionaries, Top @comment node-name, next, previous, up @chapter Commenting out @cindex commenting out @cindex prefix > @cindex prefix < @cindex prefix , @cindex prefix . You may want to comment out some region. @table @kbd @item [prefix] > @dots{} comment out region by % @item [prefix] < @dots{} uncomment region @end table @noindent cause an operation to the region between point and mark. @table @kbd @item [prefix] . @dots{} comment out current paragraph @item [prefix] , @dots{} uncomment current paragraph @end table @noindent comments or uncomments the paragraph where the cursor belongs. This `paragraph' means the region marked by the function mark-paragraph, bound to @kbd{ESC h} by default. It is NOT predictable what will happen when you continuously comment out some paragraph many times. You can also comment out an environment between @code{\begin} and @code{\end}, or a @code{\begin}-\@code{\end} pair themselves, by making the following key strokes on the line where @code{\begin@{@}} or @code{\end@{@}} exists. @table @kbd @item [prefix] > @dots{} comment out from \begin to \@code{end} @item [prefix] < @dots{} uncomment from \begin to \@code{end} @end table @noindent comment whole the contents of environment. Moreover, @table @kbd @item [prefix] . @dots{} comment out \begin and \@code{end} @item [prefix] , @dots{} uncomment \begin and \@code{end} @end table @noindent (un)comments out only environment declaration: @code{\begin@{@}} and @code{\end@{@}}. NOTE that even if you intend to comment out some region, invoking @kbd{[prefix] >} on the @code{\begin},@code{\end} line decides to work in `commenting out from @code{\begin} to @code{\end}' mode. @node Cursor jump, Changing and Deleting, Commenting out, Top @comment node-name, next, previous, up @chapter Cursor jump @cindex cursor jump @cindex prefix g @menu * Jump to corresponding object:: * Invoking image processor:: * Jump to main file:: * Jumping around the environment:: * Jumping to last completion position:: @end menu @node Jump to corresponding object, Invoking image processor, Cursor jump, Cursor jump @comment node-name, next, previous, up @section Jump to corresponding object Typing @table @kbd @item [prefix] g @dots{} go to corresponding object @end table @noindent in a certain place move the cursor to the place corresponding to the La@TeX{} command of last place. YaTeX recognize the followings as pairs that have relation each other. @itemize @bullet @item @code{\begin@{@}} <-> @code{\end@{@}} @item @code{%#BEGIN} <-> @code{%#END} @item On the image-including line -> corresponding viewer or drawing tool @item @code{\label@{@}} <-> @code{\ref@{@}} @item @code{\include(\input)} -> included file @item @code{\bibitem@{@}} <-> @code{\cite@{@}} @end itemize On a @code{\begin},@code{\end} line, typing @kbd{[prefix] g} moves the cursor to the corresponding @code{\end},@code{\begin} line, if its partner really exists. The behavior on the line @code{%#BEGIN} and @code{%#END} are the same. Note that if the correspondent of @code{label/ref} or @code{cite/bibitem} exists in another file, that file have to be opened to make a round trip between references by @kbd{[prefix] g}. If you type @code{[prefix] g} on the line of @code{\include@{chap1@}}, typically in the main text, YaTeX switches buffer to @file{chap1.tex}. @table @kbd @item [prefix] 4 g @dots{} go to corresponding object in other window @end table @noindent do the same job as @kbd{[prefix] g} except it's done in other window. Note that this function doesn't work on @code{begin/end}, @code{%#BEGIN/%#END} pairs because it is meaningless. @node Invoking image processor, Jump to main file, Jump to corresponding object, Cursor jump @comment node-name, next, previous, up @section Invoking image processor @cindex{Drawing tool invocation} `image-including line' described above means such lines as @code{\epsfile@{file=foo.ps@}}. If you type @kbd{[prefix] g} on that line, YaTeX automatically searches source of `foo.ps' and invokes image viewer or drawing tool correspoinding to it. For example; if you draw an image foo.obj with Tgif and enclose its product named foo.eps by @code{\epsfile} command. Typing @kbd{[prefix] g} on @code{\epsfile} line make YaTeX invoke @code{tgif foo.obj}. How a processor is choosen is as follows. @enumerate @item If there is an expression matching with one of the pattern defined in @code{YaTeX-processed-file-regexp-alist}, extract file name from regexp group surrounded by \\(\\). (Which group corresponds is written in the cdr part of each list.) If no matches were found, do nothing. @item If there is a pattern as `%PROCESSOR' which is defined in the variable @code{YaTeX-file-processor-alist}, call that processor giving the file name with corresponding extension. @item If not, check the existence of each file which is supplied the extension in the cdr part of each list of @code{YaTeX-file-processor-alist}. If any, call the corresponding image viewer or drawing tool. @end enumerate @node Jump to main file, Jumping around the environment, Invoking image processor, Cursor jump @comment node-name, next, previous, up @section Jump to main file Typing @table @kbd @item [prefix] ^ @dots{} visit main file @item [prefix] 4^ @dots{} visit main file in other buffer @end table @cindex prefix ^ @cindex prefix 4 ^ in a sub text switch the buffer to the main text specified by @code{%#!} notation. @node Jumping around the environment, Jumping to last completion position, Jump to main file, Cursor jump @comment node-name, next, previous, up @section Jumping around the environment And these are the functions which work on the current La@TeX{} environment: @table @kbd @item M-C-a @dots{} beginning of environment @item M-C-e @dots{} @code{end} of environment @item M-C-@@ @dots{} mark environment @end table @cindex M-C-a @cindex M-C-e @cindex M-C-@@ @node Jumping to last completion position, , Jumping around the environment, Cursor jump @comment node-name, next, previous, up @section Jumping to last completion position YaTeX always memorize the position of completion into register @code{3}. So every time you make a trip to any other part of text other than you are writing, you can return to the editing paragraph by calling register-to-point with argument YaTeX-current-position-register, which is achieved by typing @kbd{C-x j 3}(by default). @node Changing and Deleting, Filling, Cursor jump, Top @comment node-name, next, previous, up @chapter Changing and Deleting These functions are for change or deletion of La@TeX{} commands already entered. @table @kbd @item [prefix] c @dots{} change La@TeX{} command @item [prefix] k @dots{} kill La@TeX{} command @end table @cindex prefix c @cindex prefix k @menu * Changing LaTeX commands:: * Killing LaTeX commands:: @end menu @node Changing LaTeX commands, Killing LaTeX commands, Changing and Deleting, Changing and Deleting @comment node-name, next, previous, up @section Changing La@TeX{} commands @kbd{[prefix] c} can change the various (La)@TeX{} commands. This can change the followings. @itemize @bullet @item Environment names @item Section-type commands @item Argument of section-type commands @item Optional parameters (enclosed by []) of section-type commands @item Font/size designators @item Math-mode's maketitle-type commands that can be inputted with image completion @end itemize Typing @kbd{[prefix] c} on one of above objects you want to change brings a suitable reading function sometimes with completion. Note: If you want to change the argument of section-type command that contains other La@TeX{} commands, type @kbd{[prefix] c} either of surrounding braces of the argument in order to make YaTeX ignore the internal La@TeX{} sequences as an object of changing. Anyway, it is very difficult to know which argument position the cursor belongs because the La@TeX{} commands can be nested and braces can freely emerge. So keep it mind to put the cursor on a brace when you are thinking of changing a complicated argument. @node Killing LaTeX commands, , Changing LaTeX commands, Changing and Deleting @comment node-name, next, previous, up @section Killing La@TeX{} commands @cindex Killing La@TeX{} commands @kbd{[prefix] k} kills the La@TeX{} commands sometimes with their arguments. Following table illustrates the correspondence of the invoking position and what is killed. @example [Invoking position] [action] \begin, \end line kill \begin,\end pairs %#BEGIN, %#END line kill %#BEGIN,%#END pairs on a Section-type command kill section-type command on a parenthesis kill parentheses @end example Note that when killing @code{\begin, \end} or @code{%#BEGIN, %#END} pair, the lines @code{\begin, \end} or @code{%#BEGIN, %#END} exist will be killed entirely. So take care not to create any line that contains more than one @code{\begin} or so. While all operations above are to kill `containers' which surround some text, universal argument (@kbd{C-u}) for these commands kills not only `containers' but also `contents' of them. See below as a sample. @example Original text: [prefix] k C-u [prefix] k Main \footnote@{note@} here. Main note here. Main here. ~(cursor) @end example @node Filling, Updation of includeonly, Changing and Deleting, Top @comment node-name, next, previous, up @chapter Filling @cindex filling @section Filling an item @cindex filling an item @cindex prefix i To fill a term (descriptive sentences) of @code{\item}, type @c @table @kbd @c @item [prefix] i @c @dots{} fill item @c @end table @table @kbd @item M-q @dots{} fill item @end table @noindent on that item. YaTeX uses the value of the variable @code{YaTeX-item-regexp} as the regular expression to search item header in itemize environment. If you make a newcommand to itemize terms(e.g. @code{\underlineitem}), put @lisp (setq YaTeX-item-regexp "\\(\\\\\\(sub\\)*item\\)\\|\\(\\\\underlineitem\\)") @end lisp @cindex YaTeX-item-regexp in your @file{~/.emacs}. If you are not familiar with regular expression for Emacs-Lisp, name a newcommand for `itemize' beginning with @code{\item} such as @code{\itembf}, not @code{\bfitem}. This function reformats the @code{\item} into `hang-indented' style. For example: @example itemize, enumerate environment: > >\item[foo] `foo' is the typical word for describing an > arbitrarily written.... description environment: > \item[bar] When the word `for' is used as an arbitrarily > word, `bar' is bound to follow it. @end example Note that the indent depth of an @code{\item} word and its descriptive paragraph are the same in latter case. If you want to use different depth, invoke fill-paragraph at the beginning of non-whitespace character(see below). @section Filling paragraph @cindex Filling paragraph @cindex M-q Fill-paragraph is little bit adapted for La@TeX{} sources. It retains from filling in certain environments where formatting leads to a disaster such as verbatim, tabular, or so. And it protects @code{\verb} expressions from being folded (The variable @code{YaTeX-verb-regexp} controls this). Besides, putting cursor on the first occurrence of non-whitespace character on a line changes the fill-prefix temporarily to the depth of the line. @node Updation of includeonly, What column, Filling, Top @comment node-name, next, previous, up @chapter Updation of @code{\includeonly} @cindex includeonly When you edit splitting source texts, the notation @example \includeonly@{CurrentEditingFileName@} @end example @noindent in the main file reduces the time of typesetting. If you want to hack other file a little however, you have to rewrite it to @example \includeonly@{OtherFileNameYouWantToFix@} @end example @noindent in the main file. YaTeX automatically detects that the current edited text is not in includeonly list and prompts you @example A)dd R)eplace %)comment? @end example in the minibuffer. Type @kbd{a} if you want to add the current file name to @code{\includeonly} list, @kbd{r} to replace \@code{includeonly} list with the current file, and type @kbd{%} to comment out the @code{\includeonly} line. @node What column, Intelligent newline, Updation of includeonly, Top @comment node-name, next, previous, up @chapter What column? @cindex what column @cindex complex tabular @cindex prefix & We are often get tired of finding the corresponding column in large tabulars. For example, @example \begin@{tabular@}@{|c|c|c|c|c|c|c|c|@}\hline Name&Position&Post No.&Addr.&Phone No.&FAX No.& Home Addr.&Home Phone\\ \hline Thunder Bird & 6 & 223 & LA & xxx-yyy & zzz-www & Japan & 9876-54321 \\ & 2 & \multicolumn@{2@}@{c|@}@{Unknown@} &&&(???) \\ \hline \end@{tabular@} @end example Suppose you have the cursor located at @code{(???)} mark, can you tell which column it is belonging at once? Maybe no. In such case, type @table @kbd @item [prefix] & @dots{} What column @end table @noindent in that position. YaTeX tells you the column header of the current field. Since YaTeX assumes the first line of tabular environment as a row of column headers, you can create a row of virtual column headers by putting them in the first line and commenting that line with @code{%}. @node Intelligent newline, Usepackage checker, What column, Top @comment node-name, next, previous, up @chapter Intelligent newline @cindex Intelligent newline @cindex ESC RET @cindex M-C-m At the end of begin-type completion of tabular[*], array, itemize, enumerate or tabbing environment, or typing @table @kbd @item ESC RET @dots{} Intelligent newline @end table @noindent in these environments inserts the contents corresponding to the current environment in the next line. (At the begin-type completion, this contents can be removed by `undo'.) In @code{tabular} environment, for example, @kbd{ESC RET} inserts the certain number of @code{&} and trailing @code{\\}, and @code{\hline} if other @code{\hline} is found in backward. Here are the list of contents vs. environments. @itemize @item @code{tabular}, @code{tabular*}, @code{array} Corresponding number of @code{&} and @code{\\}. And @code{\hline} if needed. @item @code{tabbing} The same number of @code{\>} as @code{\=} in the first line. @item @code{itemize}, @code{enumerate}, @code{description}, @code{list} @code{\item} or @code{item[]}. @end itemize Note that since this function works seeing the contents of the first line, please call this after the second line if possible. If you want to apply these trick to other environments, @code{foo} environment for example, define the function named @code{YaTeX-intelligent-newline-foo} to insert corresponding contents. That function will be called at the beginning of the next line after the newline is inserted to the current line. Since the function @code{YaTeX-indent-line} is designed to indent the current line properly, calling this function before your code to insert certain contents must be useful. See the definition of the function @code{YaTeX-intelligent-newline-itemize} as an example. @node Usepackage checker, Online help, Intelligent newline, Top @comment node-name, next, previous, up @chapter Usepackage checker @cindex usepackage When you input begint-type, section-type, maketitle-type macros with completion, and it requires some LaTeX2e package, YaTeX examines the existence of correct @code{\usepackage}. If not, YaTeX inserts the @code{\usepackage@{@}} declaration corresponding to input macro. To activate the package completion for your favarite package, set the variable @code{YaTeX-package-alist-private} correctly. Please refere the value of @code{YaTeX-package-alist-default} as an example. @node Online help, Browsing file hierarchy, Usepackage checker, Top @comment node-name, next, previous, up @chapter Online help @cindex online help @cindex prefix ? @cindex prefix / @cindex apropos @cindex keyword search YaTeX provides you the online help with popular La@TeX{} commands. Here are the key strokes for the online help. @table @kbd @item [prefix] ? @dots{} Online help @item [prefix] / @dots{} Online apropos @end table @section Online help `Online help' shows the documentation for the popular La@TeX{} commands(defaults to the commands on the cursor) in the next buffer. There are two help file, `global help' and `private help'. The former file contains the descriptions on the standard La@TeX{} command and is specified its name by variable @code{YaTeX-help-file}. Usually, the global help file should be located in public space (@code{$EMACSEXECPATH} by default) and should be world writable so that anyone can update it to enrich its contents. The latter file contains descriptions on non-standard or personal command definitions and is specified by @code{YaTeX-help-file-private}. This file should be put into private directory. @section Online apropos `Online apropos' is an equivalent of GNU Emacs's apropos. It shows all the documentations that contains the keyword entered by the user. @section When no descriptions are found... If there is no description on a command in help files, YaTeX requires you to write a description on that command. If you are willing to do, determine which help file to add and write the description on it referring your manual of (La)TeX. Please send me your additional descriptions if you describe the help on some standard commands. I might want to include it in the next distribution. @node Browsing file hierarchy, Cooperation with other packages, Online help, Top @comment node-name, next, previous, up @chapter Browsing file hierarchy @cindex hierarchy @cindex browsing When you are editing multi-file source, typing @table @kbd @item [prefix] d @dots{} browse file hierarchy @end table @noindent asks you the parent-most file (which may be defaulted) and displays the documentation hierarchy in the next window. In this buffer, the following commands are available. @table @kbd @item n @dots{} move to the next line and show its contents @item p @dots{} move to the previous line and show its contents @item N @dots{} move to the next file in the same inclusion level @item P @dots{} move to the previous file in the same inclusion level @item j @dots{} move to the next line @item k @dots{} move to the previous line @item u @dots{} move to the parent file @item . @dots{} show the current files contents in the next window @item SPC @dots{} scroll up the current file window @item DEL, b @dots{} scroll down the current file window @item < @dots{} show the beginning of the current file @item > @dots{} show the end of the current file @item > @dots{} return to the previous postion after @kbd{<} or @kbd{>} @item RET, g @dots{} open the current file in the next window @item mouse-2 @dots{} same as RET(available only with window system) @item o @dots{} other window @item 1 @dots{} delete other windows @item - @dots{} shrink hierarchy buffer window @item + @dots{} enlarge hierarchy buffer window @item ? @dots{} describe mode @item q @dots{} quit @end table Note that operations on the file contents in the next window do not work correctly when you close the corresponding file. @node Cooperation with other packages, Customizations, Browsing file hierarchy, Top @comment node-name, next, previous, up @chapter Cooperation with other packages YaTeX works better with other brilliant packages. @section gmhist @cindex gmhist @cindex command history @cindex minibuffer history When you are loading @file{gmhist.el} and @file{gmhist-mh.el}, you can use independent command history list at the prompt of preview command (@kbd{[prefix] tp}) and print command (@kbd{[prefix] tl}). On each prompt, you can enter the previous command line string repeatedly by typing @kbd{M-p}. @section min-out @cindex min-out @file{min-out}, the outline minor mode, can be used in yatex-mode buffers. If you want to use it with YaTeX, please refer the file @file{yatexm-o.el} as an example. @node Customizations, Etcetera, Cooperation with other packages, Top @comment node-name, next, previous, up @chapter Customizations @cindex customizations You can customize YaTeX by setting Emacs-Lisp variables and by making add-in functions. @menu * Lisp variables:: * Add-in functions:: * Add-in generator:: @end menu @node Lisp variables, Add-in functions, Customizations, Customizations @comment node-name, next, previous, up @section Lisp variables @cindex customizable variables You can change the key assignments or make completion more comfortable by setting the values of various variables which control the movement of yatex-mode. For example, if you want to change the prefix key stroke from @kbd{C-c} to any other sequence, set YaTeX-prefix to whatever you want to use. If you don't want to use the key sequence @kbd{C-c letter} which is assumed to be the user reserved sequence in Emacs world, set @code{YaTeX-inhibit-prefix-letter} to @code{t}, and all of the default key bind of @kbd{C-c letter} will turn to the corresponding @kbd{C-c C-letter} (but the region based completions that is invoked with @kbd{C-c Capital-letter} remain valid, if you want to disable those bindings, set that variable to 1 instead of @code{t}). @menu * All customizable variables:: * Sample definitions:: * Hook variables:: * Hook file:: @end menu @node All customizable variables, Sample definitions, Lisp variables, Lisp variables @comment node-name, next, previous, up @subsection All customizable variables @cindex all customizable variables Here are the customizable variables of yatex-mode. Each value setq-ed in @file{~/.emacs} is preferred and that of defined in @file{yatex.el} is neglected. Parenthesized contents stands for the default value. When you are to change some of these variables, see more detailed documentation of the variable by @kbd{M-x describe-variable}. @defvar YaTeX-japan Set this nil to produce all messages in English (@code{Depends on Japanese feature of Emacs}) @end defvar @defvar YaTeX-kanji-code Default buffer-file-coding-system for YaTeX modes' buffer. Set this 0 to no language conversion. Nil to preserve original coding-system. 1=Shift JIS, 2=JIS, 3=EUC, 4=UTF-8 (@code{1 or 2}) @end defvar @defvar YaTeX-prefix Prefix key stroke (@kbd{C-c}) @end defvar @defvar YaTeX-inhibit-prefix-letter Change key stroke from @kbd{C-c letter} to @kbd{C-c C-letter} (@code{nil}) @end defvar @defvar YaTeX-fill-prefix Fill-prefix used in yatex-mode (@code{nil}) @end defvar @defvar YaTeX-user-completion-table Name of user dictionary where learned completion table will be stored. (@code{"~/.yatexrc"}) @end defvar @defvar tex-command La@TeX{} typesetter command (@code{"latex"}) @end defvar @defvar dvi2-command Preview command (@code{"xdvi -geo +0+0 -s 4"}) @end defvar @defvar dviprint-command-format Command format to print dvi file (@code{"dvi2ps %f %t %s | lpr"}) @end defvar @defvar dviprint-from-format Start page format of above %f. %b will turn to start page (@code{"-f %b"}) @end defvar @defvar dviprint-to-format End page format of above %t. %e will turn to @code{end} page (@code{"-t %e"}) @end defvar @defvar makeindex-command Default makeindex command (@code{"makeindex"} (@code{"makeind"} on MS-DOS)) @end defvar @defvar YaTeX-dvipdf-command Default command name to convert .dvi to PDF (@code{"dvipdfmx"}) @end defvar @defvar YaTeX-need-nonstop Put @code{\nonstopmode@{@}} or not (@code{nil}) @end defvar @defvar latex-warning-regexp Regular expression of warning message latex command puts out (@code{"line.* [0-9]*"}) @end defvar @defvar latex-error-regexp Regular expression of error message (@code{"l\\.[1-9][0-9]*"}) @end defvar @defvar latex-dos-emergency-message Message latex command running on DOS puts at abort (@code{"Emergency stop"}) @end defvar @defvar YaTeX-item-regexp Regular expression of item command (@code{"\\\\item"}) @end defvar @defvar YaTeX-verb-regexp Regexp of verb family. Omit \\\\. (@code{"verb\\*?\\|path"}) @end defvar @defvar YaTeX-nervous T for using local dictionary (@code{t}) @end defvar @defvar YaTeX-sectioning-regexp Regexp of La@TeX{} sectioning command (@code{"\\(part\\|chapter\\*?\\|\\(sub\\)*\\(section\\|paragraph\\)\\*?\\)\\b"}) @end defvar @defvar YaTeX-fill-inhibit-environments Inhibit fill in these environments (@code{'("tabular" "tabular*" "array" "picture" "eqnarray" "eqnarray*" "equation" "math" "displaymath" "verbatim" "verbatim*")}) @end defvar @defvar YaTeX-uncomment-once T for deleting all preceding @code{%} (@code{nil}) @end defvar @defvar YaTeX-close-paren-always T for always close all parenthesis automatically, @code{nil} for only eol (@code{t}) @end defvar @defvar YaTeX-auto-math-mode Switch math-mode automatically (@code{t}) @end defvar @defvar YaTeX-math-key-list-private User defined alist, math-mode-prefix vs completion alist used in image completion (@code{nil}). See @file{yatexmth.el} for the information about how to define a completion alist. @end defvar @defvar YaTeX-default-pop-window-height Initial height of typesetting buffer when one-window. Number for the lines of the buffer, numerical string for the percentage of the screen-height. @code{nil} for half height (10) @end defvar @defvar YaTeX-help-file Global online help file name (@file{$doc-directory/../../site-lisp/YATEXHLP.eng}) @end defvar @defvar YaTeX-help-file-private Private online help file name (@file{"~/YATEXHLP.eng"}) @end defvar @defvar YaTeX-no-begend-shortcut Disable [prefix] b ?? shortcut (@code{nil)} @end defvar @defvar YaTeX-hilit-pattern-adjustment-private List of the list that contain the regular expression and the symbol of logical meaning of the string that matches the pattern. See also the value from @code{(assq 'yatex-mode hilit-patterns-alist)} and the value of @code{YaTeX-hilit-pattern-adjustment-default} (and even the document of hilit19.el). @end defvar @defvar YaTeX-sectioning-level Alist of LaTeX's sectioning command vs its height. @end defvar @defvar YaTeX-hierarchy-ignore-heading-regexp @code{YaTeX-display-hierarchy} searches for sectioning command first, and comment line secondary as a file headings. In latter case, ignore lines that match with regular expression of this variable. Default value of this variable is RCS header expressions and mode specifying line `-*- xxxx -*'. @end defvar @defvar YaTeX-skip-default-reader Non-nil for this variable skips the default argument reader of section-type command when add-in function for it is not defined (@code{nil}) @end defvar @defvar YaTeX-create-file-prefix-g When typing @kbd{prefix g} on the @code{\include} line, open the target file even if the file doesn't exist (@code{nil}) @end defvar @defvar YaTeX-simple-messages Simplyfy messages of various completions (@code{nil}) @end defvar @defvar YaTeX-hilit-sectioning-face When hilit19 and yatex19 is active, YaTeX colors the sectioning commands. This variable specifies the foreground and background color of @code{\part} macro. The default value is @code{'(yellow/dodgerblue yellow/slateblue)}. The first element of this list is for the screen when @code{hilit-background-mode} is @code{'light}, and the second element is for @code{'dark}. You should specify both color as `forecolor/backcolor'. @end defvar @defvar YaTeX-hilit-sectioning-attenuation-rate When color mode, this variable specifies how much attenuate the color density of @code{\subparagraph} compared with that of @code{\chapter} (@code{'(15 40)}) See also @code{YaTeX-hilit-sectioning-face}. @end defvar @defvar YaTeX-use-AMS-LaTeX If you use AMS-LaTeX, set to @code{t} (@code{nil}) @end defvar @defvar YaTeX-use-LaTeX2e If you use LaTeX2e, set to @code{t} (@code{t}) @end defvar @defvar YaTeX-template-file File name which is automatically inserted at creation (@code{~/work/template.tex}) @end defvar @defvar YaTeX-search-file-from-top-directory Non-nil means to search input-files from the directory where main file exists (@code{t}) @end defvar @defvar YaTeX-use-font-lock Use font-lock to fontify buffer or not (@code{(featurep 'font-lock)} @end defvar @defvar YaTeX-use-hilit19 Use hilit19 to highlight buffer or not (@code{(featurep 'hilit19)} @end defvar @defvar YaTeX-use-italic-bold YaTeX tries to search italic, bold fontsets or not (@code{t} if Emacs-20 or later). This variable is effective only when font-lock is used. (@code{(featurep 'hilit19)} @end defvar @defvar YaTeX-singlecmd-suffix Suffix which is always inserted after maketitle-type macros. @code{"@{@}"} is recommended. @end defvar @defvar YaTeX-package-alist-private Alist of LaTeX2e-package name vs. lists of macros in it. Set this alist properly and YaTeX automatically check the declaratiion of `usepackage' for corresponding macro, when you input that macro with completion. If required `usepackage' is not found, YaTeX also automatically inserts `\usepackage'. Alist is as follows; @lisp '((PackageName1 (completionType ListOfMacro) (completionType ListOfMacro)) (PackageName2 (completionType ListOfMacro) (completionType ListOfMacro...))....) @end lisp completionType is one of @code{env, section, maketitle}. Consult the value of @code{YaTeX-package-alist-default} as an example. @end defvar @defvar YaTeX-tabular-indentation At indentation by @kbd{C-i} in tabular or array environment, YaTeX put the additional spaces to the normail indentation depth. The number of additional spaces is the product of YaTeX-tabular-indentation and the number of column position in tabular. @end defvar @defvar YaTeX-noindent-env-regexp Regexp of environment names that should begin with no indentation. All verbatime-like environment name should match with. @end defvar @defvar YaTeX-ref-default-label-string Default \\ref time string format. This format is like strftime(3) but allowed conversion char are as follows; %y -> Last 2 digit of year, %b -> Month name, %m -> Monthe number(1-12), %d -> Day, %H -> Hour, %M -> Minute, %S -> Second, %qx -> alphabetical-decimal conversion of yymmdd. %qX -> alphabetical-decimal conversion of HHMMSS. Beware defualt label-string should be always unique. So this format string should have both time part (%H+%M+%S or %qX) and date part (%y+(%b|%m)+%d or %qx). @end defvar @defvar YaTeX-ref-generate-label-function Function to generate default label string for unnamed \\label@{@}s. The function pointed to this value should take two arguments. First argument is LaTeX macro's name, second is macro's argument. Here is an example for using this value. @lisp (setq YaTeX-ref-generate-label-function 'my-yatex-generate-label) (defun my-yatex-generate-label (command value) (and (string= command "caption") (re-search-backward "\\\\begin@{\\(figure\\|table\\)@}" nil t) (setq command (match-string 1))) (let ((alist '(("chapter" . "chap") ("section" . "sec") ("subsection" . "subsec") ("figure" . "fig") ("table" . "tbl")))) (if (setq command (cdr (assoc command alist))) (concat command ":" value) (YaTeX::ref-generate-label nil nil)))) @end lisp @end defvar @node Sample definitions, Hook variables, All customizable variables, Lisp variables @comment node-name, next, previous, up @subsection Sample definitions @cindex prefix key stroke @cindex fill-prefix For instance, to change the prefix key stroke to @kbd{ESC}, and name of the user dictionary @file{~/src/emacs/yatexrc}, and set @code{fill-prefix} to single TAB character, add the following @code{setq} to @file{~/.emacs}. @lisp (setq YaTeX-prefix "\e" YaTeX-user-completion-table "~/src/emacs/yatexrc" YaTeX-fill-prefix " ") @end lisp @node Hook variables, Hook file, Sample definitions, Lisp variables @comment node-name, next, previous, up @subsection Hook variables @cindex hook variables More customizations will be done by the hook-function defined in hook-variable @code{yatex-mode-hook}. This is useful to define a shortcut key sequence to enter some environments other than @code{document} and @code{enumerate} etc. The following statement defines @code{[prefix] ba} to enter @code{\begin@{abstract@}} ... @code{=end@{abstract@}} immediately. @lisp (setq yatex-mode-hook '(lambda() (YaTeX-define-begend-key "ba" "abstract"))) @end lisp You should use functions @code{YaTeX-define-key}, or @code{YaTeX-define-begend-key} to define all the key sequences of yatex-mode. @node Hook file, , Hook variables, Lisp variables @comment node-name, next, previous, up @subsection Hook file @cindex hook file You can stuff all of YaTeX related expressions into a file named @file{yatexhks.el} if you have a lot of codes. YaTeX automatically load this file at the initialization of itself. Using @file{yatexhks.el} makes @code{yatex-mode-load-hook} unnecessary. @node Add-in functions, Add-in generator, Lisp variables, Customizations @comment node-name, next, previous, up @section Add-in functions @cindex add-in functions @cindex yatexadd.el You can easily define a function to input detailed arguments with completion according to La@TeX{} environments or commands. @c @node What is add-in functions?, , Add-in functions, Add-in functions @comment node-name, next, previous, up @subsection What is add-in functions? @cindex tabular When you input @code{tabular} environment, don't you think ``I want YaTeX to complete its argument toward my favorite one such as @code{@{|c|c|c|@}}...''? Yes, you can define the function to complete arguments for any environment and any La@TeX{} commands. @subsection Procedure Here is the procedure to define add-in functions. @enumerate @item Define the function @item Put the function into @file{yatexhks.el} @end enumerate @menu * How the add-in function works:: * How the function is called:: * Useful functions for creating add-in:: * Contribution:: @end menu @node How the add-in function works, How the function is called, Add-in functions, Add-in functions @comment node-name, next, previous, up @subsection How the add-in function works There are three types of add-in. @enumerate @item Option add-in @item argument add-in @item enclosing add-in @end enumerate @dfn{Option add-in} returns the La@TeX{}'s optional parameters such as optional strings after @code{\begin@{ENV@}}, optional strings between a section-type command and its first argument, and optional strings just after type maketitle-type command. The following illustrates the name of add-in functions, where underlined strings are generated by add-in functions. @display \begin@{table@}[ht] (Function name: YaTeX:table) ~~~~ \put(100,200)@{@} (Function name: YaTeX:put) ~~~~~~~~~ \sum_@{i=0@}^@{n@} (Function name: YaTeX:sum) ~~~~~~~~~~ @end display Obviously, the function name is decided by concatenating the prefix `YaTeX:' and La@TeX{} command's name. Another add-in type is @dfn{argument add-in}, which completes arguments for section-type commands. @display \newcommand@{\foo@}@{bar@} (Function name: YaTeX::newcommand) ~~~~ ~~~ @end display When the section-type command is inputted, the function named by concatenating `YaTeX::' and section-type command, is called automatically with an integer argument which indicates which argument of section-type command is being read. Thus the add-in should determine the job referring the value of its argument. @dfn{enclosing add-in} is for modifying and/or checking the region that will be enclosed by section-type commands via @kbd{[prefix] S}. An enclosing add-in function will be called with two arguments, beginning of the enclosed region and end of the region. Suppose you want to enclose the existing text @code{(a+b)/c} by @code{\frac@{@}}. @display a/c | | A B @end display You do set-mark-command at point A and then move to point B. Typing @kbd{[prefix] S} and input @code{frac} enclose the region like this; @display \frac@{a/c@} @end display Normally, the expression @code{a/c} is translated to @code{\frac@{a@}@{c@}}. An enclosing add-in is useful for modifying @code{/} to @code{@}@{}. @menu * Defining option-add-in:: * Defining argument-add-in:: * Defining enclosing-add-in:: @end menu @node Defining option-add-in, Defining argument-add-in, How the add-in function works, How the add-in function works @comment node-name, next, previous, up @subsubsection Defining `option add-in' If you want @code{@{|c|c|c|@}} for all @code{tabular} environment, @lisp (defun YaTeX:tabular () "@{|c|c|c|@}") @end lisp @noindent is enough. If you want more complicated format, define as below. @lisp (defun YaTeX:tabular () "@{@@@{\\vrule width 1pt\\ @}|||@@@{\\ \\vrule width 1pt@}@}") @end lisp @noindent Note that the character @code{\} must be described as @code{\\} in Emacs-Lisp. The next example reads the tabular format from keyboard. @lisp (defun YaTeX:tabular () (concat "@{" (read-string "Rule: ") "@}")) @end lisp @node Defining argument-add-in, Defining enclosing-add-in, Defining option-add-in, How the add-in function works @comment node-name, next, previous, up @subsubsection Defining `argument add-in' This section describes how to define the add-in function for @code{\newcommand}. The first argument of @code{\newcommand} begins always with @code{\}. The second argument is usually so complex that we can not edit them in the minibuffer. Here is the created function considering this. @lisp (defun YaTeX::newcommand (n) ;n is argument position (cond ((= n 1) ;1st argument is macro name (read-string "Command: " "\\")) ;initial input `\' ((= n 2) "") ;do nothing when reading arg#2 (t nil))) @end lisp Note that when the `argument add-in' function return `nil', normal argument reader will be called. @node Defining enclosing-add-in, , Defining argument-add-in, How the add-in function works @comment node-name, next, previous, up @subsubsection Defining `enclosing add-in' This section describes how to define the add-in function for text enclosed by @code{\frac@{@}}. When enclosing the text @code{5/3} by @code{\frac@{@}}, you might want to replace @code{/} with @code{@}@{}. Enclosing function @code{YaTeX::frac-region} is called with two arguments, beginning of enclosed text and end of enclosed text. The function is expected to replace @code{/} with @code{@}@{}. Here is an example expression. @lisp (defun YaTeX::frac-region (beg end) (catch 'done (while (search-forward "/" end t) (goto-char (match-beginning 0)) (if (y-or-n-p "Replace this slash(/) with `@}@{'") (throw 'done (replace-match "@}@{"))) (goto-char (match-end 0))))) @end lisp @node How the function is called, Useful functions for creating add-in, How the add-in function works, Add-in functions @comment node-name, next, previous, up @subsection How the function is called YaTeX calls the add-in functions for specified begin-type, section-type, and maketitle-type command, if any. `Option add-in' functions for begin-type are called when @code{\begin@{ENV@}} has been inserted, functions for section-type are called just before input of the first argument, and functions for maketitle-type is called after maketitle-type command has been inserted. `Argument add-in' functions are called at each entry of arguments for section-type commands. @node Useful functions for creating add-in, Contribution, How the function is called, Add-in functions @comment node-name, next, previous, up @subsection Useful functions for creating add-in Many add-in functions for typical La@TeX{} commands are defined in @file{yatexadd.el}. Those are also useful as references. Here are the short descriptions on useful functions, where [F] means function, [A] means arguments, [D] means description. @table @kbd @item [F] YaTeX:read-position @itemx [A] Character list which can show up in the brackets @itemx [D] Return the location specifier such as `[htb]'. When nothing is entered, omit [] itself. If the possible characters are "htbp", call this function as @code{(YaTeX:read-position "htbp")} @item [F] YaTeX:read-coordinates @itemx [A] Base prompt, X-axis prompt, Y-axis prompt (each optional) @itemx [D] Read the coordinates with the prompt ``BasePrompt X-axisPrompt:'' for X-axis, ``BasePrompt Y-axisPrompt:'' for Y-axis, and return it in the form of ``(X,Y)''. The default prompts are @code{Dimension}, @code{X}, @code{Y} respectively. @item [F] YaTeX:check-completion-type @itemx [A] One of the symbols: 'begin, 'section, or 'maketitle @itemx [D] Check the current completion type is specified one and cause error if not. The variable @code{YaTeX-current-completion-type} holds the symbol according to the current completion type. @end table @node Contribution, , Useful functions for creating add-in, Add-in functions @comment node-name, next, previous, up @subsection Contribution If you make your own pretty function and you let it be in public, please send me the function. I'm going to include it in the next release. @node Add-in generator, , Add-in functions, Customizations @comment node-name, next, previous, up @section Add-in generator First, don't forget to read the section of add-in functions @ref{Add-in functions}. If you easily understand how to define them, there's no need to read this section. But being not familiar with Emacs-Lisp, when you don't have clear idea what to do, this section describes how to get YaTeX make add-in function. There are two methods of generation. One is for fully interactive generator for beginners and another requires little knowledge of Emacs-Lisp. @subsection Generator for beginners The former generator is called by @center @kbd{M-x YaTeX-generate} @noindent strokes. All you have to do is follow the guidances. Defying them may cases the disaster (I wonder what is it???). So when you make some mistake, it is recommendable to type @kbd{C-g} and start afresh. @subsection Simple generator The latter generator is invoked by the next sequence. @center @kbd{M-x YaTeX-generate-simple} This generator can make both ``option add-in'' and ``argument add-in'' (@emph{refer the section add-in functions} @ref{How the add-in function works}), whereas @code{YaTeX-generate} cannot make ``argument addin''. For example, assume you have the LaTeX command as follows. @example \epsinput[t](250,50)@{hoge.eps@}@{plain@}@{Picture of foo@} (A) (B) (1) (2) (3) (A)Optional parameter to specify the position One of t(top), b(bottom), l(left), r(right) (B)Maximum size of frame (1)1st argument is filename of EPS file (2)2nd argument indicates plain do nothing frame make frame around image dframe make double-frame around image for included EPS file. (3)Caption for the picture @end example Now get start with generation. Typing @kbd{M-x YaTeX-generate-simple} brings the prompt: @display (O)ption? (A)rgument? @end display @subsubsection Generating ``option add-in'' @cindex option add-in Since (A), (B) above are optional argument, all we have to do to complete them is define the option add-in for them. Let's generate the function to complete (A). @display M-x YaTeX-generate-simple RET epsinput RET o @end display @noindent Typing as above leads the next prompt. @display Read type(1): (S)tring (C)omplete (F)ile ([)option (P)osition co(O)rd. (q)uit @end display @noindent This asks that ``Which type is the completion style of 1st argument?''. Here are the possible completion style. @table @code @item String read plain string @item Complete read with completion @item File read file name @item Option read optional string (if string omitted, omit [] too) @item Position read positional option (like [htbp]) @item Coord. read coordinates @item Quit quit from generating @end table Since (A) is the optional argument to specify the location of included EPS file, the completion style is @code{Position}, and the possible characters are t, b, l, and r. To tell these information to generator, operate as follows. @display Read type(1).... p Acceptable characters: tblr RET @end display (B) is coordinate. So its completion style is coOrd. We want a prompt meaning ``Maximum size'' when completion. @display Read type(2).... o Prompt for coordinates: Max size RET @end display That's all for optional argument. Select quit. @display Read type(3).... q @end display Then the generated option add-in function for \epsinput will be shown in the next window. @subsubsection Generating ``argument add-in'' @cindex argument add-in Next, create the argument add-in. The arguments for \epsinput are EPS file name, framing style, and caption string in sequence. @display M-x YaTeX-generate-simple RET epsinput RET a @end display Above key strokes bring the prompt that asks the number of argument. Answer it with 3. @display How many arguments?: 3 RET @end display Then the generator asks the completion style and prompt for completion. Answer them. @kbd{f} for FileName and prompt string. @display Read type(1).... f Prompt for argument#1 EPS file name RET @end display The second argument is one of selected symbol. So the completion type is @code{Completion}. @display Read type(2).... c Prompt for argument#2 Include style RET @end display Then all the candidates ready to be read. Type single RET after entering all. @display Item[1](RET to exit): plain RET Item[2](RET to exit): frame RET Item[3](RET to exit): dframe RET Item[4](RET to exit): RET @end display The following prompt asks whether the entered string must belong to candidates or not. In this case, since the argument must be one of @code{plain}, @code{frame}, and @code{dframe}, type @code{y}. @display Require match? (y or n) y @end display The last argument is the caption string for which any completion is needed. @display Read type(3).... s Prompt for argument#3 Caption RET default: Figure of RET @end display Finally we'll get the argument add-in in the next window. @subsection Contribution If you get your own pretty function and you let it be in public, please steel yourself in the happy atmosphere and do not send me the function. I do know it is not fine because it is generated by yatexgen:-p. @node Etcetera, Copying, Customizations, Top @comment node-name, next, previous, up @chapter Etcetera The standard completion tables provided in @file{yatex.el} contain a few La@TeX{} commands I frequently use. This is to lessen the key strokes to complete entire word, because too many candidates rarely used often cause too many hits. Therefore always try to use completion in order to enrich your dictionary, and you will also find `Wild Bird' growing suitable for your La@TeX{} style. The package name `Wild Bird' is the English translation of Japanese title `Yachou', which is a trick on words of Japanese. @node Copying, , Etcetera, Top @comment node-name, next, previous, up @chapter Copying This program is distributed as a free software. You can use/copy/modify/redistribute this software freely but with NO warranty to anything as a result of using this software. Adopting code from this program is also free. But I would not do contract act. Any reports and suggestions are welcome as long as I feel interests in this software. My possible e-mail address is `yuuji@@yatex.org'. (as of Jan.2004) And there is mailing list for YaTeX. Although the common language is Japanese, questions in English will be welcome. To join the ML, send the mail whose subject is `append' to the address `yatex@@yatex.org. If you have some question, please ask to `yatex-admin@@yatex.org'. The specification of this software will be surely modified (depending on my feelings) without notice :-p. @flushright HIROSE Yuuji @end flushright @bye Local variables: mode: texinfo fill-prefix: nil fill-column: 74 End: yatex_1.77+dfsg1/docs/yahtmlj0000644000175000017500000004142412126311417014700 0ustar kurakuraInfo file: yahtmlj, -*-Text-*- produced by `texinfo-format-buffer' from file `yahtmlj.tex' using `texinfmt.el' version 2.38 of 3 July 1998. START-INFO-DIR-ENTRY * yahtml: (yahtmlj). Yet Another html-mode for Emacs (Japanese). END-INFO-DIR-ENTRY  File: yahtmlj, Node: Top, Next: Intro, Prev: (dir), Up: (dir) * Menu: * Intro:: はじめに * Installation:: インストール * Command Invocation:: 外部コマンド起動 * Completion:: 補完入力 * Jump:: カーソルジャンプ * Changing and Deleting:: 変更と削除 * CSS Support:: スタイルシート補完 * Customizations:: カスタマイズ変数一覧 * Copying:: とりあつかい * Concept Index:: 索引  File: yahtmlj, Node: Intro, Next: Installation, Prev: Top, Up: Top はじめに ******** yahtmlは GNU Emacs 上で HTML文書を作成する時に、繁雑なHTMLタグの入力を補完 機能によってスムーズに行えるようにするだけでなく、weblintなどの構文チェッ クプログラム、カーソル位置のURLやファイル名に依存したブラウザ/イメージヴュー アの起動などを Emacs 編集画面中から行えるようにするパッケージです。 (このInfoは未完成です(__)…)  File: yahtmlj, Node: Installation, Next: Command Invocation, Prev: Intro, Up: Top インストール ************ * Menu: * yahtml起動のための設定:: * lintプログラム/ブラウザ/イメージヴューア環境等の設定:: * WWWページ環境用変数の設定::  File: yahtmlj, Node: yahtml起動のための設定, Next: lintプログラム/ブラウザ/イメージヴューア環境等の設定, Prev: Installation, Up: Installation yahtml起動のための設定 ====================== `~/.emacs'に下の2項目を加えます。 (setq auto-mode-alist (cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist)) (autoload 'yahtml-mode "yahtml" "Yet Another HTML mode" t) 次にyahtmlに必要なファイル(`yahtml.el', `yatexlib.el', `yatexprc.el') を置 くディレクトリを load-path に加えます。たとえば、 `~/src/emacs/yahtml'に置 くのであれば、 (setq load-path (cons (expand-file-name "~/src/emacs/yahtml") load-path)) などとします。 以上の設定により、拡張子が .html であるファイルを編集すると自動的に yahtml がロードされます。yahtmlが正常に起動できたときはモードラインの表示 が「yahtml」に変わります。  File: yahtmlj, Node: lintプログラム/ブラウザ/イメージヴューア環境等の設定, Next: WWWページ環境用変数の設定, Prev: yahtml起動のための設定, Up: Installation lintプログラム/ブラウザ/イメージヴューア環境等の設定 ==================================================== 利用する外部プログラムなどに関する以下の変数を確認し、必要なら正しい値に変 更します(括弧内はデフォルト値)。 `yahtml-www-browser' ... 起動するブラウザのコマンド名(netscape) `yahtml-image-viewer' ... 起動する画像ビューアのコマンド名(xv) `yahtml-lint-program' ... 構文チェックプログラムのコマンド名(jweblint) `yahtml-kanji-code' ... htmlファイルの漢字コード  File: yahtmlj, Node: WWWページ環境用変数の設定, Prev: lintプログラム/ブラウザ/イメージヴューア環境等の設定, Up: Installation WWWページ環境用変数の設定 ========================= ホームページとなるファイルが存在するPATH名に関する変数を設定します。 `yahtml-path-url-alist' ... ファイルシステム上のPATH名と、URLの対応表 `yahtml-directory-index' ... URL指定でファイル名を省略したときに表示されるインデックス ファイル名(NCSA系httpdなら `index.html', CERN系なら`Welcome.html'が一 般的) 変数 `yahtml-path-url-alist' の設定例を示します。例えば、自宅では、 `/home/yuuji/http/' が `http://localhost/~yuuji' で参照でき、職場では `/usr/home/yuuji/www/' が`http://www.keio.ac.jp/~yuuji/' で参照できるよう になっている場合は以下のように設定します。 (setq yahtml-path-url-alist '(("/home/yuuj/http" . "http://localhost/~yuuji") ("/usr/home/yuuj/www" . "http://www.keio.ac.jp/~yuuji"))) この対応組はいくらでも設定することができます。  File: yahtmlj, Node: Command Invocation, Next: Completion, Prev: Installation, Up: Top 外部コマンド起動 **************** HTMLファイル編集にかかわるいくつかのコマンドを即座に呼ぶことができます。 `[prefix] t j' ... HTML構文チェッカ(jweblint)起動 `[prefix] t p' ... 現在のページを対象としたブラウザ起動 `[prefix] t r' ... 現在のページがブラウザに表示されているときのreload指定  File: yahtmlj, Node: Completion, Next: Jump, Prev: Command Invocation, Up: Top 補完入力 ******** 「野鳥」で利用できる、「begin型補完」、「section型補完」、「large型補完」、 「maketitle型補完」、「アクセント補完」と全く同じキー操作で対応するHTMLタ グの補完入力ができます。それぞれの型の補完は順に、「複数行に渡るタグ入力」、 「空要素タグ(imgなど)の補完」、「一行内での開始/終了タグの入力」、「空要素 空属性タグの入力」、「文字参照入力」に対応しています。具体的には `[prefix] b (野鳥のbegin補完に対応)' ...
    のように開始タグと終了タグを二行に渡って書きたい場合の補完を指します。 おもにブロック型タグが補完候補に含まれます。 `[prefix] s (野鳥のsection型補完に対応)' ... photo のように終了タグを持たず、かつ属性値のみで機能を指定するタグを補完し ます。補完候補としては、img, input が存在します。 `[prefix] l (野鳥のlarge型補完に対応)' ... begin型補完とほぼ同じですが、 のように一行内に開始/終了タグを入れたいときに利用します。 `[prefix] m (野鳥のmaketitle型補完に対応)' ... 要素も属性値も持たないタグを補完入力します。
    などが補完候補に相当します。 `[prefix] a (野鳥のアクセント補完に対応)' ... エンティティ参照による文字表記を入力するときに用います。 デフォルトでは < (<), > (>), & (&), " ("), ' ('), ブランク ( ) の補完入力が行えます。  File: yahtmlj, Node: Jump, Next: Changing and Deleting, Prev: Completion, Up: Top カーソルジャンプ **************** 文書中のいろいろな場所で `[prefix] g' ... 対応するオブジェクトにジャンプ を押すことにより、カーソル位置のHTML構文に対応する場所にジャンプします。対 応関係が存在すると解釈されるコマンドには以下のものがあります。 * `' ←→ `' * `' → 対応するviewer起動 * `
    ' → リンク先へのポイント移動 * `' → Javaソースプログラムへの移動  File: yahtmlj, Node: Changing and Deleting, Next: CSS Support, Prev: Jump, Up: Top 変更/削除 ********* * Menu: * 対タグの変更:: * 文字参照への変更:: * リジョン内文字のURLencode:: * td括り/tr括り::  File: yahtmlj, Node: 対タグの変更, Next: 文字参照への変更, Prev: Changing and Deleting, Up: Changing and Deleting 対タグの変更 ============ 文書中のいろいろな場所で `[prefix] c' ... 対応するタグ等を変更 を押すことにより、カーソル位置のHTML構文に応じた記述内容の変更を行います。 カーソル位置と変更する内容の対応は以下の通りです。 * `'〜`' ... `TAG' の変更 * `photo' などの属性値 ... 属性値の変更  File: yahtmlj, Node: 文字参照への変更, Next: リジョン内文字のURLencode, Prev: 対タグの変更, Up: Changing and Deleting 文字参照への変更 ================ 文字としての < や > を表現するときは、文字参照を用いて< や > と表記 する必要がありますが、HTML以外のファイルからこれらの文字を含むテキストを張 り込んだ場合などに、これらの文字を一括して文字参照形式に変換できます。 `[prefix] ;' ... 指定した領域の文字参照に置き換えるべき文字の置換 `[prefix] :' ... 指定した領域の文字参照を参照文字そのものに置換([prefix] ; の逆変換)  File: yahtmlj, Node: リジョン内文字のURLencode, Next: td括り/tr括り, Prev: 文字参照への変更, Up: Changing and Deleting リジョン内文字のURLencode ========================= `[prefix] #' ... 指定した領域内に URLencode すべき文字があればそれらをエン コード表記に置換。  File: yahtmlj, Node: td括り/tr括り, Prev: リジョン内文字のURLencode, Up: Changing and Deleting td括り/tr括り ============= 空白区切りで書いた表形式の行レコードを 括りの並び,あるいはそれらをさ らに で括った行並びに変換できます。 `[prefix] }' ... 現在のリジョンにあるデータを空白区切りごとに ... で括る `[prefix] ]' ... 現在のリジョンにある行を上記td括りをほどこしてからさらに行ごと に ... で括るデフォルトでは空白区切りですが,これを変えるときは Delimiter: の問い合わせに区切り文字を指定します。たとえばカンマ(,) を指定 するとCSVから表を作ることができます。 td以外の要素,具体的には th で括りたい場合は universal-argument (`C-u') を つけて上記2つのコマンドを呼びます。どの要素で括るかの質問が増えるのでそれ に th と入れれば,各フィールドを ... で括ります。もし,第1フィー ルドのみ th で,残りを全部 td 括りにしたいときは thd と入力して下さい。  File: yahtmlj, Node: CSS Support, Next: Customizations, Prev: Changing and Deleting, Up: Top CSS(スタイルシート)サポート *************************** * Menu: * CSS-class completion:: * Reread CSS file::  File: yahtmlj, Node: CSS-class completion, Next: Reread CSS file, Prev: CSS Support, Up: CSS Support CSSクラス名補完 =============== HTML屋はCSS(Cascading Style Sheets)のクラス名を補完入力することができます。 スタイル定義として h1.foo, h2.foo { background-color: 0xffffff; } h1.bar, h2.bar { font-size: 120%; } のようなものがあった場合に、h1またはh2タグを [prefix] b や [prefix] l で補 完入力した場合に、それらに有効な class 名である foo, bar を候補として補完 入力することが可能です。また .caution { font-size: 120%; background-color: 0xc00000;} のような全てのエレメントに働くclassが定義されていた場合は、全てのタグの補 完入力時にclass参照入力を求められます。これが煩わしい場合はエレメント名入 力確定のときにリターンキー(またはC-m)ではなく、C-jを押せばclass補完入力を キャンセルできます。たとえば [prefix] l 行内タグ補完を起動 (または[prefix] l SPC) tt をいれたいのでttと入力 C-m とした場合は続いて class= と補完プロンプトが出ますが、 [prefix] l 行内タグ補完を起動 (または[prefix] l SPC) tt をいれたいのでttと入力 C-j と最後を `C-j' で入力した場合は class 補完プロンプトは出ません。  File: yahtmlj, Node: Reread CSS file, Prev: CSS-class completion, Up: CSS Support CSS定義ファイルの読み直し ========================= htmlファイルを編集中にCSS定義ファイルを修正し、追加したclassを補完候補とし て直ちに読み込ませたい場合は、`M-x yahtml-mode' として再起動を行ってくださ い。  File: yahtmlj, Node: Customizations, Next: Copying, Prev: CSS Support, Up: Top カスタマイズ ************ yahtmlの動作を制御する変数について説明します。 * Menu: * All customizable variables:: カスタマイズ変数一覧 * Hook variables:: hook変数  File: yahtmlj, Node: All customizable variables, Next: Hook variables, Prev: Customizations, Up: Customizations カスタマイズ変数一覧 ==================== -- Variable: yahtml-prefix yahtml-mode 中のプリフィクスキー (`\C-c') -- Variable: yahtml-image-viewer imgで参照している画像ファイルを表示するときに起動するコマンド (xv) -- Variable: yahtml-www-browser `[prefix]g' で外部ページを表示するときに起動するブラウザ (netscape) -- Variable: yahtml-kanji-code デフォルトの漢字コード。1=sjis, 2=jis, 3=euc, 4=utf-8 (2) .htaccess ファイルに AddType "text/html; charset=xxx" .html の記述があった場合はそれ に従う -- Variable: yahtml-fill-column auto-fillするときのカラム数 (72) -- Variable: yahtml-fill-prefix yahtml-mode 固有のfill-prefix (`nil') -- Variable: yahtml-path-url-alist OSのファイルシステム上でのフルパス名と、その外部公開時のURLの対応表。 -- Variable: yahtml-directory-index サーバアクセス時ファイル名を省略したときにデフォルトで開かれるインデッ クスファイルの名前。多くの場合 index.html。(`"index.html"') -- Variable: yahtml-lint-program HTML構文チェックプログラム。(`"jweblint"') -- Variable: yahtml-hate-too-deep-indentation ネストした列挙系環境でのインデントが深すぎるときにtにする。(`nil') -- Variable: yahtml-always-/p `

    ' をいれたら必ず `

    ' したい人向け。`nil' -- Variable: yahtml-p-prefered-env-regexp 自動的に `

    ' を入れて欲しい環境。 (`"^\\(body\\|dl\\|blockquote\\)"') -- Variable: yahtml-template-file 新規HTMLファイル作成時に自動的に挿入して欲しいファイル名。 `"~/http/template.html"' -- Variable: yahtml-prefer-upcases タグに大文字を使いたい。`nil' -- Variable: yahtml-prefer-upcase-attributes 属性指定子に大文字を使いたい。`nil' -- Variable: yahtml-server-type Apache系のサーバを利用している場合は 'apache をセットする。 ./.htaccess を参照するかどうかを決定する。`'apache' -- Variable: yahtml-apache-access-file `yahtml-server-type' が `'apache' のときにアクセス制限ファイル名を指 定。`".htaccess"' -- Variable: yahtml-shell-command-option シェルで別コマンドを起動するときのオプション。 -- Variable: yahtml-translate-hyphens-when-comment-region 領域コメントアウトをするときに既に存在するハイフンを `-' に変更す るかどうか。(`t') -- Variable: yahtml-entity-reference-chars-alist エンティティ参照(Entity Reference)で記述すべき文字群を`'(?文字 . "エ ンティティ表記")' という形式を列挙したalistで並べる。デフォルトで `<', `>', `&', `'', `"' に対するalistが設定されているので、追加したい 分だけを記述すれば良い。cdr部 `"エンティティ表記"' は、先頭の `&' と 末尾の`;' は含めずに書く。 -- Variable: yahtml-faithful-to-htmllint 構文チェッカとして htmllint を利用する場合ちょっとした余計な空白など に対しても警告を示すので、これを回避するときにはこの変数を`t'にする。 -- Variable: yahtml-use-css CSSの補完機能を使うかどうか (`t') -- Variable: yahtml-image-inspection-bytes 画像ファイルのサイズを調べるときに読み込むバイト数 (`10000') -- Variable: yahtml:img-default-alt-format のALT属性のデフォルト文字列の書式。%xは画像の幅、%yは画像 の高さ、%sはファイルサイズに置換される (`"%xx%y(%sbytes)"') -- Variable: yahtml-escape-chars href補完などのときに予約文字をURLエンコードするか; 'askのときは確認し てから置換する (`'ask') -- Variable: yahtml-use-font-lock ソースの色づけパッケージとして font-lock を利用するか(`(featurep 'font-lock)') -- Variable: yahtml-use-hilit19 ソースの色づけパッケージとして hilit19 を利用するか(`(featurep 'hilit19)') -- Variable: yahtml-indentation-boundary インデント計算を打ち切ってよい境界となる正規表現(`"^\\s *"')  File: yahtmlj, Node: Hook variables, Prev: All customizable variables, Up: Customizations hook変数 ========  File: yahtmlj, Node: Copying, Next: Concept Index, Prev: Customizations, Up: Top 取り扱い ******** 本プログラムはフリーソフトウェアです。本プログラムを使用して生じたいかな る結果に対しても作者は責任を負わないこととします。転載等に関しては制限いた しません。常識的に扱ってください。また、使用している旨をメイルでお知らせい ただくと、作者は喜んでサポートに励むことでしょう。 苦情、希望、バグ報告、感想等は歓迎いたします。連絡は yuuji@yatex.org ま で(2000年12月現在)。継続的に使用してくださる方はメイリングリスト「fj野鳥の 会」に是非加入してください。加入方法については本パッケージの `docs/htmlqa' ファイルの「その他」の章を御覧ください。 仕様は、予告なく確実に(気分次第で)変更されます:-p。 広瀬雄二  File: yahtmlj, Node: Concept Index, Prev: Copying, Up: Top 索引 **** * Menu: * カスタマイズ[かすたまいす]: Customizations. 4. * キーアサイン[きいあさいん]: Customizations. 4. * Demacs: Intro. 4. * HTML屋[HTMLや]: Intro. 4. * LaTeX: Intro. 4. * Mule: Intro. 4.  Tag table: Node: Top260 Node: Intro729 Node: Installation1008 Node: yahtml起動のための設定1196 Node: lintプログラム/ブラウザ/イメージヴューア環境等の設定1850 Node: WWWページ環境用変数の設定2350 Node: Command Invocation3121 Node: Completion3448 Node: Jump4432 Node: Changing and Deleting4831 Node: 対タグの変更5005 Node: 文字参照への変更5355 Node: リジョン内文字のURLencode5738 Node: td括り/tr括り5972 Node: CSS Support6601 Node: CSS-class completion6799 Node: Reread CSS file7783 Node: Customizations8005 Node: All customizable variables8229 Node: Hook variables11227 Node: Copying11339 Node: Concept Index11842  End tag table yatex_1.77+dfsg1/docs/yahtmle0000644000175000017500000004113212126311417014667 0ustar kurakuraInfo file: yahtmle, -*-Text-*- produced by `texinfo-format-buffer' from file `yahtmle.tex' using `texinfmt.el' version 2.38 of 3 July 1998. START-INFO-DIR-ENTRY * yahtml-e: (yahtmle). Yet Another html-mode for Emacs (English). END-INFO-DIR-ENTRY  File: yahtmle, Node: Top, Next: Intro, Prev: (dir), Up: (dir) * Menu: * Intro:: Introduction * Installation:: Installing yahtml * Command Invocation:: Using External Commands * Completion:: Input with Completion * Jump:: Moving the Cursor * Changing and Deleting:: Changing and Deleting * CSS Support:: Style Sheet Support * Customizations:: List of Customize Variables * Copying:: Copyright * Concept Index:: Index  File: yahtmle, Node: Intro, Next: Installation, Prev: Top, Up: Top Introduction ************ yahtml is a package to support creating HTML documents on Emacsens. Easy input of elements (tags) by completion, syntax checking with programs like weblint, and invoking the appropriate browser or image viewer depending on the cursor position is its main features. (This Info is still incomplete)  File: yahtmle, Node: Installation, Next: Command Invocation, Prev: Intro, Up: Top Installing yahtml ***************** * Menu: * Setting up yahtml:: * Setting environments for weblint browsers and image viewers:: * Setting environment variables for WWW pages::  File: yahtmle, Node: Setting up yahtml, Next: Setting environments for weblint browsers and image viewers, Prev: Installation, Up: Installation Setting up yahtml ================= Add the following to `~/.emacs' (setq auto-mode-alist (cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist)) (autoload 'yahtml-mode "yahtml" "Yet Another HTML mode" t) Next, add to load-path the directory with the yahtml files (`yahtml.el', `yatexlib.el', `yatexprc.el'). For example, if you put them in `~/src/emacs/yahtml', (setq load-path (cons (expand-file-name "~/src/emacs/yahtml") load-path)) is what you add. By this, yahtml will be automatically loaded when editing files with .html extensions. "yahtml" will be displayed on the mode line if no errors occurred.  File: yahtmle, Node: Setting environments for weblint browsers and image viewers, Next: Setting environment variables for WWW pages, Prev: Setting up yahtml, Up: Installation Setting environments for weblint, browsers, and image viewers ============================================================= Check the variables for invoking external commands and modify as needed. Defaults are in parenthesis. `yahtml-www-browser' ... browser command name (netscape) `yahtml-image-viewer' ... image viewer command name (xv) `yahtml-lint-program' ... syntax check programs command name (jweblint) `yahtml-kanji-code' ... kanji code for HTML files  File: yahtmle, Node: Setting environment variables for WWW pages, Prev: Setting environments for weblint browsers and image viewers, Up: Installation Setting environment variables for WWW pages =========================================== Variables regarding path names for files that will be your home page. `yahtml-path-url-alist' ... list of matching path name on file system and URLs `yahtml-directory-index' ... index file displayed when none is given in URL. Usually `index.html' on NCSA type httpd and `Welcome.html' on CERN types. Examples for `yahtml-path-url-alist'. If `/home/yuuji/http/' is `http://localhost/~yuuji' at home and `/usr/home/yuuji/www/' is `http://www.keio.ac.jp/~yuuji/' at work, then (setq yahtml-path-url-alist '(("/home/yuuji/http" . "http://localhost/~yuuji") ("/usr/home/yuuji/www" . "http://www.keio.ac.jp/~yuuji"))) Any number of additions can be made to this list.  File: yahtmle, Node: Command Invocation, Next: Completion, Prev: Installation, Up: Top Invoking external commands ************************** For easy use of commands that are handy when editing HTML files. `[prefix] t j' ... Invoke HTML syntax checker (jweblint) `[prefix] t p' ... Display current page in browser `[prefix] t r' ... Reload current page if browser is already running  File: yahtmle, Node: Completion, Next: Jump, Prev: Command Invocation, Up: Top Completion Input **************** Completion input of HTML elements is done through the same key strokes as YaTeX's begin-type completion, section-type completion, large-type completion, maketitle-type completion, and accent completion. Corresponding elements in this order is; elements that span multiple lines, empty elements such as img, tags that start and end in a single line, elements with no attributes or contents, and special or symbol entities. `[prefix] b (YaTeX begin-type completion)' ...

    Completion for elements that the start tag and the end tag span multiple lines. Mostly block-level elements. `[prefix] s (YateX section-type completion)' ... photo Completion for elements that do not have end tags and require only attributes. Possible completions are, , . `[prefix] l (YaTeX large-type completion)' ... Similar to begin-type completion but used for elements that start and end on a single line. `[prefix] m (YaTeX maketitle-type completion)' ... Completion for elements without attributes or contents. Possible completion is
    `[prefix] a (YaTeX accent completion)' ... Used to enter special or symbol entities. By default completion for < (<), > (>), & (&), " ("), ' ('), blank ( ) is possible.  File: yahtmle, Node: Jump, Next: Changing and Deleting, Prev: Completion, Up: Top Cursor Movement *************** By using `[prefix] g' ... move to corresponding object the cursor will go to the corresponding object according to the context. Recognized contexts are * `' <--> `' * `' -> invoke viewer * `' -> move cursor to linked target * `' -> open Java source  File: yahtmle, Node: Changing and Deleting, Next: CSS Support, Prev: Jump, Up: Top Changing and Deleting ********************* * Menu: * Changing tags in pairs:: * Changing entities:: * URLencoding of strings within region:: * td-enclosure/tr-enclosure::  File: yahtmle, Node: Changing tags in pairs, Next: Changing entities, Prev: Changing and Deleting, Up: Changing and Deleting Changing tags in pairs ====================== By using `[prefix] c' ... change tags in matching pairs the content can be changed according to the context of the HTML document where the cursor is located. * `'〜`' ... change `TAG' element name * attributes such as `photo' ... change attributes  File: yahtmle, Node: Changing entities, Next: URLencoding of strings within region, Prev: Changing tags in pairs, Up: Changing and Deleting Changing entities ================= Special characters such as < or > must be written as < and >. Easy conversion of these characters can be done when importing text from non HTML files. `[prefix] ;' ... convert char to special entity in marked region `[prefix] :' ... convert special entity to original char in marked region (reverse of [prefix] ;)  File: yahtmle, Node: URLencoding of strings within region, Next: td-enclosure/tr-enclosure, Prev: Changing entities, Up: Changing and Deleting URLencoding of strings within region ==================================== `[prefix] #' ... encode chars that needs to be URLencoded within region  File: yahtmle, Node: td-enclosure/tr-enclosure, Prev: URLencoding of strings within region, Up: Changing and Deleting td-enclosure/tr-enclosure ========================= If you wan to convert series of field into ... repetitions for table element, td-enclosure or tr-enclosure is convenient. `[prefix] }' ... Enclose each field in a region into ...'s. `[prefix] ]' ... Enclose each line in a region into ...'s, with every line converted to ... repetition. They presume white space as field separator by default. To change this, enter other delimiting character for a query. You can convert CSV, for example, into table by specifying comma(,) as a delimiter. If you want to enclose fields with th, call with universal-argument (`C-u'). Enter `th' to enclose fields with .... The special answer `thd' means that enclose the only first column with th, and the rest with td.  File: yahtmle, Node: CSS Support, Next: Customizations, Prev: Changing and Deleting, Up: Top CSS(Style Sheets) Support ************************* * Menu: * CSS-class completion:: * Reread CSS definition::  File: yahtmle, Node: CSS-class completion, Next: Reread CSS definition, Prev: CSS Support, Up: CSS Support CSS class-name completion ========================= You can input a class name in your CSS definition with completion. If you have CSS defined as below; h1.foo, h2.foo { background-color: 0xffffff; } h1.bar, h2.bar { font-size: 120%; } when you input h1(or h2) tag with completing-read by [prefix] b or [prefix] l, yahtml prompts you to input class name with completion from the words which are effective to h1 or h2. And if you defined global class like this; .caution { font-size: 120%; background-color: 0xc00000;} when you input any tags via completing-read, yahtml prompts you to input class name. If this is bothering, typing `C-j' instead of `RET' (or `C-m') cancels the next prompt to class name completion.  File: yahtmle, Node: Reread CSS definition, Prev: CSS-class completion, Up: CSS Support Re-reading CSS definition ========================= If you add some class to your CSS file and you want yahtml to load new definitions, type `M-x yahtml-mode RET' to make yahtml do.  File: yahtmle, Node: Customizations, Next: Copying, Prev: CSS Support, Up: Top Customizations ************** Variables that modify yahtml's behavior. * Menu: * All customizable variables:: List of customizable variables * Hook variables:: hook variables  File: yahtmle, Node: All customizable variables, Next: Hook variables, Prev: Customizations, Up: Customizations List of customizable variables. Defaults in parenthesis ======================================================== -- Variable: yahtml-prefix Prefix key for yahtml-mode. (`\C-c') -- Variable: yahtml-image-viewer Command to view image files refered by img. (xv) -- Variable: yahtml-www-browser Browser to view external pages with `[prefix]g'. (netscape) -- Variable: yahtml-kanji-code Default kanji code. 1=sjis, 2=jis, 3=euc, 4=utf-8 (2) If AddType "text/html; charset=xxx" .html is written in .htaccess, this will override yahtml-kanji-code. -- Variable: yahtml-fill-column Columns to auto-fill (72) -- Variable: yahtml-fill-prefix fill-prefix specific to yahtml-mode. (`nil') -- Variable: yahtml-path-url-alist Matching list of URL and full path name on OS's file system. -- Variable: yahtml-directory-index Default index filed opened when accessing a server without a filename, usually index.html. (`"index.html"') -- Variable: yahtml-lint-program HTML syntax check program. (`"jweblint"') -- Variable: yahtml-hate-too-deep-indentation setq to t when indentations for nested enumerate elements are too deep. (`nil') -- Variable: yahtml-always-/p setq to t if you always want `

    ' after `

    '. `nil' -- Variable: yahtml-p-prefered-env-regexp Elements that `

    ' will be automatically inserted. (`"^\\(body\\|dl\\|blockquote\\)"') -- Variable: yahtml-template-file File to automatically insert when editing a new HTML file. `"~/http/template.html"' -- Variable: yahtml-prefer-upcases Use uppercase for tags. `nil' -- Variable: yahtml-prefer-upcase-attributes Use uppercase for attributes. `nil' -- Variable: yahtml-server-type setq to 'apache if using a Apache server, and will refer ./.htaccess. `'apache' -- Variable: yahtml-apache-access-file When `yahtml-server-type' is `'apache', define name of access restriction file. `".htaccess"' -- Variable: yahtml-shell-command-option Options needed to invoke shell commands. -- Variable: yahtml-translate-hyphens-when-comment-region Whether to change hyphens to `-' when commenting out region. (`t') -- Variable: yahtml-entity-reference-chars-alist alist of characters that needs to be written by Entity Reference. Enter as `'(?char . "EntityReference")'. By default, `<', `>', `&', `'', is set. Add as needed. Do not include `&' at beginning and `;' at end of cdr portion of `"EntityReference"'. -- Variable: yahtml-faithful-to-htmllint When using htmllint to check syntax, it will complain about excess spaces. setq to `t' to avoid this. -- Variable: yahtml-use-css Use style-sheet support or not (`t') -- Variable: yahtml-image-inspection-bytes Number of bytes to inspect the image for geometry information (`10000') -- Variable: yahtml:img-default-alt-format format of img entity's ALT attributes. %x: width, %y: height, %s: size in bytes, %c: first comment string, %f: filename (`"%xx%y(%sbytes)"') -- Variable: yahtml-escape-chars When, completing href-s, Escape reserved characters to URL-encoding or not. Nil for never, t for everytime, and 'ask for inquiring at each reserved chars. (`'ask') -- Variable: yahtml-use-font-lock Use font-lock to fontify buffer or not (`(featurep 'font-lock)') -- Variable: yahtml-use-hilit19 Use hilit19 to highlight buffer or not (`(featurep 'hilit19)') -- Variable: yahtml-indentation-boundary Boundary regexp for indentation calculation. (`"^\\s *"')  File: yahtmle, Node: Hook variables, Prev: All customizable variables, Up: Customizations hook variables ==============  File: yahtmle, Node: Copying, Next: Concept Index, Prev: Customizations, Up: Top Copying ******* This program is distributed as freesoftware. The author will take no responsibility to any damages due to the usage of this software whatsoever. There are no restrictions to its redistribution, just use common sense. Mail me your thoughts on this program and I will be more than willing to help. Complaints, requests, bug reports and comments are welcome. Make contacts to yuuji@yatex.org (as of December 2000) If you like this program and use it on a regular basis, please join the mailing list "fj Wild Bird Society". Procedures can be found in the "etc" section of `docs/htmlqa.eng' in this package. HIROSE, Yuuji  File: yahtmle, Node: Concept Index, Prev: Copying, Up: Top Index ***** * Menu: * Customize: Customizations. 4. * Demacs: Intro. 4. * Key Assign: Customizations. 4. * LaTeX: Intro. 4. * Mule: Intro. 4. * yahtml: Intro. 4.  Tag table: Node: Top259 Node: Intro836 Node: Installation1234 Node: Setting up yahtml1515 Node: Setting environments for weblint browsers and image viewers2306 Node: Setting environment variables for WWW pages3002 Node: Command Invocation3973 Node: Completion4401 Node: Jump5917 Node: Changing and Deleting6397 Node: Changing tags in pairs6681 Node: Changing entities7176 Node: URLencoding of strings within region7712 Node: td-enclosure/tr-enclosure8013 Node: CSS Support8979 Node: CSS-class completion9205 Node: Reread CSS definition10058 Node: Customizations10333 Node: All customizable variables10609 Node: Hook variables14377 Node: Copying14503 Node: Concept Index15294  End tag table yatex_1.77+dfsg1/docs/htmlqa.eng0000444000175000017500000000752412126310642015266 0ustar kurakura%% %% Q and A on yahtml %% %% C-u C-x $ shows only questions. C-x $ shows all. %% -- New Item *Can I use font-lock with yahtml? [Installation] ============== *Must I install YaTeX even if I don't use LaTeX? No. Get the files starting with "yahtml" from http://www.yatex.org/ and that's all you will need. [Customization] ============== *Can I use font-lock with yahtml? Yes. Native font-lock support started at yahtml-1.69. All you have to do for font-lock-ing, is to load font-lock beforehand. If you had added such workaround as (put 'yahtml-mode 'font-lock-defaults 'another-html-mode) in hooks, please remove it! *I usually use EUC, but need JIS coding on some files. Write (setq yahtml-kanji-code 3) ;3 for EUC and your default kanji code for HTML files will be EUC. Now to change codings foe selected files. If your server is Apache, then prepare a file named ".htaccess" in the directory and write AddType "text/html; charset=iso-2020-jp" .html Apache will now inform all your visitors that the html files in this directory are in iso-2022-jp, aka JIS. yahtml will also follow this and encode all files in this directory with JIS. Not using Apache? Then adding the following to the end of your html source will make this files coding system JIS. Note that Emacs-20 and XEmacs do not need the "*" in the kanji code symbol. [What about...] ============== *Indentation for a large file is slow Should be fixed. *Inserting template.html Use autoinsert.el that comes with Emacs19/Mule2. Another option is to use auto-insert-tkld. The latter can be found at ftp://ftp.ae.keio.ac.jp/pub/emacs-lisp/util/auto-inset-tkld.tar.Z Examples in Japanese are at http://namazu.org/~tsuchiya/elisp/yahtml-mode.html [ETC] ============ *How do I pronounce yahtml A real FAQ. The author doesn't know either. Any ideas? ... It hits on me! We define the official name of yahtml as; HTML-Ya "Ya" is the Japanese word whose meaning is `shop', and sometimes `enthusiast' of something. With HTML-Ya, do the publishment of your thought efficiently and beautifully! *Mailing lists? A question, so an answer. The mailing list for YaTeX (Wild Bird) and it's implementation to Vz Editor; LaiTeX (Thunder Bird, by KATSURAGAWA Naoki), implementation to Wz Editor; HackTeX (Swan, by TAKENAKA Hiroshi), implementation to Hidemaru Editor; HiTeX (Flying Bird, by YASUDA Haruyuki) is "fj Wild Bird Society". Send a mail like To: yatex@yatex.org Subject: subscribe ----- Hi! My name is yuuji. See any birds fly by? and you're in. Once you're in, you'll get a reply with lists of commands used in the mailing list. Join along and help adding new feathers to Wild Bird. BTW, if you haven't guessed it yet, yes, this mailing list is in Japanese. But give us a try anyway. You're always welcome. *How to get the up-to-date information on yahtml? If you can access WWW, try to see; http://www.yatex.org/ And if you trace the link of `yatex-current', you can get the really latest version of yahtml. Since it collects the elisps in the author's source directory, what you'll get may contain some errors. The author cannot respond to your query about yatex-current. *Help, help HELP!! Ways of getting answers in fastest order. *Look for someone near you who knows what's he/she's doing. *Post a question to the mailing list. *Send mail to yuuji@yatex.org take a pick. *Picking a question in this file with C-u C-x $ and hitting C-x $ takes me to a weird world. You too? Try marking the question before C-x $ and to C-x C-x to take you back to it. (Mule2 doesn't seem to have the same problem) Local Variables: mode: indented-text fill-column: 72 fill-prefix: " " End: yatex_1.77+dfsg1/docs/yahtmle.tex0000444000175000017500000004024212126310642015464 0ustar kurakura\def\lang{eng} % -*- texinfo -*- for Texinfo V.3.1 \input texinfo @setfilename yahtmle @settitle Yet Another html-mode for Emacs @direntry * yahtml-e: (yahtmle). Yet Another html-mode for Emacs (English). @end direntry @iftex @c @syncodeindex fn cp @c Last modified Fri May 11 15:42:22 2012 on firestorm @syncodeindex vr cp @end iftex @titlepage @sp 10 @center @subtitle Yet Another html-mode for emacs @title // yahtml // %@subtitle // yahtml // @author @copyright{} 1994-2012 by HIROSE, Yuuji [yuuji@@yatex.org] @end titlepage @node Top, Intro, (dir), (dir) @comment node-name, next, previous, up @menu * Intro:: Introduction * Installation:: Installing yahtml * Command Invocation:: Using External Commands * Completion:: Input with Completion * Jump:: Moving the Cursor * Changing and Deleting:: Changing and Deleting * CSS Support:: Style Sheet Support * Customizations:: List of Customize Variables * Copying:: Copyright * Concept Index:: Index @end menu @node Intro, Installation, Top, Top @comment node-name, next, previous, up @chapter Introduction @cindex Demacs @cindex Mule @cindex LaTeX @cindex yahtml yahtml is a package to support creating HTML documents on Emacsens. Easy input of elements (tags) by completion, syntax checking with programs like weblint, and invoking the appropriate browser or image viewer depending on the cursor position is its main features. (This Info is still incomplete) @node Installation, Command Invocation, Intro, Top @comment node-name, next, previous, up @chapter Installing yahtml @menu * Setting up yahtml:: * Setting environments for weblint browsers and image viewers:: * Setting environment variables for WWW pages:: @end menu @node Setting up yahtml, Setting environments for weblint browsers and image viewers, Installation, Installation @comment node-name, next, previous, up @section Setting up yahtml Add the following to @file{~/.emacs} @lisp (setq auto-mode-alist (cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist)) (autoload 'yahtml-mode "yahtml" "Yet Another HTML mode" t) @end lisp Next, add to load-path the directory with the yahtml files (@file{yahtml.el}, @file{yatexlib.el}, @file{yatexprc.el}). For example, if you put them in @file{~/src/emacs/yahtml}, @lisp (setq load-path (cons (expand-file-name "~/src/emacs/yahtml") load-path)) @end lisp @noindent is what you add. By this, yahtml will be automatically loaded when editing files with .html extensions. "yahtml" will be displayed on the mode line if no errors occurred. @node Setting environments for weblint browsers and image viewers, Setting environment variables for WWW pages, Setting up yahtml, Installation @comment node-name, next, previous, up @section Setting environments for weblint, browsers, and image viewers Check the variables for invoking external commands and modify as needed. Defaults are in parenthesis. @table @code @item yahtml-www-browser @dots{} browser command name (netscape) @item yahtml-image-viewer @dots{} image viewer command name (xv) @item yahtml-lint-program @dots{} syntax check programs command name (jweblint) @item yahtml-kanji-code @dots{} kanji code for HTML files @end table @node Setting environment variables for WWW pages, , Setting environments for weblint browsers and image viewers, Installation @comment node-name, next, previous, up @section Setting environment variables for WWW pages Variables regarding path names for files that will be your home page. @table @code @item yahtml-path-url-alist @dots{} list of matching path name on file system and URLs @item yahtml-directory-index @dots{} index file displayed when none is given in URL. Usually @file{index.html} on NCSA type httpd and @file{Welcome.html} on CERN types. @end table Examples for @code{yahtml-path-url-alist}. If @file{/home/yuuji/http/} is @code{http://localhost/~yuuji} at home and @file{/usr/home/yuuji/www/} is @code{http://www.keio.ac.jp/~yuuji/} at work, then @lisp (setq yahtml-path-url-alist '(("/home/yuuji/http" . "http://localhost/~yuuji") ("/usr/home/yuuji/www" . "http://www.keio.ac.jp/~yuuji"))) @end lisp Any number of additions can be made to this list. @node Command Invocation, Completion, Installation, Top @comment node-name, next, previous, up @chapter Invoking external commands For easy use of commands that are handy when editing HTML files. @table @kbd @item [prefix] t j @dots{} Invoke HTML syntax checker (jweblint) @item [prefix] t p @dots{} Display current page in browser @item [prefix] t r @dots{} Reload current page if browser is already running @end table @node Completion, Jump, Command Invocation, Top @comment node-name, next, previous, up @chapter Completion Input Completion input of HTML elements is done through the same key strokes as YaTeX's begin-type completion, section-type completion, large-type completion, maketitle-type completion, and accent completion. Corresponding elements in this order is; elements that span multiple lines, empty elements such as img, tags that start and end in a single line, elements with no attributes or contents, and special or symbol entities. @table @kbd @item [prefix] b (YaTeX begin-type completion) @dots{} @example

    @end example @noindent Completion for elements that the start tag and the end tag span multiple lines. Mostly block-level elements. @item [prefix] s (YateX section-type completion) @dots{} @example photo @end example @noindent Completion for elements that do not have end tags and require only attributes. Possible completions are, , . @item [prefix] l (YaTeX large-type completion) @dots{} @example $B!A(B @end example @noindent Similar to begin-type completion but used for elements that start and end on a single line. @item [prefix] m (YaTeX maketitle-type completion) @dots{} Completion for elements without attributes or contents. Possible completion is
    @item [prefix] a (YaTeX accent completion) @dots{} Used to enter special or symbol entities. By default completion for < (<), > (>), & (&), " ("), ' ('), blank ( ) is possible. @end table @node Jump, Changing and Deleting, Completion, Top @comment node-name, next, previous, up @chapter Cursor Movement By using @table @kbd @item [prefix] g @dots{} move to corresponding object @end table @noindent the cursor will go to the corresponding object according to the context. Recognized contexts are @itemize @bullet @item @code{} <--> @code{} @item @code{} -> invoke viewer @item @code{} -> move cursor to linked target @item @code{} -> open Java source @c @item @code{\include(\input)} $B"*(B $BBP1~$9$k%U%!%$%k(B @end itemize @node Changing and Deleting, CSS Support, Jump, Top @comment node-name, next, previous, up @chapter Changing and Deleting @menu * Changing tags in pairs:: * Changing entities:: * URLencoding of strings within region:: * td-enclosure/tr-enclosure:: @end menu @node Changing tags in pairs, Changing entities, Changing and Deleting, Changing and Deleting @comment node-name, next, previous, up @section Changing tags in pairs By using @table @kbd @item [prefix] c @dots{} change tags in matching pairs @end table @noindent the content can be changed according to the context of the HTML document where the cursor is located. @itemize @bullet @item @code{}$B!A(B@code{} @dots{} change @code{TAG} element name @item attributes such as @code{photo} @dots{} change attributes @end itemize @node Changing entities, URLencoding of strings within region, Changing tags in pairs, Changing and Deleting @comment node-name, next, previous, up @section Changing entities Special characters such as < or > must be written as < and >. Easy conversion of these characters can be done when importing text from non HTML files. @table @kbd @item [prefix] ; @dots{} convert char to special entity in marked region @item [prefix] : @dots{} convert special entity to original char in marked region (reverse of [prefix] ;) @end table @node URLencoding of strings within region, td-enclosure/tr-enclosure, Changing entities, Changing and Deleting @comment node-name, next, previous, up @section URLencoding of strings within region @table @kbd @item [prefix] # @dots{} encode chars that needs to be URLencoded within region @end table @node td-enclosure/tr-enclosure, , URLencoding of strings within region, Changing and Deleting @comment node-name, next, previous, up @section td-enclosure/tr-enclosure If you wan to convert series of field into ... repetitions for table element, td-enclosure or tr-enclosure is convenient. @table @kbd @item [prefix] @} @dots{} Enclose each field in a region into ...'s. @item [prefix] ] @dots{} Enclose each line in a region into ...'s, with every line converted to ... repetition. @end table They presume white space as field separator by default. To change this, enter other delimiting character for a query. You can convert CSV, for example, into table by specifying comma(,) as a delimiter. If you want to enclose fields with th, call with universal-argument (@kbd{C-u}). Enter `th' to enclose fields with .... The special answer `thd' means that enclose the only first column with th, and the rest with td. @node CSS Support, Customizations, Changing and Deleting, Top @comment node-name, next, previous, up @chapter CSS(Style Sheets) Support @menu * CSS-class completion:: * Reread CSS definition:: @end menu @node CSS-class completion, Reread CSS definition, CSS Support, CSS Support @comment node-name, next, previous, up @section CSS class-name completion You can input a class name in your CSS definition with completion. If you have CSS defined as below; @display h1.foo, h2.foo @{ background-color: 0xffffff; @} h1.bar, h2.bar @{ font-size: 120%; @} @end display when you input h1(or h2) tag with completing-read by [prefix] b or [prefix] l, yahtml prompts you to input class name with completion from the words which are effective to h1 or h2. And if you defined global class like this; @display .caution @{ font-size: 120%; background-color: 0xc00000;@} @end display when you input any tags via completing-read, yahtml prompts you to input class name. If this is bothering, typing @kbd{C-j} instead of @kbd{RET} (or @kbd{C-m}) cancels the next prompt to class name completion. @node Reread CSS definition, , CSS-class completion, CSS Support @comment node-name, next, previous, up @section Re-reading CSS definition If you add some class to your CSS file and you want yahtml to load new definitions, type @kbd{M-x yahtml-mode RET} to make yahtml do. @node Customizations, Copying, CSS Support, Top @comment node-name, next, previous, up @chapter Customizations @cindex Customize @cindex Key Assign Variables that modify yahtml's behavior. @menu * All customizable variables:: List of customizable variables * Hook variables:: hook variables @end menu @node All customizable variables, Hook variables, Customizations, Customizations @comment node-name, next, previous, up @section List of customizable variables. Defaults in parenthesis @defvar yahtml-prefix Prefix key for yahtml-mode. (@kbd{\C-c}) @end defvar @defvar yahtml-image-viewer Command to view image files refered by img. (xv) @end defvar @defvar yahtml-www-browser Browser to view external pages with @kbd{[prefix]g}. (netscape) @end defvar @defvar yahtml-kanji-code Default kanji code. 1=sjis, 2=jis, 3=euc, 4=utf-8 (2) If @quotation AddType "text/html; charset=xxx" .html @end quotation is written in .htaccess, this will override yahtml-kanji-code. @end defvar @defvar yahtml-fill-column Columns to auto-fill (72) @end defvar @defvar yahtml-fill-prefix fill-prefix specific to yahtml-mode. (@code{nil}) @end defvar @defvar yahtml-path-url-alist Matching list of URL and full path name on OS's file system. @end defvar @defvar yahtml-directory-index Default index filed opened when accessing a server without a filename, usually index.html. (@code{"index.html"}) @end defvar @defvar yahtml-lint-program HTML syntax check program. (@code{"jweblint"}) @end defvar @defvar yahtml-hate-too-deep-indentation setq to t when indentations for nested enumerate elements are too deep. (@code{nil}) @end defvar @defvar yahtml-always-/p setq to t if you always want @code{

    } after @code{

    }. @code{nil} @end defvar @defvar yahtml-p-prefered-env-regexp Elements that @code{

    } will be automatically inserted. (@code{"^\\(body\\|dl\\|blockquote\\)"}) @end defvar @defvar yahtml-template-file File to automatically insert when editing a new HTML file. @file{"~/http/template.html"} @end defvar @defvar yahtml-prefer-upcases Use uppercase for tags. @code{nil} @end defvar @defvar yahtml-prefer-upcase-attributes Use uppercase for attributes. @code{nil} @end defvar @defvar yahtml-server-type setq to 'apache if using a Apache server, and will refer ./.htaccess. @code{'apache} @end defvar @defvar yahtml-apache-access-file When @code{yahtml-server-type} is @code{'apache}, define name of access restriction file. @file{".htaccess"} @end defvar @defvar yahtml-shell-command-option Options needed to invoke shell commands. @end defvar @defvar yahtml-translate-hyphens-when-comment-region Whether to change hyphens to @code{-} when commenting out region. (@code{t}) @end defvar @defvar yahtml-entity-reference-chars-alist alist of characters that needs to be written by Entity Reference. Enter as @code{'(?char . "EntityReference")}. By default, @code{<}, @code{>}, @code{&}, @code{'}, is set. Add as needed. Do not include @code{&} at beginning and @code{;} at end of cdr portion of @code{"EntityReference"}. @end defvar @defvar yahtml-faithful-to-htmllint When using htmllint to check syntax, it will complain about excess spaces. setq to @code{t} to avoid this. @end defvar @defvar yahtml-use-css Use style-sheet support or not (@code{t}) @end defvar @defvar yahtml-image-inspection-bytes Number of bytes to inspect the image for geometry information (@code{10000}) @end defvar @defvar yahtml:img-default-alt-format format of img entity's ALT attributes. %x: width, %y: height, %s: size in bytes, %c: first comment string, %f: filename (@code{"%xx%y(%sbytes)"}) @end defvar @defvar yahtml-escape-chars When, completing href-s, Escape reserved characters to URL-encoding or not. Nil for never, t for everytime, and 'ask for inquiring at each reserved chars. (@code{'ask}) @end defvar @defvar yahtml-use-font-lock Use font-lock to fontify buffer or not (@code{(featurep 'font-lock)}) @end defvar @defvar yahtml-use-hilit19 Use hilit19 to highlight buffer or not (@code{(featurep 'hilit19)}) @end defvar @defvar yahtml-indentation-boundary Boundary regexp for indentation calculation. (@code{"^\\s *"}) @end defvar @node Hook variables, , All customizable variables, Customizations @comment node-name, next, previous, up @section hook variables @node Copying, Concept Index, Customizations, Top @comment node-name, next, previous, up @chapter Copying This program is distributed as freesoftware. The author will take no responsibility to any damages due to the usage of this software whatsoever. There are no restrictions to its redistribution, just use common sense. Mail me your thoughts on this program and I will be more than willing to help. Complaints, requests, bug reports and comments are welcome. Make contacts to yuuji@@yatex.org$B!!(B(as of December 2000) If you like this program and use it on a regular basis, please join the mailing list "fj Wild Bird Society". Procedures can be found in the "etc" section of @file{docs/htmlqa.eng} in this package. @flushright HIROSE, Yuuji @end flushright @node Concept Index, , Copying, Top @comment node-name, next, previous, up @unnumbered Index @printindex cp @contents @bye @c Local Variables: @c fill-column: 74 @c fill-prefix: nil @c End:  Tag table:  End tag table yatex_1.77+dfsg1/docs/yatex.ref0000444000175000017500000001167212126310642015134 0ustar kurakura---------------------------------------------------------------------------- 『野鳥』 クイックリファレンス ---------------------------------------------------------------------------- 【注意】 野鳥では、prefix キーをカスタマイズできるため(標準ではC-c)これを [prefix] と表記します。C-c のまま変更していない場合、[prefix] a は C-c a を表わします。 begin型コマンドとは \begin〜\endの形式のコマンド、section型コ マンドとは \section{題}のように引数を取るコマンド、large型コマン ドとは {\tt } のような中括弧で囲まれたフォント/サイズ指定子、 maketitle型コマンドとは \maketitle のように引数を伴わないコマン ドを指します。 【補完】 ◆アクセント補完 [prefix] a ◆begin型補完 [prefix] b SPC ◆begin型補完(領域指定) [prefix] B SPC ◆begin型補完(即時) [prefix] b 環境の頭文字 ◆begin型補完(〃領域指定) [prefix] B 環境の頭文字 ◆end補完 [prefix] e ◆large型補完 [prefix] l ◆large型補完(領域指定) [prefix] L ◆maketitle型補完 [prefix] m ◆section型補完 [prefix] s ◆section型補完(領域指定) [prefix] S ◆随時補完 [prefix] SPC 即時begin型補完の、環境名の頭文字の対応については、Info マニュ アルをご覧ください。領域指定モードでは、マークした位置とポイント の間を\begin{center}…\end{center} や {\large } などで括ります。 ◆数式記号イメージ補完 ; ◆ギリシャ文字イメージ補完 : 上の2つはTeXの数式環境の中で押した場合のみ有効です。強制的に補 完機能を使う場合は、C-u を押してから ; や : を押します。 【プロセス起動】 ◆jbibtex起動 [prefix] tb ◆jlatex起動 [prefix] tj ◆makeindex起動 [prefix] ti ◆jlatexのkill [prefix] tk ※ ◆プリントアウト [prefix] tl ◆プリントアウト(全ページ) C-u [prefix] tl ◆プレビューア起動 [prefix] tp ◆xdvi上で文字列サーチ [prefix] ts ※※ ◆lpq起動 [prefix] tq ◆jlatex起動(領域指定) [prefix] tr [prefix] t を押せばメニューが出るので、[prefix] t の次に押すキー は覚えなくて構いません。 ※は、MS-DOS では無効です。 ※※は、-remote 機能付きの xdvi でのみ有効です。 [prefix] tr の領域指定は、文書中の、 %#BEGIN と書いてある行か ら、%#END と書いてある行までです。%#END を省略すると、%#BEGINか ら文書末まで、両方省略するとマークした位置から、ポイントまでが指 定領域となります。 【カーソルジャンプ】 ◆タイプセットエラー箇所へ [prefix] ' タイプセットエラー発生箇所へ(末尾から)遡って順次ジャンプします。 もちろん jlatex でエラーが生じた場合のみ有効です。 ◆対応するオブジェクトジャンプ [prefix] g ◆別ウィンドウで 〃 [prefix] 4g カーソルジャンプは、[prefix] g を押す時のカーソルの位置により、 ジャンプすべき場所を判断します。 ・\begin{}, \end{}の上 対応する \end{},\begin{} へ ・%#BEGIN, %#END の上 対応する %#BEGIN, %#END へ ・\include(only), \input の上 対応するファイルへ ・\ref, \label の上 対応する \label, \ref へ ・\cite, \bibitem の上 対応する \bibitem, \cite へ ◆メインファイルへジャンプ [prefix] ^ ◆別ウィンドウで 〃 [prefix] 4^ メインファイルを野鳥に知らせるために、作成ファイルの任意の位置に、 %#!jlatex メインファイル名 のような行を書いておいて下さい。 ◆環境の先頭へ ESC C-a ◆環境の末尾へ ESC C-e ◆環境全体をマーク ESC C-h 【%によるコメントアウト】 ◆領域/環境のコメントアウト [prefix] > ◆領域/環境のコメント除去 [prefix] < カーソルが、\begin{} または \end{} の行にある時は、その環境に含 まれる文章全てをコメントアウト/除去し、それ以外の時は、マークとポ イント間の文章をコメントアウト/除去します。 ◆段落/環境宣言コメントアウト [prefix] . ◆段落/環境宣言コメント除去 [prefix] , カーソルが、\begin{} または \end{} の行にある時は、それら二つの 行をコメントアウト/除去し、それ以外の時は、カーソルの属する段落を コメントアウト/除去します。 【その他】 ◆itemの桁揃え [prefix] i \item を使う環境中のみ有効です。\item の項目全体をハングインデ ントします。 ◆LaTeXコマンド変更 [prefix] c \begin{}, \end{} の行で起動すると環境名を同時に変更します。 section型コマンドの上で起動するとコマンドを変更し、コマンドの引 数の位置で起動すると引数を変更します。large型コマンドの上で起動 するとフォント/サイズ指定子を変更します。イメージ補完で入力した 数式モードコマンドの上で起動すると確定直前のイメージ補完操作に戻 ります。 ◆コマンド削除 [prefix] k \begin{}, \end{} のペア、%#BEGIN, %#END のペア、括弧のペア、ま たはsection型コマンド、フォント/文字サイズ指定子とそれを括る括弧 を一挙に削除します。 ◆領域を()で括る [prefix] ) ◆領域を{}で括る [prefix] } ◆領域を[]で括る [prefix] ] ◆領域を$$で括る [prefix] $ ◆モード切り替え [prefix] w 新規作成/修正モード、数式モードの切り替えメニューが出ます。 ◆%# 記法の編集 [prefix] % ◆tabular/array桁位置表示 [prefix] & ◆オンラインヘルプ [prefix] ? ◆オンラインapropos [prefix] / ◆おまかせ改行 ESC RET 「おまかせ改行」は tabular, array, itemize, enumerate, list, description 環境で有効です。 ◆インクルード構造ブラウズ [prefix] d ◆font-lockし直しメニュー [prefix] u 広瀬雄二 yuuji@yatex.org Local variables: mode: text fill-prefix: " " End: yatex_1.77+dfsg1/docs/yahtmlj.tex0000444000175000017500000004076712126310642015505 0ustar kurakura\def\lang{jp} % -*- texinfo -*- for Texinfo V.3.1 \input texinfo @setfilename yahtmlj @settitle Yet Another html-mode for Emacs @direntry * yahtml: (yahtmlj). Yet Another html-mode for Emacs (Japanese). @end direntry @iftex @c @syncodeindex fn cp @c Last modified Fri May 11 15:42:05 2012 on firestorm @syncodeindex vr cp @end iftex @titlepage @sp 10 @center @subtitle Yet Another html-mode for emacs @title 『HTML屋』 @subtitle // yahtml // @author @copyright{} 1994-2012 by HIROSE, Yuuji [yuuji@@yatex.org] @end titlepage @node Top, Intro, (dir), (dir) @comment node-name, next, previous, up @menu * Intro:: はじめに * Installation:: インストール * Command Invocation:: 外部コマンド起動 * Completion:: 補完入力 * Jump:: カーソルジャンプ * Changing and Deleting:: 変更と削除 * CSS Support:: スタイルシート補完 * Customizations:: カスタマイズ変数一覧 * Copying:: とりあつかい * Concept Index:: 索引 @end menu @node Intro, Installation, Top, Top @comment node-name, next, previous, up @chapter はじめに @cindex Demacs @cindex Mule @cindex LaTeX @cindex HTML屋[HTMLや] yahtmlは GNU Emacs 上で HTML文書を作成する時に、繁雑なHTMLタグの入力を補 完機能によってスムーズに行えるようにするだけでなく、weblintなどの構文チェッ クプログラム、カーソル位置のURLやファイル名に依存したブラウザ/イメージヴュー アの起動などを Emacs 編集画面中から 行えるようにするパッケージです。 (このInfoは未完成です(__)…) @node Installation, Command Invocation, Intro, Top @comment node-name, next, previous, up @chapter インストール @menu * yahtml起動のための設定:: * lintプログラム/ブラウザ/イメージヴューア環境等の設定:: * WWWページ環境用変数の設定:: @end menu @node yahtml起動のための設定, lintプログラム/ブラウザ/イメージヴューア環境等の設定, Installation, Installation @section yahtml起動のための設定 @file{~/.emacs}に下の2項目を加えます。 @lisp (setq auto-mode-alist (cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist)) (autoload 'yahtml-mode "yahtml" "Yet Another HTML mode" t) @end lisp 次にyahtmlに必要なファイル(@file{yahtml.el}, @file{yatexlib.el}, @file{yatexprc.el}) を置くディレクトリを load-path に加えます。たとえば、 @file{~/src/emacs/yahtml}に置くのであれば、 @lisp (setq load-path (cons (expand-file-name "~/src/emacs/yahtml") load-path)) @end lisp @noindent などとします。 以上の設定により、拡張子が .html であるファイルを編集すると自動的に yahtml がロードされます。yahtmlが正常に起動できたときはモードラインの表示が 「yahtml」に変わります。 @node lintプログラム/ブラウザ/イメージヴューア環境等の設定, WWWページ環境用変数の設定, yahtml起動のための設定, Installation @section lintプログラム/ブラウザ/イメージヴューア環境等の設定 利用する外部プログラムなどに関する以下の変数を確認し、必要なら正しい値に変 更します(括弧内はデフォルト値)。 @table @code @item yahtml-www-browser @dots{} 起動するブラウザのコマンド名(netscape) @item yahtml-image-viewer @dots{} 起動する画像ビューアのコマンド名(xv) @item yahtml-lint-program @dots{} 構文チェックプログラムのコマンド名(jweblint) @item yahtml-kanji-code @dots{} htmlファイルの漢字コード @end table @node WWWページ環境用変数の設定, , lintプログラム/ブラウザ/イメージヴューア環境等の設定, Installation @section WWWページ環境用変数の設定 ホームページとなるファイルが存在するPATH名に関する変数を設定します。 @table @code @item yahtml-path-url-alist @dots{} ファイルシステム上のPATH名と、URLの対応表 @item yahtml-directory-index @dots{} URL指定でファイル名を省略したときに表示されるインデックス ファイル名(NCSA系httpdなら @file{index.html}, CERN系なら @file{Welcome.html}が一般的) @end table 変数 @code{yahtml-path-url-alist} の設定例を示します。例えば、自宅では、 @file{/home/yuuji/http/} が @code{http://localhost/~yuuji} で参照でき、職 場では @file{/usr/home/yuuji/www/} が@code{http://www.keio.ac.jp/~yuuji/} で参照できるようになっている場合は以下のように設定します。 @lisp (setq yahtml-path-url-alist '(("/home/yuuj/http" . "http://localhost/~yuuji") ("/usr/home/yuuj/www" . "http://www.keio.ac.jp/~yuuji"))) @end lisp この対応組はいくらでも設定することができます。 @node Command Invocation, Completion, Installation, Top @comment node-name, next, previous, up @chapter 外部コマンド起動 HTMLファイル編集にかかわるいくつかのコマンドを即座に呼ぶことができます。 @table @kbd @item [prefix] t j @dots{} HTML構文チェッカ(jweblint)起動 @item [prefix] t p @dots{} 現在のページを対象としたブラウザ起動 @item [prefix] t r @dots{} 現在のページがブラウザに表示されているときのreload指定 @end table @node Completion, Jump, Command Invocation, Top @comment node-name, next, previous, up @chapter 補完入力 「野鳥」で利用できる、「begin型補完」、「section型補完」、 「large型補完」、「maketitle型補完」、「アクセント補完」 と全く同じキー操作で対応する HTMLタグの補完入力ができます。それぞれの型の補完は順に、 「複数行に渡るタグ入力」、「空要素タグ(imgなど)の補完」、 「一行内での開始/終了タグの入力」、「空要素空属性タグの入力」、 「文字参照入力」 に 対応しています。具体的には @table @kbd @item [prefix] b (野鳥のbegin補完に対応) @dots{} @example

    @end example @noindent のように開始タグと終了タグを二行に渡って書きたい場合の補完を指します。 おもにブロック型タグが補完候補に含まれます。 @item [prefix] s (野鳥のsection型補完に対応) @dots{} @example photo @end example @noindent のように終了タグを持たず、かつ属性値のみで機能を指定するタグを補完します。 補完候補としては、img, input が存在します。 @item [prefix] l (野鳥のlarge型補完に対応) @dots{} begin型補完とほぼ同じですが、 @example @end example @noindent のように一行内に開始/終了タグを入れたいときに利用します。 @item [prefix] m (野鳥のmaketitle型補完に対応) @dots{} 要素も属性値も持たないタグを補完入力します。
    などが補完候補に相当します。 @item [prefix] a (野鳥のアクセント補完に対応) @dots{} エンティティ参照による文字表記を入力するときに用います。 デフォルトでは < (<), > (>), & (&), " ("), ' ('), ブランク ( ) の補完入力が行えます。 @end table @node Jump, Changing and Deleting, Completion, Top @comment node-name, next, previous, up @chapter カーソルジャンプ 文書中のいろいろな場所で @table @kbd @item [prefix] g @dots{} 対応するオブジェクトにジャンプ @end table @noindent を押すことにより、カーソル位置のHTML構文に対応する場所にジャンプ します。対応関係が存在すると解釈されるコマンドには以下のものがあります。 @itemize @bullet @item @code{} ←→ @code{} @item @code{} → 対応するviewer起動 @item @code{} → リンク先へのポイント移動 @item @code{} → Javaソースプログラムへの移動 @c @item @code{\include(\input)} → 対応するファイル @end itemize @node Changing and Deleting, CSS Support, Jump, Top @comment node-name, next, previous, up @chapter 変更/削除 @menu * 対タグの変更:: * 文字参照への変更:: * リジョン内文字のURLencode:: * td括り/tr括り:: @end menu @node 対タグの変更, 文字参照への変更, Changing and Deleting, Changing and Deleting @comment node-name, next, previous, up @section 対タグの変更 文書中のいろいろな場所で @table @kbd @item [prefix] c @dots{} 対応するタグ等を変更 @end table @noindent を押すことにより、カーソル位置のHTML構文に応じた 記述内容の変更を行います。カーソル位置と変更する内容の 対応は以下の通りです。 @itemize @bullet @item @code{}〜@code{} @dots{} @code{TAG} の変更 @item @code{photo} などの属性値 @dots{} 属性値の変更 @end itemize @node 文字参照への変更, リジョン内文字のURLencode, 対タグの変更, Changing and Deleting @comment node-name, next, previous, up @section 文字参照への変更 文字としての < や > を表現するときは、文字参照を用いて < や > と表記する必要がありますが、 HTML以外のファイルからこれらの文字を含むテキストを張り込んだ場合 などに、これらの文字を一括して文字参照形式に変換できます。 @table @kbd @item [prefix] ; @dots{} 指定した領域の文字参照に置き換えるべき文字の置換 @item [prefix] : @dots{} 指定した領域の文字参照を参照文字そのものに置換 ([prefix] ; の逆変換) @end table @node リジョン内文字のURLencode, td括り/tr括り, 文字参照への変更, Changing and Deleting @comment node-name, next, previous, up @section リジョン内文字のURLencode @table @kbd @item [prefix] # @dots{} 指定した領域内に URLencode すべき文字があればそれらを エンコード表記に置換。 @end table @node td括り/tr括り, , リジョン内文字のURLencode, Changing and Deleting @comment node-name, next, previous, up @section td括り/tr括り 空白区切りで書いた表形式の行レコードを 括りの並び, あるいはそれらをさらに で括った行並びに変換できます。 @table @kbd @item [prefix] @} @dots{} 現在のリジョンにあるデータを空白区切りごとに ... で括る @item [prefix] ] @dots{} 現在のリジョンにある行を 上記td括りをほどこしてからさらに行ごとに ... で括る @end table デフォルトでは空白区切りですが,これを変えるときは Delimiter: の問い合わせに区切り文字を指定します。たとえばカンマ(,) を指定するとCSVから表を作ることができます。 td以外の要素,具体的には th で括りたい場合は universal-argument (@kbd{C-u}) をつけて上記2つのコマンドを呼びます。どの要素で括るかの 質問が増えるのでそれに th と入れれば,各フィールドを ... で括ります。もし,第1フィールドのみ th で,残りを全部 td 括りにしたいとき は thd と入力して下さい。 @node CSS Support, Customizations, Changing and Deleting, Top @comment node-name, next, previous, up @chapter CSS(スタイルシート)サポート @menu * CSS-class completion:: * Reread CSS file:: @end menu @node CSS-class completion, Reread CSS file, CSS Support, CSS Support @comment node-name, next, previous, up @section CSSクラス名補完 HTML屋はCSS(Cascading Style Sheets)のクラス名を補完入力することができます。 スタイル定義として @display h1.foo, h2.foo @{ background-color: 0xffffff; @} h1.bar, h2.bar @{ font-size: 120%; @} @end display のようなものがあった場合に、h1またはh2タグを [prefix] b や [prefix] l で補 完入力した場合に、それらに有効な class 名である foo, bar を候補として補完 入力することが可能です。また @display .caution @{ font-size: 120%; background-color: 0xc00000;@} @end display のような全てのエレメントに働くclassが定義されていた場合は、全てのタグの補 完入力時にclass参照入力を求められます。これが煩わしい場合はエレメント名入 力確定のときにリターンキー(またはC-m)ではなく、C-jを押せばclass補完入力を キャンセルできます。たとえば @display @kbd{[prefix] l} 行内タグ補完を起動 (または@kbd{[prefix] l SPC}) tt をいれたいのでttと入力 @kbd{C-m} @end display とした場合は続いて class= と補完プロンプトが出ますが、 @display @kbd{[prefix] l} 行内タグ補完を起動 (または@kbd{[prefix] l SPC}) tt をいれたいのでttと入力 @kbd{C-j} @end display と最後を @kbd{C-j} で入力した場合は class 補完プロンプトは出ません。 @node Reread CSS file, , CSS-class completion, CSS Support @comment node-name, next, previous, up @section CSS定義ファイルの読み直し htmlファイルを編集中にCSS定義ファイルを修正し、追加した classを補完候補として直ちに読み込ませたい場合は、 @kbd{M-x yahtml-mode} として再起動を行ってください。 @node Customizations, Copying, CSS Support, Top @comment node-name, next, previous, up @chapter カスタマイズ @cindex カスタマイズ[かすたまいす] @cindex キーアサイン[きいあさいん] yahtmlの動作を制御する変数について説明します。 @menu * All customizable variables:: カスタマイズ変数一覧 * Hook variables:: hook変数 @end menu @node All customizable variables, Hook variables, Customizations, Customizations @comment node-name, next, previous, up @section カスタマイズ変数一覧 @defvar yahtml-prefix yahtml-mode 中のプリフィクスキー (@kbd{\C-c}) @end defvar @defvar yahtml-image-viewer imgで参照している画像ファイルを表示するときに起動するコマンド (xv) @end defvar @defvar yahtml-www-browser @kbd{[prefix]g} で外部ページを表示するときに起動するブラウザ (netscape) @end defvar @defvar yahtml-kanji-code デフォルトの漢字コード。1=sjis, 2=jis, 3=euc, 4=utf-8 (2) .htaccess ファイルに @quotation AddType "text/html; charset=xxx" .html @end quotation の記述があった場合はそれに従う @end defvar @defvar yahtml-fill-column auto-fillするときのカラム数 (72) @end defvar @defvar yahtml-fill-prefix yahtml-mode 固有のfill-prefix (@code{nil}) @end defvar @defvar yahtml-path-url-alist OSのファイルシステム上でのフルパス名と、その外部公開時のURLの対応表。 @end defvar @defvar yahtml-directory-index サーバアクセス時ファイル名を省略したときにデフォルトで開かれる インデックスファイルの名前。多くの場合 index.html。(@code{"index.html"}) @end defvar @defvar yahtml-lint-program HTML構文チェックプログラム。(@code{"jweblint"}) @end defvar @defvar yahtml-hate-too-deep-indentation ネストした列挙系環境でのインデントが深すぎるときにtにする。(@code{nil}) @end defvar @defvar yahtml-always-/p @code{

    } をいれたら必ず @code{

    } したい人向け。@code{nil} @end defvar @defvar yahtml-p-prefered-env-regexp 自動的に @code{

    } を入れて欲しい環境。 (@code{"^\\(body\\|dl\\|blockquote\\)"}) @end defvar @defvar yahtml-template-file 新規HTMLファイル作成時に自動的に挿入して欲しいファイル名。 @file{"~/http/template.html"} @end defvar @defvar yahtml-prefer-upcases タグに大文字を使いたい。@code{nil} @end defvar @defvar yahtml-prefer-upcase-attributes 属性指定子に大文字を使いたい。@code{nil} @end defvar @defvar yahtml-server-type Apache系のサーバを利用している場合は 'apache をセットする。 ./.htaccess を参照するかどうかを決定する。@code{'apache} @end defvar @defvar yahtml-apache-access-file @code{yahtml-server-type} が @code{'apache} のときに アクセス制限ファイル名を指定。@file{".htaccess"} @end defvar @defvar yahtml-shell-command-option シェルで別コマンドを起動するときのオプション。 @end defvar @defvar yahtml-translate-hyphens-when-comment-region 領域コメントアウトをするときに既に存在するハイフンを @code{-} に 変更するかどうか。(@code{t}) @end defvar @defvar yahtml-entity-reference-chars-alist エンティティ参照(Entity Reference)で記述すべき文字群を @code{'(?文字 . "エンティティ表記")} という形式を列挙した alistで並べる。デフォルトで @code{<}, @code{>}, @code{&}, @code{'}, @code{"} に対するalistが設定されているので、追加したい分だけを記述すれば良 い。cdr部 @code{"エンティティ表記"} は、先頭の @code{&} と 末尾の@code{;} は含めずに書く。 @end defvar @defvar yahtml-faithful-to-htmllint 構文チェッカとして htmllint を利用する場合ちょっとした余計な空白などに 対しても警告を示すので、これを回避するときにはこの変数を@code{t}に する。 @end defvar @defvar yahtml-use-css CSSの補完機能を使うかどうか (@code{t}) @end defvar @defvar yahtml-image-inspection-bytes 画像ファイルのサイズを調べるときに読み込むバイト数 (@code{10000}) @end defvar @defvar yahtml:img-default-alt-format のALT属性のデフォルト文字列の書式。%xは画像の幅、 %yは画像の高さ、%sはファイルサイズに置換される (@code{"%xx%y(%sbytes)"}) @end defvar @defvar yahtml-escape-chars href補完などのときに予約文字をURLエンコードするか; 'askのときは確認してから置換する (@code{'ask}) @end defvar @defvar yahtml-use-font-lock ソースの色づけパッケージとして font-lock を利用するか (@code{(featurep 'font-lock)}) @end defvar @defvar yahtml-use-hilit19 ソースの色づけパッケージとして hilit19 を利用するか (@code{(featurep 'hilit19)}) @end defvar @defvar yahtml-indentation-boundary インデント計算を打ち切ってよい境界となる正規表現 (@code{"^\\s *"}) @end defvar @node Hook variables, , All customizable variables, Customizations @comment node-name, next, previous, up @section hook変数 @node Copying, Concept Index, Customizations, Top @comment node-name, next, previous, up @chapter 取り扱い 本プログラムはフリーソフトウェアです。本プログラムを使用して生じたいかな る結果に対しても作者は責任を負わないこととします。転載等に関しては制限いた しません。常識的に扱ってください。また、使用している旨をメイルでお知らせい ただくと、作者は喜んでサポートに励むことでしょう。 苦情、希望、バグ報告、感想等は歓迎いたします。 連絡は yuuji@@yatex.org まで(2000年12月現在)。 継続的に使用してくださる方はメイリングリスト「fj野鳥の会」に 是非加入してください。加入方法については本パッケージの @file{docs/htmlqa} ファイルの「その他」の章を御覧ください。 仕様は、予告なく確実に(気分次第で)変更されます:-p。 @flushright 広瀬雄二 @end flushright @node Concept Index, , Copying, Top @comment node-name, next, previous, up @unnumbered 索引 @printindex cp @contents @bye @c Local Variables: @c fill-column: 74 @c fill-prefix: nil @c buffer-file-coding-system: sjis @c End:  Tag table:  End tag table yatex_1.77+dfsg1/docs/qanda0000444000175000017500000007314112126310642014312 0ustar kurakura%% %% Q and A on YaTeX %% %% C-u C-x $ とすると質問項目だけ表示されます。C-x $ で元に戻ります。 %% (新項目:・RefTeXは使えますか? ・自分で定義したカウンタを\ref補完でのラベル候補対象として認識させたい ・font-lock はどうやって使えばいいんでしょ? ・XEmacsでも色は着きますか? ・{\it }内部では斜体に {\bf }では太字になるという噂を聞いたんですが…) ■インストール関連 ・マニュアルのインストール Emacsのインストールされている場所の info ディレクトリにyatexj ファ イルをコピーし、同じディレクトリにある dir というファイルに次の 行を足します。 * YaTeX: (yatexj). Yet Another tex-mode for Emacs. (Japanese). (あとは M-x info として m yatex で野鳥のマニュアルを選択して読み ます。?を押すと info の使い方が出て来ます。) ・Meadowつこてるんすが make って叩いても何も起きないです〜 makeはバイトコンパイルのために利用しているだけなのでやらなくても 構いません。makeのないMeadowユーザの最短インストールは以下の通り です。 1 Meadowのsite-lispディレクトリに yatex*.tar.gz を展開す る。これを読んでる段階では別のディレクトリに展開している可能 性が高いので、その場合はディレクトリごと移動してしまって下さ い。 2 install ファイルに書いてあるように ~/.emacs にautoloadと load-path, auto-mode-alist の設定を書く。 ・まだしたっぱなので Info ディレクトリに書き込む権利がないっすう… rootにしてもらいましょう。それがだめなときは Mule2 をインストー ルしてもらいましょう。してくれない時は、ホームディレクトリにイン ストールして、ほーらディスクの無駄遣いだよ〜んといって脅せば入れ てくれるはずです。Mule2 なら、~/.emacs に (setq Info-default-directory-list (cons "自分のInfoディレクトリ" Info-default-directory-list)) と書くことで、info を起動した時に個人用のファイルもメニューに加 わります。それでもMule2をなかなか入れてくれない時は、新しいinfo ファイルを拾って来るたびに管理者に「入れてくださーい。あ、すみま せーん毎度。でもMule2なら自分のディレクトリを追加できるんですけ どねぇ…」を繰り返しましょう。 ・LaTeXのヘルプファイルがないといわれる。 Nemacs, Mule1 では $EMACS/etc/, Mule2 では $EMACS/site-lisp/ に 置かれているとみなすようになっています。もし公共の場所に置く権限 がない時は、ホームディレクトリの下のどこかに置いて、変数 YaTeX-help-file にそのファイル名を設定して下さい。 ・Nemacsで info が読めない。 Muleでformatしているので、内部日本語処理の異なるNemacs(または NemacsベースのDemacs)では(バイト数がずれるため)正しく読むことが できません。Muleで御覧ください。なお、Texinfoファイルのフォーマッ トには texinfo-3.1.tar.gz にある Emacs-Lisp ファイルを用いてくだ さい。 また、九州大学の井上さんによると、Info の dir 画面で,M-x Info-tagify とやると info ファイルのコンバートができるそうです。 ■操作関連 ・間違って変なLaTeXコマンドを学習させてしまった。 ホームディレクトリ、またはカレントディレクトリにできている .yatexrc に間違って学習したコマンドを含む行があるはずですから、 その行を削除、あるいは正しいコマンドに書き直してから C-x C-s で .yatexrc をセーブし、C-x k でクローズします。元のLaTeX編集バッファ に戻ったことを確認してから M-x YaTeX-reload-dictionary とする と、書き換えた .yatexrc が現在のバッファに反映されます。 ・リジョンを指定してコメントアウトしようとしたのにうまくいかない。 おそらくカーソルが \begin{}, \end{} の行に乗っているのだと思いま す。一行上か下によけて C-c > してください。 ・タイプセットの時に親ファイルを聞かれて、その時に間違えてしまった。 C-x C-v RET でもう一度子ファイルを読み直すか、 C-u C-c ^ で親ファイルをもう一度入力してください。 ・Demacsでタイプセットエラーがでた時にtypesetバッファがうまく表示されない。 Demacs 1.2.0 で子プロセスが1以上の errorlevel を返した場合、この ような症状が起きる事があります。jlatex をバッチファイルから呼ぶ ようにし、その末尾で必ず errorlevel 0 を返すダミーのコマンドを呼 ぶようにします。 ・「\underline{\makebox[4em][l]{x y}{\tt z}}」 などを手軽に入力したい。 section型補完の引数をミニバッファで入力する時にも再帰的に種々の 補完機能が使えます。表題のコマンド列を補完入力したものが以下の例 です。 プロンプト キー入力 C-c s und SPC RET \underline{???}: C-c s makeb SPC RET Width: 4em RET makebox position (`lr'): - l RET \makebox{???}: x y RET \underline{???}: \makebox[4em][l]{x y} C-c l tt RET \underline{???}: \makebox[4em][l]{x y}{\tt } z RET ・「\footnote{ほげほげ}」と書いたけど\footnote{}を取り払いたい。 \footnote の部分にカーソルを合わせて C-c k としてください。 \footnote{} の部分だけ選んで消去します。 全部いらない場合は C-u C-c k とします。 ・「ほにゃらら」の部分を\footnoteにしたい。 「ほにゃらら」の部分をマークして C-c S footnote RET などとします。 (Sは大文字) ・いまある verbatim 環境を verbatim* 環境にしたい。 \begin{verbatim} か \end{verbatim} の行で、C-c c します。 ・指定領域を \verb で囲みたい。 残念ながら \verb は maketitle 型なので該当する機能はありません。 ただ C-c $ が領域を $ で括る事を利用して次のようにできます。 . . ここからここまでを \verb にする \verbここからここまでを \verb にする (\verbを入れる) ↑(C-@) (「こ」の位置でマーク) \verbここからここまでを \verb にする ($でくくる) ↑C-c $ \verb$ここからここまで$を \verb にする (完成) ・子ファイルを編集していて typeset-region をやる時に子ファイルの上の方で 定義してあるコマンドも読んで欲しい。 章毎に複数メンバーでファイルを編集する時に子ファイルだけで通用す るマクロを子ファイルの上の方で定義している場合には、typeset region をする時にそれらの行も必要になって来ます。こういう場合は、 子ファイルのマクロ定義の行の末尾に %#REQUIRE をつけることで臨時 タイプセットファイルの先頭にその行がコピーされます。 さらに孫ファイルがあった場合を考えてみましょう。 +-- main.tex --+ +---- sub.tex ----+ +-- subsub.tex --+ | : | |%#jlatex main | |%#jlatex main | |\include{sub} | |\include{macros} | |..... | | : |←| : |←|%#BEGIN | | : | | : | |この辺を | | : | +-----------------+ |タイプセット | +--------------+ ↑ |したい | +-- macros.tex ---+ |%#END | |\def\foo{bar} | |: | |\def\hoge{hero} | +----------------+ +-----------------+ このような場合 sub.tex の \include{macros} の行を以下のように変 えます。 \include{macros} %#REQUIRE さらに subsub.tex のどこかに以下のような行を加えます。 %#REQUIRE \include{macros} %#REQUIRE が行頭にある時はそれより後ろの部分が臨時ファイルにコピー されます。これにより、全体をタイプセットする時、または sub.tex, subsub.tex いずれかを typeset-region する時どちらにおいてもかな らず一度だけ macros.tex がインクルードされることになります。 ・直前に入れた \foo{引数だよ} の「引数だよ」をもう一回使いたい。 gmhist というパッケージを導入しましょう。野鳥は gmhist に対応し ています。ミニバッファで \foo{???}: と聞かれた時に M-p (ESC p)を 押すと今まで入力した文字の履歴を逆方向にたどって表示します。M-n と押すと順方向にたどります。これらの入力履歴は begin 型補完、 section 型補完、プレヴューア起動、プリントアウトコマンド起動それ ぞれに対し独立に設定されます。 gmhist は多くの Emacs-Lisp アーカイブサイトに置いてあります。 ftp.ae.keio.ac.jp:pub/emacs-lisp/util/gmhist.tar.gz にもあります。 ただし、Mule2 以降を用いている場合は、gmhistを用いなくてもミニバッ ファでのヒストリが使えます。 ・ref←→label間ジャンプで存在するはずのref/labelにジャンプしない。 C-c g とだけ打つと対応するref/labelの前方検索から始めます。 C-u C-c g と打つと後方検索から始めます。続けて \ref を検索するよ うな場合は C-s (C-r) を二回続けて押しインクリメンタルサーチの連 続検索機能を利用します。もしジャンプ先が別ファイルにある時は、そ のファイルをあらかじめオープンしておく必要があります。C-c d の YaTeX-display-hierarchy は全てのファイルを一気にオープンするため にも使えます。 ・fill-paragraph や auto-fill で行末に%が付いちゃう。 TeX version 2 ベースのNTT-jTeXでは日本語のパラグラフの各行頭をイ ンデントして書くとその分スペースが余計に入った印刷イメージになっ てしまいます。それを回避するために行末に % を付ける必要がありま す。野鳥ではインデントされたテキストをNTT版でも入力できるように 「行末%」の面倒をみています。でもバグってる可能性ありありなので、 行末以外に % が出るなどの現象を発見したらご連絡ください。 ・itemize環境の中のitemizeのインデントが深すぎやしませんか? でしょ? 某K君があのほうがいいって言って、TABを打っては一人酔いし れているのでので、そうしたんですが、私は気に入りません(←まだ根 に持ってる)。「深すぎる!」という方は、内側の\begin{itemize} の行 末でTABを打ってください。なぬ、今度は浅すぎる? さてトイレ行こ。 ・いつも雛型として使っている template.tex を簡単に入れたい autoinsert.el (Emacs19/Mule2付属)を使いましょう。もしくは、それ の機能強化版 auto-insert-tkld を使いましょう。後者は、 ftp://ftp.ae.keio.ac.jp/pub/emacs-lisp/util/auto-inset-tkld.tar.Z で入手できます。 ・bibtexとlatexとかを交互にかけるのが面倒なんですけど latexmk というスグレもののツールがあります。これは、.tex, .bib, .idx などのファイル間の依存関係をドキュメントを走査して調 べ、自動的に bibtex, makeindex, jlatex などを必要な順序で必要な 回数起動してくれます。これをインストールし、各ドキュメントの先頭 に %#!latexmk などと書いてタイプセッタとして latexmk を指定すれば複雑な依存関 係に悩んだ日々とはおさらばです。なお、latexmk は CTAN サイトの support/latexmk/ ディレクトリに置いてあります。 (例えば ftp.kdd.lab.kdd.co.jp:/CTAN/) ・タイプセットとプレヴューでキーが違うのが面倒ですね? そういうことを感じるということは、もしかして、プレヴューアを起動 して確認したのちに、いちいちプレヴューアを終了させたりしてますか? UNIXでもWindowsでもそんなことは普通しなくていいんです。一度起動 したプレヴューアは常駐させておけば、表でLaTeXソースをタイプセッ トすれば、次回プレビューアの窓を選択したときに勝手にリロードして くれます。プレビューアを毎回終了させるとフォントのロードなどオー バーヘッドが大きいので、是非常駐させましょう。意外にそのことを教 えてもらってない人がいるようなので書いてみました。 結局のところほとんど [prefix] tj のタイプセットのみで用件は終わ ります。また、もしbibtexなど、他の関連コマンドを繰り返し利用する ような場合は、前項で紹介した latexmk コマンドを利用するというの がスマートな解決策です。結局のところ、ほとんど [prefix] tj と打っ て仕事を進めることになります。 ・fillがうまく行かないなあ デフォルトのインデンテーション(TABを押すと移動するカラム)と違う パラグラフをfillしようとするとうまく行きません。auto-fill をONに して文章を入力していればこの問題は起きないはずです。もし、他のと ころからコピーした段落で、デフォルトのインデンテーションと違う段 落ができてしまった場合は、 (1)行頭で C-x . (fill-prefixをキャンセルする) (2)インデンテーションを揃えたい範囲をマークする (3)M-C-\ する。 という操作でデフォルトのインデンテーションに揃えることができます。 もし、デフォルトとは違う深さでfillしたい場合は、行の最初の非空白 文字にカーソルを合わせて M-q してください。 ・Win95/WinNTでタイプセッタなど外部プロセスが呼べない shellを変更していないならとりあえず、 (setq shell-command-option "\\/c") を .emacs に入れてみましょう。 UNIX系のshell(sh, bash, tcsh, zsh等)を使っている場合は、 (setq shell-command-option "-c") を .emacs に入れてみましょう。 ・RefTeXは使えますか? 使っている人はいるみたいですから使えるんじゃないでしょうか。でも ですね、野鳥の \ref 補完があれば、RefTeXなんぞ要らないと思います よ。これからは\label{}はいちいち自分では作らずにいきなり[prefix] s で \ref を打ち込みましょう。勝手にラベルを打てそうなところを探 して勝手にラベルを打ってその名前を\refに入れてくれます。\ref補完 は \label{} と \ref{} 両方同時に補完入力します。 でですね、\ref補完の方がしょぼいと思うなら改良しますよ。「RefTeX の方が色がついてかっちょええ」という問題以外ならすぐに頑張ります。 ・自分で定義したカウンタを\ref補完でのラベル候補対象として認識させたい おお、これは高度な質問でござるよ。ちみすごいね。え、質問の意味が 分からん? じゃLaTeXのおべんきょーから。 たとえば、プログラムリストなんかには図表と同じように番号を付けた い。そゆときあるっしょ。そういうときには定理型環境を newtheorem で定義するですよ。たとえば、セクション番号に連動してつくようなプ ログラムリスト環境を作りたいとしましょ−。そしたらこうします。 \newtheorem{Program}{リスト}[section] こうすると \begin{Program} ... \end{Program} とするとタイプセッ ト結果が リスト 2.4.1 ... なんてなるわけですな。かっちょえー。さて、このままだとこの2.4.1 という番号を\refで引っ張るためには\labelを作らないとあかんわけで すよ。でもどうせ自分で環境を定義するならlabelも自動的に定義しちゃ うようなマクロを定義しちゃった方が御便利なわけですよ。 もっとい うと独自に定義したカウンタのどの位置に \label を打たせるかを野鳥 に判断させるためのパターンを書くのはものすごくむずかしいので、ラ ベルを定義するためのマクロのパターンを教えた方がやりやすいわけで す。ということで、暗黙でラベルも打たせるような環境を定義すると、 こんな感じ。 \newenvironment{program}[1]{ \begin{table}[tbp] \begin{Program}\filename{#1}\nopagebreak[4]\label{#1}\end{Program} \nopagebreak[4] \begin{breakbox}\small }{ \end{breakbox} \end{table} } この小文字 program 環境は \begin{program}{foo.c} \begin{verbatim} #include \end{verbatim} \end{program} みたいにするとタイプセット結果が リスト 2.4.1 foo.c ┌──────────────┐ │#include │ └──────────────┘ てな具合になるわけですよ。おおかちょええ。さて、小文字program環 境のマクロ定義を良く見ると環境に渡した foo.c はそのまま自動的に \label{#1} でラベルとして打たれることになります。あ、pLaTeX のラベルは日本語もOKよ。で、その暗黙のうちに打たれたラベル名を野 鳥に教えるというのがスマートなやり方です。これを定義するのが変数 YaTeX::ref-labeling-regexp-alist-private なり。これには (正規表現 . ラベル名のグループ番号) という組(consセル)がたくさん集まったリストを定義する。たとえば、 上記のprogram環境の第1引数を拾わせるには (setq YaTeX::ref-labeling-regexp-alist-private '(("\\\\begin{program}{\\([^}]+\\)}" . 1))) とします。program環境の第一引数の部分の正規表現が {\\([^}]+\\)} の部分で、\\( \\) のグループ化された正規表現 [^}]+ つまり、閉じ 中括弧以外の文字が続くところ、がラベル名として取り出せるわけです。 ということで、上記のようなLaTeXマクロの定義と YaTeX::ref-labeling-regexp-alist-private の定義で無事、自分なり のカウンタとそのラベル名を\ref補完に取り込めるわけです。最初は面 倒臭いけど、一度定義しちゃえば一生モノでっせ! ■Mule2 関連 ・Mule2+hilit19を使っている時に数式が暗くて良く読めない。 hilit19.el のデフォルトのカラーリングが暗すぎるせいです。 以下のコードを ~/.emacs や yatexhks.el などに入れてください。 (if (and (featurep 'hilit19) (eq hilit-background-mode 'dark)) (hilit-translate string 'mediumspringgreen formula 'khaki label 'yellow-underlined)) ・font-lock はどうやって使えばいいんでしょ? 1.69以降では、XEmacs-21, Emacs-21, Emacs-20 において利用できます。 野鳥起動前に (require 'font-lock) しておいてください。 ただし、font-lock のドキュメントをみると「パターンは一行内で指定し てね」とあるので本来行とは無関係な論理的構造範囲で色付を行なうため には設計されていません。これを回避するため、野鳥では仕様外のパター ン指定を行ない論理構造範囲での色付をさせています。したがって、将来 font-lock が仕様を変えたら簡単に色付がうまく行かなくなる可能性を大 いに持っています。hilit19からの乗り換えを考えている場合は、いつで も元に戻れるようにしておいた方がよいかもしれません。 ・XEmacsでも色は着きますか? font-lock を利用して下さい。野鳥起動前にあらかじめ font-lock をロー ドしておきます。 以前、野鳥が font-lock 未対応だった時代に入れた (put 'yatex-mode 'font-lock-defaults 'tex-mode) という記述は **削除** してください。野鳥独自の色づけ規則により、ユー ザー辞書に登録してあるマクロや、section型マクロの引数を数えて光ら せるなどの特長があります。 ・Meadowでも font-lock な色は着きますか? つくことはつくんですが、2000年現在の公式版Meadow-1.10はでは 光りそうなLaTeXマクロを手で入力すると光る範囲の検出がおかしくなっ てエラーが発生することがあります。新しい Meadow では本家Emacsと 同様普通に動くであろうことを期待して、この件に関しては対処しませ ん。光らないだけで実害はないので、気にしないか、あるいは次の Meadow が登場するまで hilit19 を利用して下さい。 ・メニューバーの YaTeX をクリックした時にハングしたかと思うほど遅い。 わかりません、Emacs のせいです。我慢してください。二回目からは遅 くありません。ふつ〜メニューなんか使わないでしょ? サルのようにメ ニューバーを使う友達に野鳥を勧めてはいけません。言いすぎでした、 ごめんなさいごめんなさい。 ・\it をイタリック表示できませんか?(Mule2) まず、普段使用しているサイズの斜体フォントを探します。 *scratch* バッファで、 (set-face-font 'italic "-*-*-medium-i-*--*-*-*-*-*-*-*-*") と打ち C-j してみる(かなり時間がかかる!!)。No matches found なら (set-face-font 'italic "-*-*-medium-o-*--*-*-*-*-*-*-*-*") を試します。 どちらでもマッチするものがなかったらあきらめましょう。(;_;)/~ 大抵何かフォント名が出て来るはずです。例えば、16dotフォントを 使っている場合であれば、 "-schumacher-clean-medium-i-normal--8-80-75-75-c-80-iso8859-1" が、14dotフォントを使っている場合なら、 "-adobe-courier-medium-i-normal--12-120-75-75-m-0-iso8859-1" などが返って来るので、これを用いて (set-face-font 'italic "-schumacher-clean-medium-i-normal--8-80-75-75-c-80-iso8859-1") あるいは (set-face-font 'italic "-adobe-courier-medium-i-normal--12-120-75-75-m-0-iso8859-1") のような記述を yatexhks.el などに入れます。 以上で \it, \em, \sl の中身が斜体表示されるはずです。ただし、16 ドットフォントの場合、pixelサイズが16のものがない可能性が高いの で、幅はあっていても周りの16ドットフォントよりずいぶん小さいもの が表示される場合がほとんどです。14ドットフォントを用いている場合 はかなりましです。 ■カスタマイズ関連 ・C-c b i とかは滅多に使わないので C-c b だけで補完入力になって欲しい。 ~/.emacs などで (setq YaTeX-no-begend-shortcut t) として下さい。 ・開き括弧を入れると勝手に閉じられちゃうのが調子悪い。 しばらく使うとこちらの方が便利だと感じると思います。もしそれでも 肌に合わない時は、C-c w m で常に修正モードをONにして使って下さい。 変数 YaTeX-close-paren-always の値を nil にセットすると起動時か ら括弧の自動クローズをOFFにします。 ・; を押すと変なのがでて来たりする。 カーソル位置が数式環境であると判定されて、数式環境用イメージ補完 が起動しています。もしTeXでエラーが出ない数式を組んでいるにもか かわらず野鳥の ; が数式環境判定を誤るようなら、作者まで御連絡下 さい。なお、誤判定が起きた場合、; 自身を入力するには ; を二回押 し、; をイメージ補完prefixとして動作させるには C-u ; と押します。 ・newenvironmentした環境のオプション引数を入力させたい。 yatexadd.doc を参照してください。それでも今一つピンと来ない時は yatexgen.doc を参照し、M-x YaTeX-generate などを利用してください。 ・\foo を最初3個の引数をとるマクロとして定義し、あとで4個に変えたのに、 section型補完は \foo の補完時に3個までしか引数を聞いてくれない。 C-u 4 C-c s と4個の引数であると言う情報を与えてください。引数の 個数情報はいつでも変更可能です。 ・アドイン関数(引数型)を作ったのに2個目以降の引数の補完関数が呼ばれない。 \foo{x}{y}{z}のような3個の引数をとるコマンドの引数型アドイン関数 を作ったとすると、一度 C-u 3 C-c s foo として \foo の引数が3個で あることを辞書に学習させる必要があります。 ・自作のアドイン関数がyatexaddに上書きされてしまう。 以前は個人のアドイン関数を個人のyatexadd.elに入れることにしてい ましたが、現在は個人のアドイン関数はyatexhks.elに入れることを前 提としています。yatexhks.elは野鳥初期化の最後に読み込まれるため、 標準のyatexadd.elの定義などを上書きすることができます。 ・newenvironmentしたmylist環境でおまかせ改行を使いたい。 infoマニュアルのおまかせ改行のところを見て下さい。基本的には YaTeX-intelligent-newline-mylist という名前の関数を定義すればOK です。ただ例えば、\item だけを挿入したい、つまりitemize環境のお まかせ改行と全く同じで良いというのなら、 (fset 'YaTeX-intelligent-newline-mylist 'YaTeX-intelligent-newline-itemize) と書くと効率的です。 ・数式モードでskkを自動offにするには? canna や wnn では、$や数式環境を補完入力した時に日本語入力モード がoffになります。skkでも同様の機能を生かしたい時には、 (setq skk-mode-hook '(lambda () (if (eq major-mode 'yatex-mode) (define-key skk-map "$" 'YaTeX-insert-dollar) (define-key skk-map "$" 'skk-self-insert)) (define-key skk-map "\C-x$" 'skk-display-code-for-char-at-point))) を .emacs などに入れておいて下さい。 ・{\it }内部では斜体に {\bf }では太字になるという噂を聞いたんですが… GNU Emacs20 (on X)では簡単に設定できます。 (おそらくXEmacsでも有効) Xのデフォルトだと16ドットを使っている人が多いのですが、何故か英 字フォントは16ドットが充実していず、ちゃんとした斜体字フォントが ありません。ということでそのままでは快適なフォント生活が送れませ ん。幸い Mule の総本山である電総研でこれらのフォントを用意してく れているので、これを利用しましょう。一番楽なのは16ドットの外国語 フォントをインストールする手でしょうから、これについて説明します。 まず、ftp.etl.go.jp の /pub/mule 以下にある intlfonts- というファイルを探します。これが各国語のフォントです。 intlfonts-split/ というディレクトリがあり、ここにはフォ ントサイズによってファイルをまとめたアーカイブが置いてあるので、 例えば 16dots.tar.gz をGETします。そして以下のようにインストール します。 % tar zxpf 16dots.tar.gz % cd intlfonts- % ./configure --prefix=/usr/local/emacs \ --enable-compress=gzip --with-bdf=no # make install % xset fp+ /usr/local/emacs/share/emacs/fonts configureに渡すインストールPATHのprefixなどのオプションは環境に 合わせ適宜変更して下さい。続いて、Xのリソース定義ファイル (.Xdefautsまたは.Xresources)に、 Emacs.Fontset-0: -*-fixed-medium-r-normal--16-*-*-*-*-*-fontset-normal Emacs.Fontset-1: -*-fixed-bold-r-normal--16-*-*-*-*-*-fontset-normal Emacs.Fontset-2: -*-fixed-medium-i-normal--16-*-*-*-*-*-fontset-normal Emacs.Fontset-3: -*-fixed-bold-i-normal--16-*-*-*-*-*-fontset-normal Emacs.Font: fontset-normal と書きましょう。これで、Emacs20で斜体、太字が使えるようになりま す。もし、これらのフォントが利用できるようなら野鳥はこれを自動検 出し \it, \bf の内部のフォントとします。ただし、これは英字のみで す。 ・では{\it }とか{\bf }で漢字の見栄えを変えるのは無理なんですか? 可能です(Emacs20 & Emacs21 on X)。 日本語の場合は intlfonts だけでなく、X-TTなどのTrueTypeフォント ドライバが必要になります。XFree86 4.0 以降の場合はおそらくそのま ま利用できていることでしょう。XF86 3 の場合は http://X-TT.dsl.gr.jp/index-ja.html などを参照して X-TT をインス トールしましょう。フリーの日本語フォント、渡辺フォント(明朝)、和 田研フォント(ゴシック)をTrueType形式に変換したものがあるので、こ れらもインストールします。リコーやDynaLabなどの商用フォントを購 入しても利用できます。ここではその手順は省略し、既にX上で TrueType フォントが利用できる環境が整っていると仮定します。Xのリ ソース定義ファイルを以下のように修正します。 Emacs.Fontset-0: -*-fixed-medium-r-normal--16-*-*-*-*-*-fontset-tt,\ japanese-jisx0208:-*-fixed-medium-r-normal-*-16-*-jisx0208* Emacs.Fontset-1: -*-fixed-bold-r-normal--16-*-*-*-*-*-fontset-tt,\ japanese-jisx0208:-wadalab-*-bold-r-normal-*-0-*-jisx0208* Emacs.Fontset-2: -*-fixed-medium-i-normal--16-*-*-*-*-*-fontset-tt,\ japanese-jisx0208:-watanabe-*-medium-o-normal-*-0-*-jisx0208* Emacs.Fontset-3: -*-fixed-bold-i-normal--16-*-*-*-*-*-fontset-tt,\ japanese-jisx0208:-wadalab-*-bold-i-normal-*-0-*-jisx0208* Emacs.Font: fontset-tt これにより、やはり野鳥が自動的に和文 italic, bold フォントを検索 し、画面表示上の見映えを変えるようにしてくれます。 Windowsではもっとフォント環境が充実しているのでより簡単に設定で きるのではないかと思いますが、私はそのやり方を知りません。ご存知 の方がいらしたら教えて頂ければ幸いです。 ■その他 ・AUCほげほげを使ってる友達を改宗させたいのですが…。 まあええやん、ちょっとぐらい不便でも人間なんとか我慢できます。 なにそれでも改宗させたいとな。嬉しいことをおっしゃる。 じゃあ、次のようなデモを見せましょう。 (あらかじめ ~/.emacs で (setq YaTeX-create-file-prefix-g t) しておいて下さい) * \begin{itemize} \item ほげほげ \end{itemize} という環境を作っておいて、 「う〜ん、やっぱenumerateがいいな、うりゃ」といって カーソルを\beginか\endに合わせて [prefix] c で enumerate に変 更します。続いて、 「やっぱりここはセンタリングでしょ、おりゃ」といって 環境全体をマーク(ESC C-@)して [prefix] B(大文字) してcenter環 境に括り入れます。 「じゃあpreviewしてみよっか、でもこの部分だけでいいやね」と いってもっぺんcenter環境全体をマーク(ESC C-@)して [prefix] % b してcenter環境を %#BEGIN〜%#ENDで括ってから 領域タイプセットします。[prefix] t r。 「さてpreviewじゃ」 といいつつ [prefix] t p します。 「ほほう、よし、表を書こう」と言って、 enumerate環境の後ろにtabular環境を作ります。 「まあ3列くらいかな」といいつつデフォルトの質問には全てリター ンだけで答えます。すると & & \\ が勝手に挿入されるので適当に埋 めます。 「はい、次の行」 と言いながら ESC RET します。また適当に埋めて 領域タイプセットして xdvi をraiseします。muleに戻りcenter環境 の外に『この表は重要ネ〜』と書きます。 「うむ、『重要』にはアンダーラインを引こう」 といって『重要』をリジョン指定して [prefix] S(大文字) で underline を補完入力し、またpreviewします。 「やっぱアンダーラインはやめ」と言いながら \underline または { か } にカーソルを合わせて [prefix] k して \underline{} を消します。またpreviewして、 「やっぱセンタリングは要らんかもしれんなあ…」と言いつつ \end{center} にカーソルを合わせて [prefix] . を押します。 すると \begin{center}, \end{center} に % がつくのでまた previewします。 「うむ、やっぱりセンタリングはぽいっ」と言って \end{center}の行で [prefix] k をおして begin/end 対を消します。 「さて、ファイルがでかくなって来たので分割するか」と言って \include{foo} などを補完入力します。 「じゃあ foo.tex を作らなきゃ…」と言って [prefix] g します。 foo.tex が勝手に作られるので適当にごちゃごちゃ書いて [prefix] t j でタイプセットします。 「ほ〜ら、foo.tex の親ファイルがさっきのファイルだって分かって るでしょ?」と説明します。[prefix] ^ で親ファイルに戻ります。 「あ〜れ、おれこのソースをいくつに分割してたんだっけ?」 とすっとぼけながら [prefix] d でincludeツリーを表示させて n や p でごちゃごちゃやります。 こんな感じですかね。 あとは、イメージ補完、数式モード自動判定、先回りusepackageなんて のもAUCにはありません。 ・なんで構成ファイルがいまさらSJISなの? だっせー。 このファイルがSJISで書かれているということが分かるあなたは、野鳥 の構成ファイルがJISだろうがEUCだろうが対処できるはずです。しかし SJISで生活している人には分かりません。Meadowや Mule for win32 な らEUCでも読めるんじゃないの? と感じるかもしれませんが、Meadow な どを使いはじめた人の中からは、「pLaTeX+野鳥が便利そうだ」という ことがきっかけになっているという嬉しい報告も聞きます。そういう人 にとってEUCやJISは得体の知れない手間のかかる面倒なファイルでしか ありません。彼らがTeXやEmacsなどの素晴らしい世界に触れる目前で遠 慮してしまう可能性を考えると、やはり野鳥はSJISであり続けるべきだ と思います。 そういうわけで、野鳥ではダサくても嫌いでも、SJISを使います。 ・メイリングリストはないんですか? っていう質問項目があるくらいだからあります。「野鳥」およびそのVz への移植版「雷鳥」(by KATSURAGAWA, Naoki)、Wzへの移植版「白鳥」 (by TAKENAKA, Hiroshi)、Hidemaruへの移植板「飛鳥」(by YASUDA Haruyuki)、xyzzyへの移植版「花鳥」(by MAEDA Manabu) に関する情報 交換のためのメイリングリスト「fj野鳥の会」がそれです。 To: yatex@yatex.org Subject: subscribe ----- たぐでーし。 明けましておめでとうございまーす。 のようにメイルを送れば加入できます。手続きは全て自動で行われ、登 録が完了すると確認とともに、参加/休止/脱会等の制御コマンドの利用 方法が返送されます。是非参加して一緒に野鳥/雷鳥/白鳥/飛鳥/花鳥を 育ててください。なお、自己紹介の文が無い場合一見加入したように見 えますが、自動的に登録解除しますので御注意下さい。 ・野鳥の最新情報は? もしあなたが、WWWにアクセスできるなら、 http://www.yatex.org/ を覗いてみて下さい。このなかの、「yatex-current」というリンクを たどると最新版の野鳥を入手することができます。ただし、正式リリー ス版ではなく、作者がデバッグ中だったりして正常に動作しない可能性 があるので、current版の利用はとくに「デバッグに協力する」という 心構えでの利用をお願いします。 yatex-currentは全ファイルを毎回取得する必要があるので非効率です。 YaTeXのソースコードのMercurialリポジトリを利用し、効率的かつ安全 に更新を行なって下さい。Mercurialをインストール後、以下のように して開発版に追随します。 hg clone http://www.yatex.org:/hgrepos/yatex で、リポジトリ全体を取得します。開発ブランチは dev なので cd yatex hg up -C dev して切り替えます(リリース用ブランチは default)。以後は、同ディレ クトリで定期的に hg pull -uv すれば更新のみを取得します。このディレクトリをEmacsの load-path に加えてしまってもよいでしょう。 ・とにかくわかりませーん! まず質問の前に yatex-current(上述) を試してみて下さい。既に直面 した問題が解決されているかもしれません。それでもだめなら質問しま しょう。 回答を得るまでの早い順に ・近くにいる詳しい人に聞く ・メイリングリストに質問を出す でしょうか。お好きな方法でどうぞ。 ・このファイルを C-u C-x $ してQを眺めて項目選んで C-x $ しても変な所にいく。 ↑なっちゃいますよね? とりあえずQuestionのところで mark しておい て C-x $ したあと C-x C-x してますが(mule2だとこんな苦労しなくて 済むようです)。 Local Variables: mode: indented-text fill-column: 72 fill-prefix: " " buffer-file-coding-system: shift_jis-dos End: yatex_1.77+dfsg1/docs/yatexj0000644000175000017500000023261112126311416014533 0ustar kurakuraInfo file: yatexj, -*-Text-*- produced by `texinfo-format-buffer' from file `yatexj.tex' using `texinfmt.el' version 2.38 of 3 July 1998. START-INFO-DIR-ENTRY * YaTeX: (yatexj). Yet Another tex-mode for Emacs (Japanese). END-INFO-DIR-ENTRY  File: yatexj, Node: Top, Next: Intro, Prev: (dir), Up: (dir) * Menu: * Intro:: はじめに * Terminology:: マニュアル参照上の注意 * Main features:: 主な機能 * Installation:: インストール * Invocation:: プロセス起動 * %#notation :: %#記法 * Completion:: 補完入力 * Local dictionary:: ローカル辞書 * Commenting out:: コメントアウト * Cursor jump:: カーソルジャンプ * Modifying/Deleting:: LaTeXコマンドの変更/削除 * Filling:: 桁揃え * Includeonly:: 勝手に includeonly * What column:: カラム位置ガイド * Intelligent newline:: おまかせ改行 * Usepackage cheker:: 先回りusepackage * Changing mode of YaTeX:: 野鳥動作モード変更 * Online help:: LaTeXオンラインヘルプ * Inclusion hierarchy browser:: ファイル分割階層構造の表示 * Cooperation with other packages:: 他パッケージとの連携 * Customizations:: カスタマイズ * Etc:: その他 * Copying:: 取り扱い * Concept Index:: 索引  File: yatexj, Node: Intro, Next: Terminology, Prev: Top, Up: Top はじめに ******** 野鳥は、GNU Emacs で LaTeX 用の文書を作成する時に pLaTeX などのタイプセッ トコマンドや、プレヴューアの起動を Emacs 編集画面中から行えるようにすると 共に、拡張性の高い種々の補完機能によりソーステキストの編集を支援します。さ らに LaTeX コマンドのオンラインヘルプによりマニュアルを調べる手間を軽減し ます。 English manual *Note Top: (yatexe)Top.  File: yatexj, Node: Terminology, Next: Main features, Prev: Intro, Up: Top 本マニュアル参照上の注意 ************************ 本マニュアルでは以下の表記を用います。 * begin型コマンド `\begin{環境} 〜 \end{環境}'という形式のLaTeXコマンドを指します。 begin型コマンドを補完入力することをbegin型補完と呼びます。 * section型コマンド `\section{タイトル}'や`\mbox{内容}'のように引数を取るLaTeXコマンドを 指します。 * maketitle型コマンド `\maketitle'や`\tableofcontents'のように引数を取らないLaTeXコマンドを 指します。 * large型コマンド `{\large ...}' や `{\tt ...}' のようなフォント/サイズ指定子を指します。 * `[prefix]' 野鳥の機能を呼び出すためのプリフィクスキー。デフォルトでは`C-c'に割り 当てられているので、特に変更していない場合本マニュアルの `[prefix]' という表記は、`C-c' と読み換えてください。  File: yatexj, Node: Main features, Next: Installation, Prev: Terminology, Up: Top 主な機能 ******** * タイプセッタやプレヴューアなどの編集画面からの起動(`C-c t') * カーソル位置によらない固定リジョンの部分タイプセット * \includeonlyのワンタッチ更新 * エラー箇所への自動ジャンプ(`C-c '') * `\begin{}, \end{}, \section...' などの LaTeX コマンドの補完入力(`C-c b', `C-c s', `C-c l', `C-c m') * 既に入力したテキストを環境やコマンド引数の中に取り込む括り補完(`C-u' +通常補完キー) * セクション区切り入力時の文書構造アウトライン表示 * セクションコマンドの一括シフト (*Note view-sectioning::) * 補完辞書の学習 * LaTeX の環境やコマンドに応じたガイド付き引数入力 * 野鳥にないガイド付き引数入力関数の自動生成(`yatexgen.el') * LaTeX コマンドの削除/変更(`C-c k', `C-c c') * ファイル間、`\begin'<->`\end'間、`\ref'<->`\label'間、 `\cite'<->`\bibitem'ジャンプ(`C-c g') * 一括コメントアウト/アンコメントアウト(`C-c >', `C-c <', `C-c ,', `C-c .') * アクセント記号/数式環境用コマンド/ギリシャ文字の入力支援(`C-c a', `;', `/') * tabular/array環境のカラム位置ガイド * 標準的 LaTeX コマンドのオンラインヘルプ(`C-c ?', `C-c /') * ドキュメントのインクルード構造の視覚的表示とバッファ切り替え(`C-c d') * 補完入力したマクロに応じて必要な \userpackage を入れてくれる先回り userpackage * \labelを打つことはもう忘れよう! refやcite補完入力で自動生成します  File: yatexj, Node: Installation, Next: Invocation, Prev: Main features, Up: Top 起動法 ****** 野鳥起動のための設定 ==================== ~/.emacsに下の2項目を加えます。 (setq auto-mode-alist (cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist)) (autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t) 次に野鳥の emacs-lisp ファイル群を置くディレクトリを load-path に加えます。 たとえば、 `~/src/emacs/yatex'に置くのであれば、 (setq load-path (cons (expand-file-name "~/src/emacs/yatex") load-path)) などとします。 以上の設定により、拡張子が .tex であるファイルを編集すると自動的に野鳥が ロードされます。野鳥が正常に起動できたときはモードラインの表示が「やてふ」 に変わります。 タイプセッタ/プレヴューア環境の設定 =================================== 利用する外部プログラムに関する以下の変数を確認し、必要なら正しい値に変更 します。 `tex-command' ... 起動するタイプセッタのコマンド名 `dvi2-command' ... 起動するプレヴューアのコマンド名 `NTT-jTeX' ... 改行+インデントによって、タイプセット後の字間が空いてしま うのを抑制する場合にtにする(古いNTT-jTeXで顕著に現れる)。具体的には、 fillするときに各行の終わりに%を付加するようになる。 `YaTeX-kanji-code' ... 文書を作成する時の漢字コード `dviprint-command-format' ... ファイルの印刷に使われるコマンド列の書式 `makeindex-command' ... makeindexコマンド これらを変更する場合は、やはり`~/.emacs'にて、たとえば(setq tex-command "pdflatex") のようにしてください。どのような値をセットすれば良いかについて は、*Note All customizable variables::を参照してください。  File: yatexj, Node: Invocation, Next: %#notation, Prev: Installation, Up: Top latexコマンド起動 ***************** LaTeXソースの編集中、次のキー入力により、platex などのタイプセットプログラ ム(以後タイプセッタと呼ぶ)、プレヴューアなどの起動ができます。 `[prefix] t j' ... タイプセッタ(platex)起動 `[prefix] t r' ... タイプセッタ起動(領域指定) `[prefix] t e' ... タイプセッタ起動(ポイント位置の環境または数式モードのみ対 象) `[prefix] t k' ... 動作中のタイプセッタの停止 `[prefix] t b' ... jbibtex起動 `[prefix] t i' ... makeindex起動 `[prefix] t d' ... タイプセット完了後dvipdfmx起動 `[prefix] t p' ... プレヴューア起動 `[prefix] t l' ... lpr(プリントアウト用)コマンド起動 `[prefix] t s' ... xdvi -remote でのサーチ * Menu: * Calling typesetter:: タイプセッタ起動 * Calling previewer:: プレヴューア起動 * Print out:: プリントアウト用コマンドの起動  File: yatexj, Node: Calling typesetter, Next: Calling previewer, Prev: Invocation, Up: Invocation タイプセッタ起動 ================ タイプセッタを起動すると、編集ウィンドウが2つに分割され、片方のウィンド ウにタイプセット画面が表示されます。出力されるメッセージと連動しタイプセッ トバッファは自動的にスクロールします。もし、途中でエラーが起こって止まって しまった場合にはタイプセットバッファに移り、(`C-x o') タイプセッタの出して いる ? プロンプトに対して、`x' (処理の中断)などの指示を送ることができます。 エラーを修正する場合は、 `[prefix] '' `(prefix+アポストロフィ)' ... 直前のエラー発生行へジャンプ を入力することにより、タイプセッタがエラーを発生した行に移ることができます。 また、タイプセッタの出力する overfull hbox などのウォーニング行にも対応し ていますので、順次 `[prefix] '' を押すことにより、一つ前のウォーニング発生 行にジャンプしていきます。 もし、気になるエラー行があった場合は、タイプセットバッファで、エラーの表 示されている行にカーソルを合わせスペースキーを押すと LaTeX ソースの対応す る行にジャンプします。 領域タイプセット ---------------- ポイントとマークの間、あるいはテキスト中に埋め込んだ `%#BEGIN' と`%#END' の間の領域(*Note %#notation::)だけを切り取ってタイプセットすることができま す。この場合メインファイルのプリアンブルが一時ファイルのプリアンブルとして 使われます。したがってプリアンブルにないマクロ定義が領域内にあるとエラーに なります。領域タイプセットを使う場合、必ずマクロ定義はプリアンブル (`\begin{document}'より前)に置くようにして下さい。一時ファイルはメインファ イルのあるディレクトリの`texput.tex'という名前で出力されるので、上書きには 注意してください。 環境タイプセット ---------------- `[prefix] te' を押すと、ポイント位置の最も内側の環境、または数式モード内 の場合はその数式モード全体が自動的に領域選択されて、領域タイプセットを呼び 出します。tabular環境や数式モードで複雑なものを作っている場合は確かめたい 部分だけを確認できるので便利です。これも `texput.tex' に該当部分を書き出し ます。プレヴューアで `texput.dvi' を開いたままにしておけば修正と確認が素早 くできるでしょう。  File: yatexj, Node: Calling previewer, Next: Print out, Prev: Calling typesetter, Up: Invocation プレヴューア起動 ================ `[prefix] t p' によりプレヴューアの起動ができます。さらに、もしあなたが、- remote 機能つきのxdviを利用している場合は `[prefix] t s' を押すことにより カーソル位置の文字列を検索してそのページを表示するようにすでに起動中のxdvi に命令を送ります。これにより、現在編集中の箇所のタイプセット結果を即座に見 ることができます。  File: yatexj, Node: Print out, Prev: Calling previewer, Up: Invocation プリントアウト ============== `[prefix] t l'を押してプリントアウトを指示すると、出力開始/終了ページを 聞いてくるので、それぞれに答えます。これを省略したい時は、 universal-argument をつけ、 `C-u [prefix] t l' ... ページ確認省略lpr起動 のように起動してください。  File: yatexj, Node: %#notation, Next: Completion, Prev: Invocation, Up: Top %#記法 ****** 本文中に`%#'ではじまるキーワードを埋め込むことでタイプセッタ起動等の制御 をすることができます。 * Menu: * Changing typesetter:: タイプセット用コマンドの変更 * Splitting input files:: 入力ファイル分割 * Fix region for typesetting:: 領域の固定 * lpr format:: プリントアウトコマンド用フォーマット * Controlling which command to invoke:: その他の起動コマンド制御 * Editing %# notation:: %#記法の編集  File: yatexj, Node: Changing typesetter, Next: Splitting input files, Prev: %#notation, Up: %#notation タイプセット用コマンド変更 ========================== 起動するコマンドを変えたい時は本文中に次のような行を書きます。 %#!jlatex-ntt NTT jTeX と、ASCII jTeX を使い分けたいような場合に便利でしょう。  File: yatexj, Node: Splitting input files, Next: Fix region for typesetting, Prev: Changing typesetter, Up: %#notation 入力ファイル分割 ================ また、章毎に別ファイルの .tex を作成している場合で、`main.tex'から `sub.tex' を `\include'しているような時は、`sub.tex'の任意の位置に次のよう な行を埋め込みます。 %#!platex main.tex 上の例のようにコマンド名だけでなく引数も書いた場合には、全てをそのまま shell に渡すので次のように書けば、ghostview などをプレヴューアに使う時に便 利です。 %#!platex main && dvi2ps main.dvi > main なお、この行の最後の単語のピリオド以前を「メインファイル」のベースネームで あると仮定します(上の2つの場合どちらも`main')。この行に記述した、`%f'はメ インファイル名に、 `%r' はメインファイルの拡張子を取り除いた部分に置換され ます。ただし、`%f,%r'を利用した場合、初回タイプセット時に必ずメインファイ ル名の入力を促されます。 `[prefix] g' (*Note Cursor jump::参照) でのファイル間ジャンプを有効に機 能させるため、入力ファイル分割時には次のことに注意して下さい。 1. サブディレクトリを作って、その中にサブファイルを置くことはできるがサ ブディレクトリのサブディレクトリには置けない。 2. メインファイルからサブディレクトリ内のファイルを include する時には、 相対パス指定を用いて、`\include{chap1/sub}'のように記述。 3. メインファイルが一つ上のディレクトリにある場合も、サブファイルには %#!platex main.tex のように記述する(../mainではない)。  File: yatexj, Node: Fix region for typesetting, Next: lpr format, Prev: Splitting input files, Up: %#notation 領域の固定 ========== `[prefix] tr' の領域指定のタイプセットでは、とくに指定のないかぎり、 `C-SPC'でマークした位置と、ポイント(カーソル位置)の間を領域とみなしますが、 必ず決まった領域をタイプセットしたい場合は、その領域を %#BEGIN <渡したい領域> %#END のように`%#BEGIN'と`%#END'で囲み、カーソルを「`%#BEGIN'以降」に置いてくだ さい。この時の領域決定規則をまとめると次のようになります。 1. カーソル位置よりバッファの先頭方向に`%#BEGIN'というキーワードがある場 合 1. `%#BEGIN'よりバッファの末尾方向に`%#END'というキーワードが見つかっ た場合。 =>`%#BEGIN' から、その `%#END' のある位置まで。 2. `%#END' が見つからなかった場合。=>バッファの最後尾まで。 2. カーソル位置よりバッファの先頭方向に `%#BEGIN' というキーワードが 見つからなかった場合。 =>マーク(`C-SPC'位置)とポイント(カーソル位置)の間の領域。 tabular 環境を何度も試行錯誤しているような場合は、`\begin'の前の行に `%#BEGIN' と書き、`\end' の次の行に `%#END' と書いておくと簡単に作表結果を テストすることができます。また、長い .tex ファイルの後半に `%#BEGIN' を書 いておけば、前半の部分は無視できます。このBEGINとEND の消し忘れには十分ご 注意下さい。  File: yatexj, Node: lpr format, Next: Controlling which command to invoke, Prev: Fix region for typesetting, Up: %#notation lprフォーマット =============== まず、プリントアウト用コマンド列のフォーマットについて説明します。コマン ド列フォーマットは、3つの Lisp 変数によって表現されます。デフォルトの dvi2ps 用のフォーマットを例に説明します。 `(1)dviprint-command-format' `"dvi2ps %f %t %s | lpr"' `(2)dviprint-from-format' `"-f %b"' `(3)dviprint-to-format' `"-t %e"' 実際にプリントアウトする時は、(1)中の %s がファイル名に置き換えられ、%f が (2)の内容、%t が(3)の内容に置き換えられます。その際に(2)の文字列中の %b は 「出力開始ページ」、(3)の文字列中の %e は「出力終了ページ」に置き換えられ ます。もし、ページを指定しない時には、%f, %t 両方とも無視されます。 この、dviprint-command-format を臨時に変えたい時は、LaTeX のソーステキス ト中の任意の場所に、 %#LPR dvi2ps %f %t %s | 4up -page 4 | texfix | lpr -Plp2 のように書いて下さい。プリントアウトするページ範囲をいちいち聞かせないよう にする時に %#LPR dvi2ps %s | lpr などとするのも便利かもしれません。  File: yatexj, Node: Controlling which command to invoke, Next: Editing %# notation, Prev: lpr format, Up: %#notation その他の起動コマンド制御 ======================== LaTeX 文書に関連するコマンドは以下の %# 記法で指定することができます。 `%#BIBTEX' ... makeindexを行なうコマンドライン([prefix] t b) `%#MAKEINDEX' ... bibtexを行なうコマンドライン([prefix] t i) 行頭がこれらのキーワードで始まる行をLaTeX文書の先頭付近に書いておけば、そ れで指定したコマンドを起動できます。  File: yatexj, Node: Editing %# notation, Prev: Controlling which command to invoke, Up: %#notation %#記法自体の編集 ================ 以上のような`%#'で始まる各種制御記法を編集するためには `[prefix] %' ... `%#'記法編集メニュー を押します。 !)Edit-%#! B)EGIN-END-region L)Edit-%#LPR というメニューが出て来るので、`%#!'に続くコマンドを変更したい時には`!'を、 `%#LPR'で lpr フォーマットを変えたい時は`l'を、あらかじめ設定したリジョン を `%#BEGIN' 〜 `%#END' で括りたい時は、`b'を押します。`b'を選んだ時には、 それまでバッファ中に置かれていた`%#BEGIN', `%#END' が自動的に消去されます。  File: yatexj, Node: Completion, Next: Local dictionary, Prev: %#notation, Up: Top 補完入力 ******** LaTeX での環境名などは、野鳥の補完機能を利用して能率的に入力することがで きます。 * Menu: * begin型補完:: * section型補完:: * large型補完:: * maketitle型補完:: * Arbitrary completion:: 随時補完 * end補完:: * Accent mark completion:: アクセント記号補完 * Image completion:: 数式記号イメージ補完 * Greek letter completion:: ギリシャ文字補完  File: yatexj, Node: begin型補完, Next: section型補完, Prev: Completion, Up: Completion begin型補完 =========== `\begin{env}...\end{env}'の様な形式の入力の補完をbegin型補完と呼ぶことに します。begin 型補完は、 `[prefix] b' ... begin 型補完開始(標準では `C-c b') で始まります。頻繁に用いられる次の LaTeX 環境の補完は、[prefix] `b' に続く 次の1文字を入力するだけで、`\begin{xxx}...\end{xxx}'を完成させます。 `[prefix] b c' ... `\begin{center}...\end{center}' `[prefix] b d' ... `\begin{document}...\end{document}' `[prefix] b D' ... `\begin{description}...\end{description}' `[prefix] b e' ... `\begin{enumerate}...\end{enumerate}' `[prefix] b E' ... `\begin{equation}...\end{equation}' `[prefix] b i' ... `\begin{itemize}...\end{itemize}' `[prefix] b l' ... `\begin{flushleft}...\end{flushleft}' `[prefix] b m' ... `\begin{minipage}...\end{minipage}' `[prefix] b t' ... `\begin{tabbing}...\end{tabbing}' `[prefix] b T' ... `\begin{tabular}...\end{tabular}' `[prefix] b ^T' ... `\begin{table}...\end{table}' `[prefix] b p' ... `\begin{picture}...\end{picture}' `[prefix] b q' ... `\begin{quote}...\end{quote}' `[prefix] b Q' ... `\begin{quotation}...\end{quotation}' `[prefix] b r' ... `\begin{flushright}...\end{flushright}' `[prefix] b v' ... `\begin{verbatim}...\end{verbatim}' `[prefix] b V' ... `\begin{verse}...\end{verse}' 上記のもの以外の環境名は Emacs の持つインクリメンタルな補完機能を用いて 入力します(上記の環境名も以下の補完入力可能)。 `[prefix] b SPC' ... begin 型補完入力 `[prefix] b SPC' と入力すると、最下行のミニバッファに Begin environment(default document): と表示されます。ここで、何も入れずにリターンキーのみ押すと、括弧内に出てい るデフォルトの環境名が入力されますが、適当な環境名を入力すると、`\begin{環 境名} … \end{環境名}'が文書中に挿入されます。ミニバッファで環境名を入力す るときに、環境名の頭文字を入力し「スペース」をたたくと、一致する環境名が内 部テーブルに存在した場合、正しい環境名に補完されるので、入力の手間が省けま す。内部テーブルに存在しない環境名を入力した時はユーザ専用のテーブルに登録 され、さらにそのテーブルを自動的に、ユーザ辞書(デフォルトでは `~/.yatexrc')に保存します。 さらに、特定の環境を補完入力した時にはその環境で必ず用いられるエントリを自 動挿入します(例: `itemize'環境における`\item'など)。挿入されたエントリが不 要な場合にはundoによって消去して下さい。 既に書いたテキストを環境で括る ------------------------------ ところで、最初に書いてしまったブロックを後から、itemize 環境の中に閉じこ めたいと思うことがありますが、そのようなときは、あらかじめ閉じこめたい段落 をマークして、begin 型補完の各コマンドの `[prefix]' の次の『小文字の 'b'』 を『大文字』に変えて起動して下さい。(または、`C-u' を先に打ち、universal argument をつけても可能です) 例えばあるパラグラフを description 環境の中に入れたいときは、そのパラグ ラフをマークしてから、 `[prefix] B D' `(または ESC 1 [prefix] b D)' `(または C-u [prefix] b D など)' とタイプしてください。これは、`[prefix] b SPC'の補完入力にもあてはまり、 `b' を大文字に変えて、`[prefix] B SPC' とタイプすれば、あらかじめマークし ておいたリジョンを、begin と end の環境で括ります。  File: yatexj, Node: section型補完, Next: large型補完, Prev: begin型補完, Up: Completion section型補完 ============= `\section{目的}' のような形式の入力の補完を section 型補完と呼ぶことにし ます。section 型補完は、 `[prefix] s' ... section 型補完 で実行します。`[prefix] s' を入力するとミニバッファに、 (C-v for view-section) \???{} (default documentclass): というプロンプトが現れるので、そこで `section' のような LaTeX コマンド名を 入力します。ここでもリターンキーのみで括弧内のデフォルト値が選択されるほか、 `chapter'などのような頻度の高い名称入力にはスペースキーによる補完機能が有 効です。 次に、{}の中身の入力を促す、 \section{???}: というプロンプトが現れるので、セクションのタイトルなどを入力します。たとえ ば、 (C-v for view-section) \???{} (default documentclass): section \section{???}: 目的 のように入力した場合は、文章中に \section{目的} が挿入され、 (C-v for view-section) \???{} (default section): vspace* \vspace*{???}: のように{}の中身を省略したときは、 \vspace*{} だけが挿入され、改行はせずカーソルは自動的に中括弧の内側に移動します。 * Menu: * 2個以上の引数をとる section型コマンド:: * Enclose section-type command:: 括り補完 * Recursive completion:: 再帰補完 * view-sectioning:: セクション区切りのアウトライン表示 * label-generation:: ラベル自動生成  File: yatexj, Node: 2個以上の引数をとる section型コマンド, Next: Enclose section-type command, Prev: section型補完, Up: section型補完 2個以上の引数をとる section型コマンド ------------------------------------- ところで、`\addtolength{\topmargin}{8mm}' などのように、引数を二つ以上取 る LaTeX コマンドがあります。このようなコマンドの補完入力には、 section 型 補完呼び出しに引数を付けてください。例えば上の`addtolength' の例であれば、 引数2を指定します。つまり、 C-u 2 [prefix] s (または、ESC 2 [prefix] s) と section 型補完を呼び出した後、 (Ctrl-v for view-section) \???{} (default vspace*): addtolength \addtolength{???}: \topmargin Argument 2: 8mm のように入力してください。最初の addtolength の部分と、第一引数である \topmargin の入力は当然スペースによる補完入力が可能です。ユーザ辞書に登録 される LaTeX コマンドには、この引数の数も学習されるので、最初の補完の時引 数の数を指定して起動しておけば、以後の補完時には、記憶された個数だけ引数を 聞いて来るようになります。あとで引数の個数を変えたい時は、再び `C-u' を用 いて個数を指定し直すことで、自動的に辞書中の引数の個数の部分を更新します。  File: yatexj, Node: Enclose section-type command, Next: Recursive completion, Prev: 2個以上の引数をとる section型コマンド, Up: section型補完 既に書いたテキストを括る ------------------------ また、起動コマンドの`s'を大文字に変えて起動すると、あらかじめ書いた文章 を section 型コマンドの第一引数として括ります。  File: yatexj, Node: Recursive completion, Next: view-sectioning, Prev: Enclose section-type command, Up: section型補完 再帰補完 -------- 高度な使い方になるかもしれませんが、section型補完の引数の入力時にさらに 補完入力を利用することができます(section/large/maketitle型に限る)。section 型コマンドの引数に更に LaTeX コマンドが来る場合にはミニバッファで野鳥の補 完キーを再帰的に入力することで引数の入力も効率的に行なえます。  File: yatexj, Node: view-sectioning, Next: label-generation, Prev: Recursive completion, Up: section型補完 セクション区切りのアウトライン表示 ---------------------------------- 通常のsection型補完の時にミニバッファで`C-v'を押すと現在存在するセクショ ン区切りコマンド全てを `*Sectioning Lines*'というバッファに一覧表示します (「<<--」のついている行がもっとも近いセクション区切り)。この時ミニバッファ で`C-p', `C-n' を押すと`part', `chapter', ..., `subparagraph' のコマンドが 論理階層の高さにしたがって上下します。また、`C-v', `M-v' を押すとセクショ ン区切り一覧バッファがスクロールし、数字の`0'〜`7'を押すとある高さ以上のセ クション区切りだけを選んで表示します(実際にやって見れば分かります)。 `*Sectioning Lines*'バッファは、 `M-x YaTeX-section-overview' ... セクション区切り一覧バッファを生成 で作成することができます。このバッファを選択し任意の行でスペースを押すと、 該当するセクション区切りのある本文中の場所にジャンプします。さらに、同バッ ファで `u' を押すと、ソーステキストの対応するセクションコマンドが一階層上 がり(例: subsection が section に変わる)、`d'を押すと一階層下がります。 `*Sectioning Lines*'バッファにあるセクション区切りの行をマークしておいて `U'を押すとリジョン内のものに対応するソーステキストのセクションコマンドす べてが一階層上がり、`D'を押すと下がります。セクション区切り一覧バッファで 利用できるキーコマンドには以下のものがあります。 `SPC' ... 対応するソース行へジャンプ `.' ... 対応するソース行を表示 `u' ... カーソル位置に対応するセクションコマンドを一階層上げる `d' ... カーソル位置に対応するセクションコマンドを一階層下げる `U' ... マークしたセクションコマンドを一階層上げる `D' ... マークしたセクションコマンドを一階層上げる `0〜6' ... レベル n 以下のセクションコマンドを隠して表示  File: yatexj, Node: label-generation, Prev: view-sectioning, Up: section型補完 ラベル自動生成 -------------- `\ref{}' や `\cite{}' マクロをsection型補完で入れた場合参照先となり得る ものを全て探してメニューにして選択できます。参照先には`\label{}'をつけてお く必要はありません。もしあれば、そのラベルを使い、なければその場で参照先に `\label{}'を作らせてくれます。ラベル名を考えるのは苦痛に感じるものです。全 てのカウンタにラベルをつけるのもたいへんです。もうラベル名に何をつけるか、 ラベルをつけるかつけまいか、などということは忘れましょう!  File: yatexj, Node: large型補完, Next: maketitle型補完, Prev: section型補完, Up: Completion large型補完 =========== `{\large }' のような形式の補完を large 型補完と呼ぶことにします。 `[prefix] l' ... large 型補完開始 がlarge型補完の開始です。`[prefix] l' を押すと、ミニバッファに {\??? } (default large): と表示されるので、上記のものと同じ要領で補完入力して下さい。補完候補に用意 されているのは、`footnotesize' や `huge' のような文字サイズ指定子と、`bf' や`dg'のようなフォント指定子です。 既に書いた文字を括る -------------------- また、begin型補完の時と同様、先に書いてしまった一連の文章の文字のサイズ を変えたいと思う時がありますが、そのような時は、サイズや大きさを変えたい文 字の範囲をマークしてから、呼び出しキーを `[prefix] L' と、大文字の L に変 えて呼び出せば、そのリジョン全体が、ブレースで囲まれます。  File: yatexj, Node: maketitle型補完, Next: Arbitrary completion, Prev: large型補完, Up: Completion maketitle型補完 =============== `\maketitle' の形式の補完を maketitle 型補完と呼ぶことにします。 `[prefix] m' ... maketitle 型補完開始 で、maketitle 型補完を開始します。補完の要領は今までのものとまったく同じで す。LaTeX 用のコマンド名が補完候補として用意されています。  File: yatexj, Node: Arbitrary completion, Next: end補完, Prev: maketitle型補完, Up: Completion 随時補完 ======== さて、今まで述べた典型的な LaTeX コマンド形式の補完入力を用いずに、今入 力しようとしている LaTeX コマンドを文書中の任意の位置で随時補完することも できます。LaTeX コマンド(先頭が\で始まる)を入力している途中で、 `[prefix] SPC' ... 随時補完 を入力すれば、全ての補完候補の中から一致するものが選ばれカーソル位置に挿入 されます。  File: yatexj, Node: end補完, Next: Accent mark completion, Prev: Arbitrary completion, Up: Completion end補完 ======= 現在開いたままの環境名を自動的に検出し、`\end{環境名}'を挿入します。 begin 型補完を用いれば環境の閉じ忘れはないのですが、時にはついつい手で `\begin{環境名}' を入れてしまい、悲しい思いをすることがあります。そのよう な時には気にせず続けて文章を入力し、しかるのちに `[prefix] e' ... end 補完 とすることで、現在開いている環境名で \end{} が補われます。  File: yatexj, Node: Accent mark completion, Next: Image completion, Prev: end補完, Up: Completion アクセント記号補完 ================== 欧文のアクセント記号(`\`{o}'など)を入力する時は、 `[prefix] a' ... アクセント記号入力 を押すと、ミニバッファに 1:` 2:' 3:^ 4:" 5:~ 6:= 7:. u v H t c d b というメニューが出て来るので、数字、または対応する記号/英字を入力して下さ い。すると編集バッファに、 \`{} が現われ、カーソルが{}内に位置するので、さらに一文字入力する事で、 \`{o} が完成され、カーソルは{}の外に戻ります。  File: yatexj, Node: Image completion, Next: Greek letter completion, Prev: Accent mark completion, Up: Completion 数式記号イメージ補完 ==================== 主に数式モードで使用される、矢印やΣなどの記号を擬似的に表現するキー入力 で、LaTeX コマンドを入力できます。これは野鳥自身の「数式モード」でのみ動作 します。野鳥はカーソルがTeXの数式環境の中にある時に`;'や、`:'に特殊な機能 を持たせます。 さて、例えば、←(leftarrow)をASCII文字だけで表現する場合、一般的には「<-」 のようにしますが、これを利用して、数式記号イメージ入力モードで`\leftarrow' を入力するには、`;'(セミコロン)を打ってから`<-'と入力します。同様に、長い 矢印←-(long-leftarrow) をASCII文字だけで表現する場合「<--」とするので、 `\longleftarrow'を入力するためには、`;<--' と入力します。あるいは無限大記 号をASCII文字だけで表現する時は「oo」のようにすることから、`\infty' を入力 する時は、`;oo'とキー入力します。 これらの操作をまとめると次のようになります。 INPUT 入力される LaTeX コマンド ; < - `\leftarrow' ; < - - `\longleftarrow' ; < - - > `\longleftrightarrow' ; o `\circ' ; o o `\infty' いずれの場合も、イメージ入力を行っている途中で望みのものがバッファに表示 されたなら、そこでイメージ入力を止めて次の編集動作に移っても構いません。 数式環境中で`;'自身を入力するには`;;'のようにします。イメージ入力の途中 でTABを押すと、それまで入力した文字で始まるもの一覧が表示されます。ここで 目的の LaTeX コマンドまでカーソルを移動し再度TABを押すことでその LaTeX コ マンドがバッファに挿入されます。 どのキー入力にどの記号が対応しているか全て知りたい時は、`;'を押した直後 にTABを押してください。以下の例は、`;<'と押した後にTABを押したものです。 KEY LaTeX sequence sign < \leq ≦ << \ll 《 <- \leftarrow ← <= \Leftarrow <= 左から[入力キー]、[対応する LaTeX コマンド]、[(擬似)記号図示]、という順で メニューが出て来るので、よく使うものを覚えておくと良いでしょう。ものによっ てはASCII文字で表現することが困難なので、あまり覚えやすいキー並びではない ものがあるでしょうから、そのような場合は \maketitle 型補完で入力するか、以 下に述べる対応表の設定を行って単純なキー並びのものを設定すると良いでしょう。 入力キーと LaTeX コマンド、記号の対応表を個人的に設定したい場合は Emacs-Lisp 変数 `YaTeX-math-sign-alist-private' に定義してください。その内 容とデフォルトのものを合わせたものが対応表として使用されます(private の方 が優先される)。なお、この変数の構造については `yatexmth.el' を参照してくだ さい。  File: yatexj, Node: Greek letter completion, Prev: Image completion, Up: Completion ギリシャ文字補完 ================ もう一つ、数式環境中で`:'を押すとギリシャ文字入力モードに入ります。`:'を 押した直後に`a'を押すと`\alpha'が、`g' を押すと `\gamma'が、などアルファベッ トに対応したギリシャ文字が挿入されます。操作方法は;の数式記号補完とまった く同じです。まずは`:'の直後にTABを押してどのアルファベットにどのギリシャ文 字が対応しているか調べてみてください。 `;'と`:'を数式環境中で押しているにもかかわらず、イメージ補完が働かない場 合は、`C-u ;'のように universal-argument をつけてキーを押すことにより、強 制的にイメージ補完に入ることができます。また、この時にどのような状態で数式 環境内判定に失敗したかをご連絡下さい。  File: yatexj, Node: Local dictionary, Next: Commenting out, Prev: Completion, Up: Top ローカル辞書 ************ 補完入力用の候補は三種類の辞書から構成されています。一つは`yatex.el'に組 み込まれた「標準辞書」、もう一つはユーザが個人的に常用するコマンドを保存す る「ユーザ辞書」、そしてもうひとつはあるディレクトリでのみ有効なコマンドを 保存する「ローカル辞書」です。 補完入力時に新しい単語を入れた場合に、その単語をどの辞書に入れるか聞いて 来ます。 `foo' is not in table. Register into: U)serDic L)ocalDic N)one D)iscard というプロンプトに対し、`u'と答えると「ユーザ辞書」を、`l'と答えるとローカ ル辞書を更新し、`n'と答えると辞書ファイルは更新せず現在のEmacs セッション のみ有効な単語とし、`d'と答えると新たな単語を学習せずに捨てることになりま す。 もし、ローカル辞書の機能はいらず、全てユーザ辞書の更新のみでよいと言う場 合には`~/.emacs'などで、 (setq YaTeX-nervous nil) として下さい。  File: yatexj, Node: Commenting out, Next: Cursor jump, Prev: Local dictionary, Up: Top コメントアウト ************** LaTeXの編集には試行錯誤がつきものです。ある部分を一括でコメントアウトし たり、コメントを外したりしたいことがあります。 `[prefix] >' ... リジョンを % でコメントアウト `[prefix] <' ... リジョンの % のコメントを外す は、あらかじめ設定したリジョンに対しての操作、 `[prefix] .' ... 現在のパラグラフをコメントアウト `[prefix] ,' ... 現在のパラグラフのコメントを外す は、カーソルの位置するパラグラフ全体に対しての操作です。なお、ここでいう 「パラグラフ」は (`mark-paragraph') 関数によりマークされる範囲を指します (標準設定で`ESC h'にバインドされている)。なお、既に`%'でコメントアウトされ ているパラグラフに対して繰り返しパラグラフのコメントを使用した場合の動作は 保証しませんので御注意ください。 さて、文章に対してだけでなく、時には`\begin', `\end' 自体に対してもコメ ントアウトの操作をしたいときがあります。このようなときは、`\begin{}' ある いは `\end{}' の行にカーソルを合わせ、 `[prefix] >' ... `\begin{}'〜`\end{}' 全てコメントアウト `[prefix] <' ... `\begin{}'〜`\end{}' 全てコメントを外す とすることで、`\begin〜\end'で囲まれる環境全てに対してコメント操作し、 `[prefix] .' ... `\begin{}' と `\end{}' をコメントアウト `[prefix] ,' ... `\begin{}' と `\end{}' のコメントを外す は、対応する `\begin' と `\end' 2行だけを、コメント操作の対象とします。リ ジョンをコメントアウトしようとして、マークを設定したのちにカーソルを移動し `[preifx] >' を押してもカーソルが `\begin{}' の上にあると`\begin{}'〜 `\end{}'モードでコメント機能が働いてしまうので注意して下さい。  File: yatexj, Node: Cursor jump, Next: Modifying/Deleting, Prev: Commenting out, Up: Top カーソルジャンプ **************** * Menu: * 対応オブジェクトへのジャンプ:: * お絵描きツール起動:: * メインファイルへのジャンプ:: * 環境を単位としたジャンプ:: * 最後の補完位置へのジャンプ::  File: yatexj, Node: 対応オブジェクトへのジャンプ, Next: お絵描きツール起動, Prev: Cursor jump, Up: Cursor jump 対応オブジェクトへのジャンプ ============================ 文書中のいろいろな場所で `[prefix] g' ... 対応するオブジェクトにジャンプ を押すことにより、カーソル位置のLaTeXコマンドに対応する場所にジャンプしま す。対応関係が存在すると解釈されるコマンドには以下のものがあります。 * `\begin{}' ←→ `\end{}' * `%#BEGIN' ←→ `%#END' * 画像ファイルの取り込みマクロ → 対応するviewer/お絵かきツール起動 * `\label{}' ←→ `\ref{}' * `\include(\input)' → 対応するファイル * `\bibitem{}' ←→ `\cite{}' `\begin{}' か `\end{}' の行で`[prefix] g'を押すことにより、対応する `end/begin'の行にジャンプします。もちろん対応するものがない場合はエラーに なります。またこれは、領域固定のための `%#BEGIN' と `%#END' のペアに対して も同様に動作します。なお、`label/ref'や`cite/bibitem'対応するものが別ファ イルにある時は、ジャンプ先となるファイルがオープンされていなければなりませ ん。*Note %#notation::. メインの .tex ファイルの `\include{chap1}' などに カーソルを合わせ、`[prefix] g' を押すと、`chap1.tex' にジャンプします。 また、 `[prefix] 4 g' ... 別ウィンドウで対応オブジェクトにジャンプ を押すと、対応するオブジェクトへのジャンプを別ウィンドウで行います。ただし、 この機能は `begin/end', `%#BEGIN/%#END' 間のジャンプに対しては(意味がない と思われるので)機能しないので注意してください。  File: yatexj, Node: お絵描きツール起動, Next: メインファイルへのジャンプ, Prev: 対応オブジェクトへのジャンプ, Up: Cursor jump お絵描きツール起動 ================== 上記の「画像ファイルの取り込みマクロ」とは、例えば `\epsfile{file=foo}' の ような挿絵取り込みコマンドのことで、この行にカーソルを合わせて`[prefix] g' を押すとその画像ファイルの元となったファイルを対応するお絵描きツールを起動 してオープンします。起動するツールの判定は以下のようになされます。 1. カレント行が変数 `YaTeX-processed-file-regexp-alist' に定義されている 正規表現のいずれかとマッチしたら、ファイル名に相当する部分を \\(\\)か ら抜き出して覚えておく(何番目の\\(\\)かは変数の各リストの cdr 部に入 れておく)。マッチしなければ何もしない。 2. 行末に、変数 `YaTeX-file-processor-alist' に登録されているコマンドが 「%コマンド」 のように書いてあれば強制的に「コマンド ファイル名.拡張 子」を起動。 3. なければ、変数 `YaTeX-file-processor-alist' の各リストのcdr部に入って いる拡張子を「ファイル名」の後ろに足したファイルが存在するか順次調べ て、存在した場合car部に入っているコマンドを起動する。 4. 以上どれかにマッチしなければあきらめる。 変数 `YaTeX-file-processor-alist' と変数 `YaTeX-file-processor-alist' の設 定方法についてはそれぞれの変数について describe-variable して説明を読んで 下さい。うまく設定すると、画像ファイルにかぎらず、任意の形式のファイルを任 意のプロセッサで処理するコマンドを簡単に呼び出すことができます。  File: yatexj, Node: メインファイルへのジャンプ, Next: 環境を単位としたジャンプ, Prev: お絵描きツール起動, Up: Cursor jump メインファイルへのジャンプ ========================== `chap1.tex'のようなサブファイルで、 `[prefix] ^' ... メインファイルにジャンプ `[prefix] 4 ^' ... 別ウィンドウでメインファイルにジャンプ を押すと、メインファイルの編集バッファに切替えます。もし、メインファイルを オープンしていない場合は、カレントディレクトリから探して自動的にオープンし ます。  File: yatexj, Node: 環境を単位としたジャンプ, Next: 最後の補完位置へのジャンプ, Prev: メインファイルへのジャンプ, Up: Cursor jump 環境を単位としたジャンプ ======================== さらに現在の環境を単位として機能するコマンドに以下のものがあります。 `M-C-a' ... 環境の先頭(`\begin')へジャンプ `M-C-e' ... 環境の末尾(`\end')へジャンプ `M-C-@' ... 環境全体をマーク 上記のコマンドは通常の`[prefix]'キーではなく`META'キーをプリフィクスとして 機能するのでご注意下さい。  File: yatexj, Node: 最後の補完位置へのジャンプ, Prev: 環境を単位としたジャンプ, Up: Cursor jump 最後の補完位置へのジャンプ ========================== 野鳥は補完入力した位置を常にレジスタ `3'に保存しています。入力途中で如何な るファイルの如何なる位置に行ったとしても、`C-x j 3'(`jump-to-register')を 使って直ちに最後の補完入力位置に戻ることができます。  File: yatexj, Node: Modifying/Deleting, Next: Filling, Prev: Cursor jump, Up: Top 変更/削除 ********* 既に入力されている LaTeX コマンドの変更/削除のために以下の機能が用意され ています。 `[prefix] c' ... カーソル位置の LaTeX コマンドの変更 `[prefix] k' ... カーソル位置の LaTeX コマンドの削除 これらのコマンドは、コマンドを起動する場所によって動作を決定するので注意し て下さい。 * Menu: * Changing LaTeX command:: LaTeX コマンドの変更 * Killing LaTeX command:: LaTeX コマンドの削除  File: yatexj, Node: Changing LaTeX command, Next: Killing LaTeX command, Prev: Modifying/Deleting, Up: Modifying/Deleting LaTeX コマンドの変更 ==================== 変更したい LaTeX コマンドにカーソルを合わせて `[prefix] c' を押すとそのコ マンドを補完入力などを用いて手軽に変えることができます。`[prefix] c' で変 更できるコマンドには以下のものがあります。 * `begin/end' の環境名 * section型コマンドのコマンド名 * section型コマンドの引数 * section型コマンドのオプションパラメータ([]で囲まれたもの) * large型コマンド * (イメージ補完で入力可能な)数式モード専用のmaketitle型コマンド 変えたいsection型コマンドの引数がさらに LaTeX コマンドを含む場合は、その 引数を囲む中括弧の上で `[prefix] c' を押すことで中のコマンドを変更対象判定 から除外することができます。  File: yatexj, Node: Killing LaTeX command, Prev: Changing LaTeX command, Up: Modifying/Deleting LaTeX コマンドの削除 ==================== `[prefix] k' は起動する位置により次のような動作を行います。 起動位置 動作 \begin, \endの行 `\begin\end'ペアの削除 %#BEGIN, %#END の行 %#BEGIN,%#ENDペアの削除 section型コマンドの上(中) section型コマンドの削除 フォント指定括弧の上 フォント指定の削除 括弧の上 対をなす括弧の削除 `\begin, \end' および `%#BEGIN, %#END' を削除する場合、`\begin, \end' や `%#BEGIN, %#END' の存在する行はまるごと削除されるので、それらの一行に `\begin' などを二つ以上連ねて書かないように注意してください。上記のものは すべて本文を囲う「容器」を削除するように働きますが、universal-argument (`C-u') を打った後で`[prefix] k'をタイプすると、それぞれの「容器」に含まれ る「中身」も一気に削除します。以下の例を参考にして下さい。 元のテキスト: [prefix] k C-u [prefix] k 本文\footnote{脚注}です。 本文脚注です。 本文です。 ↑(カーソル位置)  File: yatexj, Node: Filling, Next: Includeonly, Prev: Modifying/Deleting, Up: Top 桁揃え ****** itemの桁揃え ============ itemize 環境中にある`\item'の項目(文章)が複数行に渡る場合に、項目の先頭 を桁揃えしたい場合には、 `M-q' ... 桁揃え によって、その item のインデントの深さに応じて fill されます。なお、古い NTT jTeX を使用している場合には、Lisp 変数`NTT-jTeX'を`t'にセットして下さ い。 このとき、変数`YaTeX-item-regexp'の値(標準では `"\\\\item"')を項目指定コ マンドの正規表現として検索に使用します。itemize 環境で、独自のコマンドを定 義して項目を列挙している場合(例えば`\underlineitem')は、`~/.emacs' で次の ように指定して下さい。 (setq YaTeX-item-regexp "\\(\\\\\\(sub\\)*item\\)\\|\\(\\\\underlineitem\\)") この変数の指定の仕方がよく分からない場合は、独自の項目列挙コマンドの名前を ``"\item"'で始まるものにして下さい(例えば"\itembf"')。 野鳥の `M-q' では `\item' を環境に応じて以下のように「ハングインデント」し ます。 itemize, enumerate環境: >\item[ほげほげ] 英語では、特に意味のない単語を `foo' であらわしま > すが、これの日本語版ともいえる単語が「ほげほげ」 > です。 description環境: > \item[へろへろ] 「ほげほげ」をでたらめが単語として使った時に、第 > 2のでたらめな単語として「へろへろ」が使われることが多 > いようです。 パラグラフの桁揃え ================== itemize環境以外でのパラグラフの桁揃え(fill)は、基本的に他のモードと同じ ように機能しますが、verbatim環境や、tabular環境など桁揃えをすると悲惨な状 況になるような環境中では機能しません。また、\verb で括ってあるものは決して 行分割されません(変数 `YaTeX-verb-regexp' で制御) )。さらに、一時的にイン デントの深さを変えてある箇所では、そのインデントの先頭で`M-q'を押すことに より fill-prefix をいちいち変更しなくて桁揃えができます。  File: yatexj, Node: Includeonly, Next: What column, Prev: Filling, Up: Top 勝手にincludeonly ***************** ファイルを分割して文章を入力している時には、メインファイル中に \includeonly{現在編集中のファイル名} のように書いておくことで、タイプセットの時間を節約できますが、ちょっと他の ファイルを手直ししたい時には \includeonly{ちょっと手直ししたいファイル名} と書き直さなければならず手間がかかります。野鳥では現在編集しているファイル 名がメインファイルの`\includeonly'にない場合には自動的にこれを検出し、次の 指示を仰ぎます。 A)dd R)eplace %)comment? 現在編集中のファイルを `\includeonly' のリストに加えたい時には`a' を、現在 編集中のファイルだけを `\includeonly' にしたい時は`r'を、`\includeonly' の 行をコメントアウトして無効化したい時には、`%'をそれぞれ押して下さい。  File: yatexj, Node: What column, Next: Intelligent newline, Prev: Includeonly, Up: Top ここはどこ? *********** 項目数の多い tabular などをたくさん書いていると下の方の行で、いま書いて いる桁がどこに対応するのかわからなくなってしまうことがあります。例えば、以 下のような tabular において、 \begin{tabular}{|c|c|c|c|c|c|c|c|}\hline 氏名&所属&〒&住所&電話&FAX&帰省先&帰省先電話\\ \hline 矢上二郎 & 6 & 223 & 横浜市港北区日吉 & xxx-yyy & zzz-www & トンガ & 9876-54321 \\ 日吉小僧 & 2 & \multicolumn{2}{c|}{教えない} &&&(???) \\ \hline \end{tabular} (???)の部分がどの項目なのかすぐに判断するのは難しいでしょう。こんな時は、 `[prefix] &' ... 現在のカラム表示 を押すとカーソル位置のカラムがどの項目に該当するかをミニバッファに表示しま す。tabular/array環境の第1行目を項目名の並びとみなして対応するものを探しま す。もし項目名として別のものを表示して欲しい場合は、行頭を`%'にしてダミー の項目並びを作っておくと良いでしょう。  File: yatexj, Node: Intelligent newline, Next: Usepackage cheker, Prev: What column, Up: Top おまかせ改行 ************ tabular[*], array, itemize, enumerate, tabbing 環境をbegin型補完で入力し た時、または各環境内で `ESC RET' ... おまかせ改行 を押すと、その環境に応じた行エントリを次の行に挿入します(begin型補完時に自 動挿入されたエントリが不要な場合は undo によって消去できます)。例えば、 tabular環境では、その環境のカラム数に対応した個数の `&' に加え、行末の `\\' を入れます。この時それ以前に `\hline' があればそれも付け加えます。環 境とそれに応じて自動入力するものの対応は以下のようになります。 * `tabular', `tabular*', `array' カラム数-1 だけの `&' と `\\'。必要に応じて `\hline' * `tabbing' 一行目で定義している `\=' と同じ個数の `\>'。 * `itemize', `enumerate', `description', `list' `\item' または `item[]' tabular 環境の例のように、本機能は各環境の一行目の内容を参考にして動作す るので、なるべく二行目以降で呼び出すようにしてください。 もし、その他の環境、例えば `foo'、に対して`おまかせ改行'を動作させたい時 は、`YaTeX-intelligent-newline-foo' という名前の関数を定義します。定義した 関数は、現在の行に改行を挿入した直後の行頭の位置で呼ばれます。関数 `YaTeX-indent-line' を呼ぶと現在の環境のネストに応じた深さにインデントされ るので、これを呼んでから何かを挿入するようなコードを書くとよいでしょう。 `yatexenv.el'内の関数 `YaTeX-intelligent-newline-itemize' の定義などを参考 にしてください。  File: yatexj, Node: Usepackage cheker, Next: Changing mode of YaTeX, Prev: Intelligent newline, Up: Top 先回りusepackage **************** begin型、section型、maketitle型、いずれかのLaTeX2eマクロを補完入力すると、 そのマクロの利用に外部パッケージを必要とする場合、そのパッケージを本文中で `\usepackage{}' しているかどうかを調査し、もししていなければプリアンブルに 対応するパッケージを引数にした `\usepackage' 文を(確認後に)挿入します。 ただしこの機能が働くためには、パッケージ名とその中で定義されているマクロ 群をalistの形式で変数 `YaTeX-package-alist-private' に設定しておく必要があ ります。  File: yatexj, Node: Changing mode of YaTeX, Next: Online help, Prev: Usepackage cheker, Up: Top 野鳥の動作モード切り替え ************************ `[prefix] w' ... 野鳥動作モード切り替えメニュー で野鳥自身の動作を決定する以下のモードを切り替えます。 * 修正モード * 野鳥数式モード 修正モードは、開き括弧入力時の処理をコントロールし、修正モードONの時は開き 括弧の入力は開き括弧のみの入力になり、修正モードOFFの時は開き括弧の入力だ けで閉じ括弧まで入力します。デフォルト(起動時)の設定は*OFF*です。 野鳥数式モードは、変数 `YaTeX-auto-math-mode' が `nil' の時のみ有効で、 このとき`;'や`:'を押した時(*Note Image completion::参照)に、どのようなイメー ジ補完を機能させるか、通常のキーとして機能させるかを手動で切り替えます。自 動判定が遅いマシンでは`YaTeX-auto-math-mode' `nil'にセットし、野鳥数式モー ドを手動で切り替えると良いでしょう。  File: yatexj, Node: Online help, Next: Inclusion hierarchy browser, Prev: Changing mode of YaTeX, Up: Top オンラインヘルプ **************** 使おうとする LaTeX コマンドの用法がよく分からない時は、オンラインヘルプ をひきましょう。ヘルプに関するキーには以下のものがあります。 `[prefix] ?' ... オンラインヘルプ `[prefix] /' ... オンラインapropos オンラインヘルプ ================ 「オンラインヘルプ」は、一般的な LaTeX コマンド(デフォルトでカーソル位置 のコマンド)に対する説明を隣のバッファに表示します。この時参照されるヘルプ 用ファイルには「グローバルヘルプ」と「プライベートヘルプ」の二種類があり、 前者は LaTeX の標準コマンドの主なものの説明を含むファイルで、変数 `YaTeX-help-file'の値で指定されます。このファイルは通常公共の場所(デフォル トで`$EMACSEXECPATH')に置かれ、誰もがその内容を更新できるように全員に書き 込み権が与えられるべきものです。後者は、非標準もしくは個人的なマクロ定義に 関する説明が書かれているファイルで、変数`YaTeX-help-file-private'の値で指 定されます。こちらはユーザのホームディレクトリの下などに置かれます。 オンラインapropos ================= 「オンラインapropos」は GNU Emacs の apropos と同様、ユーザが指定したキー ワードを説明文に含む項目すべてを隣のバッファに表示します。 もし、調べようとしたLaTeXコマンドに対する説明がヘルプファイル中に見つか らなかった場合は、説明文の入力を求めてくるので、可能であれば参考書などを調 べてそのコマンドの説明を入力してください。もし、なにか標準的なコマンドに対 する説明を書いたならばぜひ私までその説明をお送り下さい。次回の配布に含めた いと思います。  File: yatexj, Node: Inclusion hierarchy browser, Next: Cooperation with other packages, Prev: Online help, Up: Top インクルード構造ブラウザ ************************ 複数のファイルに分割しているドキュメントを書いている場合、 `[prefix] d' ... インクルード構造ブラウズ を押すと、そのドキュメントの親ファイルを聞いて来ます。ここで全てのファイル の親となるファイル(デフォルトが示されているので大抵はRETのみ)を入力すると インクルードしている全てのファイルを解析し、インクルード状況を視覚的に表示 します。このバッファでは以下のキー操作が有効です。 `n' ... 次の行に移動し対応するファイルを隣のバッファに表示 `p' ... 上の行に移動し対応するファイルを隣のバッファに表示 `N' ... 同じインクルードレベルの次のファイルに移動 `P' ... 同じインクルードレベルの前のファイルに移動 `j' ... 次の行に移動 `k' ... 上の行に移動 `u' ... 一代親にあたるファイルに移動 `.' ... カーソル位置のファイルを隣のバッファに表示 `SPC' ... 隣のバッファの対応ファイルをスクロールアップ `DEL, b' ... 隣のバッファの対応ファイルをスクロールダウン `<' ... 隣のバッファの対応ファイルの先頭を表示 `>' ... 隣のバッファの対応ファイルの末尾を表示 `'' ... (`<'や`>'の後で)元の表示位置に戻る `RET, g' ... カーソル位置のファイルを隣のバッファでオープン `mouse-2' ... RETと同じ(ウィンドウ使用時のみ) `o' ... 隣のウィンドウに移動 `1' ... 他のウィンドウを消す `-' ... ブラウズウィンドウを小さくする `+' ... ブラウズウィンドウを大きくする `?' ... ヘルプ表示 `q' ... 表示前の状態に戻る ただし、隣のウィンドウのファイルの内容を表示する機能に関しては、対応する ファイルをクローズしてしまうとうまく働きませんのでご注意ください。  File: yatexj, Node: Cooperation with other packages, Next: Customizations, Prev: Inclusion hierarchy browser, Up: Top 他パッケージとの連携 ******************** gmhist ====== `gmhist.el'と`gmhist-mh.el' をロードしている場合、プレヴューコマンドの入 力(`[prefix] tp]')、印刷コマンドの入力(`[prefix] tl')の時に独立したヒスト リを利用できます。それぞれのプロンプトで、`M-p' を押すと直前に利用したコマ ンド文字列をくり返し呼び出すことができます。 min-out ======= `min-out.el' (`outline-minor-mode') と野鳥を組み合わせて使うことももちろ ん可能です。設定の方法に関しては`yatexm-o.el'をご覧ください。  File: yatexj, Node: Customizations, Next: Etc, Prev: Cooperation with other packages, Up: Top カスタマイズ ************ 野鳥の動作を制御する種々の変数を独自に設定することにより、補完入力を起動 するキーアサインを変えたり、環境名の補完候補をさらに充実させることなどがで きます。 * Menu: * Lisp variables:: lisp 変数 * Add-in functions:: 付加関数(アドイン関数)  File: yatexj, Node: Lisp variables, Next: Add-in functions, Prev: Customizations, Up: Customizations lisp 変数 ========= 例えば prefix キーを `C-c' 以外のキーにしたい場合は、`YaTeX-prefix'に prefix キーにしたいシンボルを定義してください。さらに、「`C-c 英字'」とい うキーバインドは独自の関数が割り当ててあるので使いたくない。このような時は、 `YaTeX-inhibit-prefix-letter' を `t' に設定することにより、`C-c 英字…'の バインドが全て、対応する`C-c C-英字…'に変わります(ただし、begin型 large型 補完の大文字起動によるリジョン指定は可能なままです。これも無効にしたい場合 は`t'ではなく 1 にセットして下さい。)。 * Menu: * All customizable variables:: カスタマイズ変数一覧 * Sample definitions:: カスタマイズ変数設定例 * Hook variables:: hook変数 * Hook file:: hook用ファイル  File: yatexj, Node: All customizable variables, Next: Sample definitions, Prev: Lisp variables, Up: Lisp variables カスタマイズ変数一覧 -------------------- yatex-mode における次の変数がカスタマイズ可能です。`~/.emacs' で `setq' しておけば、そちらの定義が優先されます。括弧の中はデフォルト値です。実際に 変数の値を変更する場合は `M-x describe-variable' で変数の詳細な説明を参照 してください。 -- Variable: YaTeX-prefix yatex-mode 中のプリフィクスキー (`\C-c') -- Variable: YaTeX-inhibit-prefix-letter prefix キーの直後のキーバインドで `英字' のものを `C-英字' に変更 (`nil') -- Variable: YaTeX-fill-prefix 本文を書く時の行頭に挿入する接頭辞すなわち fill-prefix (`""(nil)') -- Variable: YaTeX-user-completion-table 学習したLaTeXコマンド保存ファイル名 (`"~/.yatexrc"') -- Variable: YaTeX-kanji-code 文書を作成する時の漢字コードnil=既存のコードのまま 0=no-conversion 1=Shift JIS, 2=JIS, 3=EUC, 4=UTF-8 (2 (MS-DOSでは1)) -- Variable: tex-command LaTeXタイプセッタコマンド名 (`"platex"') -- Variable: dvi2-command プレヴューアコマンド名 (`"xdvi -geo +0+0 -s 4"') -- Variable: dviprint-command-format dviファイルの印刷に使われるコマンド式 (`"dvi2ps %f %t %s | lpr"') -- Variable: dviprint-from-format 上の`%f'に相当する開始ページ指定書式、`%b' が開始ページ番号に変わる (`"-f %b"') -- Variable: dviprint-to-format `%t' に相当する終了ページ指定書式、`%e'が終了ページ番号に変わる (`"-t %e"') -- Variable: makeindex-command makeindexコマンド (`"makeindex"' (MS-DOSでは`"makeind"')) -- Variable: YaTeX-dvipdf-command dviをPDFに変換するコマンド (`"dvipdfmx"') -- Variable: YaTeX-need-nonstop `\nonstopmode{}'を自動的に付加するか (`nil') -- Variable: latex-warning-regexp latexコマンドの出力するウォーニング行の正規表現 (`"line.* [0-9]*"') -- Variable: latex-error-regexp 同じくエラー行の正規表現 (`"l\\.[1-9][0-9]*"') -- Variable: latex-dos-emergency-message MS-DOS上で動作する latex コマンドが、エラーにより停止するとき出力する メッセージ (`"Emergency stop"') -- Variable: latex-message-kanji-code タイプセッタの出力するメッセージの漢字コード.タイプセットバッファの出 力が化ける時は、これを設定する (2, Nemacsでのみ有効) -- Variable: NTT-jTeX 古いNTT-jTeX使用時のようにインデントした行の先頭と前の行の(タイプセッ ト後の)字間が空いてしまうのを嫌う場合は`t'にする(`nil') -- Variable: YaTeX-item-regexp itemの桁揃えの時に用いる、itemの正規表現 (`"\\\\(sub\\)*item"') -- Variable: YaTeX-verb-regexp verbコマンドの正規表現。先頭の\\\\はつけない (`"verb\\*?\\|path"') -- Variable: YaTeX-nervous ローカル辞書を用いる時 `t' (`t') -- Variable: YaTeX-sectioning-regexp セクション区切り設定コマンドの正規表現 (`"\\(part\\|chapter\\*?\\|\\(sub\\)*\\(section\\|paragraph\\)\\*?\\)\\b"') -- Variable: YaTeX-fill-inhibit-environments fill を抑止する環境名のリスト (`'("tabular" "tabular*" "array" "picture" "eqnarray" "eqnarray*" "equation" "math" "displaymath" "verbatim" "verbatim*")') -- Variable: YaTeX-uncomment-once 領域uncommentで行頭の複数の`%'を全て削除するか (`nil') -- Variable: YaTeX-close-paren-always 開き括弧の入力で常に閉じ括弧を入力する (`t') -- Variable: YaTeX-auto-math-mode 数式モードの切り替えを自動的に行う (`t') -- Variable: YaTeX-math-key-list-private 数式イメージ補完で用いる (プリフィクスキー . 対応補完テーブル) の alist (`nil')。補完テーブルの書き方については`yatexmth.el'を参照。 -- Variable: YaTeX-default-pop-window-height 1画面の時にタイプセットバッファを初めて作成する時の高さ。数値で行数、 数字文字列でEmacsウィンドウに対する百分率 (10) -- Variable: YaTeX-help-file 共用ヘルプファイル (`$doc-directory/../../site-lisp/YATEXHLP.jp') -- Variable: YaTeX-help-file-private 個人用ヘルプファイル (`"~/YATEXHLP.jp"') -- Variable: YaTeX-no-begend-shortcut `[prefix] b ??' のショートカットを使わず、`[prefix] b' だけで補完入力 に入る (`nil') -- Variable: YaTeX-hilit-pattern-adjustment-private 正規表現とそれにマッチするものの論理的意味をシンボルであらわしたもの のリスト…のリスト。hilit19 を組み込んでいる時のみ有効。詳しくは `(assq 'yatex-mode hilit-patterns-alist)' した結果と、変数 `YaTeX-hilit-pattern-adjustment-default' の値(と場合によっては hilit19 のドキュメント)を参照せよ。 -- Variable: YaTeX-sectioning-level LaTeXのセクション単位宣言コマンドとその論理的高さのalist。 -- Variable: YaTeX-hierarchy-ignore-heading-regexp Hierarchy バッファは通常ファイルヘッダとして、LaTeXのセクション宣言コ マンドの引数を検索し、それがなければコメント行を探すが、その際にヘッ ダとしては意味を持たないパターンをこの変数に設定する。デフォルトでは RCS ヘッダとモード指定行(-*- xxx -*-)が設定されている。 -- Variable: YaTeX-skip-default-reader Non-nil に設定するとsection型コマンドの引数入力時、アドイン関数がなけ ればミニバッファでの読み込みをせずに入力を完了させる (`nil') -- Variable: YaTeX-create-file-prefix-g `\include'などで `prefix g'した時に、ジャンプ先が存在しないファイルで あってもオープンする (`nil') -- Variable: YaTeX-simple-messages 各種補完時のメッセージ出力を簡素化する (`nil') -- Variable: YaTeX-hilit-sectioning-face 色付けが有効な時の `\part' の色 (`'(yellow/dodgerblue yellow/slateblue)')。リストの第一要素は `hilit-background-mode' が `'light' の時の、第二要素は `'dark' の時の `\chapter' の色で、文字色/ 背景色 のように指定する。 -- Variable: YaTeX-hilit-sectioning-attenuation-rate 色付けが有効な時の、`\subparagraph' の色を `\chapter' の濃度の何%薄く したものにするか (`'(15 40)') `YaTeX-hilit-sectioning-face' の項参照。 -- Variable: YaTeX-use-AMS-LaTeX AMS-LaTeX を使用する場合は `t' に設定する (`nil') -- Variable: YaTeX-use-LaTeX2e LaTeX2e を使用する場合は `t' に設定する (`t') -- Variable: YaTeX-template-file 新規ファイル作成時に自動挿入するファイル名 (`~/work/template.tex') -- Variable: YaTeX-search-file-from-top-directory inputするファイルを探すときの基準ディレクトリをmainファイルのあるディ レクトリにするか (`t') -- Variable: YaTeX-use-font-lock ソースの色づけパッケージとして font-lock を利用するかどうか (`(featurep 'font-lock)') -- Variable: YaTeX-use-hilit19 ソースの色づけパッケージとして hilit19 を利用するかどうか(`(featurep 'hilit19)') -- Variable: YaTeX-use-italic-bold italic, boldフォントを野鳥が探すかどうか (Emacs20以降なら`t') font-lock利用時のみ有効。(`(featurep 'hilit19)' -- Variable: YaTeX-singlecmd-suffix 全てのmaketitle型コマンドの補完入力直後に挿入する文字列。`"{}"' など がお勧め。 -- Variable: YaTeX-package-alist-private LaTeX2eのパッケージ名とその中に含まれるマクロのリスト。適切に設定して おくと本文入力時にマクロを補完入力するとそのマクロに必要なパッケージ を usepackage するか自動的に検査してくれる。していなければ \usepackage を自動追加することもできる。リストは'((パッケージ名1 (補 完タイプ マクロのリスト……) (補完タイプ マクロのリスト……)) (パッケー ジ名2 (補完タイプ マクロのリスト……) (補完タイプ マクロのリス ト……))………) という形式にする。補完タイプは `env, section, maketitle' のどれか。具体例は変数 `YaTeX-package-alist-default' の値 参照。 -- Variable: YaTeX-tabular-indentation tabular/array 環境で現在行の先頭位置が表の第Nカラムのときは標準インデ ント位置から N*YaTeX-tabular-indentation 桁下げたインデントにする。 -- Variable: YaTeX-noindent-env-regexp 別の環境内にあっても \begin{} が行頭から始まるべき環境名の正規表現。 verbatim環境などを指定する。 -- Variable: YaTeX-ref-default-label-string \ref{} のラベル補完でラベル未設定のものに自動的に生成するラベル名の書 式。strftime(3)関数に似た日付ベースで指定する。利用できる書式は以下の とおり。%y -> 西暦下二桁, %b -> 月の英名, %m -> 月(1〜12) %d -> 日, %H -> 時, %M -> 分, %S -> 秒, %qx -> アルファベットで26進数化した yymmdd. %qX -> アルファベットで26進数化した HHMMSS. デフォルトは "%H%M%S_%d%b%y" -- Variable: YaTeX-ref-generate-label-function \ref{}のラベル名自動生成のときに使う関数のシンボル。デフォルトは標準 の YaTeX::ref-generate-label 関数が割り当ててある。引数を2つ取る関数 を定義して、この変数にセットするとその関数を呼んだ結果をデフォルトの ラベル名候補とする。設定例: (setq YaTeX-ref-generate-label-function 'my-yatex-generate-label) (defun my-yatex-generate-label (command value) (and (string= command "caption") (re-search-backward "\\\\begin{\\(figure\\|table\\)}" nil t) (setq command (match-string 1))) (let ((alist '(("chapter" . "chap") ("section" . "sec") ("subsection" . "subsec") ("figure" . "fig") ("table" . "tbl")))) (if (setq command (cdr (assoc command alist))) (concat command ":" value) (YaTeX::ref-generate-label nil nil))))  File: yatexj, Node: Sample definitions, Next: Hook variables, Prev: All customizable variables, Up: Lisp variables カスタマイズ変数設定例 ---------------------- たとえば、prefix キーとして`ESC'を使用し、新たな補完候補を格納するファイ ルを、`~/src/emacs/yatexrc' にし、行頭の prefix をタブ文字一つに変えたいと きは、 (setq YaTeX-prefix "\e" YaTeX-user-completion-table "~/src/emacs/yatexrc" YaTeX-fill-prefix " ") を `~/.emacs' に加えます。  File: yatexj, Node: Hook variables, Next: Hook file, Prev: Sample definitions, Up: Lisp variables hook変数 -------- また、hook 変数 `yatex-mode-hook', `yatex-mode-load-hook' を用意していま す。すべての yatex-mode のバッファで作用させたいものは、`yatex-mode-hook' に記述し、`yatex.el' をロードする時だけ作用させたいものは `yatex-mode-load-hook' に記述します。例えば、`outline-minor-mode' を利用す る場合、それぞれのバッファで `outline-minor-mode' を有効にしたいので、 `yatex-mode-hook' を次のように設定します。 (setq yatex-mode-hook '(lambda () (outline-minor-mode t))) 逆に、独自のキー定義を行いたい時などは、`yatex-mode-load-hook' を利用しま す。例えば、begin 型補完において、 document や、enumerate 以外の環境名も ショートカットキーで入れたいなどという時は、次のようにします。以下の例は、 `[prefix] ba' で `\begin{abstract}', `\end{abstract}' を挿入します。 (setq yatex-mode-load-hook '(lambda() (YaTeX-define-begend-key "ba" "abstract"))) なお、新たなキーの定義には、関数 `YaTeX-define-key' `YaTeX-define-begend-key'を利用するようにしてください。  File: yatexj, Node: Hook file, Prev: Hook variables, Up: Lisp variables hook用ファイル -------------- 変数 `yatex-mode-load-hook' で定義する内容が多い時は、`yatexhks.el'とい うファイルを作り、その中に野鳥関連の設定を書く事で、初期化の時に自動的にロー ドします。  File: yatexj, Node: Add-in functions, Prev: Lisp variables, Up: Customizations 付加関数(アドイン関数) ====================== 各種補完時に、環境名やコマンド名に応じたきめ細やかな補完入力機能を実現す るための関数を作成することができます。この関数の作成方法や、組み込み方法に 関しては、`yatexadd.doc' をご覧ください。  File: yatexj, Node: Etc, Next: Copying, Prev: Customizations, Up: Top その他 ****** 野鳥の標準の LaTeX コマンドの辞書には、作者が頻繁に使うものしか登録され ていません。これは、補完候補に使いそうもないコマンドが存在して、補完したい コマンドを出すまでのストローク数を増やしてしまう事を防止するためです。標準 辞書にないコマンドも、できるだけ補完入力方式を利用し、ユーザ辞書を充実させ ることで、あなたの LaTeX スタイルにあった野鳥へと育っていくことでしょう。  File: yatexj, Node: Copying, Next: Concept Index, Prev: Etc, Up: Top 取り扱い ******** 本プログラムはフリーソフトウェアです。本プログラムを使用して生じたいかな る結果に対しても作者は責任を負わないこととします。転載等に関しては制限いた しません。常識的に扱ってください。また、本プログラムに含まれるコードを利用 すること、改造することも自由に行なって構いませんが、流用することにより契約 締結の必要が生じる場合、私はいかなる契約も締結しません。具体的にはGPLへの サインはしませんので、GNUに寄贈するものを作っている場合私の作品から取り込 んだコードを流用すると苦労するかもしれません。いかなるコード流用も拒否しま せんが契約締結は辞退します。 苦情、希望、バグ報告、感想等は歓迎いたします。連絡は yuuji@yatex.org ま で(2004年1月現在)。継続的に使用してくださる方はメイリングリスト「fj野鳥の 会」に是非加入してください。加入方法については本パッケージの `docs/qanda' ファイルの「その他」の章を御覧ください。 仕様は、予告なく確実に(気分次第で)変更されます:-p。 広瀬雄二  File: yatexj, Node: Concept Index, Prev: Copying, Up: Top 索引 **** * Menu: * :: Greek letter completion. 4. * ;: Image completion. 4. * Σ[しくま]: Image completion. 4. * 括る[くくる]: Enclose section-type command. 4. * 括る[くくる]: large型補完. 22. * 引数[ひきすう]: 2個以上の引数をとる section型コマンド. 4. * 欧文[おうふん]: Accent mark completion. 4. * ;自身[;ししん]: Image completion. 32. * ∞[むけんたい]: Image completion. 4. * 矢印[やしるし]: Image completion. 4. * ブロック[ふろつく]: begin型補完. 81. * ヒストリ[ひすとり]: Cooperation with other packages. 8. * 桁揃え[けたそろえ]: Filling. 4. * やちょう[やちよう]: Intro. 4. * ジャンプ[しやんふ]: view-sectioning. 42. * &入力[&にゆうりよく]: Intelligent newline. 4. * 設定例[せつていれい]: Sample definitions. 4. * 随時補完[すいしほかん]: Arbitrary completion. 4. * 閉じ込める[としこめる]: begin型補完. 81. * 再帰補完[さいきほかん]: Recursive completion. 4. * ユーザ辞書[ゆうさししよ]: begin型補完. 71. * 論理階層[ろんりかいそう]: view-sectioning. 42. * ここはどこ?[ここはとこ?]: What column. 4. * お絵描きツール起動[おえかきつうるきとう]: お絵描きツール起動. 4. * 環境の先頭へ[かんきようのせんとうへ]: 環境を単位としたジャンプ. 7. * 環境の末尾へ[かんきようのまつひへ]: 環境を単位としたジャンプ. 7. * 環境をマーク[かんきようをまあく]: 環境を単位としたジャンプ. 7. * カスタマイズ[かすたまいす]: Customizations. 4. * キーアサイン[きいあさいん]: Customizations. 4. * 数式モード[すうしきもおと]: Image completion. 4. * インストール[いんすとおる]: Installation. 4. * タイプセッタ[たいふせつた]: Invocation. 4. * プレヴューア[ふれひゆうあ]: Invocation. 4. * アウトライン[あうとらいん]: view-sectioning. 4. * 引数の個数を変える[ひきすうのこすうをかえる]: 2個以上の引数をとる section型コマンド. 24. * アクセント記号補完[あくせんときこうほかん]: Accent mark completion. 4. * カスタマイズ変数一覧[かすたまいすへんすういちらん]: All customizable variables. 4. * 環境名の補完[かんきようめいのほかん]: begin型補完. 4. * エラー修正[えらあしゆうせい]: Calling typesetter. 4. * タイプセッタ起動[たいふせつたきとう]: Calling typesetter. 4. * タイプセットエラー[たいふせつとえらあ]: Calling typesetter. 4. * 環境名の変更[かんきようめいのへんこう]: Changing LaTeX command. 20. * モード切り替え[もうときりかえ]: Changing mode of YaTeX. 4. * タイプセッタの使い分け[たいふせつたのつかいわけ]: Changing typesetter. 12. * 起動するコマンドを変える[きとうするこまんとをかえる]: Changing typesetter. 7. * コメントアウト[こめんとあうと]: Commenting out. 4. * その他のコマンド制御[そのたのこまんとせいきよ]: Controlling which command to invoke. 4. * 他パッケージとの連携[たはつけえしとのれんけい]: Cooperation with other packages. 4. * コマンドヒストリ[こまんとひすとり]: Cooperation with other packages. 8. * カーソルジャンプ[かあそるしやんふ]: Cursor jump. 4. * %#記法自体の編集[%#きほうしたいのへんしゆう]: Editing %# notation. 4. * パラグラフの桁揃え[はらくらふのけたそろえ]: Filling. 47. * 領域決定規則[りよういきけつていきそく]: Fix region for typesetting. 25. * 長いファイルの編集[なかいふあいるのへんしゆう]: Fix region for typesetting. 34. * 固定領域のタイプセット[こていりよういきのたいふせつと]: Fix region for typesetting. 4. * ギリシャ文字補完[きりしやもしほかん]: Greek letter completion. 4. * イメージ補完[いめえしほかん]: Image completion. 4. * 数式記号イメージ補完[すうしききこういめえしほかん]: Image completion. 4. * 他のファイルの手直し[ほかのふあいるのてなおし]: Includeonly. 11. * インクルード構造[いんくるうとこうそう]: Inclusion hierarchy browser. 4. * おまかせ改行[おまかせかいきよう]: Intelligent newline. 4. * プリントアウト[ふりんとあうと]: Invocation. 4. * 環境の削除[かんきようのさくしよ]: Killing LaTeX command. 6. * ラベル自動生成[らへるしとうせいせい]: label-generation. 4. * フォント指定子[ふおんとしていし]: large型補完. 18. * 文字サイズ指定子[もしさいすしていし]: large型補完. 18. * ローカル辞書[ろおかるししよ]: Local dictionary. 4. * 変更/削除[へんこう/さくしよ]: Modifying/Deleting. 4. * グローバルヘルプ[くろおはるへるふ]: Online help. 16. * オンラインヘルプ[おんらいんへるふ]: Online help. 4. * キーワード検索[きいわあとけんさく]: Online help. 4. * プライベートヘルプ[ふらいへえとへるふ]: Online help. 16. * 入力ファイル分割[にゆうりよくふあいるふんかつ]: Splitting input files. 11. * セクション区切り一覧バッファ[せくしよんくきりいちらんはつふあ]: view-sectioning. 18. * セクション区切り[せくしよんくきり]: view-sectioning. 42. * 現在のカラム表示[けんさいのからむひようし]: What column. 23. * apropos: Online help. 4. * autoload: Installation. 4. * auto-mode-alist: Installation. 4. * %#BEGIN: Fix region for typesetting. 4. * begin型補完[beginかたほかん]: begin型補完. 4. * C-c: Invocation. 4. * Demacs: Intro. 4. * .emacs: Installation. 4. * %#END: Fix region for typesetting. 4. * end補完[endほかん]: end補完. 4. * ghostview: Splitting input files. 16. * gmhist: Cooperation with other packages. 8. * hook変数[hookへんすう]: Hook variables. 4. * 出力終了ページ[しゆつりよくしゆうりようへえし]: Print out. 9. * includeonly: Includeonly. 4. * Install: Installation. 4. * itemなどの桁揃え[itemなとのけたそろえ]: Filling. 8. * 出力開始ページ[しゆつりよくかいしへえし]: Print out. 9. * jlatex: Invocation. 4. * large型補完[largeかたほかん]: large型補完. 4. * LaTeX: Intro. 4. * leftarrow: Image completion. 4. * lpr format: lpr format. 4. * lprフォーマットの変更[lprふおおまつとのへんこう]: Editing %# notation. 18. * lprふぉーまっと[lprふおおまつと]: lpr format. 4. * lprフォーマット[lprふおおまつと]: lpr format. 4. * maketitle型補完[maketitleかたほかん]: maketitle型補完. 4. * M-C-@: 環境を単位としたジャンプ. 7. * M-C-a: 環境を単位としたジャンプ. 7. * M-C-e: 環境を単位としたジャンプ. 7. * min-out: Cooperation with other packages. 17. * M-q: Filling. 47. * Mule: Intro. 4. * 勝手にincludeonly[かつてにincludeonly]: Includeonly. 4. * NTT-jTeX[えぬていいていいしえいてつく]: Filling. 15. * platex: Invocation. 4. * prefix ,: Commenting out. 4. * prefix .: Commenting out. 4. * prefix <: Commenting out. 4. * prefix >: Commenting out. 4. * prefix /: Online help. 4. * prefix ?: Online help. 4. * prefix &: What column. 4. * prefix a: Accent mark completion. 4. * prefix b: begin型補完. 4. * prefix c: Modifying/Deleting. 4. * prefix d: Inclusion hierarchy browser. 4. * prefix e: end補完. 4. * prefix g: Cursor jump. 4. * prefix i: Filling. 8. * prefix k: Modifying/Deleting. 4. * prefix key: Invocation. 4. * prefix l: large型補完. 4. * prefix m: maketitle型補完. 4. * prefix s: section型補完. 4. * prefix SPC: Arbitrary completion. 4. * prefix w: Changing mode of YaTeX. 4. * prefixキー変更[prefixきいへんこう]: Lisp variables. 4. * ページ確認省略lpr起動[へえしかくにんしようりやくlprきとう]: Print out. 12. * section型補完[sectionかたほかん]: section型補完. 4. * 複雑なtabular[ふくさつなtabular]: What column. 4. * 先回りusepackage[さきまわり]: Usepackage cheker. 4. * YaTeX-help-file: Online help. 16. * YaTeX-help-file-private: Online help. 16. * YaTeX-item-regexp: Filling. 20. * YaTeX-math-sign-alist-private: Image completion. 57. * yatex-mode-hook: Hook variables. 4. * yatex-mode-load-hook: Hook variables. 4. * YaTeX-nervous: Local dictionary. 22. * .yatexrc: Local dictionary. 4.  Tag table: Node: Top257 Node: Intro1311 Node: Terminology1614 Node: Main features2249 Node: Installation3282 Node: Invocation4500 Node: Calling typesetter5319 Node: Calling previewer6556 Node: Print out6872 Node: %#notation7138 Node: Changing typesetter7566 Node: Splitting input files7824 Node: Fix region for typesetting8776 Node: lpr format9677 Node: Controlling which command to invoke10486 Node: Editing %# notation10887 Node: Completion11344 Node: begin型補完11817 Node: section型補完14401 Node: 2個以上の引数をとる section型コマンド15496 Node: Enclose section-type command16314 Node: Recursive completion16551 Node: view-sectioning16857 Node: label-generation18053 Node: large型補完18402 Node: maketitle型補完18982 Node: Arbitrary completion19281 Node: end補完19594 Node: Accent mark completion19936 Node: Image completion20361 Node: Greek letter completion22178 Node: Local dictionary22638 Node: Commenting out23243 Node: Cursor jump24402 Node: 対応オブジェクトへのジャンプ24639 Node: お絵描きツール起動25627 Node: メインファイルへのジャンプ26547 Node: 環境を単位としたジャンプ26883 Node: 最後の補完位置へのジャンプ27240 Node: Modifying/Deleting27477 Node: Changing LaTeX command27883 Node: Killing LaTeX command28434 Node: Filling29305 Node: Includeonly30634 Node: What column31195 Node: Intelligent newline31974 Node: Usepackage cheker33007 Node: Changing mode of YaTeX33433 Node: Online help34009 Node: Inclusion hierarchy browser34985 Node: Cooperation with other packages36263 Node: Customizations36718 Node: Lisp variables37015 Node: All customizable variables37622 Node: Sample definitions44923 Node: Hook variables45357 Node: Hook file46251 Node: Add-in functions46457 Node: Etc46684 Node: Copying46968 Node: Concept Index47599  End tag table yatex_1.77+dfsg1/docs/yatexj.tex0000444000175000017500000022516012126310636015334 0ustar kurakura\def\lang{jp} % -*- texinfo -*- for Texinfo V.3.1 \input texinfo @setfilename yatexj @settitle Yet Another tex-mode for Emacs @direntry * YaTeX: (yatexj). Yet Another tex-mode for Emacs (Japanese). @end direntry @iftex @c @syncodeindex fn cp @c いつも忘れるのでここに書いとくか。 @c C-l C-c n でノード入れ @c ノードいじったら C-l C-u C-n 全部のノード更新 C-l C-u C-e @c メニュー増やしたら C-l C-u C-m 全部のメニュー更新 C-l C-u C-a @c フォーマットするときは C-l C-e C-b @c Last modified Fri May 11 15:40:21 2012 on firestorm @syncodeindex vr cp @end iftex @titlepage @sp 10 @center @subtitle Yet Another tex-mode for emacs @title 『野鳥』 @subtitle // YaTeX // @author @copyright{} 1991-2012 by HIROSE, Yuuji [yuuji@@yatex.org] @end titlepage @node Top, Intro, (dir), (dir) @comment node-name, next, previous, up @menu * Intro:: はじめに * Terminology:: マニュアル参照上の注意 * Main features:: 主な機能 * Installation:: インストール * Invocation:: プロセス起動 * %#notation :: %#記法 * Completion:: 補完入力 * Local dictionary:: ローカル辞書 * Commenting out:: コメントアウト * Cursor jump:: カーソルジャンプ * Modifying/Deleting:: LaTeXコマンドの変更/削除 * Filling:: 桁揃え * Includeonly:: 勝手に includeonly * What column:: カラム位置ガイド * Intelligent newline:: おまかせ改行 * Usepackage cheker:: 先回りusepackage * Changing mode of YaTeX:: 野鳥動作モード変更 * Online help:: LaTeXオンラインヘルプ * Inclusion hierarchy browser:: ファイル分割階層構造の表示 * Cooperation with other packages:: 他パッケージとの連携 * Customizations:: カスタマイズ * Etc:: その他 * Copying:: 取り扱い * Concept Index:: 索引 @end menu @node Intro, Terminology, Top, Top @comment node-name, next, previous, up @chapter はじめに @cindex Demacs @cindex Mule @cindex LaTeX @cindex やちょう[やちよう] 野鳥は、GNU Emacs で La@TeX{} 用の文書を作成する時に pLa@TeX{} などの タイプセットコマンドや、プレヴューアの起動を Emacs 編集画面中から 行えるようにすると共に、拡張性の高い種々の補完機能によりソーステキ ストの編集を支援します。さらに La@TeX{} コマンドのオンラインヘルプに よりマニュアルを調べる手間を軽減します。 English manual @xref{Top, , , yatexe,YaTeX English info}. @node Terminology, Main features, Intro, Top @comment node-name, next, previous, up @chapter 本マニュアル参照上の注意 本マニュアルでは以下の表記を用います。 @itemize @bullet @item begin型コマンド @code{\begin@{環境@} 〜 \end@{環境@}}という形式のLaTeXコマンドを指します。 begin型コマンドを補完入力することをbegin型補完と呼びます。 @item section型コマンド @code{\section@{タイトル@}}や@code{\mbox@{内容@}}のように 引数を取るLaTeXコマンドを指します。 @item maketitle型コマンド @code{\maketitle}や@code{\tableofcontents}のように引数を取らないLaTeXコマ ンドを指します。 @item large型コマンド @code{@{\large ...@}} や @code{@{\tt ...@}} のようなフォント/サイズ指定子 を指します。 @item @kbd{[prefix]} 野鳥の機能を呼び出すためのプリフィクスキー。デフォルトでは@kbd{C-c}に割り 当てられているので、特に変更していない場合本マニュアルの @kbd{[prefix]} と いう表記は、@kbd{C-c} と読み換えてください。 @end itemize @node Main features, Installation, Terminology, Top @comment node-name, next, previous, up @chapter 主な機能 @itemize @bullet @item タイプセッタやプレヴューアなどの編集画面からの起動(@kbd{C-c t}) @item カーソル位置によらない固定リジョンの部分タイプセット @item \includeonlyのワンタッチ更新 @item エラー箇所への自動ジャンプ(@kbd{C-c '}) @item @code{\begin@{@}, \end@{@}, \section...} などの La@TeX{} コマンドの補完入力 (@kbd{C-c b}, @kbd{C-c s}, @kbd{C-c l}, @kbd{C-c m}) @item 既に入力したテキストを環境やコマンド引数の中に取り込む括り補完 (@kbd{C-u} +通常補完キー) @item セクション区切り入力時の文書構造アウトライン表示 @item セクションコマンドの一括シフト (@ref{view-sectioning}) @item 補完辞書の学習 @item La@TeX{} の環境やコマンドに応じたガイド付き引数入力 @item 野鳥にないガイド付き引数入力関数の自動生成(@file{yatexgen.el}) @item La@TeX{} コマンドの削除/変更(@kbd{C-c k}, @kbd{C-c c}) @item ファイル間、@code{\begin}<->@code{\end}間、 @code{\ref}<->@code{\label}間、 @code{\cite}<->@code{\bibitem}ジャンプ(@kbd{C-c g}) @item 一括コメントアウト/アンコメントアウト (@kbd{C-c >}, @kbd{C-c <}, @kbd{C-c ,}, @kbd{C-c .}) @item アクセント記号/数式環境用コマンド/ギリシャ文字の入力支援 (@kbd{C-c a}, @kbd{;}, @kbd{/}) @item tabular/array環境のカラム位置ガイド @item 標準的 La@TeX{} コマンドのオンラインヘルプ(@kbd{C-c ?}, @kbd{C-c /}) @item ドキュメントのインクルード構造の視覚的表示とバッファ切り替え (@kbd{C-c d}) @item 補完入力したマクロに応じて必要な \userpackage を入れてくれる先回り userpackage @item \labelを打つことはもう忘れよう! refやcite補完入力で自動生成します @end itemize @node Installation, Invocation, Main features, Top @comment node-name, next, previous, up @chapter 起動法 @cindex Install @cindex インストール[いんすとおる] @cindex .emacs @cindex auto-mode-alist @cindex autoload @section 野鳥起動のための設定 ~/.emacsに下の2項目を加えます。 @lisp (setq auto-mode-alist (cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist)) (autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t) @end lisp 次に野鳥の emacs-lisp ファイル群を置くディレクトリを load-path に加えます。 たとえば、 @file{~/src/emacs/yatex}に置くのであれば、 @lisp (setq load-path (cons (expand-file-name "~/src/emacs/yatex") load-path)) @end lisp @noindent などとします。 以上の設定により、拡張子が .tex であるファイルを編集すると自動的に野鳥が ロードされます。野鳥が正常に起動できたときはモードラインの表示が「やてふ」 に変わります。 @section タイプセッタ/プレヴューア環境の設定 利用する外部プログラムに関する以下の変数を確認し、必要なら正しい値に変更 します。 @table @code @item tex-command @dots{} 起動するタイプセッタのコマンド名 @item dvi2-command @dots{} 起動するプレヴューアのコマンド名 @item NTT-jTeX @dots{} 改行+インデントによって、タイプセット後の字間が空いてしま うのを抑制する場合にtにする(古いNTT-jTeXで顕著に現れる)。具体的には、 fillするときに各行の終わりに%を付加するようになる。 @item YaTeX-kanji-code @dots{} 文書を作成する時の漢字コード @item dviprint-command-format @dots{} ファイルの印刷に使われるコマンド列の書式 @item makeindex-command @dots{} makeindexコマンド @end table これらを変更する場合は、やはり@file{~/.emacs}にて、たとえば @lisp (setq tex-command "pdflatex") @end lisp のようにしてください。どのような値をセットすれば良いかについては、 @ref{All customizable variables}を参照してください。 @node Invocation, %#notation , Installation, Top @comment node-name, next, previous, up @chapter latexコマンド起動 @cindex prefix key @cindex C-c @cindex タイプセッタ[たいふせつた] @cindex プレヴューア[ふれひゆうあ] @cindex jlatex @cindex platex @cindex プリントアウト[ふりんとあうと] LaTeXソースの編集中、次のキー入力により、platex などのタイプセットプログラ ム(以後タイプセッタと呼ぶ)、プレヴューアなどの起動ができます。 @table @kbd @item [prefix] t j @dots{} タイプセッタ(platex)起動 @item [prefix] t r @dots{} タイプセッタ起動(領域指定) @item [prefix] t e @dots{} タイプセッタ起動 (ポイント位置の環境または数式モードのみ対象) @item [prefix] t k @dots{} 動作中のタイプセッタの停止 @item [prefix] t b @dots{} jbibtex起動 @item [prefix] t i @dots{} makeindex起動 @item [prefix] t d @dots{} タイプセット完了後dvipdfmx起動 @item [prefix] t p @dots{} プレヴューア起動 @item [prefix] t l @dots{} lpr(プリントアウト用)コマンド起動 @item [prefix] t s @dots{} xdvi -remote でのサーチ @end table @menu * Calling typesetter:: タイプセッタ起動 * Calling previewer:: プレヴューア起動 * Print out:: プリントアウト用コマンドの起動 @end menu @node Calling typesetter, Calling previewer, Invocation, Invocation @comment node-name, next, previous, up @section タイプセッタ起動 @cindex タイプセッタ起動[たいふせつたきとう] @cindex タイプセットエラー[たいふせつとえらあ] @cindex エラー修正[えらあしゆうせい] タイプセッタを起動すると、編集ウィンドウが2つに分割され、片方のウィンド ウにタイプセット画面が表示されます。出力されるメッセージと連動しタイプセッ トバッファは自動的にスクロールします。もし、途中でエラーが起こって止まって しまった場合にはタイプセットバッファに移り、(@kbd{C-x o}) タイプセッタの出 している ? プロンプトに対して、@kbd{x} (処理の中断)などの指示を送ることが できます。エラーを修正する場合は、 @table @kbd @item [prefix] ' @itemx (prefix+アポストロフィ) @dots{} 直前のエラー発生行へジャンプ @end table を入力することにより、タイプセッタがエラーを発生した行に移ることができます。 また、タイプセッタの出力する overfull hbox などのウォーニング行にも対応し ていますので、順次 @kbd{[prefix] '} を押すことにより、一つ前のウォーニング 発生行にジャンプしていきます。 もし、気になるエラー行があった場合は、タイプセットバッファで、エ ラーの表示されている行にカーソルを合わせスペースキーを押すと La@TeX{} ソースの対応する行にジャンプします。 @subsection 領域タイプセット ポイントとマークの間、あるいはテキスト中に埋め込んだ @code{%#BEGIN} と @code{%#END}の間の領域(@ref{%#notation})だけを切り取ってタイプセットすることが できます。この場合メインファイルのプリアンブルが一時ファイルの プリアンブルとして使われます。したがってプリアンブルにないマクロ定義が 領域内にあるとエラーになります。領域タイプセットを使う場合、 必ずマクロ定義はプリアンブル(@code{\begin@{document@}}より前)に置くよう にして下さい。一時ファイルはメインファイルのある ディレクトリの@file{texput.tex}という名前で出力されるので、 上書きには注意してください。 @subsection 環境タイプセット @kbd{[prefix] te} を押すと、ポイント位置の最も内側の環境、または数式モー ド内の場合はその数式モード全体が自動的に領域選択されて、領域タイプセットを 呼び出します。tabular環境や数式モードで複雑なものを作っている場合は確かめた い部分だけを確認できるので便利です。これも @file{texput.tex} に該当部分を 書き出します。プレヴューアで @file{texput.dvi} を開いたままにしておけば 修正と確認が素早くできるでしょう。 @node Calling previewer, Print out, Calling typesetter, Invocation @comment node-name, next, previous, up @section プレヴューア起動 @kbd{[prefix] t p} によりプレヴューアの起動ができます。さらに、もしあな たが、-remote 機能つきのxdviを利用している場合は @kbd{[prefix] t s} を押す ことによりカーソル位置の文字列を検索してそのページを表示するようにすでに起 動中のxdviに命令を送ります。これにより、現在編集中の箇所のタイプセット結果 を即座に見ることができます。 @c なお、-remote 機能付きの xdvi は @c @code{ftp://ftp.ae.keio.ac.jp/pub/text/xdvi/xdvi-remote} @c などから入手することができます。 @node Print out, , Calling previewer, Invocation @comment node-name, next, previous, up @section プリントアウト @kbd{[prefix] t l}を押してプリントアウトを指示すると、出力開始/終了ペー ジを聞いてくるので、それぞれに答えます。これを省略したい時は、 universal-argument をつけ、 @cindex 出力開始ページ[しゆつりよくかいしへえし] @cindex 出力終了ページ[しゆつりよくしゆうりようへえし] @table @kbd @item C-u [prefix] t l @dots{} ページ確認省略lpr起動 @end table @cindex ページ確認省略lpr起動[へえしかくにんしようりやくlprきとう] @noindent のように起動してください。 @node %#notation , Completion, Invocation, Top @comment node-name, next, previous, up @chapter %#記法 本文中に@code{%#}ではじまるキーワードを埋め込むことでタイプセッタ起動等 の制御をすることができます。 @menu * Changing typesetter:: タイプセット用コマンドの変更 * Splitting input files:: 入力ファイル分割 * Fix region for typesetting:: 領域の固定 * lpr format:: プリントアウトコマンド用フォーマット * Controlling which command to invoke:: その他の起動コマンド制御 * Editing %# notation:: %#記法の編集 @end menu @node Changing typesetter, Splitting input files, %#notation , %#notation @comment node-name, next, previous, up @section タイプセット用コマンド変更 起動するコマンドを変えたい時は本文中に次のような行を書きます。 @cindex 起動するコマンドを変える[きとうするこまんとをかえる] @example %#!jlatex-ntt @end example NTT jTeX と、ASCII jTeX を使い分けたいような場合に便利でしょう。 @cindex タイプセッタの使い分け[たいふせつたのつかいわけ] @node Splitting input files, Fix region for typesetting, Changing typesetter, %#notation @comment node-name, next, previous, up @section 入力ファイル分割 また、章毎に別ファイルの .tex を作成している場合で、@file{main.tex}から @file{sub.tex} を @code{\include}しているような時は、@file{sub.tex}の任意の 位置に次のような行を埋め込みます。 @example %#!platex main.tex @end example @cindex 入力ファイル分割[にゆうりよくふあいるふんかつ] 上の例のようにコマンド名だけでなく引数も書いた場合には、全てをそのまま shell に渡すので次のように書けば、ghostview などをプレヴューアに使う時に便 利です。 @cindex ghostview @example %#!platex main && dvi2ps main.dvi > main @end example なお、この行の最後の単語のピリオド以前を「メインファイル」のベース ネームであると仮定します(上の2つの場合どちらも@file{main})。 この行に記述した、@code{%f}はメインファイル名に、 @code{%r} はメインファイルの拡張子を取り除いた部分に置換されます。 ただし、@code{%f,%r}を利用した場合、初回タイプセット時に必ずメインファイル 名の入力を促されます。 @kbd{[prefix] g} (@ref{Cursor jump}参照) での ファイル間ジャンプを有効に機能させるため、入力ファイル分割時には次のことに 注意して下さい。 @enumerate @item サブディレクトリを作って、その中にサブファイルを置くことはできるが サブディレクトリのサブディレクトリには置けない。 @item メインファイルからサブディレクトリ内のファイルを include する時には、 相対パス指定を用いて、 @code{\include@{chap1/sub@}}のように記述。 @item メインファイルが一つ上のディレクトリにある場合も、サブファイルには %#!platex main.tex のように記述する(../mainではない)。 @end enumerate @node Fix region for typesetting, lpr format, Splitting input files, %#notation @comment node-name, next, previous, up @section 領域の固定 @cindex 固定領域のタイプセット[こていりよういきのたいふせつと] @cindex %#BEGIN @cindex %#END @kbd{[prefix] tr} の領域指定のタイプセットでは、とくに指定のないかぎり、 @kbd{C-SPC}でマークした位置と、ポイント(カーソル位置)の間を領域とみなしま すが、必ず決まった領域をタイプセットしたい場合は、その領域を @example %#BEGIN <渡したい領域> %#END @end example @noindent のように@code{%#BEGIN}と@code{%#END}で囲み、カーソルを「@code{%#BEGIN}以降」 に置いてください。この時の領域決定規則をまとめると次のようになります。 @enumerate @item カーソル位置よりバッファの先頭方向に@code{%#BEGIN}というキーワードが ある場合 @enumerate @item @code{%#BEGIN}よりバッファの末尾方向に@code{%#END}というキーワードが見つかっ た場合。 @result{}@code{%#BEGIN} から、その @code{%#END} のある位置まで。 @item @code{%#END} が見つからなかった場合。 @result{}バッファの最後尾まで。 @end enumerate @cindex 領域決定規則[りよういきけつていきそく] @item カーソル位置よりバッファの先頭方向に @code{%#BEGIN} というキーワードが 見つからなかった場合。 @result{}マーク(@kbd{C-SPC}位置)とポイント(カーソル位置)の間の領域。 @end enumerate tabular 環境を何度も試行錯誤しているような場合は、@code{\begin}の前の行 に @code{%#BEGIN} と書き、@code{\end} の次の行に @code{%#END} と書いておく と簡単に作表結果をテストすることができます。また、長い .tex ファイルの後半 に @code{%#BEGIN} を書いておけば、前半の部分は無視できます。このBEGINとEND の消し忘れには十分ご注意下さい。 @cindex 長いファイルの編集[なかいふあいるのへんしゆう] @c @node Require, lpr format, Fix region for typesetting, %#notation @comment node-name, next, previous, up @node lpr format, Controlling which command to invoke, Fix region for typesetting, %#notation @comment node-name, next, previous, up @section lprフォーマット @cindex lprふぉーまっと[lprふおおまつと] @cindex lprフォーマット[lprふおおまつと] @cindex lpr format まず、プリントアウト用コマンド列のフォーマットについて説明します。 コマンド列フォーマットは、3つの Lisp 変数によって表現されます。デ フォルトの dvi2ps 用のフォーマットを例に説明します。 @table @code @item (1)dviprint-command-format @code{"dvi2ps %f %t %s | lpr"} @item (2)dviprint-from-format @code{"-f %b"} @item (3)dviprint-to-format @code{"-t %e"} @end table 実際にプリントアウトする時は、(1)中の %s がファイル名に置き換えられ、%f が (2)の内容、%t が(3)の内容に置き換えられます。その際に(2)の文字列中の %b は 「出力開始ページ」、(3)の文字列中の %e は「出力終了ページ」に置き換えられ ます。もし、ページを指定しない時には、%f, %t 両方とも無視されます。 この、dviprint-command-format を臨時に変えたい時は、La@TeX{} の ソーステキスト中の任意の場所に、 @example %#LPR dvi2ps %f %t %s | 4up -page 4 | texfix | lpr -Plp2 @end example @noindent のように書いて下さい。プリントアウトするページ範囲をいちいち聞かせないよう にする時に @example %#LPR dvi2ps %s | lpr @end example @noindent などとするのも便利かもしれません。 @node Controlling which command to invoke, Editing %# notation, lpr format, %#notation @comment node-name, next, previous, up @section その他の起動コマンド制御 @cindex その他のコマンド制御[そのたのこまんとせいきよ] La@TeX{} 文書に関連するコマンドは以下の %# 記法で指定することができます。 @table @code @item %#BIBTEX @dots{} makeindexを行なうコマンドライン([prefix] t b) @item %#MAKEINDEX @dots{} bibtexを行なうコマンドライン([prefix] t i) @end table 行頭がこれらのキーワードで始まる行をLa@TeX{}文書の先頭付近に書いておけば、 それで指定したコマンドを起動できます。 @node Editing %# notation, , Controlling which command to invoke, %#notation @comment node-name, next, previous, up @section %#記法自体の編集 @cindex %#記法自体の編集[%#きほうしたいのへんしゆう] 以上のような@code{%#}で始まる各種制御記法を編集するためには @table @kbd @item [prefix] % @dots{} @code{%#}@var{記法編集メニュー} @end table @noindent を押します。 @example !)Edit-%#! B)EGIN-END-region L)Edit-%#LPR @end example @noindent というメニューが出て来るので、@code{%#!}に続くコマンドを変更したい時には @kbd{!}を、@code{%#LPR}で lpr フォーマットを変えたい時は@kbd{l}を、あらか じめ設定したリジョンを @code{%#BEGIN} 〜 @code{%#END} で括りたい時は、 @kbd{b}を押します。@kbd{b}を選んだ時には、それまでバッファ中に置かれていた @code{%#BEGIN}, @code{%#END} が自動的に消去されます。 @cindex lprフォーマットの変更[lprふおおまつとのへんこう] @node Completion, Local dictionary, %#notation , Top @comment node-name, next, previous, up @chapter 補完入力 La@TeX{} での環境名などは、野鳥の補完機能を利用して能率的に入力すること ができます。 @menu * begin型補完:: * section型補完:: * large型補完:: * maketitle型補完:: * Arbitrary completion:: 随時補完 * end補完:: * Accent mark completion:: アクセント記号補完 * Image completion:: 数式記号イメージ補完 * Greek letter completion:: ギリシャ文字補完 @end menu @node begin型補完, section型補完, Completion, Completion @comment node-name, next, previous, up @section begin型補完 @cindex begin型補完[beginかたほかん] @cindex 環境名の補完[かんきようめいのほかん] @cindex prefix b @code{\begin@{env@}...\end@{env@}}の様な形式の入力の補完をbegin型補完と 呼ぶことにします。begin 型補完は、 @table @kbd @item [prefix] b @dots{} begin 型補完開始(標準では @kbd{C-c b}) @end table @noindent で始まります。頻繁に用いられる次の La@TeX{} 環境の補完は、[prefix] @kbd{b} に続く次の1文字を入力するだけで、@code{\begin@{xxx@}...\end@{xxx@}}を完成 させます。 @table @kbd @item [prefix] b c @dots{} @code{\begin@{center@}...\end@{center@}} @item [prefix] b d @dots{} @code{\begin@{document@}...\end@{document@}} @item [prefix] b D @dots{} @code{\begin@{description@}...\end@{description@}} @item [prefix] b e @dots{} @code{\begin@{enumerate@}...\end@{enumerate@}} @item [prefix] b E @dots{} @code{\begin@{equation@}...\end@{equation@}} @item [prefix] b i @dots{} @code{\begin@{itemize@}...\end@{itemize@}} @item [prefix] b l @dots{} @code{\begin@{flushleft@}...\end@{flushleft@}} @item [prefix] b m @dots{} @code{\begin@{minipage@}...\end@{minipage@}} @item [prefix] b t @dots{} @code{\begin@{tabbing@}...\end@{tabbing@}} @item [prefix] b T @dots{} @code{\begin@{tabular@}...\end@{tabular@}} @item [prefix] b ^T @dots{} @code{\begin@{table@}...\end@{table@}} @item [prefix] b p @dots{} @code{\begin@{picture@}...\end@{picture@}} @item [prefix] b q @dots{} @code{\begin@{quote@}...\end@{quote@}} @item [prefix] b Q @dots{} @code{\begin@{quotation@}...\end@{quotation@}} @item [prefix] b r @dots{} @code{\begin@{flushright@}...\end@{flushright@}} @item [prefix] b v @dots{} @code{\begin@{verbatim@}...\end@{verbatim@}} @item [prefix] b V @dots{} @code{\begin@{verse@}...\end@{verse@}} @end table 上記のもの以外の環境名は Emacs の持つインクリメンタルな補完機能を用いて 入力します(上記の環境名も以下の補完入力可能)。 @table @kbd @item [prefix] b @key{SPC} @dots{} begin 型補完入力 @end table @kbd{[prefix] b @key{SPC}} と入力すると、最下行のミニバッファに @example Begin environment(default document): @end example @noindent と表示されます。ここで、何も入れずにリターンキーのみ押すと、括弧内に出てい るデフォルトの環境名が入力されますが、適当な環境名を入力すると、 @code{\begin@{環境名@} … \end@{環境名@}}が文書中に挿入されます。ミニバッ ファで環境名を入力するときに、環境名の頭文字を入力し「スペース」をたたくと、 一致する環境名が内部テーブルに存在した場合、正しい環境名に補完されるので、 入力の手間が省けます。内部テーブルに存在しない環境名を入力した時はユーザ専 用のテーブルに登録され、さらにそのテーブルを自動的に、ユーザ辞書(デフォル トでは @file{~/.yatexrc})に保存します。 さらに、特定の環境を補完入力した時にはその環境で必ず用いられるエントリを自 動挿入します(例: @code{itemize}環境における@code{\item}など)。挿入されたエ ントリが不要な場合にはundoによって消去して下さい。 @cindex ユーザ辞書[ゆうさししよ] @subsection 既に書いたテキストを環境で括る ところで、最初に書いてしまったブロックを後から、itemize 環境の中 に閉じこめたいと思うことがありますが、そのようなときは、あらかじめ 閉じこめたい段落をマークして、begin 型補完の各コマンドの @kbd{[prefix]} の次の『小文字の 'b'』 を『大文字』に変えて起動して下さい。(または、 @kbd{C-u} を先に打ち、universal argument をつけても可能です) @cindex ブロック[ふろつく] @cindex 閉じ込める[としこめる] 例えばあるパラグラフを description 環境の中に入れたいときは、 そのパラグラフをマークしてから、 @table @kbd @item [prefix] B D @itemx (または ESC 1 [prefix] b D) @itemx (または C-u [prefix] b D など) @end table とタイプしてください。これは、@kbd{[prefix] b SPC}の補完入力にもあてはまり、 @kbd{b} を大文字に変えて、@kbd{[prefix] B SPC} とタイプすれば、あらかじめ マークしておいたリジョンを、begin と end の環境で括ります。 @node section型補完, large型補完, begin型補完, Completion @comment node-name, next, previous, up @section section型補完 @cindex section型補完[sectionかたほかん] @cindex prefix s @code{\section@{目的@}} のような形式の入力の補完を section 型補完と呼ぶこ とにします。section 型補完は、 @table @kbd @item [prefix] s @dots{} section 型補完 @end table で実行します。@kbd{[prefix] s} を入力するとミニバッファに、 @example (C-v for view-section) \???@{@} (default documentclass): @end example @noindent というプロンプトが現れるので、そこで @samp{section} のような La@TeX{} コマ ンド名を入力します。ここでもリターンキーのみで括弧内のデフォルト値が選択さ れるほか、@samp{chapter}などのような頻度の高い名称入力にはスペースキーによ る補完機能が有効です。 次に、@{@}の中身の入力を促す、 @example \section@{???@}: @end example @noindent というプロンプトが現れるので、セクションのタイトルなどを入力します。 たとえば、 @example (C-v for view-section) \???@{@} (default documentclass): section \section@{???@}: 目的 @end example @noindent のように入力した場合は、文章中に @example \section@{目的@} @end example @noindent が挿入され、 @example (C-v for view-section) \???@{@} (default section): vspace* \vspace*@{???@}: @end example @noindent のように@{@}の中身を省略したときは、 @example \vspace*@{@} @end example @noindent だけが挿入され、改行はせずカーソルは自動的に中括弧の内側に移動します。 @menu * 2個以上の引数をとる section型コマンド:: * Enclose section-type command:: 括り補完 * Recursive completion:: 再帰補完 * view-sectioning:: セクション区切りのアウトライン表示 * label-generation:: ラベル自動生成 @end menu @node 2個以上の引数をとる section型コマンド, Enclose section-type command, section型補完, section型補完 @comment node-name, next, previous, up @subsection 2個以上の引数をとる section型コマンド @cindex 引数[ひきすう] ところで、@samp{\addtolength@{\topmargin@}@{8mm@}} などのように、引数を二つ 以上取る La@TeX{} コマンドがあります。このようなコマンドの補完入力には、 section 型補完呼び出しに引数を付けてください。例えば上の@samp{addtolength} の例であれば、引数2を指定します。つまり、 @example C-u 2 [prefix] s (または、ESC 2 [prefix] s) @end example @noindent と section 型補完を呼び出した後、 @example (Ctrl-v for view-section) \???@{@} (default vspace*): addtolength \addtolength@{???@}: \topmargin Argument 2: 8mm @end example @noindent のように入力してください。最初の addtolength の部分と、第一引数である \topmargin の入力は当然スペースによる補完入力が可能です。ユーザ辞書に登録 される La@TeX{} コマンドには、この引数の数も学習されるので、最初の補完の時 引数の数を指定して起動しておけば、以後の補完時には、記憶された個数だけ引数 を聞いて来るようになります。あとで引数の個数を変えたい時は、再び @kbd{C-u} を用いて個数を指定し直すことで、自動的に辞書中の引数の個数の部分を更新しま す。 @cindex 引数の個数を変える[ひきすうのこすうをかえる] @node Enclose section-type command, Recursive completion, 2個以上の引数をとる section型コマンド, section型補完 @subsection 既に書いたテキストを括る @cindex 括る[くくる] また、起動コマンドの@kbd{s}を大文字に変えて起動すると、あらかじめ書 いた文章を section 型コマンドの第一引数として括ります。 @node Recursive completion, view-sectioning, Enclose section-type command, section型補完 @comment node-name, next, previous, up @subsection 再帰補完 @cindex 再帰補完[さいきほかん] 高度な使い方になるかもしれませんが、section型補完の引数の入力時にさらに 補完入力を利用することができます(section/large/maketitle型に限る)。section 型コマンドの引数に更に La@TeX{} コマンドが来る場合にはミニバッファで野鳥の 補完キーを再帰的に入力することで引数の入力も効率的に行なえます。 @node view-sectioning, label-generation, Recursive completion, section型補完 @comment node-name, next, previous, up @subsection セクション区切りのアウトライン表示 @cindex アウトライン[あうとらいん] 通常のsection型補完の時にミニバッファで@kbd{C-v}を押すと現在存在するセク ション区切りコマンド全てを @code{*Sectioning Lines*}というバッファに一覧表 示します(「<<--」のついている行がもっとも近いセクション区切り)。この時ミニ バッファで@kbd{C-p}, @kbd{C-n} を押すと@samp{part}, @samp{chapter}, ..., @samp{subparagraph} のコマンドが論理階層の高さにしたがって上下します。また、 @kbd{C-v}, @kbd{M-v} を押すとセクション区切り一覧バッファがスクロールし、 数字の@kbd{0}〜@kbd{7}を押すとある高さ以上のセクション区切りだけを選んで表 示します(実際にやって見れば分かります)。 @code{*Sectioning Lines*}バッファは、 @table @kbd @item M-x YaTeX-section-overview @dots{} セクション区切り一覧バッファを生成 @end table @cindex セクション区切り一覧バッファ[せくしよんくきりいちらんはつふあ] で作成することができます。このバッファを選択し任意の行でスペースを押すと、 該当するセクション区切りのある本文中の場所にジャンプします。さらに、同バッ ファで @kbd{u} を押すと、ソーステキストの対応するセクションコマンドが一階 層上がり(例: subsection が section に変わる)、@kbd{d}を押すと一階層下がり ます。@code{*Sectioning Lines*}バッファにあるセクション区切りの行をマーク しておいて@kbd{U}を押すとリジョン内のものに対応するソーステキストのセクショ ンコマンドすべてが一階層上がり、@kbd{D}を押すと下がります。セクション区切 り一覧バッファで利用できるキーコマンドには以下のものがあります。 @table @kbd @item SPC @dots{} 対応するソース行へジャンプ @item . @dots{} 対応するソース行を表示 @item u @dots{} カーソル位置に対応するセクションコマンドを一階層上げる @item d @dots{} カーソル位置に対応するセクションコマンドを一階層下げる @item U @dots{} マークしたセクションコマンドを一階層上げる @item D @dots{} マークしたセクションコマンドを一階層上げる @item 0〜6 @dots{} レベル n 以下のセクションコマンドを隠して表示 @end table @cindex 論理階層[ろんりかいそう] @cindex セクション区切り[せくしよんくきり] @cindex ジャンプ[しやんふ] @node label-generation, , view-sectioning, section型補完 @comment node-name, next, previous, up @subsection ラベル自動生成 @cindex ラベル自動生成[らへるしとうせいせい] @code{\ref@{@}} や @code{\cite@{@}} マクロをsection型補完で入れた場合 参照先となり得るものを全て探してメニューにして選択できます。参照先には @code{\label@{@}}をつけておく必要はありません。もしあれば、そのラベルを 使い、なければその場で参照先に@code{\label@{@}}を作らせてくれます。 ラベル名を考えるのは苦痛に感じるものです。全てのカウンタにラベルを つけるのもたいへんです。もうラベル名に何をつけるか、ラベルをつけるかつけま いか、などということは忘れましょう! @node large型補完, maketitle型補完, section型補完, Completion @comment node-name, next, previous, up @section large型補完 @cindex large型補完[largeかたほかん] @cindex prefix l @code{@{\large @}} のような形式の補完を large 型補完と呼ぶことにします。 @table @kbd @item [prefix] l @dots{} large 型補完開始 @end table @noindent がlarge型補完の開始です。@kbd{[prefix] l} を押すと、ミニバッファに @example @{\??? @} (default large): @end example と表示されるので、上記のものと同じ要領で補完入力して下さい。補完候補に用意 されているのは、@samp{footnotesize} や @samp{huge} のような文字サイズ指定 子と、@samp{bf}や@samp{dg}のようなフォント指定子です。 @cindex 文字サイズ指定子[もしさいすしていし] @cindex フォント指定子[ふおんとしていし] @subsection 既に書いた文字を括る @cindex 括る[くくる] また、begin型補完の時と同様、先に書いてしまった一連の文章の文字のサイズ を変えたいと思う時がありますが、そのような時は、サイズや大きさを変えたい文 字の範囲をマークしてから、呼び出しキーを @kbd{[prefix] L} と、大文字の L に変えて呼び出せば、そのリジョン全体が、ブレースで囲まれます。 @node maketitle型補完, Arbitrary completion, large型補完, Completion @comment node-name, next, previous, up @section maketitle型補完 @cindex maketitle型補完[maketitleかたほかん] @cindex prefix m @code{\maketitle} の形式の補完を maketitle 型補完と呼ぶことにします。 @table @kbd @item [prefix] m @dots{} maketitle 型補完開始 @end table @noindent で、maketitle 型補完を開始します。補完の要領は今までのものとまったく同じで す。La@TeX{} 用のコマンド名が補完候補として用意されています。 @node Arbitrary completion, end補完, maketitle型補完, Completion @comment node-name, next, previous, up @section 随時補完 @cindex 随時補完[すいしほかん] @cindex prefix SPC さて、今まで述べた典型的な La@TeX{} コマンド形式の補完入力を用いずに、今 入力しようとしている La@TeX{} コマンドを文書中の任意の位置で随時補完するこ ともできます。La@TeX{} コマンド(先頭が\で始まる)を入力している途中で、 @table @kbd @item [prefix] SPC @dots{} 随時補完 @end table @noindent を入力すれば、全ての補完候補の中から一致するものが選ばれカーソル位置に挿入 されます。 @node end補完, Accent mark completion, Arbitrary completion, Completion @comment node-name, next, previous, up @section end補完 @cindex end補完[endほかん] @cindex prefix e 現在開いたままの環境名を自動的に検出し、@code{\end@{環境名@}}を挿入しま す。begin 型補完を用いれば環境の閉じ忘れはないのですが、時にはついつい手で @code{\begin@{環境名@}} を入れてしまい、悲しい思いをすることがあります。そ のような時には気にせず続けて文章を入力し、しかるのちに @table @kbd @item [prefix] e @dots{} end 補完 @end table @noindent とすることで、現在開いている環境名で \end@{@} が補われます。 @node Accent mark completion, Image completion, end補完, Completion @comment node-name, next, previous, up @section アクセント記号補完 @cindex アクセント記号補完[あくせんときこうほかん] @cindex prefix a @cindex 欧文[おうふん] 欧文のアクセント記号(@code{\`@{o@}}など)を入力する時は、 @table @kbd @item [prefix] a @dots{} アクセント記号入力 @end table @noindent を押すと、ミニバッファに @example 1:` 2:' 3:^ 4:" 5:~ 6:= 7:. u v H t c d b @end example @noindent というメニューが出て来るので、数字、または対応する記号/英字を入力 して下さい。すると編集バッファに、 @example \`@{@} @end example @noindent が現われ、カーソルが@{@}内に位置するので、さらに一文字入力する事で、 @example \`@{o@} @end example @noindent が完成され、カーソルは@{@}の外に戻ります。 @node Image completion, Greek letter completion, Accent mark completion, Completion @comment node-name, next, previous, up @section 数式記号イメージ補完 @cindex 数式記号イメージ補完[すうしききこういめえしほかん] @cindex イメージ補完[いめえしほかん] @cindex ; @cindex 数式モード[すうしきもおと] @cindex 矢印[やしるし] @cindex Σ[しくま] @cindex leftarrow @cindex ∞[むけんたい] 主に数式モードで使用される、矢印やΣなどの記号を擬似的に表現するキー入力 で、La@TeX{} コマンドを入力できます。これは野鳥自身の「数式モード」でのみ 動作します。野鳥はカーソルが@TeX{}の数式環境の中にある時に@kbd{;}や、 @kbd{:}に特殊な機能を持たせます。 さて、例えば、←(leftarrow)をASCII文字だけで表現する場合、一般的には「<-」 のようにしますが、これを利用して、数式記号イメージ入力モードで @code{\leftarrow}を入力するには、@kbd{;}(セミコロン)を打ってから@kbd{<-}と 入力します。同様に、長い矢印←-(long-leftarrow) をASCII文字だけで表現する 場合「<--」とするので、@code{\longleftarrow}を入力するためには、@kbd{;<--} と入力します。あるいは無限大記号をASCII文字だけで表現する時は「oo」のよう にすることから、@code{\infty} を入力する時は、@kbd{;oo}とキー入力します。 これらの操作をまとめると次のようになります。 @example INPUT 入力される La@TeX{} コマンド ; < - @code{\leftarrow} ; < - - @code{\longleftarrow} ; < - - > @code{\longleftrightarrow} ; o @code{\circ} ; o o @code{\infty} @end example いずれの場合も、イメージ入力を行っている途中で望みのものがバッファ に表示されたなら、そこでイメージ入力を止めて次の編集動作に移っても 構いません。 @cindex ;自身[;ししん] 数式環境中で@samp{;}自身を入力するには@kbd{;;}のようにします。イメージ 入力の途中でTABを押すと、それまで入力した文字で始まるもの一覧が表示されま す。ここで目的の La@TeX{} コマンドまでカーソルを移動し再度TABを押すことで その La@TeX{} コマンドがバッファに挿入されます。 どのキー入力にどの記号が対応しているか全て知りたい時は、@kbd{;}を押した 直後にTABを押してください。以下の例は、@kbd{;<}と押した後にTABを押したもの です。 @example KEY LaTeX sequence sign < \leq ≦ << \ll 《 <- \leftarrow ← <= \Leftarrow <= @end example 左から[入力キー]、[対応する La@TeX{} コマンド]、[(擬似)記号図示]、と いう順でメニューが出て来るので、よく使うものを覚えておくと良いでしょ う。ものによってはASCII文字で表現することが困難なので、あまり覚え やすいキー並びではないものがあるでしょうから、そのような場合は \maketitle 型補完で入力するか、以下に述べる対応表の設定を行って単 純なキー並びのものを設定すると良いでしょう。 入力キーと La@TeX{} コマンド、記号の対応表を個人的に設定したい場合は Emacs-Lisp 変数 @code{YaTeX-math-sign-alist-private} に定義してください。 その内容とデフォルトのものを合わせたものが対応表として使用されます(private の方が優先される)。なお、この変数の構造については @file{yatexmth.el} を参 照してください。 @cindex YaTeX-math-sign-alist-private @node Greek letter completion, , Image completion, Completion @comment node-name, next, previous, up @section ギリシャ文字補完 @cindex ギリシャ文字補完[きりしやもしほかん] @cindex : もう一つ、数式環境中で@kbd{:}を押すとギリシャ文字入力モードに入ります。 @kbd{:}を押した直後に@kbd{a}を押すと@code{\alpha}が、@kbd{g} を押すと @code{\gamma}が、などアルファベットに対応したギリシャ文字が挿入されます。 操作方法は;の数式記号補完とまったく同じです。まずは@kbd{:}の直後に TABを押してどのアルファベットにどのギリシャ文字が対応しているか調べてみて ください。 @kbd{;}と@kbd{:}を数式環境中で押しているにもかかわらず、イメージ補完が働 かない場合は、@kbd{C-u ;}のように universal-argument をつけてキーを押すこ とにより、強制的にイメージ補完に入ることができます。また、この時にどのよう な状態で数式環境内判定に失敗したかをご連絡下さい。 @node Local dictionary, Commenting out, Completion, Top @comment node-name, next, previous, up @chapter ローカル辞書 @cindex ローカル辞書[ろおかるししよ] @cindex .yatexrc 補完入力用の候補は三種類の辞書から構成されています。一つは @file{yatex.el}に組み込まれた「標準辞書」、もう一つはユーザが個人的に常用 するコマンドを保存する「ユーザ辞書」、そしてもうひとつはあるディレクトリで のみ有効なコマンドを保存する「ローカル辞書」です。 補完入力時に新しい単語を入れた場合に、その単語をどの辞書に入れるか聞いて 来ます。 @example `foo' is not in table. Register into: U)serDic L)ocalDic N)one D)iscard @end example @noindent というプロンプトに対し、@kbd{u}と答えると「ユーザ辞書」を、@kbd{l}と答える とローカル辞書を更新し、@kbd{n}と答えると辞書ファイルは更新せず現在のEmacs セッションのみ有効な単語とし、@kbd{d}と答えると新たな単語を学習せずに捨て ることになります。 もし、ローカル辞書の機能はいらず、全てユーザ辞書の更新のみでよいと言う場 合には@file{~/.emacs}などで、 @cindex YaTeX-nervous @lisp (setq YaTeX-nervous nil) @end lisp @noindent として下さい。 @node Commenting out, Cursor jump, Local dictionary, Top @comment node-name, next, previous, up @chapter コメントアウト @cindex コメントアウト[こめんとあうと] @cindex prefix < @cindex prefix > @cindex prefix . @cindex prefix , La@TeX{}の編集には試行錯誤がつきものです。ある部分を一括でコメントアウト したり、コメントを外したりしたいことがあります。 @table @kbd @item [prefix] > @dots{} リジョンを % でコメントアウト @item [prefix] < @dots{} リジョンの % のコメントを外す @end table @noindent は、あらかじめ設定したリジョンに対しての操作、 @table @kbd @item [prefix] . @dots{} 現在のパラグラフをコメントアウト @item [prefix] , @dots{} 現在のパラグラフのコメントを外す @end table @noindent は、カーソルの位置するパラグラフ全体に対しての操作です。なお、ここでいう 「パラグラフ」は (@code{mark-paragraph}) 関数によりマークされる範囲を指し ます(標準設定で@kbd{ESC h}にバインドされている)。なお、既に@code{%}でコメ ントアウトされているパラグラフに対して繰り返しパラグラフのコメントを使用し た場合の動作は保証しませんので御注意ください。 さて、文章に対してだけでなく、時には@code{\begin}, @code{\end} 自体に対 してもコメントアウトの操作をしたいときがあります。このようなときは、 @code{\begin@{@}} あるいは @code{\end@{@}} の行にカーソルを合わせ、 @table @kbd @item [prefix] > @dots{} @code{\begin@{@}}〜@code{\end@{@}} 全てコメントアウト @item [prefix] < @dots{} @code{\begin@{@}}〜@code{\end@{@}} 全てコメントを外す @end table @noindent とすることで、@code{\begin〜\end}で囲まれる環境全てに対してコメント操作し、 @table @kbd @item [prefix] . @dots{} @code{\begin@{@}} と @code{\end@{@}} をコメントアウト @item [prefix] , @dots{} @code{\begin@{@}} と @code{\end@{@}} のコメントを外す @end table は、対応する @code{\begin} と @code{\end} 2行だけを、コメント操作の対象と します。リジョンをコメントアウトしようとして、マークを設定したのちにカーソ ルを移動し@kbd{[preifx] >} を押してもカーソルが @code{\begin@{@}} の上にあ ると@code{\begin@{@}}〜@code{\end@{@}}モードでコメント機能が働いてしまうの で注意して下さい。 @node Cursor jump, Modifying/Deleting, Commenting out, Top @comment node-name, next, previous, up @chapter カーソルジャンプ @cindex カーソルジャンプ[かあそるしやんふ] @cindex prefix g @menu * 対応オブジェクトへのジャンプ:: * お絵描きツール起動:: * メインファイルへのジャンプ:: * 環境を単位としたジャンプ:: * 最後の補完位置へのジャンプ:: @end menu @node 対応オブジェクトへのジャンプ, お絵描きツール起動, Cursor jump, Cursor jump @comment node-name, next, previous, up @section 対応オブジェクトへのジャンプ 文書中のいろいろな場所で @table @kbd @item [prefix] g @dots{} 対応するオブジェクトにジャンプ @end table @noindent を押すことにより、カーソル位置のLa@TeX{}コマンドに対応する場所にジャンプ します。対応関係が存在すると解釈されるコマンドには以下のものがあります。 @itemize @bullet @item @code{\begin@{@}} ←→ @code{\end@{@}} @item @code{%#BEGIN} ←→ @code{%#END} @item 画像ファイルの取り込みマクロ → 対応するviewer/お絵かきツール起動 @item @code{\label@{@}} ←→ @code{\ref@{@}} @item @code{\include(\input)} → 対応するファイル @item @code{\bibitem@{@}} ←→ @code{\cite@{@}} @end itemize @code{\begin@{@}} か @code{\end@{@}} の行で@kbd{[prefix] g}を押すことに より、対応する@code{end/begin}の行にジャンプします。もちろん対応するものが ない場合はエラーになります。またこれは、領域固定のための @code{%#BEGIN} と @code{%#END} のペアに対しても同様に動作します。なお、@code{label/ref}や @code{cite/bibitem}対応するものが別ファイルにある時は、ジャンプ先となるファ イルがオープンされていなければなりません。@xref{%#notation}. メインの .tex ファイルの @code{\include@{chap1@}} などにカーソルを合わせ、 @kbd{[prefix] g} を押すと、@file{chap1.tex} にジャンプします。 また、 @table @kbd @item [prefix] 4 g @dots{} 別ウィンドウで対応オブジェクトにジャンプ @end table @noindent を押すと、対応するオブジェクトへのジャンプを別ウィンドウで行います。ただし、 この機能は @code{begin/end}, @code{%#BEGIN/%#END} 間のジャンプに対しては (意味がないと思われるので)機能しないので注意してください。 @node お絵描きツール起動, メインファイルへのジャンプ, 対応オブジェクトへのジャンプ, Cursor jump @comment node-name, next, previous, up @section お絵描きツール起動 @cindex お絵描きツール起動[おえかきつうるきとう] 上記の「画像ファイルの取り込みマクロ」とは、例えば @code{\epsfile@{file=foo@}} のような挿絵取り込みコマンドのことで、この行に カーソルを合わせて@kbd{[prefix] g}を押すとその画像ファイルの元となったファ イルを対応するお絵描きツールを起動してオープンします。起動するツールの判定 は以下のようになされます。 @enumerate @item カレント行が変数 @code{YaTeX-processed-file-regexp-alist} に定義さ れている正規表現のいずれかとマッチしたら、ファイル名に相当する部分を \\(\\)から抜き出して覚えておく(何番目の\\(\\)かは変数の各リストの cdr 部に 入れておく)。マッチしなければ何もしない。 @item 行末に、変数 @code{YaTeX-file-processor-alist} に登録されているコマンドが 「%コマンド」 のように書いてあれば強制的に「コマンド ファイル名.拡張子」を 起動。 @item なければ、変数 @code{YaTeX-file-processor-alist} の各リストのcdr部に入って いる拡張子を「ファイル名」の後ろに足したファイルが存在するか順次調べて、存 在した場合car部に入っているコマンドを起動する。 @item 以上どれかにマッチしなければあきらめる。 @end enumerate 変数 @code{YaTeX-file-processor-alist} と変数 @code{YaTeX-file-processor-alist} の設定方法についてはそれぞれの変数につい て describe-variable して説明を読んで下さい。うまく設定すると、画像ファイ ルにかぎらず、任意の形式のファイルを任意のプロセッサで処理するコマンドを簡 単に呼び出すことができます。 @node メインファイルへのジャンプ, 環境を単位としたジャンプ, お絵描きツール起動, Cursor jump @comment node-name, next, previous, up @section メインファイルへのジャンプ @file{chap1.tex}のようなサブファイルで、 @table @kbd @item [prefix] ^ @dots{} メインファイルにジャンプ @item [prefix] 4 ^ @dots{} 別ウィンドウでメインファイルにジャンプ @end table @noindent を押すと、メインファイルの編集バッファに切替えます。もし、メインファイルを オープンしていない場合は、カレントディレクトリから探して自動的にオープンし ます。 @node 環境を単位としたジャンプ, 最後の補完位置へのジャンプ, メインファイルへのジャンプ, Cursor jump @comment node-name, next, previous, up @section 環境を単位としたジャンプ さらに現在の環境を単位として機能するコマンドに以下のものがあります。 @cindex 環境の先頭へ[かんきようのせんとうへ] @cindex 環境の末尾へ[かんきようのまつひへ] @cindex 環境をマーク[かんきようをまあく] @cindex M-C-a @cindex M-C-e @cindex M-C-@@ @table @kbd @item M-C-a @dots{} 環境の先頭(@code{\begin})へジャンプ @item M-C-e @dots{} 環境の末尾(@code{\end})へジャンプ @item M-C-@@ @dots{} 環境全体をマーク @end table 上記のコマンドは通常の@kbd{[prefix]}キーではなく@kbd{META}キーをプリフィク スとして機能するのでご注意下さい。 @node 最後の補完位置へのジャンプ, , 環境を単位としたジャンプ, Cursor jump @comment node-name, next, previous, up @section 最後の補完位置へのジャンプ 野鳥は補完入力した位置を常にレジスタ @code{3}に保存しています。 入力途中で如何なるファイルの如何なる位置に行ったとしても、 @kbd{C-x j 3}(@code{jump-to-register})を使って直ちに最後の補完入力位置に戻 ることができます。 @node Modifying/Deleting, Filling, Cursor jump, Top @comment node-name, next, previous, up @chapter 変更/削除 @cindex 変更/削除[へんこう/さくしよ] @cindex prefix c @cindex prefix k 既に入力されている La@TeX{} コマンドの変更/削除のために以下の機能が用意 されています。 @table @kbd @item [prefix] c @dots{} カーソル位置の La@TeX{} コマンドの変更 @item [prefix] k @dots{} カーソル位置の La@TeX{} コマンドの削除 @end table これらのコマンドは、コマンドを起動する場所によって動作を決定するので注意し て下さい。 @menu * Changing LaTeX command:: La@TeX{} コマンドの変更 * Killing LaTeX command:: La@TeX{} コマンドの削除 @end menu @node Changing LaTeX command, Killing LaTeX command, Modifying/Deleting, Modifying/Deleting @comment node-name, next, previous, up @section La@TeX{} コマンドの変更 変更したい La@TeX{} コマンドにカーソルを合わせて @kbd{[prefix] c} を押すとそのコマンドを補完入力などを用いて手軽に変えることができます。 @kbd{[prefix] c} で変更できるコマンドには以下のものがあります。 @itemize @item @code{begin/end} の環境名 @item section型コマンドのコマンド名 @item section型コマンドの引数 @item section型コマンドのオプションパラメータ([]で囲まれたもの) @item large型コマンド @item (イメージ補完で入力可能な)数式モード専用のmaketitle型コマンド @end itemize 変えたいsection型コマンドの引数がさらに La@TeX{} コマンドを含む場合は、 その引数を囲む中括弧の上で @kbd{[prefix] c} を押すことで中のコマンドを変更 対象判定から除外することができます。 @cindex 環境名の変更[かんきようめいのへんこう] @node Killing LaTeX command, , Changing LaTeX command, Modifying/Deleting @comment node-name, next, previous, up @section La@TeX{} コマンドの削除 @kbd{[prefix] k} は起動する位置により 次のような動作を行います。 @cindex 環境の削除[かんきようのさくしよ] @example 起動位置 動作 \begin, \endの行 @code{\begin\end}ペアの削除 %#BEGIN, %#END の行 %#BEGIN,%#ENDペアの削除 section型コマンドの上(中) section型コマンドの削除 フォント指定括弧の上 フォント指定の削除 括弧の上 対をなす括弧の削除 @end example @code{\begin, \end} および @code{%#BEGIN, %#END} を削除する場合、 @code{\begin, \end} や @code{%#BEGIN, %#END} の存在する行は まるごと削除されるので、それらの一行に @code{\begin} などを二つ以上連ねて 書かないように注意してください。 上記のものはすべて本文を囲う「容器」を削除するように働きますが、 universal-argument (@kbd{C-u}) を打った後で@kbd{[prefix] k}をタイプすると、 それぞれの「容器」に含まれる「中身」も一気に削除します。以下の例を参考にし て下さい。 @example 元のテキスト: [prefix] k C-u [prefix] k 本文\footnote@{脚注@}です。 本文脚注です。 本文です。 ↑(カーソル位置) @end example @node Filling, Includeonly, Modifying/Deleting, Top @comment node-name, next, previous, up @chapter 桁揃え @cindex 桁揃え[けたそろえ] @section itemの桁揃え @cindex itemなどの桁揃え[itemなとのけたそろえ] @cindex prefix i itemize 環境中にある@code{\item}の項目(文章)が複数行に渡る場合に、項 目の先頭を桁揃えしたい場合には、 @c @table @kbd @c @item [prefix] i @c @dots{} itemの桁揃え @c @end table @table @kbd @item M-q @dots{} 桁揃え @end table @cindex NTT-jTeX[えぬていいていいしえいてつく] @noindent によって、その item のインデントの深さに応じて fill されます。なお、古い NTT jTeX を使用している場合には、Lisp 変数@code{NTT-jTeX}を@code{t}にセッ トして下さい。 @cindex YaTeX-item-regexp このとき、変数@code{YaTeX-item-regexp}の値(標準では @code{"\\\\item"})を 項目指定コマンドの正規表現として検索に使用します。itemize 環境で、独自のコ マンドを定義して項目を列挙している場合(例えば@code{\underlineitem})は、 @file{~/.emacs} で次のように指定して下さい。 @lisp (setq YaTeX-item-regexp "\\(\\\\\\(sub\\)*item\\)\\|\\(\\\\underlineitem\\)") @end lisp この変数の指定の仕方がよく分からない場合は、独自の項目列挙コマンドの名前を @code{@code{"\item"}で始まるものにして下さい(例えば"\itembf"})。 野鳥の @kbd{M-q} では @code{\item} を環境に応じて以下のように「ハングイン デント」します。 @example itemize, enumerate環境: >\item[ほげほげ] 英語では、特に意味のない単語を `foo' であらわしま > すが、これの日本語版ともいえる単語が「ほげほげ」 > です。 description環境: > \item[へろへろ] 「ほげほげ」をでたらめが単語として使った時に、第 > 2のでたらめな単語として「へろへろ」が使われることが多 > いようです。 @end example @section パラグラフの桁揃え @cindex パラグラフの桁揃え[はらくらふのけたそろえ] @cindex M-q itemize環境以外でのパラグラフの桁揃え(fill)は、基本的に他のモードと同じ ように機能しますが、verbatim環境や、tabular環境など桁揃えをすると悲惨な状 況になるような環境中では機能しません。また、\verb で括ってあるものは決して 行分割されません(変数 @code{YaTeX-verb-regexp} で制御) )。さらに、一時的に インデントの深さを変えてある箇所では、そのインデントの先頭で@kbd{M-q}を押 すことにより fill-prefix をいちいち変更しなくて桁揃えができます。 @node Includeonly, What column, Filling, Top @comment node-name, next, previous, up @chapter 勝手にincludeonly @cindex 勝手にincludeonly[かつてにincludeonly] @cindex includeonly ファイルを分割して文章を入力している時には、メインファイル中に @example \includeonly@{現在編集中のファイル名@} @end example @noindent のように書いておくことで、タイプセットの時間を節約できますが、ちょっと他の ファイルを手直ししたい時には @cindex 他のファイルの手直し[ほかのふあいるのてなおし] @example \includeonly@{ちょっと手直ししたいファイル名@} @end example と書き直さなければならず手間がかかります。野鳥では現在編集しているファイル 名がメインファイルの@code{\includeonly}にない場合には自動的にこれを検出し、 次の指示を仰ぎます。 @example A)dd R)eplace %)comment? @end example 現在編集中のファイルを @code{\includeonly} のリストに加えたい時には@kbd{a} を、現在編集中のファイルだけを @code{\includeonly} にしたい時は@kbd{r}を、 @code{\includeonly} の行をコメントアウトして無効化したい時には、@kbd{%}を それぞれ押して下さい。 @node What column, Intelligent newline, Includeonly, Top @comment node-name, next, previous, up @chapter ここはどこ? @cindex ここはどこ?[ここはとこ?] @cindex prefix & @cindex 複雑なtabular[ふくさつなtabular] 項目数の多い tabular などをたくさん書いていると下の方の行で、いま書いて いる桁がどこに対応するのかわからなくなってしまうことがあります。例えば、以 下のような tabular において、 @example \begin@{tabular@}@{|c|c|c|c|c|c|c|c|@}\hline 氏名&所属&〒&住所&電話&FAX&帰省先&帰省先電話\\ \hline 矢上二郎 & 6 & 223 & 横浜市港北区日吉 & xxx-yyy & zzz-www & トンガ & 9876-54321 \\ 日吉小僧 & 2 & \multicolumn@{2@}@{c|@}@{教えない@} &&&(???) \\ \hline \end@{tabular@} @end example (???)の部分がどの項目なのかすぐに判断するのは難しいでしょう。こんな時は、 @table @kbd @item [prefix] & @dots{} 現在のカラム表示 @end table @cindex 現在のカラム表示[けんさいのからむひようし] @noindent を押すとカーソル位置のカラムがどの項目に該当するかをミニバッファに表示しま す。tabular/array環境の第1行目を項目名の並びとみなして対応するものを探しま す。もし項目名として別のものを表示して欲しい場合は、行頭を@code{%}にしてダ ミーの項目並びを作っておくと良いでしょう。 @node Intelligent newline, Usepackage cheker, What column, Top @comment node-name, next, previous, up @chapter おまかせ改行 @cindex おまかせ改行[おまかせかいきよう] @cindex &入力[&にゆうりよく] tabular[*], array, itemize, enumerate, tabbing 環境をbegin型補完で入力し た時、または各環境内で @table @kbd @item ESC RET @dots{} おまかせ改行 @end table を押すと、その環境に応じた行エントリを次の行に挿入します(begin型補完時に自 動挿入されたエントリが不要な場合は undo によって消去できます)。例えば、 tabular環境では、その環境のカラム数に対応した個数の @code{&} に加え、行末 の @code{\\} を入れます。この時それ以前に @code{\hline} があればそれも付け 加えます。環境とそれに応じて自動入力するものの対応は以下のようになります。 @itemize @item @code{tabular}, @code{tabular*}, @code{array} カラム数-1 だけの @code{&} と @code{\\}。必要に応じて @code{\hline} @item @code{tabbing} 一行目で定義している @code{\=} と同じ個数の @code{\>}。 @item @code{itemize}, @code{enumerate}, @code{description}, @code{list} @code{\item} または @code{item[]} @end itemize tabular 環境の例のように、本機能は各環境の一行目の内容を参考にして動作す るので、なるべく二行目以降で呼び出すようにしてください。 もし、その他の環境、例えば @code{foo}、に対して@code{おまかせ改行}を動作 させたい時は、@code{YaTeX-intelligent-newline-foo} という名前の関数を定義 します。定義した関数は、現在の行に改行を挿入した直後の行頭の位置で呼ばれま す。関数 @code{YaTeX-indent-line} を呼ぶと現在の環境のネストに応じた深さに インデントされるので、これを呼んでから何かを挿入するようなコードを書くとよ いでしょう。@file{yatexenv.el}内の関数 @code{YaTeX-intelligent-newline-itemize} の定義などを参考にしてください。 @node Usepackage cheker, Changing mode of YaTeX, Intelligent newline, Top @comment node-name, next, previous, up @chapter 先回りusepackage @cindex 先回りusepackage[さきまわり] begin型、section型、maketitle型、いずれかのLaTeX2eマクロを補完入力すると、 そのマクロの利用に外部パッケージを必要とする場合、そのパッケージを 本文中で @code{\usepackage@{@}} しているかどうかを調査し、もししていなければ プリアンブルに対応するパッケージを引数にした @code{\usepackage} 文を (確認後に)挿入します。 ただしこの機能が働くためには、パッケージ名とその中で定義されているマクロ 群をalistの形式で変数 @code{YaTeX-package-alist-private} に設定しておく必 要があります。 @node Changing mode of YaTeX, Online help, Usepackage cheker, Top @comment node-name, next, previous, up @chapter 野鳥の動作モード切り替え @cindex モード切り替え[もうときりかえ] @cindex prefix w @table @kbd @item [prefix] w @dots{} 野鳥動作モード切り替えメニュー @end table @noindent で野鳥自身の動作を決定する以下のモードを切り替えます。 @itemize @bullet @item 修正モード @item 野鳥数式モード @end itemize 修正モードは、開き括弧入力時の処理をコントロールし、修正モードONの時は開き 括弧の入力は開き括弧のみの入力になり、修正モードOFFの時は開き括弧の入力だ けで閉じ括弧まで入力します。デフォルト(起動時)の設定は@emph{OFF}です。 野鳥数式モードは、変数 @code{YaTeX-auto-math-mode} が @code{nil} の時の み有効で、このとき@kbd{;}や@kbd{:}を押した時(@ref{Image completion}参照)に、 どのようなイメージ補完を機能させるか、通常のキーとして機能させるかを手動で 切り替えます。自動判定が遅いマシンでは@code{YaTeX-auto-math-mode} @code{nil}にセットし、野鳥数式モードを手動で切り替えると良いでしょう。 @node Online help, Inclusion hierarchy browser, Changing mode of YaTeX, Top @comment node-name, next, previous, up @chapter オンラインヘルプ @cindex オンラインヘルプ[おんらいんへるふ] @cindex apropos @cindex キーワード検索[きいわあとけんさく] @cindex prefix ? @cindex prefix / 使おうとする La@TeX{} コマンドの用法がよく分からない時は、オンラインヘル プをひきましょう。ヘルプに関するキーには以下のものがあります。 @table @kbd @item [prefix] ? @dots{} オンラインヘルプ @item [prefix] / @dots{} オンラインapropos @end table @section オンラインヘルプ @cindex グローバルヘルプ[くろおはるへるふ] @cindex プライベートヘルプ[ふらいへえとへるふ] @cindex YaTeX-help-file @cindex YaTeX-help-file-private 「オンラインヘルプ」は、一般的な La@TeX{} コマンド(デフォルトでカーソル 位置のコマンド)に対する説明を隣のバッファに表示します。この時参照されるヘ ルプ用ファイルには「グローバルヘルプ」と「プライベートヘルプ」の二種類があ り、前者は La@TeX{} の標準コマンドの主なものの説明を含むファイルで、変数 @code{YaTeX-help-file}の値で指定されます。このファイルは通常公共の場所(デ フォルトで@code{$EMACSEXECPATH})に置かれ、誰もがその内容を更新できるように 全員に書き込み権が与えられるべきものです。後者は、非標準もしくは個人的なマ クロ定義に関する説明が書かれているファイルで、変数 @code{YaTeX-help-file-private}の値で指定されます。こちらはユーザのホームディ レクトリの下などに置かれます。 @section オンラインapropos 「オンラインapropos」は GNU Emacs の apropos と同様、ユーザが指定したキー ワードを説明文に含む項目すべてを隣のバッファに表示します。 もし、調べようとしたLa@TeX{}コマンドに対する説明がヘルプファイル中に見つ からなかった場合は、説明文の入力を求めてくるので、可能であれば参考書などを 調べてそのコマンドの説明を入力してください。もし、なにか標準的なコマンドに 対する説明を書いたならばぜひ私までその説明をお送り下さい。次回の配布に含め たいと思います。 @node Inclusion hierarchy browser, Cooperation with other packages, Online help, Top @comment node-name, next, previous, up @chapter インクルード構造ブラウザ @cindex インクルード構造[いんくるうとこうそう] @cindex prefix d 複数のファイルに分割しているドキュメントを書いている場合、 @table @kbd @item [prefix] d @dots{} インクルード構造ブラウズ @end table @noindent を押すと、そのドキュメントの親ファイルを聞いて来ます。ここで全てのファイル の親となるファイル(デフォルトが示されているので大抵はRETのみ)を入力すると インクルードしている全てのファイルを解析し、インクルード状況を視覚的に表示 します。このバッファでは以下のキー操作が有効です。 @table @kbd @item n @dots{} 次の行に移動し対応するファイルを隣のバッファに表示 @item p @dots{} 上の行に移動し対応するファイルを隣のバッファに表示 @item N @dots{} 同じインクルードレベルの次のファイルに移動 @item P @dots{} 同じインクルードレベルの前のファイルに移動 @item j @dots{} 次の行に移動 @item k @dots{} 上の行に移動 @item u @dots{} 一代親にあたるファイルに移動 @item . @dots{} カーソル位置のファイルを隣のバッファに表示 @item SPC @dots{} 隣のバッファの対応ファイルをスクロールアップ @item DEL, b @dots{} 隣のバッファの対応ファイルをスクロールダウン @item < @dots{} 隣のバッファの対応ファイルの先頭を表示 @item > @dots{} 隣のバッファの対応ファイルの末尾を表示 @item ' @dots{} (@kbd{<}や@kbd{>}の後で)元の表示位置に戻る @item RET, g @dots{} カーソル位置のファイルを隣のバッファでオープン @item mouse-2 @dots{} RETと同じ(ウィンドウ使用時のみ) @item o @dots{} 隣のウィンドウに移動 @item 1 @dots{} 他のウィンドウを消す @item - @dots{} ブラウズウィンドウを小さくする @item + @dots{} ブラウズウィンドウを大きくする @item ? @dots{} ヘルプ表示 @item q @dots{} 表示前の状態に戻る @end table ただし、隣のウィンドウのファイルの内容を表示する機能に関しては、対応する ファイルをクローズしてしまうとうまく働きませんのでご注意ください。 @node Cooperation with other packages, Customizations, Inclusion hierarchy browser, Top @comment node-name, next, previous, up @chapter 他パッケージとの連携 @cindex 他パッケージとの連携[たはつけえしとのれんけい] @section gmhist @cindex gmhist @cindex コマンドヒストリ[こまんとひすとり] @cindex ヒストリ[ひすとり] @file{gmhist.el}と@file{gmhist-mh.el} をロードしている場合、プレヴューコ マンドの入力(@kbd{[prefix] tp]})、印刷コマンドの入力(@kbd{[prefix] tl})の 時に独立したヒストリを利用できます。それぞれのプロンプトで、@kbd{M-p} を押 すと直前に利用したコマンド文字列をくり返し呼び出すことができます。 @section min-out @cindex min-out @file{min-out.el} (@code{outline-minor-mode}) と野鳥を組み合わせて使うこ とももちろん可能です。設定の方法に関しては@file{yatexm-o.el}をご覧ください。 @node Customizations, Etc, Cooperation with other packages, Top @comment node-name, next, previous, up @chapter カスタマイズ @cindex カスタマイズ[かすたまいす] @cindex キーアサイン[きいあさいん] 野鳥の動作を制御する種々の変数を独自に設定することにより、補完入 力を起動するキーアサインを変えたり、環境名の補完候補をさらに充実さ せることなどができます。 @menu * Lisp variables:: lisp 変数 * Add-in functions:: 付加関数(アドイン関数) @end menu @node Lisp variables, Add-in functions, Customizations, Customizations @comment node-name, next, previous, up @section lisp 変数 @cindex prefixキー変更[prefixきいへんこう] 例えば prefix キーを @kbd{C-c} 以外のキーにしたい場合は、 @code{YaTeX-prefix}に prefix キーにしたいシンボルを定義してください。さら に、「@kbd{C-c 英字}」というキーバインドは独自の関数が割り当ててあるので使 いたくない。このような時は、@code{YaTeX-inhibit-prefix-letter} を @code{t} に設定することにより、@kbd{C-c 英字…}のバインドが全て、対応する@kbd{C-c C-英字…}に変わります(ただし、begin型 large型補完の大文字起動によるリジョ ン指定は可能なままです。これも無効にしたい場合は@code{t}ではなく 1 にセッ トして下さい。)。 @menu * All customizable variables:: カスタマイズ変数一覧 * Sample definitions:: カスタマイズ変数設定例 * Hook variables:: hook変数 * Hook file:: hook用ファイル @end menu @node All customizable variables, Sample definitions, Lisp variables, Lisp variables @comment node-name, next, previous, up @subsection カスタマイズ変数一覧 @cindex カスタマイズ変数一覧[かすたまいすへんすういちらん] yatex-mode における次の変数がカスタマイズ可能です。@file{~/.emacs} で @code{setq} しておけば、そちらの定義が優先されます。括弧の中はデフォルト値 です。実際に変数の値を変更する場合は @kbd{M-x describe-variable} で 変数の詳細な説明を参照してください。 @defvar YaTeX-prefix yatex-mode 中のプリフィクスキー (@kbd{\C-c}) @end defvar @defvar YaTeX-inhibit-prefix-letter prefix キーの直後のキーバインドで @kbd{英字} のものを @kbd{C-英字} に変更 (@code{nil}) @end defvar @defvar YaTeX-fill-prefix 本文を書く時の行頭に挿入する接頭辞すなわち fill-prefix (@code{""(nil)}) @end defvar @defvar YaTeX-user-completion-table 学習したLa@TeX{}コマンド保存ファイル名 (@code{"~/.yatexrc"}) @end defvar @defvar YaTeX-kanji-code 文書を作成する時の漢字コード nil=既存のコードのまま 0=no-conversion 1=Shift JIS, 2=JIS, 3=EUC, 4=UTF-8 (2 (MS-DOSでは1)) @end defvar @defvar tex-command La@TeX{}タイプセッタコマンド名 (@code{"platex"}) @end defvar @defvar dvi2-command プレヴューアコマンド名 (@code{"xdvi -geo +0+0 -s 4"}) @end defvar @defvar dviprint-command-format dviファイルの印刷に使われるコマンド式 (@code{"dvi2ps %f %t %s | lpr"}) @end defvar @defvar dviprint-from-format 上の@code{%f}に相当する開始ページ指定書式、@code{%b} が開始ページ番号に変 わる (@code{"-f %b"}) @end defvar @defvar dviprint-to-format @code{%t} に相当する終了ページ指定書式、@code{%e}が終了ページ番号に変わる (@code{"-t %e"}) @end defvar @defvar makeindex-command makeindexコマンド (@code{"makeindex"} (MS-DOSでは@code{"makeind"})) @end defvar @defvar YaTeX-dvipdf-command dviをPDFに変換するコマンド (@code{"dvipdfmx"}) @end defvar @defvar YaTeX-need-nonstop @code{\nonstopmode@{@}}を自動的に付加するか (@code{nil}) @end defvar @defvar latex-warning-regexp latexコマンドの出力するウォーニング行の正規表現 (@code{"line.* [0-9]*"}) @end defvar @defvar latex-error-regexp 同じくエラー行の正規表現 (@code{"l\\.[1-9][0-9]*"}) @end defvar @defvar latex-dos-emergency-message MS-DOS上で動作する latex コマンドが、エラーにより停止するとき出力するメッ セージ (@code{"Emergency stop"}) @end defvar @defvar latex-message-kanji-code タイプセッタの出力するメッセージの漢字コード.タイプセットバッファ の出力が化ける時は、これを設定する (2, Nemacsでのみ有効) @end defvar @defvar NTT-jTeX 古いNTT-j@TeX{}使用時のようにインデントした行の先頭と前の行の (タイプセット後の)字間が空いてしまうのを嫌う場合は@code{t}にする (@code{nil}) @end defvar @defvar YaTeX-item-regexp itemの桁揃えの時に用いる、itemの正規表現 (@code{"\\\\(sub\\)*item"}) @end defvar @defvar YaTeX-verb-regexp verbコマンドの正規表現。先頭の\\\\はつけない (@code{"verb\\*?\\|path"}) @end defvar @defvar YaTeX-nervous ローカル辞書を用いる時 @code{t} (@code{t}) @end defvar @defvar YaTeX-sectioning-regexp セクション区切り設定コマンドの正規表現 (@code{"\\(part\\|chapter\\*?\\|\\(sub\\)*\\(section\\|paragraph\\)\\*?\\)\\b"}) @end defvar @defvar YaTeX-fill-inhibit-environments fill を抑止する環境名のリスト (@code{'("tabular" "tabular*" "array" "picture" "eqnarray" "eqnarray*" "equation" "math" "displaymath" "verbatim" "verbatim*")}) @end defvar @defvar YaTeX-uncomment-once 領域uncommentで行頭の複数の@code{%}を全て削除するか (@code{nil}) @end defvar @defvar YaTeX-close-paren-always 開き括弧の入力で常に閉じ括弧を入力する (@code{t}) @end defvar @defvar YaTeX-auto-math-mode 数式モードの切り替えを自動的に行う (@code{t}) @end defvar @defvar YaTeX-math-key-list-private 数式イメージ補完で用いる (プリフィクスキー . 対応補完テーブル) の alist (@code{nil})。補完テーブルの書き方については@file{yatexmth.el}を参照。 @end defvar @defvar YaTeX-default-pop-window-height 1画面の時にタイプセットバッファを初めて作成する時の高さ。数値で行数、数字 文字列でEmacsウィンドウに対する百分率 (10) @end defvar @defvar YaTeX-help-file 共用ヘルプファイル (@file{$doc-directory/../../site-lisp/YATEXHLP.jp}) @end defvar @defvar YaTeX-help-file-private 個人用ヘルプファイル (@file{"~/YATEXHLP.jp"}) @end defvar @defvar YaTeX-no-begend-shortcut @kbd{[prefix] b ??} のショートカットを使わず、@kbd{[prefix] b} だけで補完 入力に入る (@code{nil}) @end defvar @defvar YaTeX-hilit-pattern-adjustment-private 正規表現とそれにマッチするものの論理的意味をシンボルであらわしたものの リスト…のリスト。hilit19 を組み込んでいる時のみ有効。 詳しくは @code{(assq 'yatex-mode hilit-patterns-alist)} した結果と、変数 @code{YaTeX-hilit-pattern-adjustment-default} の値(と場合 によっては hilit19 のドキュメント)を参照せよ。 @end defvar @defvar YaTeX-sectioning-level LaTeXのセクション単位宣言コマンドとその論理的高さのalist。 @end defvar @defvar YaTeX-hierarchy-ignore-heading-regexp Hierarchy バッファは通常ファイルヘッダとして、LaTeXのセクション宣言コマン ドの引数を検索し、それがなければコメント行を探すが、その際にヘッダとしては 意味を持たないパターンをこの変数に設定する。デフォルトでは RCS ヘッダとモー ド指定行(-*- xxx -*-)が設定されている。 @end defvar @defvar YaTeX-skip-default-reader Non-nil に設定するとsection型コマンドの引数入力時、アドイン関数がなければ ミニバッファでの読み込みをせずに入力を完了させる (@code{nil}) @end defvar @defvar YaTeX-create-file-prefix-g @code{\include}などで @kbd{prefix g}した時に、ジャンプ先が存在しないファイ ルであってもオープンする (@code{nil}) @end defvar @defvar YaTeX-simple-messages 各種補完時のメッセージ出力を簡素化する (@code{nil}) @end defvar @defvar YaTeX-hilit-sectioning-face 色付けが有効な時の @code{\part} の色 (@code{'(yellow/dodgerblue yellow/slateblue)})。 リストの第一要素は @code{hilit-background-mode} が @code{'light} の時の、 第二要素は @code{'dark} の時の @code{\chapter} の色で、文字色/背景色 のよ うに指定する。 @end defvar @defvar YaTeX-hilit-sectioning-attenuation-rate 色付けが有効な時の、@code{\subparagraph} の色を @code{\chapter} の濃度の何 %薄くしたものにするか (@code{'(15 40)}) @code{YaTeX-hilit-sectioning-face} の項参照。 @end defvar @defvar YaTeX-use-AMS-LaTeX AMS-LaTeX を使用する場合は @code{t} に設定する (@code{nil}) @end defvar @defvar YaTeX-use-LaTeX2e LaTeX2e を使用する場合は @code{t} に設定する (@code{t}) @end defvar @defvar YaTeX-template-file 新規ファイル作成時に自動挿入するファイル名 (@code{~/work/template.tex}) @end defvar @defvar YaTeX-search-file-from-top-directory inputするファイルを探すときの基準ディレクトリをmainファイルのあるディレクト リにするか (@code{t}) @end defvar @defvar YaTeX-use-font-lock ソースの色づけパッケージとして font-lock を利用するかどうか (@code{(featurep 'font-lock)}) @end defvar @defvar YaTeX-use-hilit19 ソースの色づけパッケージとして hilit19 を利用するかどうか (@code{(featurep 'hilit19)}) @end defvar @defvar YaTeX-use-italic-bold italic, boldフォントを野鳥が探すかどうか (Emacs20以降なら@code{t}) font-lock利用時のみ有効。 (@code{(featurep 'hilit19)} @end defvar @defvar YaTeX-singlecmd-suffix 全てのmaketitle型コマンドの補完入力直後に挿入する文字列。 @code{"@{@}"} などがお勧め。 @end defvar @defvar YaTeX-package-alist-private LaTeX2eのパッケージ名とその中に含まれるマクロのリスト。 適切に設定しておくと本文入力時にマクロを補完入力すると そのマクロに必要なパッケージを usepackage するか自動的に検査してくれる。 していなければ \usepackage を自動追加することもできる。 リストは @lisp '((パッケージ名1 (補完タイプ マクロのリスト……) (補完タイプ マクロのリスト……)) (パッケージ名2 (補完タイプ マクロのリスト……) (補完タイプ マクロのリスト……))………) @end lisp という形式にする。補完タイプは @code{env, section, maketitle} のどれか。 具体例は変数 @code{YaTeX-package-alist-default} の値参照。 @end defvar @defvar YaTeX-tabular-indentation tabular/array 環境で現在行の先頭位置が表の第Nカラムのときは 標準インデント位置から N*YaTeX-tabular-indentation 桁下げた インデントにする。 @end defvar @defvar YaTeX-noindent-env-regexp 別の環境内にあっても \begin@{@} が行頭から始まるべき環境名の正規表現。 verbatim環境などを指定する。 @end defvar @defvar YaTeX-ref-default-label-string \ref@{@} のラベル補完でラベル未設定のものに自動的に生成する ラベル名の書式。strftime(3)関数に似た日付ベースで指定する。 利用できる書式は以下のとおり。 %y -> 西暦下二桁, %b -> 月の英名, %m -> 月(1〜12) %d -> 日, %H -> 時, %M -> 分, %S -> 秒, %qx -> アルファベットで26進数化した yymmdd. %qX -> アルファベットで26進数化した HHMMSS. デフォルトは "%H%M%S_%d%b%y" @end defvar @defvar YaTeX-ref-generate-label-function \ref@{@}のラベル名自動生成のときに使う関数のシンボル。 デフォルトは標準の YaTeX::ref-generate-label 関数が割り当ててある。 引数を2つ取る関数を定義して、この変数にセットするとその関数を呼んだ 結果をデフォルトのラベル名候補とする。設定例: @lisp (setq YaTeX-ref-generate-label-function 'my-yatex-generate-label) (defun my-yatex-generate-label (command value) (and (string= command "caption") (re-search-backward "\\\\begin@{\\(figure\\|table\\)@}" nil t) (setq command (match-string 1))) (let ((alist '(("chapter" . "chap") ("section" . "sec") ("subsection" . "subsec") ("figure" . "fig") ("table" . "tbl")))) (if (setq command (cdr (assoc command alist))) (concat command ":" value) (YaTeX::ref-generate-label nil nil)))) @end lisp @end defvar @node Sample definitions, Hook variables, All customizable variables, Lisp variables @comment node-name, next, previous, up @subsection カスタマイズ変数設定例 @cindex 設定例[せつていれい] たとえば、prefix キーとして@kbd{ESC}を使用し、新たな補完候補を格納するファ イルを、@file{~/src/emacs/yatexrc} にし、行頭の prefix をタブ文字一つに変 えたいときは、 @lisp (setq YaTeX-prefix "\e" YaTeX-user-completion-table "~/src/emacs/yatexrc" YaTeX-fill-prefix " ") @end lisp @noindent を @file{~/.emacs} に加えます。 @node Hook variables, Hook file, Sample definitions, Lisp variables @comment node-name, next, previous, up @subsection hook変数 @cindex hook変数[hookへんすう] @cindex yatex-mode-hook @cindex yatex-mode-load-hook また、hook 変数 @code{yatex-mode-hook}, @code{yatex-mode-load-hook} を用 意しています。すべての yatex-mode のバッファで作用させたいものは、 @code{yatex-mode-hook} に記述し、@file{yatex.el} をロードする時だけ作用さ せたいものは@code{yatex-mode-load-hook} に記述します。例えば、 @code{outline-minor-mode} を利用する場合、それぞれのバッファで @code{outline-minor-mode} を有効にしたいので、@code{yatex-mode-hook} を次 のように設定します。 @lisp (setq yatex-mode-hook '(lambda () (outline-minor-mode t))) @end lisp 逆に、独自のキー定義を行いたい時などは、@code{yatex-mode-load-hook} を利用 します。例えば、begin 型補完において、 document や、enumerate 以外の環境名 もショートカットキーで入れたいなどという時は、次のようにします。以下の例は、 @kbd{[prefix] ba} で @code{\begin@{abstract@}}, @code{\end@{abstract@}} を 挿入します。 @lisp (setq yatex-mode-load-hook '(lambda() (YaTeX-define-begend-key "ba" "abstract"))) @end lisp なお、新たなキーの定義には、関数 @code{YaTeX-define-key} @code{YaTeX-define-begend-key}を利用するようにしてください。 @node Hook file, , Hook variables, Lisp variables @comment node-name, next, previous, up @subsection hook用ファイル 変数 @code{yatex-mode-load-hook} で定義する内容が多い時は、 @file{yatexhks.el}というファイルを作り、その中に野鳥関連の設定を書く事で、 初期化の時に自動的にロードします。 @node Add-in functions, , Lisp variables, Customizations @comment node-name, next, previous, up @section 付加関数(アドイン関数) 各種補完時に、環境名やコマンド名に応じたきめ細やかな補完入力機能を実現す るための関数を作成することができます。この関数の作成方法や、組み込み方法に 関しては、@code{yatexadd.doc} をご覧ください。 @node Etc, Copying, Customizations, Top @comment node-name, next, previous, up @chapter その他 野鳥の標準の La@TeX{} コマンドの辞書には、作者が頻繁に使うものしか登録さ れていません。これは、補完候補に使いそうもないコマンドが存在して、補完した いコマンドを出すまでのストローク数を増やしてしまう事を防止するためです。標 準辞書にないコマンドも、できるだけ補完入力方式を利用し、ユーザ辞書を充実さ せることで、あなたの La@TeX{} スタイルにあった野鳥へと育っていくことでしょ う。 @node Copying, Concept Index, Etc, Top @comment node-name, next, previous, up @chapter 取り扱い 本プログラムはフリーソフトウェアです。本プログラムを使用して生じたいかな る結果に対しても作者は責任を負わないこととします。転載等に関しては制限いた しません。常識的に扱ってください。また、本プログラムに含まれるコードを利用 すること、改造することも自由に行なって構いませんが、流用することにより契約 締結の必要が生じる場合、私はいかなる契約も締結しません。具体的にはGPLへの サインはしませんので、GNUに寄贈するものを作っている場合私の作品から取り込 んだコードを流用すると苦労するかもしれません。いかなるコード流用も拒否しま せんが契約締結は辞退します。 苦情、希望、バグ報告、感想等は歓迎いたします。 連絡は yuuji@@yatex.org まで(2004年1月現在)。 継続的に使用してくださる方はメイリングリスト「fj野鳥の会」に 是非加入してください。加入方法については本パッケージの @file{docs/qanda} ファイルの「その他」の章を御覧ください。 仕様は、予告なく確実に(気分次第で)変更されます:-p。 @flushright 広瀬雄二 @end flushright @node Concept Index, , Copying, Top @comment node-name, next, previous, up @unnumbered 索引 @printindex cp @c カスタマイズ変数索引を索引と分離する場合にはコメントアウトを外す!!! @c @node Variable Index @c @comment node-name, next, previous, up @c @unnumbered カスタマイズ変数索引 @c @printindex vr @contents @bye @c Local Variables: @c fill-column: 74 @c fill-prefix: nil @c buffer-file-coding-system: sjis @c End:  Tag table:  End tag table yatex_1.77+dfsg1/yatex.new0000444000175000017500000006277612126310636014237 0ustar kurakura What's new in YaTeX/yahtml 野鳥/yahtml - 各バージョンの変更点について 1.77 last-command-char 廃止対策を追加。 === yatex === %#DVIPDF でdviからpdfへの変換コマンドを指定可能に。 PDFヴューアに xpdf, pdfopen, mupdf, zathura, okular を追加。 1.76 === yatex === タイプセットでラベル未定義があったら自動的にrerunする。 自動rerun無効化は YaTeX-typeset-auto-rerun を nil に。 %#BIBTEX で始まる行に起動すべき bibtex コマンドを記述可能。 %#MAKEINDEX で始まる行に起動すべき makeindex コマンドを記述可能。 [prefix] t % で %#BIBTEX、%#MAKEINDEX 行を更新可能に。 [prefix] t d の platex+dvipdfmx をメニューに追加。 \includegraphicsでPNG/JPG/GIF/BMP指定時、bb= を自動生成する(c)。 数式用環境のお任せ改行を刷新。 === yahtml ===

      , の属性入力を C-j でスキップ可能に。 1.75 === yatex === [prefix] t e でポイント位置を含む環境か数式環境をタイプセット。 M-C-SPC で環境だけでなく数式環境もマークする。 [prefix] t d でタイプセッタ起動成功のあと dvipdfmx を起動。 \label{}でラベル名を入れたときは \ref{NAME} を自動的にkill-ringに追加。 [prefix] c で\label{NAME} の NAME を変えたら \ref のNAMEも変える。 同上のことを \cite/\bibitem にも。 \bibitem{}を入れたときは \cite{TAG} を自動的にkill-ringに追加。 \end 補完のお節介検査の精度を少し上げた。 jsarticle, jsbook をデフォルト補完辞書に入れた。 \begin の直後の { で自動的に \end 込みで環境補完(modify-modeと連動)。 === yahtml === [prefix] t ブラウザメニューに「n:新規ページ作成」を追加(実験)。 [prefix] t j のlintコマンドを 行で指定可。 [prefix] } でリジョンを td 要素で括る(デフォルトは空白区切り)。 [prefix] ] でリジョンを tr, td 要素で括る(1行1レコード)。 閉じ括弧のないCSSファイル解析が終われない問題を修正。 li, dt, dd のインデント計算を環境型的に深さを変えるようにした。 1.74 === yatex === YaTeX-kanji-code が 4 のときは UTF-8 とした。 Previewファイルの拡張子が.dviであるという仮定を弱くした(pdf等)。 pdfopenを呼ぶときの問題への対策追加(by松田さん)。 拡張子 pdf に対するデフォルトヴューアを追加。 === yahtml === yahtml-kanji-code が 4 のときは UTF-8 とした。 [prefix] Return Intelligent-newline をtable対応にした。 cssファイル中に@importがあったときのバグを除去。 cssの *.class 解釈を修正。 yahtml-image-inspection-bytes を50000に増やした。 1.73 === yatex === C-i (YaTeX-indent-line) のtabular/array環境対応。行頭位置の tabular的カラム位置に応じてインデントの深さを4桁ずつ深くする。 深くする桁数を制御する変数 YaTeX-tabular-indentation 新設。 \ref補完で出る一覧で数式は\label文字列も出すようにした。 \ref補完で自動的に生成するラベル名を短くした。カスタマイズも可。 生成するラベル名の書式を変える変数YaTeX-ref-default-label-string新設。 ラベル名生成関数そのものは YaTeX-ref-generate-label-function で変更可。 AMS-LaTeX独自のカウンタつき数式環境も全てref補完でlabel打ち可能 な場所を検出できるようにした。 AMS-LaTeX独自の数式環境でのお任せ改行サポート。 tabularのお任せ改行で *{N}{REP} もカラム数を取れるようにした。 verbatim環境/alltt環境宣言はTABインデントで行頭に来るようにした。 インデントなしの環境宣言を決める変数 YaTeX-noindent-env-regexp 新設。 [prefix] c, [prefix] g などがセクション型マクロの英字のみの引数 で動かないのを修正。 先回りusepackageでパッケージのオプションを確認できるようにした。 [prefix] k でセクション型マクロの引数の数を考慮して消すようにした。 [prefix] k ではマクロの最後の引数の中味のみを残すようにした。 [prefix] S ではリジョンをセクション型マクロの最後の引数に括り入 れるようにしてそれ以前の引数入力にアドイン関数を呼ぶようにした。 数式モード内の _添字 ^上字 を変えるfaceを作成。とりあえず色だけ 変えるようにした(Emacs21.4なら上下にスライドできるだろう)。 変数 YaTeX-dvi2-command-ext-alist 新設。Previewerコマンドと、そ れでPreviewするファイルのデフォルト拡張子を指定できるようにした。 tabular中のカラム内に\begin\endがある場合はfill-paragraph境界を そこまでに絞るようにした。 \cite上での[prefix] g で\bibliography{}で指定したBibファイルの対 応エントリに飛べるようにした。 === yahtml === cssの @import に対応(たぶん)。 class補完でクラス名をSPCで区切った複数指定の補完入力を可能に。 Emacs-21.3 以降のため insert-default-directory をnilに。 single-cmd-tableから p を削除。 変数 yahtml-html4-strict を新設。HTML4Strict準拠をできるだけ補助。 script, noscript要素の補完を追加。script要素のアドインも追加。 [prefix] m に 補完を追加。 [prefix] m でもアドイン補完を呼ぶようにしたので M-C-m の
    1. 挿入 でクラス名補完が起きる。これを回避するために M-C-j にも intelligent newline を割り当ててクラス名補完を飛ばせるようにした。 [prefix] g に universal arg を指定しても隣窓で開かないのを修正。 1.72 === yatex === YaTeX-kanji-code が nil なら coding-system に感知しない 補完したマクロがLaTeX2eの特定のpackageに依存している場合 そのpackageを半自動で \usepackage する(yatexpkg.el新設) {} の末尾がイタリック補正 \/ ならそれを消す === yahtml == yahtml-kanji-code が nil なら coding-system に感知しない 1.71 === yatex === fill-prefix を指定している場合、Emacs21で \item の auto-fill が \item の深さにかかわらず fill-prefix になってしまうのを回避 \refのラベル補完で、既にlabel定義してあるものがカウンタと\label 両方が補完候補に出現していたのを修正。またenumerate環境内では \itemとラベルが重複して候補に現れていたのを修正。 Emacsの背景色の定義がXリソースに全く無いときの不具合修正 [prefix] c で AMS-LaTeX の大括弧対の種類を変えられるようにした [prefix] g で AMS-LaTeX の括弧対間でジャンプできるようにした 1.70 Emacs21でmake-frameがエラーになることがあるのを回避 font-lock での Recenter が効かなくなるのを修正 (他、細かい修正がほとんど) 1.69 font-lock 対応(XEmacs, Emacs-20, Emacs-21 のみ)。 hilit19, font-lockを共存させている場合 YaTeX-use-hilit19 か、 YaTeX-use-font-lock どちらか一方を Non-nil にする。 ~/.emacs で (put 'yatex-mode 'font-lock-defaults ....) や (put 'yahtml-mode 'font-lock-defaults ...)などを入れている人はその 設定を削り、(setq YaTeX-use-font-lock t) を入れてください。 Emacs-21(pretest version)で動くようにした。 kill-bufferしたときに親ファイルが出現するよう努力。 野鳥起動時の段階でEmacsに italic, bold フォントが登録されていれ ば、それを積極的に利用するようにした。 === yatex === section型補完のときに直前の文字列でデフォルト候補を変える機能を 試験的に入れてみた。 (Meadow)Typeset menu での IME OFF。 yatexmth, ;[TAB] 一覧の最初の \| が選択できなかったのを修正。 === yahtml === XEmacsで img src での画像サイズ取得ができなかったのを修正。 [prefix] ESC で yahtml-mode に入る前の major-mode に復帰(メイルの draftバッファでHTMLを書くために一時的にyahtmlを読んで元に戻るとき に有効)。 1.68 === yatex === XEmacsでyatexgenが動かなくなったのに対処。 Windowsでのインストールが少し楽になるように makefile を修正。 ref/cite ラベル補完で全てのカウンタを補完候補にあげてなおかつ labelが設定していないところには自動的にラベルを付加するようにした。 \cite の補完を BibTeX データベースファイルからも探すようにした。 LaTeX2eの多くのコマンドに、本体/アドイン共に対応。 === yahtml === 英語版info、Q&Aの添付(by Jun Ohyaさん) 補完でsrcとなる画像ファイルのピクセルサイズを自前 で調べて width, height 属性の補完のデフォルトとなるようにした。 M-C-a(beginning-of-environment), M-C-e(end-of-environment), M-C-@(mark-environment) が yatex.el 内に定義されていてyahtmlだけ をロードしているときにエラーになったので、これら関数定義を yatexlibに移動。 css定義ファイル中ピリオドで始まるエントリを全てのエレメントに共 通なclass補完候補として出すようにした。 yahtmlを使用するとYaTeXでのインデントがおかしくなるのを直した。 & でchar-entity reference補完。 1.67 [[[ http://www.yatex.org/ が誕生しました ]]] === yahtml === href入力でSPCなどのunsafe-charを%エンコードに置換するかを yahtml-escape-chars で選べるようにした。nilならしない、tなら常に、 'ask なら確認する。デフォルトは 'ask。 初回href入力時に yahtml-urls を補完候補に入れてなかったのを修正。 [prefix] ; でリジョン中の <>'"& をエンティティ参照に変換、 [prefix] : で逆変換する機能を追加。 yahtml-translate-hyphens-when-comment-region が non-nil のときに 領域コメントアウトで - を - に変換。 yahtml-prefer-upcase-attributes が non-nil のとき属性名を大文字に。 カレントまたは上位ディレクトリに .htaccess ファイルがありその中に AddType "text/html; charset=XXXX" .html 宣言があれば編集するHTMLソースの漢字コードもその宣言に合わせる。 ") (point)) alist))))) ((and (string-match "link" tag) (stringp (setq type (yahtml-get-attrvalue "type"))) (string-match "text/css" type) (setq href (yahtml-get-attrvalue "href")) (file-exists-p (yahtml-url-to-path href))) (setq alist (yahtml-css-collect-classes-file (yahtml-url-to-path href) alist)))) (setq yahtml-css-class-alist alist))))) (defun yahtml-css-get-element-completion-alist (element) (let ((alist (cdr-safe (assoc (downcase element) yahtml-css-class-alist))) (global (cdr-safe (assoc "*" yahtml-css-class-alist)))) (and (or alist global) (append alist global)))) ;;; ---------- ---------- ;;; ;;hilit19 ;;; (defvar yahtml-default-face-table '( (form black/ivory white/hex-442233 italic) )) (defvar yahtml-hilit-patterns-alist '( 'case-fold ;; comments ("" comment) ;; include&exec ("" include) ;; string (hilit-string-find ?\\ string) (yahtml-hilit-region-tag "<\\(strong\\|b\\)\\>" bold) ("" 0 decl) ("<\\(di\\|dt\\|li\\|dd\\)>" 0 label) (yahtml-hilit-region-tag "<\\(em\\|i\\>\\)" italic) ;("" crossref) ;good for hilit19, but odd for font-lock.. (yahtml-hilit-region-tag "<\\(a\\)\\s +href" crossref) (yahtml-hilit-region-tag-itself "" decl) )) (defun yahtml-hilit-region-tag (tag) "Return list of start/end point of form." (if (re-search-forward tag nil t) (let ((m0 (match-beginning 0)) (e0 (match-end 0)) (elm (YaTeX-match-string 1))) (skip-chars-forward "^>") (prog1 (cons (1+ (point)) (progn (re-search-forward (concat "") nil t) (match-beginning 0))) (goto-char e0))))) (defun yahtml-hilit-region-tag-itself (ptn) "Return list of start/end point of itself." (if (re-search-forward ptn nil t) (let ((m0 (match-beginning 0)) (e0 (match-end 0))) (skip-chars-forward "^<>") (if (eq (char-after (point)) ?<) nil (prog1 (cons m0 (min (point-max) (1+ (point)))) (goto-char e0)))))) ;(setq hilit-patterns-alist (delq (assq 'yahtml-mode hilit-patterns-alist) hilit-patterns-alist)) (and yahtml-use-hilit19 (or (assq 'yahtml-mode hilit-patterns-alist) (setq hilit-patterns-alist (cons (cons 'yahtml-mode yahtml-hilit-patterns-alist) hilit-patterns-alist)))) ;;; ;; for font-lock ;;; ; <> ;(defvar yahtml-font-lock-keywords ; '( ; ;; comments ; ("" . font-lock-comment-face) ; ;; include&exec ; ("" ; 0 font-lock-include-face keep) ; ;; string ; ;(hilit-string-find ?\\ string) ; ;(yahtml-hilit-region-tag "\\(em\\|strong\\)" bold) ; ("" 0 font-lock-keyword-face) ; ("<\\(di\\|dt\\|li\\|dd\\)>" 0 font-lock-label-face) ; ("" (0 font-lock-crossref-face keep)) ; ;(yahtml-hilit-region-tag-itself "" decl) ; ("" (yahtml-fontify-to-tagend nil nil)) ; ) ; "*Defualt font-lock-keywords for yahtml-mode.") (defvar yahtml-font-lock-keywords (YaTeX-convert-pattern-hilit2fontlock yahtml-hilit-patterns-alist) "Default fontifying patterns for yahtml-mode") (defun yahtml-font-lock-set-default-keywords () (put 'yahtml-mode 'font-lock-defaults '(yahtml-font-lock-keywords nil t))) (if yahtml-use-font-lock (progn (if (and (boundp 'hilit-mode-enable-list) hilit-mode-enable-list) ;;for those who use both hilit19 and font-lock (if (eq (car hilit-mode-enable-list) 'not) (or (member 'yahtml-mode hilit-mode-enable-list) (nconc hilit-mode-enable-list (list 'yahtml-mode))) (setq hilit-mode-enable-list (delq 'yahtml-mode hilit-mode-enable-list)))) (yahtml-font-lock-set-default-keywords))) (defun yahtml-font-lock-recenter (&optional arg) (interactive "P") (font-lock-mode -1) ;is stupid, but sure. (font-lock-mode 1)) (run-hooks 'yahtml-load-hook) (provide 'yahtml) ; Local variables: ; fill-prefix: ";;; " ; paragraph-start: "^$\\| \\|;;;$" ; paragraph-separate: "^$\\| \\|;;;$" ; coding: sjis ; End: yatex_1.77+dfsg1/yatex19.el0000444000175000017500000007206112126310636014204 0ustar kurakura;;; yatex19.el -- YaTeX facilities for Emacs 19 or later ;;; (c)1994-2013 by HIROSE Yuuji.[yuuji@yatex.org] ;;; Last modified Mon Apr 1 22:42:46 2013 on firestorm ;;; $Id: yatex19.el,v 1.77 2013/04/01 13:53:45 yuuji Rel $ ;;; Code: ;(require 'yatex) (and (boundp 'YaTeX-use-hilit19) YaTeX-use-hilit19 (require 'hilit19)) (defvar YaTeX-use-highlighting (or YaTeX-use-font-lock YaTeX-use-hilit19) "*Use highlighting buffer or not.") (defvar YaTeX-background-mode (or (if (fboundp 'get-frame-background-mode) (get-frame-background-mode (selected-frame))) (if (fboundp 'frame-parameters) (cdr (assq 'background-mode (frame-parameters)))) (if (boundp 'frame-background-mode) frame-background-mode) (if (boundp 'hilit-background-mode) hilit-background-mode) (if (face-background 'default) (if (> (+ 32768 32768 32768) (apply '+ (funcall (if (fboundp 'color-rgb-components) 'color-rgb-components 'x-color-values) (face-background 'default)))) 'dark 'light)))) (defvar YaTeX-mode-menu-map (make-sparse-keymap "YaTeX")) (defvar YaTeX-mode-menu-map-process (make-sparse-keymap "Process")) (define-key YaTeX-mode-map [menu-bar yatex] (cons "YaTeX" YaTeX-mode-menu-map)) (YaTeX-define-menu 'YaTeX-mode-menu-map-process (nreverse '((buffer "LaTeX" . (lambda () (interactive) (YaTeX-typeset-menu nil ?j))) (pdf "LaTeX+PDF" . (lambda () (interactive) (YaTeX-typeset-menu nil ?d))) (kill "Kill LaTeX" . (lambda () (interactive) (YaTeX-typeset-menu nil ?k))) (bibtex "BibTeX" . (lambda () (interactive) (YaTeX-typeset-menu nil ?b))) (mindex "makeindex" . (lambda () (interactive) (YaTeX-typeset-menu nil ?i))) (preview "Preview" . (lambda () (interactive) (YaTeX-typeset-menu nil ?p))) (lpr "lpr" . (lambda () (interactive) (YaTeX-typeset-menu nil ?l))) (lpq "lpq" . (lambda () (interactive) (YaTeX-typeset-menu nil ?q)))))) (defvar YaTeX-mode-menu-map-modes (make-sparse-keymap "Modes")) (YaTeX-define-menu 'YaTeX-mode-menu-map-modes (delq nil (nreverse (list (if YaTeX-auto-math-mode nil (cons 'math (cons "Toggle math-mode" '(lambda () (interactive) (YaTeX-switch-mode-menu nil ?t))))) (cons 'mod (cons "Toggle Modify Mode" '(lambda () (interactive) (YaTeX-switch-mode-menu nil ?m)))))))) (defvar YaTeX-mode-menu-map-percent (make-sparse-keymap "percent")) (YaTeX-define-menu 'YaTeX-mode-menu-map-percent (nreverse '((! "Change LaTeX typesetter(%#!)" . (lambda () (interactive) (YaTeX-%-menu nil nil ?!))) (begend "Set %#BEGIN-%#END on region" . (lambda () (interactive) (YaTeX-%-menu nil nil ?b))) (lpr "Change LPR format" . (lambda () (interactive) (YaTeX-%-menu nil nil ?l)))))) (defvar YaTeX-mode-menu-map-jump (make-sparse-keymap "jump")) (YaTeX-define-menu 'YaTeX-mode-menu-map-jump (nreverse '((corres "Goto corersponding position" . YaTeX-goto-corresponding-*) (main "Visit main source" . (lambda () (interactive) (YaTeX-visit-main))) (main-other "Visit main source other window" . YaTeX-visit-main-other-window)))) (defvar YaTeX-mode-menu-map-comment (make-sparse-keymap "comment")) (YaTeX-define-menu 'YaTeX-mode-menu-map-comment (nreverse '((comment "Comment region or environment" . YaTeX-comment-region) (uncomment "Unomment region or environment" . YaTeX-uncomment-region) (commentp "Comment paragraph" . YaTeX-comment-paragraph) (uncommentp "Uncomment paragraph" . YaTeX-uncomment-paragraph)))) (YaTeX-define-menu 'YaTeX-mode-menu-map (nreverse (list ;; Change/Kill/Fill ------------------------------------------------------- (cons (list 'chg "Change") (cons "Change macros" 'YaTeX-change-*)) (cons (list 'kill "Kill") (cons "Kill macros" 'YaTeX-kill-*)) (cons (list 'fill "Fill") (cons "Fill \\item" 'YaTeX-fill-item)) (cons (list 'nl "Newline") (cons "Newline" 'YaTeX-intelligent-newline)) ;; ======================================================================== (cons (list 'sep1 "---") (cons "---" nil)) ;; Comment/Uncomment ------------------------------------------------------ (cons (list 'comment "comment") (cons "Comment region or environment" 'YaTeX-comment-region)) (cons (list 'uncomment "uncomment") (cons "Uncomment region or environment" 'YaTeX-uncomment-region)) (cons (list 'commentp "commentp") (cons "Comment paragraph" 'YaTeX-comment-paragraph)) (cons (list 'uncommentp "uncommentp") (cons "Uncomment paragraph" 'YaTeX-uncomment-paragraph)) ;; ======================================================================== (cons (list 'sep2 "---") (cons "---" nil)) ;; Jump cursor ------------------------------------------------------------ (cons (list 'jump "jump") (cons "Jump Cursor" YaTeX-mode-menu-map-jump)) ;; Document hierarchy --------------------------------------------------- (cons (list 'hier "hier") (cons "Display Document hierarchy" 'YaTeX-display-hierarchy)) ;; What position ---------------------------------------------------------- (cons (list 'col "column") (cons "What column in tabular" 'YaTeX-what-column)) ;; % menu ----------------------------------------------------------------- (cons (list 'percent "percent") (cons "Edit %# notation" YaTeX-mode-menu-map-percent)) ;; Switch modes ----------------------------------------------------------- (cons (list 'mode "mode") (cons "Switching YaTeX's modes" YaTeX-mode-menu-map-modes)) ;; ======================================================================== (cons (list 'sep "---") (cons "---" nil)) ;; Help for LaTeX --------------------------------------------------------- (cons (list 'ap "apr") (cons "Apropos on LaTeX commands" 'YaTeX-apropos)) (cons (list 'help "help") (cons "Help on LaTeX commands" 'YaTeX-help)) ;; Menu for Typeset relating processes ------------------------------------ (cons (list 'process "Process menu") (cons "Process" YaTeX-mode-menu-map-process))) )) ;; Make section-type commands menu ------------------------------------------- (defvar YaTeX-mode-menu-map-sectionr (make-sparse-keymap "Enclose region with section-type macro")) (defvar YaTeX-mode-menu-map-section (make-sparse-keymap "Section-type macro")) (let ((sorted-section (sort (delq nil (mapcar (function (lambda (s) (if (> (length (car s)) 5) (car s)))) (append section-table user-section-table))) 'string<))) (YaTeX-define-menu 'YaTeX-mode-menu-map-section (mapcar (function (lambda (secname) (cons (intern secname) (cons secname (list 'lambda () (list 'interactive) (list 'YaTeX-make-section nil nil nil secname)))))) sorted-section)) (YaTeX-define-menu 'YaTeX-mode-menu-map-sectionr (mapcar (function (lambda (secname) (cons (intern secname) (cons secname (list 'lambda () (list 'interactive) (list 'YaTeX-make-section nil (list 'region-beginning) (list 'region-end) secname)))))) sorted-section))) (YaTeX-define-menu 'YaTeX-mode-menu-map (nreverse (list (cons '(sectionr "Section-type (long name)") (cons "Section type" YaTeX-mode-menu-map-section)) (cons '(section "Section-type region (long name)") (cons "Section type region (long name)" YaTeX-mode-menu-map-sectionr))))) ;; Make large-type commands menu --------------------------------------------- (defvar YaTeX-mode-menu-map-envr (make-sparse-keymap "Environment region")) (defvar YaTeX-mode-menu-map-env (make-sparse-keymap "Environment")) (let ((sorted-env (sort (mapcar (function (lambda (s) (car s))) (append env-table user-env-table)) 'string<))) (YaTeX-define-menu 'YaTeX-mode-menu-map-env (mapcar (function (lambda (envname) (cons (intern envname) (cons envname (list 'lambda () (list 'interactive) (list 'YaTeX-insert-begin-end envname nil)))))) sorted-env)) (YaTeX-define-menu 'YaTeX-mode-menu-map-envr (mapcar (function (lambda (envname) (cons (intern envname) (cons envname (list 'lambda () (list 'interactive) (list 'YaTeX-insert-begin-end envname t)))))) sorted-env))) (YaTeX-define-menu 'YaTeX-mode-menu-map (nreverse (list (cons '(envr "Environment") (cons "Environment" YaTeX-mode-menu-map-env)) (cons '(env "Environment region") (cons "Environment region" YaTeX-mode-menu-map-envr))))) (and (featurep 'xemacs) (add-hook 'yatex-mode-hook '(lambda () (or (assoc "YaTeX" current-menubar) (progn (set-buffer-menubar (copy-sequence current-menubar)) (add-submenu nil YaTeX-mode-menu-map)))))) ;; Other key bindings for window-system ;(YaTeX-define-key [?\C- ] 'YaTeX-do-completion) (define-key YaTeX-mode-map [?\M-\C- ] 'YaTeX-mark-environment) ;; Highlightening ;; メニューに比べてこっちは結構本気でやってます。 ;; だって文書構造がとっても分かり易いんだもん。 ;; みんなも hilit19.el を使おう! ;; とかいってるうちに hilit19 って obsolete になってしまった… ;; …ということで、hilit19 用のパターンを font-lock に変換する関数を ;; 作成してなんとか font-lock にも対応(2000年12月)。 ;; しかし、font-lock は仕様が変わりやすい雰囲気でずっと動き続けるか ;; どうかは不明。むしろ進化の止まったhilit19を使い続ける方が安心と ;; 言えないこともないが世の流れは読めず……。 ;; ;; さて、まずは対応する {} をピカピカ範囲とするような関数を作る。 ;; これは hilit-LaTeX.el を参考にした。でも、ちゃんと section 型コマンドの ;; 引数を数えて正しい位置までピカピカさせるよ〜ん! (defun YaTeX-19-region-section-type (pattern) "Return cons of starting and end point of section-type commands of PATTERN." (if (re-search-forward pattern nil t) (let ((m0 (match-beginning 0)) (e0 (match-end 0)) cmd (argc 1)) (setq cmd (substring (YaTeX-match-string 0) 1) argc (or (car (cdr (YaTeX-lookup-table cmd 'section))) argc)) (if (= argc 0) (cons m0 (point)) ;引数個数0ならマッチした領域 (skip-chars-forward " \n\t*") (while (looking-at "\\[") (forward-list 1)) ;optionならスキップ (skip-chars-forward " \n\t") (prog1 (if (looking-at "{") ;{}が始まるならちゃんとしたsection型 (cons m0 (condition-case err (progn ;;(skip-chars-backward "^{") (forward-char -2) (while (> argc 0) (skip-chars-forward "^{") (forward-list 1) (setq argc (1- argc))) (point)) (error m0))) ;{}でないならたぶん \verb 環境などにあるダミー (cons m0 e0)) ;;move to re-search end not to make font-lock confused (goto-char e0)))))) (defun YaTeX-19-region-large-type (pattern) "Return cons of large-type contents. Assumes PATTERN begins with `{'." (if (re-search-forward pattern nil t) (let ((m0 (match-beginning 0)) (e0 (match-end 0))p) (goto-char m0) (skip-chars-forward "^ \t\n") (skip-chars-forward " \t\n") (prog1 (cons (setq p (point)) (condition-case err (progn (goto-char m0) (forward-list 1) (1- (point))) (error (1+ p)))) ;;move to re-search end not to make font-lock confused (goto-char e0))))) (defun YaTeX-19-region-env-type (envptn) "Return cons of environment contents specified by ENVPTN as regexp." (if (and (looking-at envptn) ;;re-search-forward envptn nil t) (save-excursion (not(search-backward YaTeX-comment-prefix (point-beginning-of-line) t)))) (let ((m0 (match-beginning 0)) (e0 (match-end 0)) (env (YaTeX-match-string 1)) (nextline (progn (forward-line 1) (point)))) (goto-char m0) ;(message "max=%d" (point-max))(sit-for 2) (condition-case err (if (YaTeX-goto-corresponding-environment) (prog1 (cons nextline (match-beginning 0)) (goto-char e0))) (error nil))))) (defun YaTeX-19-region-paren-math (ptn) "Return cons of \(...\) or \[...\] type math environment." (if (looking-at "\\\\\\([\[(]\\)") (let*((ptype (cdr (assoc (YaTeX-match-string 1) '(("(" . ")") ("[" "]"))))) (b (match-beginning 0)) (e (match-end 0))) (condition-case err (if (re-search-forward (concat "[^\\]\\\\" (regexp-quote ptype)) nil t) (prog1 (cons b (match-beginning 0)) (goto-char e))) (error nil))))) (defun YaTeX-19-region-math-sub (ptn) "Return cons of _{...}" (if (and (looking-at ptn) (eq YaTeX-font-lock-formula-face (get-text-property (point) 'face))) (let ((e (match-end 0)) (p (point))) (goto-char e) (prog1 (condition-case () (if (looking-at "{") (cons (1+ (point)) (progn (forward-list 1) (1- (point)))) (cons e (cond ((looking-at (concat YaTeX-ec-regexp YaTeX-TeX-token-regexp)) (match-end 0)) ;; other case?? (t (1+ (point))))))) (goto-char e))))) ;; 些細なことだが % の前の文字もピカリとさせてしまうようで… >hilit19 ;; ↓この関数は下の hilit-set-mode-patterns の "[^\\]\\(%\\).*$" に ;; 依存している (defun YaTeX-19-region-comment (pattern) "Return list of comment start and end point." (if (re-search-forward pattern nil t) (cons (match-beginning 2) (match-end 0)))) ;; 2006/6/23 match only if it's in specified envrironment. (defun YaTeX-19-re-search-in-env (ptn_env) (catch 'done ;; For font-lock, this function should find it. (let (md r) (while (YaTeX-re-search-active-forward (car ptn_env) YaTeX-comment-prefix nil t) (setq md (match-data) r (string-match (cdr ptn_env) (or (YaTeX-inner-environment 'quick) ""))) (store-match-data md) (if r (setq r (cons (match-beginning 0) (match-end 0)))) (if (or YaTeX-use-hilit19 r) (throw 'done r)) (goto-char (match-end 0))) (throw 'done r)))) ;;(make-face 'tt) ;;(set-face-font 'tt "-schumacher-clean-medium-r-normal--*-*-*-*-*-*-*-*") ;;(hilit-translate 'tt "white") ;; font-lockの関数呼びパターンの場合は正規表現が行末までマッチすると ;; hilit候補対象外にされてしまうので1字手前で正規表現を止める (defvar YaTeX-hilit-patterns-alist '( ;; formulas (YaTeX-19-region-math-sub "[^\\]^" YaTeX-font-lock-math-sup-face overwrite) (YaTeX-19-region-math-sub "[^\\]_" YaTeX-font-lock-math-sub-face overwrite) (YaTeX-19-region-env-type "\\\\begin{\\(equation\\|eqnarray\\|displaymath\\|\\(x?x?\\|fl\\)align\\|multline\\|gather\\)" formula) ;(YaTeX-19-region-paren-math "\\\\" formula) ;;("[^\\]\\\\(" "\\\\)" formula) ; \( \) ;;("[^\\]\\\\\\[" "\\\\\\]" formula) ; \[ \] ;; comments (YaTeX-19-region-comment "\\([^\\]\\|^\\)\\(%\\).*$" comment) (YaTeX-19-region-section-type "\\\\footnote\\(mark\\|text\\)?\\>" keyword) ("\\\\[a-z]+box" 0 keyword) (YaTeX-19-region-section-type "\\\\\\(v\\|h\\)space\\>" keyword) ;; (re-)define new commands/environments/counters (YaTeX-19-region-section-type "\\\\\\(re\\)?new\\(environment\\|command\\|theorem\\|length\\|counter\\)\\>" defun) (YaTeX-19-region-section-type "\\\\textbf\\>" bold) ;; various declarations/definitions (YaTeX-19-region-section-type "\\\\\\(set\\|setto\\|addto\\)\\(length\\|width\\|counter\\)\\>" define) (YaTeX-19-region-section-type "\\\\\\(title\\|author\\|date\\|thanks\\)\\>" define) ("\\\\document\\(style\\|class\\)\\(\\[.*\\]\\)?{" "}" decl) ("\\\\\\(begin\\|end\\|nofiles\\|includeonly\\|usepackage\\(\\[.*\\]\\)?\\){" "}" decl) ("\\\\\\(raggedright\\|makeindex\\|makeglossary\\|maketitle\\)\\b" 0 decl) ("\\\\\\(pagestyle\\|thispagestyle\\|pagenumbering\\){" "}" decl) ("\\\\\\(normalsize\\|small\\|footnotesize\\|scriptsize\\|tiny\\|large\\|Large\\|LARGE\\|huge\\|Huge\\)\\b" 0 decl) ("\\\\\\(appendix\\|tableofcontents\\|listoffigures\\|listoftables\\)\\b" 0 decl) ("\\\\\\(bf\\|em\\|it\\|rm\\|sf\\|sl\\|ss\\|tt\\)\\b" 0 decl) ;; label-like things ;;this should be customized by YaTeX-item-regexp ("\\\\\\(sub\\)*item\\b\\(\\[[^]]*\\]\\)?" 0 label) (YaTeX-19-region-section-type "\\\\\\(caption\\|bibitem\\)\\(\\[[^]]*\\]\\)?\\>" label) ;; things that do some sort of cross-reference (YaTeX-19-region-section-type "\\\\\\(\\(no\\|possessive\\)?cite[a-z]*\\|[a-z]*ref\\|label\\|index\\|glossary\\)\\>" crossref) ;; things that bring in external files ("\\\\\\(include\\|input\\|bibliography\\(style\\)?\\){" "}" include) ;; ("\\\\begin{\\(eqn\\|equation\\|x?x?align\\|split\\|multline\\|gather\\)" ;; "\\\\end{\\(eqn\\|equation\\|x?x?align\\|split\\|multline\\|gather\\).*}" ;; formula) ("\\([^\\$]\\|^\\)\\($\\($[^$]*\\$\\|[^$]*\\)\\$\\)" 2 formula); '$...$' or '$$...$$' ;; "wysiwyg" emphasis -- these don't work on nested expressions (YaTeX-19-region-large-type "{\\\\\\(em\\|it\\|sl\\)" italic) (YaTeX-19-region-large-type "{\\\\bf" bold) ;;;(YaTeX-19-region-large-type "{\\\\tt" tt) ;;;("\\\\begin{verbatim" "\\\\end{verbatim" tt) ("``" "''" string) ("\\\\\\(new\\|clear\\(double\\)?\\)page\\>\\|\\\\\\(\\\\\\|cr\\)\\>" 0 delimiter) ;; re-search-in-env seems to make it slow down. 2007/2/11 ;;(YaTeX-19-re-search-in-env ;; ("&\\|\\\\hline" . "tabular\\|equation\\|eqn\\|array\\|align") delimiter) ;;(YaTeX-19-re-search-in-env ("\\\\[+-=><'`]" . "tabbing") delimiter) ("&\\|\\\\hline\\|\\\\[+-=><'`]" 0 delimiter) ) "*Hiliting pattern alist for LaTeX text.") ;;(defvar YaTeX-hilit-pattern-adjustment-default nil) ;; ↑いらなくなった。 (defvar YaTeX-hilit-pattern-adjustment-private nil "*Adjustment hilit-pattern-alist for default yatex-mode's pattern.") (defvar YaTeX-hilit-sectioning-face '(yellow/dodgerblue yellow/slateblue) "*Hilightening face for sectioning unit. '(FaceForLight FaceForDark)") (defvar YaTeX-hilit-sectioning-attenuation-rate '(15 40) "*Maximum attenuation rate of sectioning face. '(ForeRate BackRate) Each rate specifies how much portion of RGB value should be attenuated towards to lowest sectioning unit. Numbers should be written in percentage.") (defvar YaTeX-sectioning-patterns-alist nil "Hilightening patterns for sectioning units.") (defvar YaTeX-hilit-singlecmd-face '("slateblue2" . "aquamarine") "*Hilightening face for maketitle type. '(FaceForLight FaceForDark)") ;;; セクションコマンドを、構造レベルの高さに応じて色の濃度を変える ;;; 背景が黒でないと何が嬉しいのか分からないに違いない. ;;; もしかして白地の時は構造レベルに応じて色を明るくしたほうが良いのか? ;;; ...どうやらそうでもないらしい。これでいいみたい(2000/12)。 ;(if (fboundp 'win32-color-values) ; (fset 'x-color-values 'win32-color-values)) (defun YaTeX-19-create-face (sym fgcolor &optional bgcolor) "Create face named SYM with face of FGCOLOR/BGCOLOR." (cond ((and YaTeX-use-font-lock (fboundp 'defface)) (custom-declare-face sym (list (list (list '(class color) ;(list 'background YaTeX-background-mode) ) (delq nil (append (list ':foreground fgcolor) (if bgcolor (list ':background bgcolor)) )) ) (list t (list ':bold t ':underline t)) ) (format "Font lock face for %s" sym) ':group 'font-lock-faces) (set sym sym) sym) ((and YaTeX-use-hilit19 (and (fboundp 'hilit-translate))) (let ((face (intern (concat fgcolor "/" bgcolor)))) (if (facep sym) (hilit-translate sym face) (make-face sym) (or (memq sym hilit-predefined-face-list) (progn (set-face-foreground sym fgcolor) (set-face-background sym bgcolor) (setq hilit-predefined-face-list (cons sym hilit-predefined-face-list))))) face)))) (cond (YaTeX-use-highlighting (cond (window-system (let*((sectface (car (if (eq YaTeX-background-mode 'dark) (cdr YaTeX-hilit-sectioning-face) YaTeX-hilit-sectioning-face))) (sectcol (symbol-name sectface)) (fl YaTeX-use-font-lock) (form (if fl "#%02x%02x%02x" "hex-%02x%02x%02x")) sect-pat-alist) (if (string-match "/" sectcol) (let ((fmin (nth 0 YaTeX-hilit-sectioning-attenuation-rate)) (bmin (nth 1 YaTeX-hilit-sectioning-attenuation-rate)) colorvalue fR fG fB bR bG bB pat fg bg level from face list lm) (require 'yatexsec) (setq fg (substring sectcol 0 (string-match "/" sectcol)) bg (substring sectcol (1+ (string-match "/" sectcol))) colorvalue (x-color-values fg) fR (/ (nth 0 colorvalue) 256) fG (/ (nth 1 colorvalue) 256) fB (/ (nth 2 colorvalue) 256) colorvalue (x-color-values bg) bR (/ (nth 0 colorvalue) 256) bG (/ (nth 1 colorvalue) 256) bB (/ (nth 2 colorvalue) 256) lm YaTeX-sectioning-max-level list YaTeX-sectioning-level) (while list (setq pat (concat YaTeX-ec-regexp (car (car list)) ;;"\\*?\\(\\[[^]]*\\]\\)?\\>" ;改行はさむと駄目 "\\>" ) level (cdr (car list)) fg (format form (- fR (/ (* level fR fmin) lm 100)) (- fG (/ (* level fG fmin) lm 100)) (- fB (/ (* level fB fmin) lm 100))) bg (format form (- bR (/ (* level bR bmin) lm 100)) (- bG (/ (* level bG bmin) lm 100)) (- bB (/ (* level bB bmin) lm 100))) from (intern (format "YaTeX-sectioning-%d" level)) ;;face (intern (concat fg "/" bg)) ) (setq face (YaTeX-19-create-face from fg bg)) (setq sect-pat-alist (cons;;(list pat "}" face) (list 'YaTeX-19-region-section-type pat face) sect-pat-alist)) (setq list (cdr list))) (setq YaTeX-sectioning-patterns-alist sect-pat-alist))))) (t ;not window-system (setq YaTeX-sectioning-patterns-alist (list (list (concat YaTeX-ec-regexp "\\(\\(sub\\)*\\(section\\|paragraph\\)\\|chapter" "\\|part\\){[^}]*}") 0 'define))))))) ;; ローカルなマクロを読み込んだ後 redraw すると ;; ローカルマクロを keyword として光らせる(keywordじゃまずいかな…)。 (defvar hilit-patterns-alist nil) ;for absence of hilit19 (defun YaTeX-19-collect-macros () (cond (YaTeX-use-highlighting (let ((get-face (function (lambda (table) (cond ((eq YaTeX-background-mode 'light) (car table)) ((eq YaTeX-background-mode 'dark) (cdr table)) ;; Default case equals to 'light mode...is it OK? (t (car table)))))) sect single pattern-alist) (YaTeX-19-create-face ;;hilit-translate ;;sectioning (funcall get-face YaTeX-hilit-sectioning-face) 'macro (funcall get-face YaTeX-hilit-singlecmd-face)) (if (setq sect (append user-section-table tmp-section-table)) (setq sect (concat "\\\\\\(" (mapconcat (function (lambda (s) (regexp-quote (car s)))) sect "\\|") "\\)\\>"))) (if (setq single (append user-singlecmd-table tmp-singlecmd-table)) (setq single (concat "\\\\\\(" (mapconcat (function (lambda (s) (regexp-quote (car s)))) single "\\|") "\\)\\b"))) (cons 'yatex-mode (append (list nil) YaTeX-sectioning-patterns-alist YaTeX-hilit-pattern-adjustment-private ;;YaTeX-hilit-pattern-adjustment-default YaTeX-hilit-patterns-alist (delq nil (list (if sect (list 'YaTeX-19-region-section-type sect 'keyword)) (if single (list single 0 'macro)))))))))) ;;2006/6/23 new face, `delimiter' introduced (YaTeX-19-create-face 'delimiter "saddlebrown" "ivory") ;;(YaTeX-19-collect-macros) ;causes an error (defun YaTeX-hilit-setup-alist () (cond ((boundp 'hilit-patterns-alist) (setq hilit-patterns-alist (delq (assq 'yatex-mode hilit-patterns-alist) hilit-patterns-alist)) (if YaTeX-use-hilit19 (setq hilit-patterns-alist (cons (YaTeX-19-collect-macros) hilit-patterns-alist)))))) (defun YaTeX-hilit-recenter (arg) "Collect current local macro and hilit-recenter." (interactive "P") (YaTeX-hilit-setup-alist) (if (fboundp 'font-lock-mode) (font-lock-mode -1)) (hilit-recenter arg)) (let ((k (append (where-is-internal 'hilit-recenter) (where-is-internal 'recenter)))) (while k (define-key YaTeX-mode-map (car k) 'YaTeX-19-recenter) (setq k (cdr k)))) (defun YaTeX-19-recenter (&optional arg) (interactive "P") (if YaTeX-use-hilit19 (YaTeX-hilit-recenter arg) (YaTeX-font-lock-recenter arg))) (defun YaTeX-font-lock-recenter (&optional arg) (interactive "P") (cond ((and (boundp 'hilit-patterns-alist) (assq 'yatex-mode hilit-patterns-alist)) (if (fboundp 'hilit-unhighlight-region) (hilit-unhighlight-region (point-min) (point-max))) (setq hilit-patterns-alist ;ensure to remove (delq (assq 'yatex-mode hilit-patterns-alist) hilit-patterns-alist)))) (setq YaTeX-font-lock-keywords (YaTeX-convert-pattern-hilit2fontlock (cdr (YaTeX-19-collect-macros))) ;;; Keep this section for debugging. ;; YaTeX-font-lock-keywords ;; (append (YaTeX-convert-pattern-hilit2fontlock ;; (cdr (YaTeX-19-collect-macros))) ;; '(((lambda (lim) ;; (YaTeX-19-re-search-in-env '("foo" . "tabular")) ;; ;(search-forward "foo" nil t) ;; ) ;; (0 YaTeX-font-lock-delimiter-face)))) ;;font-lock-keywords nil font-lock-set-defaults nil) ;;(save-excursion ;; (font-lock-fontify-region (window-start) (window-end)) (font-lock-mode -1) ;is stupid, but sure. (font-lock-mode 1) (recenter arg)) (defun YaTeX-font-lock-fontify-region (beg end) (interactive "r") (save-excursion (font-lock-fontify-region beg end))) (defun YaTeX-font-lock-fontify-environment () (interactive) (save-excursion (save-match-data ;is safe after emacs-19 (YaTeX-mark-environment) (message "") (YaTeX-font-lock-fontify-region (region-beginning) (region-end))))) (defun YaTeX-font-lock-highlight-menu () (interactive) (message "Force Highlight: R)egion E)nvironment") (let ((c (read-char))) (cond ((memq c '(?R ?r)) (YaTeX-font-lock-fontify-region (region-beginning) (region-end))) ((memq c '(?e ?e)) (YaTeX-font-lock-fontify-environment))))) (if YaTeX-use-font-lock (YaTeX-define-key "u" 'YaTeX-font-lock-highlight-menu)) (defvar YaTeX-font-lock-keywords nil "Pattern-face alist of yahtml-mode for font-lock") (defun YaTeX-font-lock-set-default-keywords () (put 'yatex-mode 'font-lock-defaults (list 'YaTeX-font-lock-keywords nil nil)) (setq YaTeX-font-lock-keywords (YaTeX-convert-pattern-hilit2fontlock (cons nil (append YaTeX-sectioning-patterns-alist YaTeX-hilit-pattern-adjustment-private YaTeX-hilit-patterns-alist))))) (if YaTeX-use-font-lock (progn (if (and (boundp 'hilit-mode-enable-list) hilit-mode-enable-list) ;;for those who use both hilit19 and font-lock (if (eq (car hilit-mode-enable-list) 'not) (or (member 'yatex-mode hilit-mode-enable-list) (nconc hilit-mode-enable-list (list 'yatex-mode))) (setq hilit-mode-enable-list (delq 'yatex-mode hilit-mode-enable-list)))) (YaTeX-font-lock-set-default-keywords))) (defun YaTeX-switch-to-new-window () (let ((c 0) (i 1) (free (make-string win:max-configs ? ))) (while (< i win:max-configs) (or (aref win:configs i) (aset free i (+ i win:base-key))) (setq i (1+ i))) (while (not (string-match (char-to-string c) free)) (message "Which window to create? [%s]: " free) (setq c (read-char))) (message "Creating window [%c]" c) (set-buffer (get-buffer-create "*scratch*")) (win:switch-window (- c win:base-key)))) (defun YaTeX-visit-main-other-frame () "Visit main file in other frame. WARNING, This code is not perfect." (interactive) (if (YaTeX-main-file-p) (message "I think this is main LaTeX source.") (let (parent) (save-excursion (YaTeX-visit-main t) (setq parent (current-buffer))) (cond ((get-buffer-window parent t) (goto-buffer-window parent)) ((and (featurep 'windows) win:use-frame) (YaTeX-switch-to-new-window) (switch-to-buffer parent)) (t (switch-to-buffer-other-frame (buffer-name parent))))))) (defun YaTeX-goto-corresponding-*-other-frame (arg) "Go to corresponding object in other frame." (interactive "P") (let (b p) (save-window-excursion (save-excursion (YaTeX-goto-corresponding-* arg) (setq b (current-buffer) p (point)))) (cond ((get-buffer-window b t) (goto-buffer-window b) (goto-char p)) ((and (featurep 'windows) win:use-frame) (YaTeX-switch-to-new-window) (switch-to-buffer b) (goto-char p)) (t (switch-to-buffer-other-frame (buffer-name b)) (goto-char p))))) ;;; reverseVideo にして hilit-background-mode を 'dark ;;; にしている人は数式などが暗くなりすぎて見づらいかもしれない。 ;;; 次のコードを hilit19 をロードしている場所の直後に置くとちょっ ;;; とはまし。 ;;; (if (eq hilit-background-mode 'dark) ;;; (hilit-translate ;;; string 'mediumspringgreen ;;; formula 'khaki ;;; label 'yellow-underlined)) (and YaTeX-emacs-19 (not (featurep 'xemacs)) (boundp 'byte-compile-current-file) byte-compile-current-file (progn (if YaTeX-emacs-20 (require 'font-lock)) (if (and (boundp 'window-system) window-system) (require 'hilit19) (error "Byte compile this file on window system! Not `-nw'!")))) (provide 'yatex19) ; Local variables: ; fill-prefix: ";;; " ; paragraph-start: "^$\\| \\|;;;$" ; paragraph-separate: "^$\\| \\|;;;$" ; coding: sjis ; End: