diff --git a/docs/qanda.eng b/docs/qanda.eng index 86c7f0d..ea16bf2 100644 --- a/docs/qanda.eng +++ b/docs/qanda.eng @@ -52,9 +52,11 @@ ============ *I accidentally learned in a wrong LaTeX command. - There should be a line with the wrong command in the .yatexrc - file in you home or current directory. Erase that line, do M-x - eval-current-buffer and save the results with C-x C-s. + 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. @@ -294,6 +296,16 @@ yatexhks.el will be read in at the end of YaTeX's initialization, so you can overwrite definitions in yatexadd.el. +*Can I make intelligent newline work for my `mylist' environment? + + Yes. See the section `Intelligent newline' in the info manual. + But if you want the same as the intelligent newline for itemize + environment which inserts simply `\item', the following code is + efficient. + + (fset 'YaTeX-intelligent-newline-mylist + 'YaTeX-intelligent-newline-itemize) + [ETC] ===== *Mailing lists? @@ -315,6 +327,16 @@ 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 YaTeX? + + If you can access WWW, try to see; + http://www.comp.ae.keio.ac.jp/~yuuji/yatex/ + And if you trace the link of `yatex-current', you can get the + really latest version of YaTeX. 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. diff --git a/docs/yatex.ref b/docs/yatex.ref index ee681b7..c2871b4 100644 --- a/docs/yatex.ref +++ b/docs/yatex.ref @@ -51,6 +51,7 @@ ���v�����g�A�E�g [prefix] tl ���v�����g�A�E�g(�S�y�[�W) C-u [prefix] tl ���v���r���[�A�N�� [prefix] tp + ��xdvi��ŕ�����T�[�` [prefix] ts ���� ��lpq�N�� [prefix] tq ��jlatex�N��(�̈�w��) [prefix] tr @@ -58,6 +59,7 @@ �͊o���Ȃ��č\���܂���B ���́AMS-DOS �ł͖����ł��B + �����́A-remote �@�\�t���� xdvi �ł̂ݗL���ł��B [prefix] tr �̗̈�w��́A�������́A %#BEGIN �Ə����Ă���s�� ��A%#END �Ə����Ă���s�܂łł��B%#END ���ȗ�����ƁA%#BEGIN�� diff --git a/docs/yatexe.tex b/docs/yatexe.tex index 3a841c4..1506780 100644 --- a/docs/yatexe.tex +++ b/docs/yatexe.tex @@ -25,7 +25,7 @@ @cindex YaTeX @menu -* What is YaTeX?:: Introduction +* What is YaTeX?:: * Main features:: What YaTeX can do * Installation:: Guide to install * Typesetting:: Call typesetting processes @@ -48,6 +48,12 @@ --- The Detailed Node Listing --- +Typesetting + +* Calling typesetter:: +* Calling previewer:: +* Printing out:: + %# notation * Changing typesetter:: @@ -91,12 +97,12 @@ Procedure -* How the add-in function works?:: +* How the add-in function works:: * How the function is called:: * Useful functions for creating add-in:: * Contribution:: -How the add-in function works? +How the add-in function works * Defining `option add-in':: * Defining `argument add-in':: @@ -138,7 +144,7 @@ @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 /})(English help is not yet supported) + (@kbd{C-c ?}, @kbd{C-c /}) @item Document files hierarchy browser (@kbd{C-c d}) @end itemize @@ -189,25 +195,37 @@ strokes execute typeset or preview command. @table @kbd -@item [prefix] tj +@item [prefix] t j @dots{} invoke latex -@item [prefix] tr +@item [prefix] t r @dots{} invoke latex on region -@item [prefix] tk +@item [prefix] t k @dots{} kill current typesetting process -@item [prefix] tb +@item [prefix] t b @dots{} invoke bibtex -@item [prefix] tp +@item [prefix] t p @dots{} preview -@item [prefix] tl +@item [prefix] t l @dots{} lpr dvi-file +@item [prefix] t s + @dots{} search current string on xdvi-remote @end table - 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 +@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 @@ -233,8 +251,23 @@ file if you edit one file, and is the same as main file's if you edit splitting files. - YaTeX asks you the range of dvi-printing by default. You can -skip this by invoking it with universal-argument as follows: +@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. You can get xdvi with `-remote feature' from; +@code{ftp://ftp.ae.keio.ac.jp/pub/text/xdvi/xdvi-remote}. + +@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 @@ -519,6 +552,10 @@ 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 @@ -660,6 +697,38 @@ 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$B!A(B6 + @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 @@ -849,8 +918,8 @@ 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 v.s. Greek letters. +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 @@ -1114,7 +1183,7 @@ ~(cursor) @end example -@node Filling, Updation of @code{\includeonly}, Changing and Deleting, Top +@node Filling, Updation of includeonly, Changing and Deleting, Top @comment node-name, next, previous, up @chapter Filling @cindex filling @@ -1125,8 +1194,12 @@ 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 [prefix] i +@item M-q @dots{} fill item @end table @@ -1139,7 +1212,7 @@ @lisp (setq YaTeX-item-regexp - "\\(\\\\item\\)\\|\\(\\\\underlineitem\\)") + "\\(\\\\\\(sub\\)*item\\)\\|\\(\\\\underlineitem\\)") @end lisp @cindex YaTeX-item-regexp @@ -1147,22 +1220,17 @@ for Emacs-Lisp, name a newcommand for `itemize' beginning with @code{\item} such as @code{\itembf}, not @code{\bfitem}. - This function -- YaTeX-fill-item -- reformats the @code{\item} into -`hang-indented' style. When you separate the topic word and its -description, use @kbd{M-q} instead. For example: + This function reformats the @code{\item} into `hang-indented' style. +For example: @example -Hang indentation: +itemize, enumerate environment: > >\item[foo] `foo' is the typical word for describing an > arbitrarily written.... - -Normal indentation: - > - > \item bar - > - > When the word `for' is used as an arbitrarily word, `bar' - > is bound to follow it. +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 @@ -1214,7 +1282,7 @@ by the current file, and type @kbd{%} to comment out the @code{\includeonly} line. -@node What column?, Intelligent newline, Updation of @code{\includeonly}, Top +@node What column?, Intelligent newline, Updation of includeonly, Top @comment node-name, next, previous, up @chapter What column? @cindex what column @@ -1259,7 +1327,8 @@ @cindex ESC RET @cindex M-C-m - In tabular[*], array, itemize, enumerate or tabbing environment, + At the end of begin-type completion of tabular[*], array, itemize, +enumerate or tabbing environment, or typing @table @kbd @item ESC RET @@ -1267,11 +1336,12 @@ @end table @noindent -inserts the contents corresponding to the current environment in the next -line. 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 v.s. environments. +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} @@ -1505,11 +1575,6 @@ Fill-prefix used in yatex-mode (@code{nil}) @end defvar -@defvar YaTeX-open-lines - Number of blank lines between cursor and @code{\begin@{@}}, - @code{\@code{end}@{@}} (0) -@end defvar - @defvar YaTeX-user-completion-table Name of user dictionary where learned completion table will be stored. (@code{"~/.yatexrc"}) @@ -1688,6 +1753,9 @@ See also $B!#(B@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 @node Sample definitions, Hook variables, All customizable variables, Lisp variables @comment node-name, next, previous, up @@ -1731,7 +1799,7 @@ @subsection Hook file @cindex hook file - You can stuff all of YaTeX relating expressions into a file named + 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. @@ -1766,15 +1834,15 @@ @end enumerate @menu -* How the add-in function works?:: +* 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 +@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? +@subsection How the add-in function works There are two kinds of add-in. @dfn{Option add-in} returns the La@TeX{}'s optional parameters such as optional strings after @@ -1814,7 +1882,7 @@ * Defining `argument 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? +@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' @@ -1841,7 +1909,7 @@ (concat "{" (read-string "Rule: ") "}")) @end lisp -@node Defining `argument add-in', , Defining `option add-in', How the add-in function works? +@node Defining `argument add-in', , Defining `option add-in', How the add-in function works @comment node-name, next, previous, up @subsubsection Defining `argument add-in' @@ -1864,7 +1932,7 @@ Note that when the `argument add-in' function return `nil', normal argument reader will be called. -@node How the function is called, Useful functions for creating add-in, How the add-in function works?, Add-in functions +@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 diff --git a/docs/yatexj.tex b/docs/yatexj.tex index f296c8f..a6a3e1d 100644 --- a/docs/yatexj.tex +++ b/docs/yatexj.tex @@ -38,6 +38,7 @@ * Intelligent newline:: ���܂������s * Changing mode of YaTeX:: �쒹���샂�[�h�ύX * Online help:: LaTeX�I�����C���w���v +* Inclusion hierarchy browser:: �t�@�C�������K�w�\���̕\�� * Cooperation with other packages:: ���p�b�P�[�W�Ƃ̘A�g * Customizations:: �J�X�^�}�C�Y * Etc:: ���̑� @@ -49,6 +50,7 @@ latex�R�}���h�N�� * Calling typesetter:: �^�C�v�Z�b�^�N�� +* Calling previewer:: �v�������[�A�N�� * Print out:: �v�����g�A�E�g�p�R�}���h�̋N�� %#�L�@ @@ -74,7 +76,7 @@ section�^�⊮ * 2�ˆȏ�̈������Ƃ� section�^�R�}���h:: -* Enclose region-type command:: +* Enclose section-type command:: ����⊮ * Recursive completion:: �ċA�⊮ * view-sectioning:: �Z�N�V������؂�̃A�E�g���C���\�� @@ -267,10 +269,13 @@ @dots{} �v�������[�A�N�� @item [prefix] t l @dots{} lpr(�v�����g�A�E�g�p)�R�}���h�N�� +@item [prefix] t s + @dots{} xdvi -remote �ł̃T�[�` @end table @menu * Calling typesetter:: �^�C�v�Z�b�^�N�� +* Calling previewer:: �v�������[�A�N�� * Print out:: �v�����g�A�E�g�p�R�}���h�̋N�� @end menu @@ -313,6 +318,17 @@ ���C���t�@�C���̂���f�B���N�g����@file{texput.tex}�Ƃ����Վ��t�@�C���ɏo �͂���܂��̂ŁA�㏑���ɂ͒��ӂ��Ă��������B +@node Calling previewer, Print out, Calling typesetter, Invocation +@comment node-name, next, previous, up +@section �v�������[�A�N�� + @kbd{[prefix] t p} �ɂ��v�������[�A�̋N�����ł��܂��B����ɁA�������� +�����A-remote �@�\�‚���xdvi�𗘗p���Ă���ꍇ�� @kbd{[prefix] t s} ������ +���Ƃɂ��J�[�\���ʒu�̕�������������Ă��̃y�[�W��\������悤�ɂ��łɋN +������xdvi�ɖ��߂𑗂�܂��B����ɂ��A���ݕҏW���̉ӏ��̃^�C�v�Z�b�g���� +�𑦍��Ɍ��邱�Ƃ��ł��܂��B�Ȃ��A-remote �@�\�t���� xdvi �� +@code{ftp://ftp.ae.keio.ac.jp/pub/text/xdvi/xdvi-remote} +�Ȃǂ�����肷�邱�Ƃ��ł��܂��B + @node Print out, , Calling typesetter, Invocation @comment node-name, next, previous, up @section �v�����g�A�E�g @@ -635,6 +651,10 @@ ���͂̎�Ԃ��Ȃ��܂��B�����e�[�u���ɑ��݂��Ȃ��‹�������͂������̓��[�U�� �p�̃e�[�u���ɓo�^����A����ɂ��̃e�[�u���������I�ɁA���[�U����(�f�t�H�� �g�ł� @file{~/.yatexrc})�ɕۑ����܂��B + +����ɁA����̊‹���⊮���͂������ɂ͂��̊‹��ŕK���p������G���g������ +���}�����܂�(��: @code{itemize}�‹��ɂ�����@code{\item}�Ȃ�)�B�}�����ꂽ�G +���g�����s�v�ȏꍇ�ɂ�undo�ɂ���ď������ĉ������B @cindex ���[�U����[�䂤��������] @subsection ���ɏ������e�L�X�g���‹��Ŋ��� @@ -727,12 +747,12 @@ @menu * 2�ˆȏ�̈������Ƃ� section�^�R�}���h:: -* Enclose region-type command:: +* Enclose section-type command:: ����⊮ * Recursive completion:: �ċA�⊮ * view-sectioning:: �Z�N�V������؂�̃A�E�g���C���\�� @end menu -@node 2�ˆȏ�̈������Ƃ� section�^�R�}���h, Enclose region-type command, section�^�⊮, section�^�⊮ +@node 2�ˆȏ�̈������Ƃ� section�^�R�}���h, Recursive completion, section�^�⊮, section�^�⊮ @comment node-name, next, previous, up @subsection 2�ˆȏ�̈������Ƃ� section�^�R�}���h @cindex ����[�Ђ�����] @@ -766,15 +786,14 @@ @cindex �����̌���ς���[�Ђ������̂�������������] -@node Enclose region-type command, Recursive completion, 2�ˆȏ�̈������Ƃ� section�^�R�}���h, section�^�⊮ -@comment node-name, next, previous, up +@node Enclose section-type command, Recursive completion, 2�ˆȏ�̈������Ƃ� section�^�R�}���h, section�^�⊮ @subsection ���ɏ������e�L�X�g������ @cindex ����[������] �܂��A�N���R�}���h��@kbd{s}��啶���ɕς��ċN������ƁA���炩���ߏ� �������͂� section �^�R�}���h�̑������Ƃ��Ċ���܂��B -@node Recursive completion, view-sectioning, Enclose region-type command, section�^�⊮ +@node Recursive completion, view-sectioning, 2�ˆȏ�̈������Ƃ� section�^�R�}���h, section�^�⊮ @comment node-name, next, previous, up @subsection �ċA�⊮ @cindex �ċA�⊮[�������ق���] @@ -790,14 +809,46 @@ @cindex �A�E�g���C��[�����Ƃ炢��] �ʏ��section�^�⊮�̎��Ƀ~�j�o�b�t�@��@kbd{C-v}�������ƌ��ݑ��݂���Z�N -�V������؂�R�}���h�S�Ă��ꗗ�\�����܂�(�u<<--�v�̂‚��Ă���s�������Ƃ� -�߂��Z�N�V������؂�)�B���̎��~�j�o�b�t�@��@kbd{C-p}, @kbd{C-n} �������� -@samp{part}, @samp{chapter}, ..., @samp{subparagraph} �̃R�}���h���_���K�w -�̍����ɂ��������ď㉺���܂��B�܂��A@kbd{C-v}, @kbd{M-v} �������ƃZ�N�V�� -����؂�ꗗ�o�b�t�@���X�N���[�����A������@kbd{0}�`@kbd{7}�������Ƃ��鍂�� -�ȏ�̃Z�N�V������؂肾����I��ŕ\�����܂�(���ۂɂ���Č���Ε�����܂�)�B -���̈ꗗ�o�b�t�@�ɃJ�[�\�����ڂ��X�y�[�X�������ƁA�Y������Z�N�V������؂� -�̂���{�����̏ꏊ�ɃW�����v���܂��B +�V������؂�R�}���h�S�Ă� @code{*Sectioning Lines*}�Ƃ����o�b�t�@�Ɉꗗ�\ +�����܂�(�u<<--�v�̂‚��Ă���s�������Ƃ��߂��Z�N�V������؂�)�B���̎��~�j +�o�b�t�@��@kbd{C-p}, @kbd{C-n} ��������@samp{part}, @samp{chapter}, ..., +@samp{subparagraph} �̃R�}���h���_���K�w�̍����ɂ��������ď㉺���܂��B�܂��A +@kbd{C-v}, @kbd{M-v} �������ƃZ�N�V������؂�ꗗ�o�b�t�@���X�N���[�����A +������@kbd{0}�`@kbd{7}�������Ƃ��鍂���ȏ�̃Z�N�V������؂肾����I��ŕ\ +�����܂�(���ۂɂ���Č���Ε�����܂�)�B + +@code{*Sectioning Lines*}�o�b�t�@�́A +@table @kbd +@item M-x YaTeX-section-overview + @dots{} �Z�N�V������؂�ꗗ�o�b�t�@�𐶐� +@end table +@cindex �Z�N�V������؂�ꗗ�o�b�t�@[��������񂭂��肢�����͂‚�] +�ō쐬���邱�Ƃ��ł��܂��B���̃o�b�t�@����I�����C�ӂ̍s�ŃX�y�[�X�������ƁA +�Y������Z�N�V������؂�̂���{�����̏ꏊ�ɃW�����v���܂��B����ɁA���o�b +�t�@�� @kbd{u} �������ƁA�\�[�X�e�L�X�g�̑Ή�����Z�N�V�����R�}���h����K +�w�オ��(��: subsection �� section �ɕς��)�A@kbd{d}�������ƈ�K�w������ +�܂��B@code{*Sectioning Lines*}�o�b�t�@�ɂ���Z�N�V������؂�̍s���}�[�N +���Ă�����@kbd{U}�������ƃ��W�������̂��̂ɑΉ�����\�[�X�e�L�X�g�̃Z�N�V�� +���R�}���h���ׂĂ���K�w�オ��A@kbd{D}�������Ɖ�����܂��B�Z�N�V������� +��ꗗ�o�b�t�@�ŗ��p�ł���L�[�R�}���h�ɂ͈ȉ��̂��̂�����܂��B + +@table @kbd +@item SPC + @dots{} �Ή�����\�[�X�s�փW�����v +@item . + @dots{} �Ή�����\�[�X�s��\�� +@item u + @dots{} �J�[�\���ʒu�ɑΉ�����Z�N�V�����R�}���h����K�w�グ�� +@item d + @dots{} �J�[�\���ʒu�ɑΉ�����Z�N�V�����R�}���h����K�w������ +@item U + @dots{} �}�[�N�����Z�N�V�����R�}���h����K�w�グ�� +@item D + @dots{} �}�[�N�����Z�N�V�����R�}���h����K�w�グ�� +@item 0�`6 + @dots{} ���x�� n �ȉ��̃Z�N�V�����R�}���h���B���ĕ\�� +@end table + @cindex �_���K�w[���肩������] @cindex �Z�N�V������؂�[��������񂭂���] @cindex �W�����v[������] @@ -1305,16 +1356,21 @@ itemize �‹����ɂ���@code{\item}�̍���(����)�������s�ɓn��ꍇ�ɁA�� �ڂ̐擪���������������ꍇ�ɂ́A +@c @table @kbd +@c @item [prefix] i +@c @dots{} item�̌����� +@c @end table + @table @kbd -@item [prefix] i - @dots{} item�̌����� +@item M-q + @dots{} ������ @end table @cindex NTT-jTeX[���ʂĂ����Ă����������Â�] @noindent -�ɂ���āA���� item �̃C���f���g�̐[���ɉ����� fill ����܂��B�Ȃ��ANTT -jTeX ���g�p���Ă���ꍇ�ɂ́ALisp �ϐ�@code{NTT-jTeX}��@code{t}�ɃZ�b�g�� -�ĉ������B +�ɂ���āA���� item �̃C���f���g�̐[���ɉ����� fill ����܂��B�Ȃ��A�Â� +NTT jTeX ���g�p���Ă���ꍇ�ɂ́ALisp �ϐ�@code{NTT-jTeX}��@code{t}�ɃZ�b +�g���ĉ������B @cindex YaTeX-item-regexp ���̂Ƃ��A�ϐ�@code{YaTeX-item-regexp}�̒l(�W���ł� @code{"\\\\item"})�� @@ -1324,44 +1380,37 @@ @lisp (setq YaTeX-item-regexp - "\\(\\\\item\\)\\|\\(\\\\underlineitem\\)") + "\\(\\\\\\(sub\\)*item\\)\\|\\(\\\\underlineitem\\)") @end lisp @noindent ���̕ϐ��̎w��̎d�����悭������Ȃ��ꍇ�́A�Ǝ��̍��ڗ񋓃R�}���h�̖��O�� @code{@code{"\item"}�Ŏn�܂���̂ɂ��ĉ�����(�Ⴆ��"\itembf"})�B - @kbd{[prefix] i} �ł�@code{\item} ���u�n���O�C���f���g�v�ɐ��`���܂��B�� -��@code{\item}�Ƃ��̐����p�p���O���t��؂藣�����͒ʏ�� -@kbd{M-q}(���̃��[�h�ł�fill-paragraph�����蓖�Ă��Ă���)���g���Ă����� -���B(�‚܂�ȉ��̂悤�ȏꍇ:) +�쒹�� @kbd{M-q} �ł� @code{\item} ���‹��ɉ����Ĉȉ��̂悤�Ɂu�n���O�C�� +�f���g�v���܂��B @example -�n���O�C���f���g: +itemize, enumerate�‹�: >\item[�ق��ق�] �p��ł́A���ɈӖ��̂Ȃ��P��� `foo' �ł���킵�� > �����A����̓��{��łƂ�������P�ꂪ�u�ق��ق��v > �ł��B -�ʏ�C���f���g: - > \item �ւ�ւ� - > - > �u�ق��ق��v���ł���߂��P��Ƃ��Ďg�������ɁA��2�̂ł��� - > �߂ȒP��Ƃ��āu�ւ�ւ�v���g���邱�Ƃ������悤�ł��B +description�‹�: + > \item[�ւ�ւ�] �u�ق��ق��v���ł���߂��P��Ƃ��Ďg�������ɁA�� + > 2�̂ł���߂ȒP��Ƃ��āu�ւ�ւ�v���g���邱�Ƃ��� + > ���悤�ł��B @end example - ��̒ʏ�C���f���g�̏ꍇ�A�����p���O���t�̃C���f���g�� \item �̌��o���� -�����[���Ƃ���K�v������܂��B�������A@kbd{M-q}���s�̍ŏ��̔�󔒕����̈� -�u�ʼn������Ƃɂ��[����ς��邱�Ƃ��ł��܂�(��q)�B - @section �p���O���t�̌����� @cindex �p���O���t�̌�����[�͂炭��ӂ̂������낦] @cindex M-q - �p���O���t�̌�����(fill)�́A��{�I�ɒʏ�ʂ�@�\���܂����Averbatim�‹���A -tabular�‹��Ȃnj�����������ƔߎS�ȏ󋵂ɂȂ�悤�Ȋ‹����ł͋@�\���܂���B -�܂��A\verb �Ŋ����Ă�����̂͌����čs��������܂���(�ϐ� -@code{YaTeX-verb-regexp} �Ő���) )�B����ɁA�ꎞ�I�ɃC���f���g�̐[����ς� -�Ă���ӏ��ł́A���̃C���f���g�̐擪��@kbd{M-q}���������Ƃɂ�� -fill-prefix �����������ύX���Ȃ��Č��������ł��܂��B + itemize�‹��ȊO�ł̃p���O���t�̌�����(fill)�́A��{�I�ɑ��̃��[�h�Ɠ��� +�悤�ɋ@�\���܂����Averbatim�‹���Atabular�‹��Ȃnj�����������ƔߎS�ȏ� +���ɂȂ�悤�Ȋ‹����ł͋@�\���܂���B�܂��A\verb �Ŋ����Ă�����̂͌����� +�s��������܂���(�ϐ� @code{YaTeX-verb-regexp} �Ő���) )�B����ɁA�ꎞ�I�� +�C���f���g�̐[����ς��Ă���ӏ��ł́A���̃C���f���g�̐擪��@kbd{M-q}���� +�����Ƃɂ�� fill-prefix �����������ύX���Ȃ��Č��������ł��܂��B @node Includeonly, What column, Filling, Top @@ -1443,7 +1492,8 @@ @cindex &����[&�ɂイ��傭] @cindex prefix & - tabular[*], array, itemize, enumerate, tabbing �‹��� + tabular[*], array, itemize, enumerate, tabbing �‹���begin�^�⊮�œ��͂� +�����A�܂��͊e�‹����� @table @kbd @item ESC RET @@ -1451,10 +1501,11 @@ @end table @noindent -�������ƁA���̊‹��ɉ������s�G���g�������̍s�ɑ}�����܂��B�Ⴆ�΁Atabular -�‹��ł́A���̊‹��̃J�������ɑΉ��������� @code{&} �ɉ����A�s���� -@code{\\} �����܂��B���̎�����ȑO�� @code{\hline} ������΂�����t���� -���܂��B�‹��Ƃ���ɉ����Ď������͂�����̂̑Ή��͈ȉ��̂悤�ɂȂ�܂��B +�������ƁA���̊‹��ɉ������s�G���g�������̍s�ɑ}�����܂�(begin�^�⊮���Ɏ� +���}�����ꂽ�G���g�����s�v�ȏꍇ�� undo �ɂ���ď����ł��܂�)�B�Ⴆ�΁A +tabular�‹��ł́A���̊‹��̃J�������ɑΉ��������� @code{&} �ɉ����A�s�� +�� @code{\\} �����܂��B���̎�����ȑO�� @code{\hline} ������΂�����t�� +�����܂��B�‹��Ƃ���ɉ����Ď������͂�����̂̑Ή��͈ȉ��̂悤�ɂȂ�܂��B @itemize @item @code{tabular}, @code{tabular*}, @code{array} @@ -1478,8 +1529,8 @@ ���܂��B��`�����֐��́A���݂̍s�ɉ��s��}����������̍s���̈ʒu�ŌĂ΂�� ���B�֐� @code{YaTeX-indent-line} ���ĂԂƌ��݂̊‹��̃l�X�g�ɉ������[���� �C���f���g�����̂ŁA������Ă�ł��牽����}������悤�ȃR�[�h�������Ƃ� -���ł��傤�B�֐� @code{YaTeX-intelligent-newline-itemize} �̒�`�Ȃǂ��Q�l -�ɂ��Ă��������B +���ł��傤�B@file{yatexenv.el}���̊֐� +@code{YaTeX-intelligent-newline-itemize} �̒�`�Ȃǂ��Q�l�ɂ��Ă��������B @node Changing mode of YaTeX, Online help, Intelligent newline, Top @comment node-name, next, previous, up @@ -1705,10 +1756,6 @@ �{�����������̍s���ɑ}������ړ������Ȃ킿 fill-prefix (@code{""(nil)}) @end defvar -@defvar YaTeX-open-lines -\begin{�‹�}��\end{�‹�}�̂������̋󔒍s�� (0) -@end defvar - @defvar YaTeX-user-completion-table �w�K����La@TeX{}�R�}���h�ۑ��t�@�C����(@code{"~/.yatexrc"}) @end defvar @@ -1893,6 +1940,10 @@ �̍��Q�ƁB @end defvar +@defvar YaTeX-use-AMS-LaTeX +AMS-LaTeX ���g�p����ꍇ�� @code{t} �ɐݒ肷��(@code{nil})�B +@end defvar + @node Sample definitions, Hook variables, All customizable variables, Lisp variables @comment node-name, next, previous, up @subsection �J�X�^�}�C�Y�ϐ��ݒ�� diff --git a/help/YATEXHLP.jp b/help/YATEXHLP.jp index 0ab4c06..bc62b26 100644 --- a/help/YATEXHLP.jp +++ b/help/YATEXHLP.jp @@ -652,6 +652,7 @@ description \begin{description} \item[���o���P��] ���� ... \end{description} [���o���P��]�����o���Ƃ��� + subitem \subitem ���� @@ -1199,20 +1200,44 @@ ��i�g�݃y�[�W�łԂ������^�C�g�����쐬���鎞�ɗp����Ƃ悢�B LaiTeX -a Little Assistant Interface for TeX +a Little Assistant Interface for TeX on Vz �����炭���Ȃ����� Vz ��Ŏg���Ă��邱�̃��[�h�B LaTeX�������I�Ɏg�����߂̑����̋@�\�𐷂荞��ł��܂��B �y�����ɂ‚��āz - laitex.def�Ȃǃv���O�������w�����́u�炢�Ă����v�A�V�X�e�����w�����́u�� �����傤�v�Ɠǂ݂܂��B �y�⑫�z �u�����v�̋����������́u�炢�Ă��v�������ł��B +�y�ӎ��z +�ȉ��̕��X�̌䋦�͂𒸂��܂����B�����Ɋ��Ӑ\���グ�܂��B + +(���s��/��\���ڂ̂�) +���c��炳��(�}�c�_) + �]�ڂ��s���Ē����܂����B + +�k�ݗ��j����(�L���Z�p�Ȋw��) +���э��u����(�L����) +�ە�P�삳��(�����ّ�) +�������񂳂�(�É���) +���є�����(����H�Ƒ�) +��c�ꐶ����(niftyserve) +�R�ے��V����(niftyserve) +����m����(niftyserve) + �o�O�̎w�E��A�v�]�A��܂��̃��[���𒸂��܂����B + (�܂Ƃ߂Ăł��߂�Ȃ��� -- �j��) + +�ēc�݂䂫����(���s�\�t�g�E�F�A���T�[�`) + Software Design ���Ŗ{�\�t�g�����Љ�������܂����B + +�o�b�L�["�Ń��b�R"�g�~�U������(�}�g��) + �����ׂ̈Ƀm�[�g�p�\�R���𖳏��őݗ^���ĉ������܂����B + �ނ̂������ŁA�����͂͂΂������Ƃ��o���܂����B + laitex -a Little Assistant Interface for TeX +a Little Assistant Interface for TeX on Vz YaTeX @@ -1227,7 +1252,7 @@ �y�ӎ��z �ȉ��̕��X�̌䋦�͂𒸂��܂����B�����Ɋ��Ӑ\���グ�܂��B -(���s��) +(���s��/��\���ڂ̂�) ���P������(��B��) Bibtex�N���Atypeset process �� kill�A�G���[�ӏ��̐��������� �̗v�]���̑��𒸂��܂����B @@ -1258,9 +1283,11 @@ ��˂�������(asciinet) �肢�t�������ł��B + http://www.comp.ae.keio.ac.jp/~yuuji/lune/astrology/ ���삳��(prc) �e���Ŗ\��Ă��܂��B + http://www.prc.tsukuba.ac.jp/~katsura/ �O���P�Y����(�c���) �J�����ʂ̓��͎��̏����̃��[�h�����̃A�C�f�A�𒸂��܂����B @@ -1326,6 +1353,8 @@ �|���_����(������) M-q (YaTeX-fill-paragraph) �̃o�O��񍐂��Ē����܂����B YaTeX-insert-amper ��contribute���Ē����܂����B + ��҂̐������̖}�~�X�𒚔J�ɏE���ĉ������܂����B + YaTeX-shift-section-undo �̎������@�������Ă��������܂����B �����\����(�c���) �l�X�g���������itemize�‹��ł�indentation�̕s����w�E���Ē��� @@ -1347,6 +1376,24 @@ label/ref�⊮�ŁAlabel��ref�Ŏn�܂�P��S�Ă����ɂ���Ă��܂� �o�O��񍐂��Ē����܂����B +��c��������(�L���Z�ȑ�) + Emacs 19.29 �ȍ~�Ő�����YaTeX-indent-new-comment-line�̕s��� + �w�E���Ē����܂����B + +���{���V����(�x�R��w) + �u���߂Ďg��YaTeX�v�Ƃ���Cool��WWW�y�[�W���쐬���ĉ������܂����B + +�c���q����(�x�R��w) + AMS-LaTeX �ɑΉ����邽�߂̃p�b�`�𑗂��Ē����܂����B + +���V�K�i����(���k��w) +�c��������([��]�P�C�P���G���W�j�A�����O�V�X�e��) + begin�^�⊮�ł��܂������s�֐�������΁A�⊮���ɏ����G���g����} + ������Ƃ����A�C�f�A��񋟂��Ă��������܂����B + +�������l����(�c���) + YaTeX-default-pop-window-height �̌��Ă𒸂��܂����B + $ \% $ �̂悤�ȏꍇ�̐������[�h�I������̃~�X���w�E���Ē����܂����B yatex (setq auto-mode-alist (cons '("\\.tex$" . yatex-mode) auto-mode-alist)) diff --git a/yahtml.el b/yahtml.el index 71dc922..20227b5 100644 --- a/yahtml.el +++ b/yahtml.el @@ -1,9 +1,24 @@ ;;; -*- Emacs-Lisp -*- -;;; (c ) 1994 by HIROSE Yuuji [yuuji@ae.keio.ac.jp, pcs39334@ascii-net.or.jp] -;;; Last modified Mon Nov 20 11:26:38 1995 on inspire -;;; This is PURELY tentative. +;;; (c ) 1994 by HIROSE Yuuji [yuuji@ae.keio.ac.jp, pcs39334@asciinet.or.jp] +;;; Last modified Fri Feb 2 02:37:23 1996 on supra +;;; This package is no longer tentative. ;;; $Id$ +;;;[Installation] +;;; +;;; First, you have to install YaTeX and make sure it works fine. Then +;;; put these expressions into your ~/.emacs +;;; +;;; (setq auto-mode-alist +;;; (cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist)) +;;; (autoload 'yahtml-mode "yahtml" "Yet Another HTML mode" t) +;;; (setq yahtml-www-browser "netscape") +;;; ;Write your favorite browser. But netscape is advantageous. +;;; (setq yahtml-path-url-alist +;;; '(("/home/yuuji/public_html" . "http://www.mynet/~yuuji") +;;; ("/home/staff/yuuji/html" . "http://www.othernet/~yuuji"))) +;;; ;Write correspondence alist from ABSOLUTE unix path name to URL path. +;;; ;;;[Commentary] ;;; ;;; It is assumed you are already familiar with YaTeX. The following @@ -19,10 +34,19 @@ ;;; * [prefix] l Complete typeface-changing commands such as ;;; ` ... ' or ` ... ' ;;; * [prefix] m Complete single commands such as -;;; `
' or `
' +;;; `
' or `
or
  • ...' ;;; * menu-bar yahtml Complete all by selecting a menu item (Though I ;;; hate menu, this is most useful) -;;; +;;; * [prefix] g Goto corresponding Tag or HREF such as +;;;
    <->
    or href="xxx" +;;; * [prefix] k Kill html tags on the point. If you provide +;;; universal-argument, kill surrounded contents too. +;;; * [prefix] c Change html tags on the point. +;;; * [prefix] t b View current html with WWW browser +;;; (To activate this, never fail to set the lisp +;;; variable yahtml-www-browser. Recommended value +;;; is "netscape") +;;; ;;; NOTE! This program is truly tentative. If you find some bright ;;; future with this, please send me a mail to drive me to maintain this :) @@ -30,6 +54,20 @@ (require 'yatex) (defvar yahtml-prefix-map nil) (defvar yahtml-mode-map nil "Keymap used in yahtml-mode.") +(defvar yahtml-image-viewer "xv" "*Image viewer program") +(defvar yahtml-www-browser "netscape" + "*WWW Browser command") +(defvar yahtml-kanji-code 2 + "Kanji coding system of html file; 1=sjis, 2=jis, 3=euc") +;;(defvar yahtml-www-server "www" "*Host name of your domain's WWW server") +(defvar yahtml-path-url-alist nil + "*Alist of unix path name vs. URL name of WWW server. +Ex. +'((\"/usr/home/yuuji/http\" . \"http://www.comp.ae.keio.ac.jp/~yuuji\") + (\"/usr/home/yuuji/darts/http\" . \"http://inspire.comp.ae.keio.ac.jp/~darts\"))") +(defvar yahtml-directory-index "index.html" + "*Directory index file name; +Consult your site's WWW administrator.") (defun yahtml-define-begend-key-normal (key env &optional map) "Define short cut yahtml-insert-begin-end key." @@ -57,10 +95,13 @@ (setq yahtml-mode-map (make-sparse-keymap) yahtml-prefix-map (make-sparse-keymap)) (define-key yahtml-mode-map YaTeX-prefix yahtml-prefix-map) - (define-key yahtml-mode-map "\M-\C-@" 'YaTeX-mark-environment) + (define-key yahtml-mode-map "\M-\C-@" 'yahtml-mark-begend) + (if (and (boundp 'window-system) (eq window-system 'x) YaTeX-emacs-19) + (define-key yahtml-mode-map [?\M-\C- ] 'yahtml-mark-begend)) (define-key yahtml-mode-map "\M-\C-a" 'YaTeX-beginning-of-environment) (define-key yahtml-mode-map "\M-\C-e" 'YaTeX-end-of-environment) - (define-key yahtml-mode-map "\C-i" 'YaTeX-indent-line) + (define-key yahtml-mode-map "\M-\C-m" 'yahtml-intelligent-newline) + (define-key yahtml-mode-map "\C-i" 'yahtml-indent-line) (define-key yahtml-mode-map YaTeX-prefix yahtml-prefix-map) (let ((map yahtml-prefix-map)) (YaTeX-define-key "^" 'yahtml-visit-main map) @@ -96,18 +137,22 @@ (yahtml-define-begend-key "bf" "form" map) (yahtml-define-begend-key "bs" "select" map) (YaTeX-define-key "b " 'yahtml-insert-begend map) - (YaTeX-define-key "B " 'yahtml-insert-begend map) + (YaTeX-define-key "B " 'yahtml-insert-begend-region map) ) - (YaTeX-define-key "e" 'yahtml-end-environment map) + (YaTeX-define-key "e" 'YaTeX-end-environment map) (YaTeX-define-key ">" 'yahtml-comment-region map) (YaTeX-define-key "<" 'yahtml-uncomment-region map) (YaTeX-define-key "g" 'yahtml-goto-corresponding-* map) + (YaTeX-define-key "k" 'yahtml-kill-* map) + (YaTeX-define-key "c" 'yahtml-change-* map) + (YaTeX-define-key "t" 'yahtml-browse-menu map) + ;;;;;(YaTeX-define-key "i" 'yahtml-fill-item map) ) ) (defvar yahtml-paragraph-separate (concat - "^$\\|
    \\|

    \\|^[ \t]*") + "^$\\|<[bh]r>\\|

    \\|^[ \t]*") "*Regexp of html paragraph separater") (defvar yahtml-syntax-table nil "*Syntax table for typesetting buffer") @@ -120,8 +165,6 @@ ) (defvar yahtml-command-regexp "[A-Za-z0-9]+" "Regexp of constituent of html commands.") -(defvar yahtml-kanji-code 2 - "Kanji coding system of html file; 1=sjis, 2=jis, 3=euc") ;;; Completion tables for `form' (defvar yahtml-form-table @@ -131,8 +174,15 @@ (defvar yahtml-env-table '(("html") ("head") ("title") ("body") ("dl") ("a") ("form") ("select") + ("OrderedList" . "ol") + ("UnorderedList" . "ul") + ("DefinitionList" . "dl") ("h1") ("h2") ("h3") ("h4") ("h5") ("h6") ("ul"))) +(defvar yahtml-itemizing-regexp + "\\(ul\\|ul\\|dl\\)" + "Regexp of itemizing forms") + (defvar yahtml-user-env-table nil) (defvar yahtml-tmp-env-table nil) @@ -143,9 +193,18 @@ "Default completion table of typeface designator") (defvar yahtml-user-typeface-table nil) (defvar yahtml-tmp-typeface-table nil) +(defvar yahtml-last-typeface-cmd "address") (defvar yahtml-single-cmd-table - '(("hr") ("br") ("option") ("p")) + '(("hr") ("br") ("option") ("p") + ("HorizontalLine" . "hr") + ("BreakLine" . "br") + ("Paragraph" . "p") + ("Item" . "li") + ("DefineTerm" . "dt") + ("Description" . "dd") + ("dd") ("dt") ("li") + ) "Default completion table of HTML single command.") (defvar yahtml-user-single-cmd-table nil) (defvar yahtml-tmp-single-cmd-table nil) @@ -165,7 +224,7 @@ yahtml-typeface-table)))) (defvar yahtml-struct-name-regexp - "\\<\\(h[1-6]\\|[uod]l\\|body\\|title\\|head\\)") + "\\<\\(h[1-6]\\|[uod]l\\|body\\|title\\|head\\|table\\|t[rhd]\\)") (defun yahtml-mode () @@ -188,8 +247,8 @@ (make-local-variable 'YaTeX-prefix-map) (make-local-variable 'YaTeX-command-token-regexp) (setq YaTeX-command-token-regexp yahtml-command-regexp) - (make-local-variable 'YaTeX-environment-indent) - (setq YaTeX-environment-indent 0) + ;;(make-local-variable 'YaTeX-environment-indent) + ;;(setq YaTeX-environment-indent 0) (make-local-variable 'fill-prefix) (setq fill-prefix nil) (make-local-variable 'paragraph-separate) @@ -198,6 +257,10 @@ (make-local-variable 'comment-start) (make-local-variable 'comment-end) (setq comment-start "") + (make-local-variable 'indent-line-function) + (setq indent-line-function 'yahtml-indent-line) + (make-local-variable 'YaTeX-item-regexp) + (setq YaTeX-item-regexp "<\\(li\\|d[td]\\)>") (set-syntax-table yahtml-syntax-table) (use-local-map yahtml-mode-map) (run-hooks 'yahtml-mode-hook)) @@ -227,57 +290,57 @@ (yahtml-define-menu yahtml-menu-map-sectioning (nreverse - '((1 "H1" . (lambda () (interactive) (yahtml-insert-begin-end "H1" nil))) - (2 "H2" . (lambda () (interactive) (yahtml-insert-begin-end "H2" nil))) - (3 "H3" . (lambda () (interactive) (yahtml-insert-begin-end "H3" nil))) - (4 "H4" . (lambda () (interactive) (yahtml-insert-begin-end "H4" nil))) - (5 "H5" . (lambda () (interactive) (yahtml-insert-begin-end "H5" nil))) - (6 "H6" . (lambda () (interactive) (yahtml-insert-begin-end "H6" nil))) + '((1 "H1" . (lambda () (interactive) (yahtml-insert-begend nil "H1"))) + (2 "H2" . (lambda () (interactive) (yahtml-insert-begend nil "H2"))) + (3 "H3" . (lambda () (interactive) (yahtml-insert-begend nil "H3"))) + (4 "H4" . (lambda () (interactive) (yahtml-insert-begend nil "H4"))) + (5 "H5" . (lambda () (interactive) (yahtml-insert-begend nil "H5"))) + (6 "H6" . (lambda () (interactive) (yahtml-insert-begend nil "H6"))) ))) (setq yahtml-menu-map-logical (make-sparse-keymap "logical tags")) (yahtml-define-menu yahtml-menu-map-logical (nreverse '((em "Embolden" . - (lambda () (interactive) (yahtml-insert-tag "EM"))) + (lambda () (interactive) (yahtml-insert-tag nil "EM"))) (defn "Define a word" . - (lambda () (interactive) (yahtml-insert-tag "DEFN"))) + (lambda () (interactive) (yahtml-insert-tag nil "DEFN"))) (cite "Citation" . - (lambda () (interactive) (yahtml-insert-tag "CITE"))) + (lambda () (interactive) (yahtml-insert-tag nil "CITE"))) (code "Code" . - (lambda () (interactive) (yahtml-insert-tag "CODE"))) + (lambda () (interactive) (yahtml-insert-tag nil "CODE"))) (kbd "Keyboard" . - (lambda () (interactive) (yahtml-insert-tag "KBD"))) + (lambda () (interactive) (yahtml-insert-tag nil "KBD"))) (samp "Sample display" . - (lambda () (interactive) (yahtml-insert-tag "SAMP"))) + (lambda () (interactive) (yahtml-insert-tag nil "SAMP"))) (strong "Strong" . - (lambda () (interactive) (yahtml-insert-tag "STRONG"))) + (lambda () (interactive) (yahtml-insert-tag nil "STRONG"))) (VAR "Variable notation" . - (lambda () (interactive) (yahtml-insert-tag "VAR"))) + (lambda () (interactive) (yahtml-insert-tag nil "VAR"))) ))) (setq yahtml-menu-map-typeface (make-sparse-keymap "typeface tags")) (yahtml-define-menu yahtml-menu-map-typeface (nreverse '((b "Bold" . - (lambda () (interactive) (yahtml-insert-tag "B"))) + (lambda () (interactive) (yahtml-insert-tag nil "B"))) (i "Italic" . - (lambda () (interactive) (yahtml-insert-tag "I"))) + (lambda () (interactive) (yahtml-insert-tag nil "I"))) (tt "Typewriter" . - (lambda () (interactive) (yahtml-insert-tag "TT"))) + (lambda () (interactive) (yahtml-insert-tag nil "TT"))) (u "Underlined" . - (lambda () (interactive) (yahtml-insert-tag "U"))) + (lambda () (interactive) (yahtml-insert-tag nil "U"))) ))) (setq yahtml-menu-map-listing (make-sparse-keymap "listing")) (yahtml-define-menu yahtml-menu-map-listing (nreverse - '((ul "Unnumbered" . - (lambda () (interactive) (yahtml-insert-begin-end "UL" nil))) - (ol "Numbered" . - (lambda () (interactive) (yahtml-insert-begin-end "OL" nil))) - (dl "Description" . - (lambda () (interactive) (yahtml-insert-begin-end "DL" nil))) + '((ul "Unordered" . + (lambda () (interactive) (yahtml-insert-begend nil "UL"))) + (ol "Ordered" . + (lambda () (interactive) (yahtml-insert-begend nil "OL"))) + (dl "Definition" . + (lambda () (interactive) (yahtml-insert-begend nil "DL"))) ))) (setq yahtml-menu-map-item (make-sparse-keymap "item")) (yahtml-define-menu @@ -292,6 +355,10 @@ ))) (define-key yahtml-mode-map [menu-bar yahtml] (cons "yahtml" yahtml-menu-map)) + (let ((keys (where-is-internal 'fill-paragraph global-map))) + (while keys + (define-key yahtml-mode-map (car keys) 'yahtml-fill-paragraph) + (setq keys (cdr keys)))) (yahtml-define-menu yahtml-menu-map (nreverse @@ -329,14 +396,22 @@ ;;; ----------- Completion ---------- (defvar yahtml-last-begend "html") -(defun yahtml-insert-begend (&optional region) +(defun yahtml-insert-begend (&optional region env) "Insert ... ." (interactive "P") - (let ((cmd (YaTeX-cplread-with-learning + (let*((completion-ignore-case t) + (cmd + (or env + (YaTeX-cplread-with-learning (format "Environment(default %s): " yahtml-last-begend) - 'yahtml-env-table 'yahtml-user-env-table 'yahtml-tmp-env-table)) - (bolp (bolp))) + 'yahtml-env-table 'yahtml-user-env-table 'yahtml-tmp-env-table))) + (bolp (save-excursion + (skip-chars-backward " \t" (point-beginning-of-line)) (bolp))) + (cc (current-column))) (if (string< "" cmd) (setq yahtml-last-begend cmd)) + (setq yahtml-last-begend + (or (cdr (assoc yahtml-last-begend yahtml-env-table)) + yahtml-last-begend)) (setq cmd yahtml-last-begend) (if region (let ((beg (region-beginning)) @@ -346,11 +421,14 @@ (insert (format "%s" cmd (if bolp "\n" ""))) (goto-char beg) (insert (format "<%s%s>%s" cmd addin (if bolp "\n" "")))) - (insert (format "<%s%s" cmd (yahtml-addin cmd))) - (if bolp (progn (insert (format ">\n\n" cmd cmd)) - (forward-line -1)) - (insert ">") - (save-excursion (insert (format "" cmd))))))) + (insert (format "<%s%s>" cmd (yahtml-addin cmd))) + (save-excursion + (if bolp (progn + (insert "\n") + (indent-to-column cc) + (insert (format "" cmd))) + (insert (format "" cmd)))) + (if bolp (yahtml-intelligent-newline nil))))) (defun yahtml-insert-begend-region () "Call yahtml-insert-begend in the region mode." @@ -368,7 +446,7 @@ 'yahtml-form-table 'yahtml-user-form-table 'yahtml-tmp-form-table))) (let ((p (point)) q) - (insert (format "<%s%s>" form (yahtml-addin (downcase form)))) + (insert (format "<%s%s>" form (yahtml-addin form))) ;;(indent-relative-maybe) (if (cdr (assoc form yahtml-form-table)) (save-excursion (insert (format "" form)))) @@ -376,24 +454,81 @@ (defun yahtml-addin (form) "Check add-in function's existence and call it if exists." - (let ((addin (concat "yahtml:" form))) - (if (and (intern-soft addin) (fboundp (intern-soft addin))) - (concat " " (funcall (intern addin))) + (let ((addin (concat "yahtml:" (downcase form))) s) + (if (and (intern-soft addin) (fboundp (intern-soft addin)) + (stringp (setq s (funcall (intern addin)))) + (string< "" s)) + (concat " " s) ""))) +(defvar yahtml-url-completion-map nil "Key map used in URL completion buffer") +(if yahtml-url-completion-map nil + (setq yahtml-url-completion-map + (copy-keymap minibuffer-local-completion-map)) + (define-key yahtml-url-completion-map "\t" 'yahtml-complete-url) + (define-key yahtml-url-completion-map " " 'yahtml-complete-url) +) + +(defun yahtml-complete-url () + "Complete external URL from history or local file name." + (interactive) + (let (initial cmpl path dir file listfunc beg (p (point))) + (setq initial (buffer-string)) + (cond + ((string-match "^http:" initial) + (setq cmpl (try-completion initial yahtml-urls) + listfunc (list 'lambda nil + (list 'all-completions initial 'yahtml-urls)) + beg (point-min))) + (t + (setq path (if (string-match "^/" initial) + (yahtml-url-to-path initial) + initial)) + (setq dir (or (file-name-directory path) ".") + file (file-name-nondirectory path) + initial file + cmpl (file-name-completion file dir) + listfunc (list 'lambda nil + (list 'file-name-all-completions + file dir)) + beg (save-excursion (skip-chars-backward "^/") (point))))) + (cond + ((stringp cmpl) + (if (string= initial cmpl) + (with-output-to-temp-buffer "*Completions*" + (princ "Possible completinos are:\n") + (princ + (mapconcat '(lambda (x) x) (funcall listfunc) "\n"))) + (delete-region (point) beg) + (insert cmpl))) + ((null cmpl) + (ding)) + ((eq t cmpl) + (save-excursion + (unwind-protect + (progn + (goto-char p) + (insert " [Sole completion]")) + (delete-region p (point-max)))))))) + (defun yahtml:a () "Add-in function for " -; (or yahtml-urls (yahtml-collect-url-history)) + (or yahtml-urls (yahtml-collect-url-history)) ; (concat "href=\"" ; (completing-read "href: " yahtml-urls) ; "\"") - (concat "href=\"" (read-file-name "href: " "" nil nil "") "\"") -) + (message "(H)ref (N)ame?") + (cond + ((string-match "[hH]" (char-to-string (read-char))) + (concat "href=\"" + (read-from-minibuffer "href: " "" yahtml-url-completion-map) + "\"")) + (t (concat "name=\"" (read-string "name: ") "\"")))) (defun yahtml:img () "Add-in function for " (or yahtml-urls (yahtml-collect-url-history)) - (let ((src (read-file-name "src: " "" nil t "")) + (let ((src (read-file-name "src: " "" nil nil "")) (alg (completing-read "align: " '(("top") ("middle") ("bottom"))))) (concat "src=\"" src "\"" (if (string< "" alg) (concat " align=\"" alg "\""))))) @@ -410,6 +545,16 @@ (setq yahtml-last-single-cmd "option") (concat " name=\"" (read-string "name: ") "\"")) +(defun yahtml:ol () + (setq yahtml-last-single-cmd "li") "") +(defun yahtml:ul () + (setq yahtml-last-single-cmd "li") "") +(defun yahtml:dl () + (setq yahtml-last-single-cmd "dt") "") +(defun yahtml:dt () + (setq yahtml-last-single-cmd "dd") "") + + (defvar yahtml-input-types '(("text") ("password") ("checkbox") ("radio") ("submit") ("reset") ("image") ("hidden"))) @@ -432,36 +577,46 @@ (if (string< "" maxlength) (concat " maxlength=\"" maxlength "\"")) ))) - -(defun yahtml-insert-begin-end (env &optional region-mode) - "Insert \\n by calling YaTeX-insert-begin-end." - (interactive "sEnv: ") - (setq env (funcall (if yahtml-prefer-upcases 'upcase 'downcase) env)) - (YaTeX-insert-begin-end env region-mode)) - -(defun yahtml-insert-tag (tag) +(defun yahtml-insert-tag (region-mode &optional tag) "Insert and put cursor inside of them." - (interactive - (list - (YaTeX-cplread-with-learning - "Tag: " - 'yahtml-typeface-table 'yahtml-user-typeface-table - 'yahtml-tmp-typeface-table))) - (setq tag (funcall (if yahtml-prefer-upcases 'upcase 'downcase) tag)) - (insert (format "<%s> " tag)) - (save-excursion (insert (format "" tag)))) + (interactive "P") + (or tag + (setq tag + (YaTeX-cplread-with-learning + (format "Tag %s(default %s): " + (if region-mode "region: " "") yahtml-last-typeface-cmd) + 'yahtml-typeface-table 'yahtml-user-typeface-table + 'yahtml-tmp-typeface-table))) + (if (string= "" tag) (setq tag yahtml-last-typeface-cmd)) + (setq tag (funcall (if yahtml-prefer-upcases 'upcase 'downcase) tag) + yahtml-last-typeface-cmd tag) + (if region-mode + (if (if (string< "19" emacs-version) (mark t) (mark)) + (save-excursion + (if (> (point) (mark)) (exchange-point-and-mark)) + (insert "<" tag ">") + (exchange-point-and-mark) + (insert "")) + (message "No mark set now")) + (insert (format "<%s> " tag)) + (save-excursion (insert (format "" tag))))) (defun yahtml-insert-single (cmd) "Insert ." (interactive - (list (YaTeX-cplread-with-learning - (format "Command%s: " - (if yahtml-last-single-cmd - (concat "(default " yahtml-last-single-cmd ")") "")) - 'yahtml-single-cmd-table 'yahtml-user-single-cmd-table - 'yahtml-tmp-single-cmd-table))) - (setq cmd (funcall (if yahtml-prefer-upcases 'upcase 'downcase) cmd)) + (list + (let ((completion-ignore-case t)) + (YaTeX-cplread-with-learning + (format "Command%s: " + (if yahtml-last-single-cmd + (concat "(default " yahtml-last-single-cmd ")") "")) + 'yahtml-single-cmd-table 'yahtml-user-single-cmd-table + 'yahtml-tmp-single-cmd-table)))) (if (string< "" cmd) (setq yahtml-last-single-cmd cmd)) + (setq cmd (funcall (if yahtml-prefer-upcases 'upcase 'downcase) cmd)) + (setq yahtml-last-single-cmd + (or (cdr (assoc yahtml-last-single-cmd yahtml-single-cmd-table)) + yahtml-last-single-cmd)) (insert (format "<%s>" yahtml-last-single-cmd))) ;;; ---------- Jump ---------- @@ -469,25 +624,73 @@ "Check if point is on href clause." (let ((p (point)) cmd) (save-excursion - (or (bobp) (skip-chars-backward "^ \t")) - (and (looking-at "href\\s *=\\s *\"?\\([^\"]+\\)\"?") + (or (bobp) (skip-chars-backward "^ \t\n")) + (and (looking-at "href\\s *=\\s *\"?\\([^\"> \t\n]+\\)\"?") (< p (match-end 0)) (YaTeX-match-string 1))))) +(defun yahtml-netscape-sentinel (proc mes) + (cond + ((null (buffer-name (process-buffer proc))) + (set-process-buffer proc nil)) + ((eq (process-status proc) 'exit) + (let ((cb (current-buffer))) + (set-buffer (process-buffer proc)) + (goto-char (point-min)) + (if (search-forward "not running" nil t) + (progn + (message "Starting netscape...") + (start-process + "browser" (process-buffer proc) shell-file-name "-c" + (format "%s %s" yahtml-www-browser + (get 'yahtml-netscape-sentinel 'url))) + (message "Starting netscape...Done"))) + (set-buffer cb))))) + +(defvar yahtml-browser-process nil) + +(defun yahtml-browse-html (href) + "Call WWW Browser to see HREF." + (let ((pb "* WWW Browser *") (cb (current-buffer))) + (cond + ((string-match "[Nn]etscape" yahtml-www-browser) + (if (get-buffer pb) + (progn (set-buffer pb) (erase-buffer) (set-buffer cb))) + (put 'yahtml-netscape-sentinel 'url href) + (set-process-sentinel + (setq yahtml-browser-process + (start-process + "browser" pb shell-file-name "-c" + (format "%s -remote 'openURL(%s)'" yahtml-www-browser href))) + 'yahtml-netscape-sentinel)) + ((and (string= "w3" yahtml-www-browser) (fboundp 'w3-fetch)) + (w3-fetch href)) + ((stringp yahtml-www-browser) + (if (eq (process-status yahtml-browser-process) 'run) + (message "%s is already running" yahtml-www-browser) + (setq yahtml-browser-process + (start-process + "browser" "* WWW Browser *" shell-file-name + (format "%s %s" yahtml-www-browser href))))) + (t + (message "Sorry, jump across http is not supported."))))) + (defun yahtml-goto-corresponding-href (&optional other) "Go to corresponding name." (let ((href (yahtml-on-href-p)) file name) (if href (cond ((string-match "^http:" href) - (message "Sorry, jump across http is not supported.")) + (yahtml-browse-html href)) (t (setq file (substring href 0 (string-match "#" href))) (if (string-match "#" href) (setq name (substring href (1+ (string-match "#" href))))) (if (string< "" file) (progn (if (string-match "/$" file) - (setq file (concat file "index.html"))) + (setq file (concat file yahtml-directory-index))) + (if (string-match "^/" file) + (setq file (yahtml-url-to-path file))) (if other (YaTeX-switch-to-buffer-other-window file) (YaTeX-switch-to-buffer file)))) (if name @@ -503,33 +706,87 @@ (defun yahtml-on-begend-p (&optional p) "Check if point is on begend clause." - (let ((p (point)) cmd) + (let ((p (point)) cmd (case-fold-search t)) (save-excursion (if p (goto-char p)) - (if (= (char-after (point)) ?<) (forward-char 1)) + (if (equal (char-after (point)) ?<) (forward-char 1)) (if (and (re-search-backward "<" nil t) (looking-at (concat "<\\(/?" yahtml-command-regexp "\\)\\b")) (condition-case nil - (forward-list 1)) + (forward-list 1) + (error nil)) (< p (point))) (YaTeX-match-string 1))))) -(defun yahtml-goto-corresponding-begend () - (let ((cmd (yahtml-on-begend-p))) - (if cmd - (progn - (if (= (aref cmd 0) ?/) ;on line - (re-search-backward (format "<%s" (substring cmd 1))) - (re-search-forward (format " line + (setq cmd (substring cmd 1) + str (format "\\(<%s\\)\\|\\(= nest 0) (funcall func str nil t)) + (if (equal m0 (match-beginning 0)) + nil + (setq nest (+ nest (if (match-beginning 1) -1 1))))) + (if (< nest 0) + (goto-char (match-beginning 0)) + (funcall + (if noerr 'message 'error) + "Corresponding tag of `%s' not found." cmd) + (goto-char p) + nil)) + (t nil)))) + +(defun yahtml-current-tag () + "Return the current tag name." + (save-excursion + (let ((p (point)) b tag) + (or (bobp) + (looking-at "<") + (progn (skip-chars-backward "^<") (forward-char -1))) + (setq b (point)) + (skip-chars-forward "<") + (setq tag (buffer-substring + (point) (progn (skip-chars-forward "^ \t\n") (point)))) + (goto-char b) + (forward-list 1) + (and (< p (point)) tag)))) + + +(defun yahtml-goto-corresponding-img () + "View image on point" + (let ((tag (yahtml-current-tag)) image (p (point)) (case-fold-search t)) + (if (and tag + (string-match "img" tag) + (save-excursion + (re-search-backward "<\\s *img" nil t) + (re-search-forward "src=\"?\\([^\"> ]+\\)\"?>") + (match-beginning 1) + (setq image + (buffer-substring (match-beginning 1) (match-end 1))))) + (progn + (message "Invoking %s %s..." yahtml-image-viewer image) + (start-process + "Viewer" " * Image Viewer *" shell-file-name "-c" + (concat yahtml-image-viewer " " image)) + (message "Invoking %s %s...Done" yahtml-image-viewer image))))) (defun yahtml-goto-corresponding-* (&optional other) "Go to corresponding object." (interactive) (cond ((yahtml-goto-corresponding-href other)) - ((yahtml-goto-corresponding-begend other)) + ((yahtml-goto-corresponding-img)) + ((yahtml-goto-corresponding-begend)) )) (defun yahtml-goto-corresponding-*-other-window () @@ -537,6 +794,82 @@ (interactive) (yahtml-goto-corresponding-* t)) +;;; ---------- killing ---------- +(defun yahtml-kill-begend (&optional whole) + (let ((tag (yahtml-on-begend-p)) (p (make-marker)) (q (make-marker))) + (if tag + (progn + (or (looking-at "<") + (progn (skip-chars-backward "^<") (forward-char -1))) + (set-marker p (point)) + (yahtml-goto-corresponding-begend) + (or (looking-at "<") + (progn (skip-chars-backward "^<") (forward-char -1))) + (delete-region (point) (progn (forward-list 1) (point))) + (set-marker q (point)) + (beginning-of-line) + (if (looking-at "^\\s *$") + (delete-region (point) (progn (forward-line 1) (point)))) + (goto-char p) + (delete-region (point) (progn (forward-list 1) (point))) + (if (looking-at "^\\s *$") + (delete-region (point) (progn (forward-line 1) (point)))) + (if whole (delete-region p q)) + tag)))) + +(defun yahtml-kill-* (whole) + "Kill current position's HTML tag (set)." + (interactive "P") + (cond + ((yahtml-kill-begend whole)) + )) + + +;;; ---------- changing ---------- +(defun yahtml-change-begend () + (let ((tag (yahtml-on-begend-p)) + (completion-ignore-case t) + (p (point)) (q (make-marker)) + (default (append yahtml-env-table yahtml-typeface-table)) + (user (append yahtml-user-env-table yahtml-user-typeface-table)) + (tmp (append yahtml-tmp-env-table yahtml-tmp-typeface-table)) + ) + (if tag + (save-excursion + (if (= (aref tag 0) ?/) (setq tag (substring tag 1))) + (or (= (char-after (point)) ?<) (skip-chars-backward "^<")) + (skip-chars-forward "^A-Za-z") + (set-marker q (point)) + (setq p (point)) + (yahtml-goto-corresponding-begend) + (or (= (char-after (point)) ?<) + (skip-chars-backward "^<")) + (skip-chars-forward "^A-Za-z") + (if (= (char-after (1- (point))) ?/) + (progn + (set-marker q (point)) + (goto-char p))) + (setq tag (YaTeX-cplread-with-learning + (format "Change `%s' to(default %s): " + tag yahtml-last-begend) + 'default 'user 'tmp)) + (delete-region (point) (progn (skip-chars-forward "^>") (point))) + (if (string= "" tag) (setq tag yahtml-last-begend)) + (setq yahtml-last-begend + (or (cdr (assoc tag yahtml-env-table)) tag) + tag yahtml-last-begend) + (insert (format "%s%s" tag (yahtml-addin tag))) + (goto-char q) + (delete-region (point) (progn (skip-chars-forward "^>") (point))) + (insert tag))))) + +(defun yahtml-change-* () + "Change current position's HTML tag (set)." + (interactive) + (cond + ((yahtml-change-begend)) + )) + ;;; ---------- commenting ---------- (defun yahtml-comment-region (beg end) (interactive "r") @@ -548,6 +881,238 @@ +;;; ---------- filling ---------- +(defun yahtml-fill-paragraph (arg) + (interactive "P") + (let ((case-fold-search t) (p (point))) + (save-excursion + (fill-region-as-paragraph + (progn (re-search-backward paragraph-start nil t) + (or (save-excursion + (goto-char (match-end 0)) + (if (looking-at "[ \t]*$") + (progn (forward-line 1) (point)))) + (point))) + (progn (goto-char p) + (re-search-forward paragraph-start nil t) + (match-beginning 0)))))) + +;;; +;;; ---------- indentation ---------- +;;; +(defvar yahtml-hate-too-deep-indentation nil) +(defun yahtml-indent-line () + (interactive) + (let ((envs "[uod]l\\|table\\|t[rhd]") + (itms "<\\(dt\\|dd\\|li\\|t[rdh]\\)>") + inenv p col peol (case-fold-search t)) + (save-excursion + (beginning-of-line) + (setq inenv (or (YaTeX-inner-environment) "html") + col (get 'YaTeX-inner-environment 'indent) + p (get 'YaTeX-inner-environment 'point) + op)) + (save-excursion + (cond + ((string-match envs inenv) + (save-excursion + (beginning-of-line) + (skip-chars-forward " \t") + (cond + ((looking-at (concat "")) + (YaTeX-reindent col)) + ((or (looking-at itms) + (and yahtml-hate-too-deep-indentation + (looking-at (concat "<" envs)))) + (YaTeX-reindent (+ col YaTeX-environment-indent))) + ((and (< p (point)) + (save-excursion + (and + ;;(re-search-backward itms p t) + (setq op (point)) + (goto-char p) + (re-search-forward itms op t) + (goto-char (match-end 0)) + (skip-chars-forward " \t") + (setq col (current-column))))) + (YaTeX-reindent col)) + (t + (YaTeX-reindent (+ col YaTeX-environment-indent))))))) + (and (bolp) (skip-chars-forward " \t")) + (if (and (setq inenv (yahtml-on-begend-p)) + (string-match (concat "^\\(" envs "\\)") inenv)) + (save-excursion + (setq peol (point-end-of-line)) + (or (= (char-after (point)) ?<) + (progn (skip-chars-backward "^<") (forward-char -1))) + (setq col (current-column)) + (if (and (yahtml-goto-corresponding-begend t) + (> (point) peol)) ;if on the different line + (YaTeX-reindent col))))) + (and (bolp) (skip-chars-forward " \t")))) + +;(defun yahtml-fill-item () +; "Fill item HTML version" +; (interactive) +; (let (inenv p fill-prefix peol (case-fold-search t)) +; (setq inenv (or (YaTeX-inner-environment) "html") +; p (get 'YaTeX-inner-environment 'point)) +; (cond +; ((string-match "^[uod]l" inenv) +; (save-excursion +; (if (re-search-backward "<\\(d[td]\\|li\\)>[ \t\n]*" p t) +; (progn +; (goto-char (match-end 0)) +; (setq col (current-column))) +; (error "No

  • ,
    ,
    "))) +; (save-excursion +; (end-of-line) +; (setq peol (point)) +; (newline) +; (indent-to-column col) +; (setq fill-prefix (buffer-substring (point) (1+ peol))) +; (delete-region (point) peol) +; (fill-region-as-paragraph +; (progn (re-search-backward paragraph-start nil t) (point)) +; (progn (re-search-forward paragraph-start nil t 2) +; (match-beginning 0))))) +; (t nil)))) + +;;; +;;; ---------- Browsing ---------- +;;; +(defun yahtml-browse-menu () + "Browsing menu" + (interactive) + (message "B)rowse R)eload...") + (let ((c (char-to-string (read-char)))) + (cond + ((string-match "[bj]" c) + (yahtml-browse-current-file)) + ((string-match "r" c) + (yahtml-browse-reload))))) + +(defun yahtml-file-to-url (file) + "Convert local unix file name to URL. +If no matches found in yahtml-path-url-alist, return raw file name." + (let ((list yahtml-path-url-alist) p url) + (if (file-directory-p file) + (setq file (expand-file-name yahtml-directory-index file)) + (setq file (expand-file-name file))) + (while list + (if (string-match (concat "^" (regexp-quote (car (car list)))) file) + (setq url (cdr (car list)) + file (substring file (match-end 0)) + url (concat url file) + list nil)) + (setq list (cdr list))) + (or url (concat "file:" file)))) + +(defun yahtml-url-to-path (file &optional basedir) + "Convert local URL name to unix file name." + (let ((list yahtml-path-url-alist) url realpath docroot + (dirsufp (string-match "/$" file))) + (setq basedir (or basedir + (file-name-directory + (expand-file-name default-directory)))) + (cond + ((string-match "^/" file) + (while list + (if (string-match (concat "^" (regexp-quote (car (car list)))) basedir) + (progn + (setq url (cdr (car list))) + (if (string-match "\\(http://[^/]*\\)/" url) + (setq docroot (substring url (match-end 1))) + (setq docroot url)) + (if (string-match (regexp-quote docroot) file) + (setq realpath + (expand-file-name + (substring + file (min (1+ (match-end 0)) (length file))) + (car (car list))))) + (if realpath + (progn (setq list nil) + (if (and dirsufp (not (string-match "/$" realpath))) + (setq realpath (concat realpath "/"))))))) + (setq list (cdr list))) + realpath) + (t file)))) + +(defun yahtml-browse-current-file () + "Call WWW browser on current file." + (interactive) + (basic-save-buffer) + (yahtml-browse-html (yahtml-file-to-url (buffer-file-name)))) + +(defun yahtml-browse-reload () + "Send `reload' event to netzscape." + (let ((pb "* WWW Browser *") (cb (current-buffer))) + (cond + ((string-match "[Nn]etscape" yahtml-www-browser) + (if (get-buffer pb) + (progn (set-buffer pb) (erase-buffer) (set-buffer cb))) + ;;(or (get 'yahtml-netscape-sentinel 'url) + ;; (error "Reload should be called after Browsing.")) + (put 'yahtml-netscape-sentinel 'url + (yahtml-file-to-url (buffer-file-name))) + (basic-save-buffer) + (set-process-sentinel + (setq yahtml-browser-process + (start-process + "browser" pb shell-file-name "-c" + (format "%s -remote 'reload'" yahtml-www-browser))) + 'yahtml-netscape-sentinel)) + (t + (message "Sorry, RELOAD is supported only for Netscape."))))) + +;;; ---------- Intelligent newline ---------- +(defun yahtml-intelligent-newline (arg) + "Intelligent newline for HTML" + (interactive "P") + (let ((env (downcase (or (YaTeX-inner-environment) "html"))) func) + (setq func (intern-soft (concat "yahtml-intelligent-newline-" env))) + (end-of-line) + (newline) + (if (and env func (fboundp func)) + (funcall func)))) + +(defun yahtml-intelligent-newline-ul () + (interactive) + (insert (if yahtml-prefer-upcases "
  • " "
  • ")) + (yahtml-indent-line)) + +(fset 'yahtml-intelligent-newline-ol 'yahtml-intelligent-newline-ul) + +(defun yahtml-intelligent-newline-dl () + (interactive) + (let ((case-fold-search t)) + (if (save-excursion + (re-search-backward "<\\(\\(dt\\)\\|\\(dd\\)\\)>" + (get 'YaTeX-inner-environment 'point) t)) + (cond + ((match-beginning 2) + (insert (if yahtml-prefer-upcases "
    " "
    ")) + (setq yahtml-last-single-cmd "dt")) + ((match-beginning 3) + (insert (if yahtml-prefer-upcases "
    " "
    ")) + (setq yahtml-last-single-cmd "dd"))) + (insert (if yahtml-prefer-upcases "
    " "
    "))) + (yahtml-indent-line))) + +;;; ---------- Marking ---------- +(defun yahtml-mark-begend () + "Mark current tag" + (interactive) + (YaTeX-beginning-of-environment) + (let ((p (point))) + (save-excursion + (skip-chars-backward " \t" (point-beginning-of-line)) + (if (bolp) (setq p (point)))) + (push-mark p t)) + (yahtml-goto-corresponding-begend) + (forward-list 1) + (if (eolp) (forward-char 1))) + ;;; ---------- ---------- ;;; ---------- ---------- ;;; ---------- ---------- @@ -582,7 +1147,7 @@ (skip-chars-forward " \t\n") (cons (point) (progn (re-search-forward (concat "") nil t) - (1- (match-beginning 0))))))) + (match-beginning 0)))))) ;(setq hilit-patterns-alist (delq (assq 'yahtml-mode hilit-patterns-alist) hilit-patterns-alist)) (cond diff --git a/yatex.el b/yatex.el index 3f8d0f9..ddb74b1 100644 --- a/yatex.el +++ b/yatex.el Binary files differ diff --git a/yatex.new b/yatex.new index b01ffc5..27a6893 100644 --- a/yatex.new +++ b/yatex.new @@ -1,5 +1,32 @@ What's new in YaTeX - yatex.el �e�o�[�W�����̕ύX�_�ɂ‚��� + �쒹 - �e�o�[�W�����̕ύX�_�ɂ‚��� + +1.61 AMS-LaTeX �Ή� + xdvi -remote �ɂ��T�[�`�ɑΉ� [prefix] t s + begin�^�⊮�I������Ɏ����I�ɂ��܂������s�����s����悤�ɂ��� + yahtml��

    ,
    ���s���ɂ��鎞�� fill-paragraph �������̃o�O�C�� + html�^�O���̂��̂ł͂Ȃ��A�Ӗ���\��������ŕ⊮�ł���悤�ɂ��� + yahtml �� [prefix] g �� �̏�ʼn�������Viewer(xv)���N�� + ����悤�ɂ��A
    �̏�ʼn�������netscape + ���N��(�܂��̓v���Z�X�R���g���[��)����悤�ɂ��� + yahtml �� [preix] t (�쒹�ł����^�C�v�Z�b�g���j���[)��݂��A + [prefix] t b �ŃJ�����g�t�@�C����WWW�u���E�U�Ō�����悤�ɂ��� + [prefix] t r �� Netscape �� reload �R�}���h�𑗂��悤�ɂ��� + html �̊���⊮���܂Ƃ��ɂ��� + yahtml-indent-line ���쐬�B���X�e�B���O�‹��̃C���f���g�̂ݏ��� + �܂Ƃ��ɂ��� + yahtml �ɂ��܂������s��lj� + html �̕⊮���Ahttp:// �Ŏn�܂��Ă���΃q�X�g������̕⊮�A/ + �Ŏn�܂��Ă����WWW�T�[�o����URL���⊮�A������ł��Ȃ����UNIX�t�@ + �C���V�X�e���ł̃t�@�C�����⊮�ƂȂ�悤�ɂ��� + html3 ���̊��ɋy��ł܂��������B���ꂩ�������ā[ + \pagebreak, \linebreak �̃A�h�C���֐��̒lj� + �Z�N�V������؂�A�E�g���C���\���̃o�b�t�@�� u, d ���������Ƃɂ� + ��A�Ή�����Z�N�V�����R�}���h�̃��x�����グ��/������BU, D ���� + ���Ɨ̈���̃Z�N�V�����R�}���h���ꊇ�V�t�g + �ϐ� YaTeX-open-lines ��p�~ + [prefix] i �� YaTeX-fill-item ��p�~ + $$ ���� \% ���������ꍇ�̐������[�h�I������~�X���C�� 1.60 LaTeX2e �Ή� documentclass �p�����[�^���C�����AASCII �� jLaTeX2e �ɑΉ� diff --git a/yatex19.el b/yatex19.el index 9d2b5b6..64641cf 100644 --- a/yatex19.el +++ b/yatex19.el @@ -1,7 +1,7 @@ ;;; -*- Emacs-Lisp -*- ;;; YaTeX facilities for Emacs 19 ;;; (c )1994-1995 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] -;;; Last modified Sun Dec 3 03:29:56 1995 on inspire +;;; Last modified Wed Dec 20 22:32:21 1995 on supra ;;; $Id$ ;;; �Ƃ肠���� hilit19 ���g���Ă��鎞�ɐF���t���悤�ɂ��� @@ -263,11 +263,11 @@ '( ;; 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\\){" defun) @@ -299,8 +299,10 @@ ;; formulas ("[^\\]\\\\(" "\\\\)" formula) ; \( \) ("[^\\]\\\\\\[" "\\\\\\]" formula) ; \[ \] - ("\\\\begin{\\(eqn\\|equation\\)" "\\\\end{\\(eqn\\|equation\\)" formula) - ("[^\\$]\\($\\($[^$]*\\$\\|[^$]*\\)\\$\\)" 1 formula) ; '$...$' or '$$...$$' + ("\\\\begin{\\(eqn\\|equation\\|x?x?align\\|split\\|multiline\\|gather\\)" + "\\\\end{\\(eqn\\|equation\\|x?x?align\\|split\\|multiline\\|gather\\).*}" + formula) + ("[^\\$]\\($\\($[^$]*\\$\\|[^$]*\\)\\$\\)" 1 formula); '$...$' or '$$...$$' ;; things that bring in external files ("\\\\\\(include\\|input\\|bibliography\\){" "}" include) @@ -316,9 +318,8 @@ ;; things that do some sort of cross-reference (YaTeX-19-region-section-type "\\\\\\(\\(no\\)?cite\\|\\(page\\)?ref\\|label\\|index\\|glossary\\){" - crossref) - ) - "*Hiliting pattern alist for LaTeX text.") + crossref)) +"*Hiliting pattern alist for LaTeX text.") ;;(defvar YaTeX-hilit-pattern-adjustment-default nil) ;; ������Ȃ��Ȃ����B @@ -505,9 +506,9 @@ ;;; formula 'khaki ;;; label 'yellow-underlined)) (and YaTeX-emacs-19 - (eval-when-compile - (if (and (boundp 'window-system) window-system) - (require 'hilit19) - (error "Byte compile this file on window system! Not `-nw'!")))) + (boundp 'byte-compile-current-file) + (if (and (boundp 'window-system) window-system) + (require 'hilit19) + (error "Byte compile this file on window system! Not `-nw'!"))) (provide 'yatex19) diff --git a/yatexadd.el b/yatexadd.el index 10118ec..5e8f551 100644 --- a/yatexadd.el +++ b/yatexadd.el @@ -2,7 +2,7 @@ ;;; YaTeX add-in functions. ;;; yatexadd.el rev.13 ;;; (c )1991-1995 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] -;;; Last modified Mon Nov 6 14:30:25 1995 on inspire +;;; Last modified Thu Dec 21 21:47:34 1995 on supra ;;; $Id$ ;;; @@ -51,14 +51,9 @@ hline "\\hline")))) (setq rule (read-string "rule format: " rule)) + (setq single-command "hline") - (message "Dont forget to remove null line at the end of tabular.") - (format "%s%s{%s}%s" - width loc rule - (if (and (boundp 'region-mode) region-mode) - "" ;do nothing in region-mode - (format "\n%s\n%s \\\\ \\hline\n%s\n\\\\ %s" - hline and and hline)))) + (format "%s%s{%s}" width loc rule)) ) (fset 'YaTeX:tabular* 'YaTeX:tabular) (defun YaTeX:array () @@ -294,6 +289,16 @@ (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 ;;; diff --git a/yatexenv.el b/yatexenv.el index 3eec3b5..54b909b 100644 --- a/yatexenv.el +++ b/yatexenv.el @@ -2,7 +2,7 @@ ;;; YaTeX environment-specific functions. ;;; yatexenv.el ;;; (c ) 1994, 1995 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] -;;; Last modified Thu May 18 11:52:05 1995 on inspire +;;; Last modified Fri Feb 2 03:47:14 1996 on supra ;;; $Id$ ;;; @@ -116,18 +116,23 @@ (let*((p (point)) (format (YaTeX-tabular-parse-format tabular*)) (cols (car format)) (beg (car (cdr format))) space hline) - (setq hline (search-backward "\\hline" beg t)) + (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) - (setq space (if (search-backward "\t&" beg t) "\t" " ")) - (goto-char p) - (YaTeX-indent-line) - (setq p (point)) (while (> (1- cols) 0) (insert "&" space) (setq cols (1- cols))) (insert "\\\\") (if hline (insert " \\hline")) - (goto-char p)) + (goto-char p) + (YaTeX-indent-line) +) ) (defun YaTeX-intelligent-newline-tabular* () @@ -160,17 +165,17 @@ (insert "\\>\t") (setq tabcount (1- tabcount)))) (forward-char 2)) - (insert "\\="))) + (insert "\\= \\\\") + (forward-char -5))) ) ;;; ;; Functions for itemize/enumerate/list environments ;;; -(defvar YaTeX-item-for-insert "\\item ") (defun YaTeX-intelligent-newline-itemize () "Insert '\\item '." - (insert YaTeX-item-for-insert) + (insert "\\item ") (YaTeX-indent-line) ) (fset 'YaTeX-intelligent-newline-enumerate 'YaTeX-intelligent-newline-itemize) @@ -199,6 +204,7 @@ (setq func (intern-soft (concat "YaTeX-intelligent-newline-" env))) (end-of-line) (newline) + (undo-boundary) (if (and env func (fboundp func)) (funcall func))) ) diff --git a/yatexhks.el b/yatexhks.el index 17bcbb0..a36a902 100644 --- a/yatexhks.el +++ b/yatexhks.el @@ -8,7 +8,7 @@ ;;; named `yatexhks.el'. The file `yatexhks.el' will be automatically ;;; loaded at the end of loading `yatex.el'. -;Private definitions begins from here. +;Private definitions begin from here. (define-key YaTeX-user-extensional-map "0" '(lambda () (interactive) (YaTeX-make-section nil nil nil "part"))) diff --git a/yatexhlp.el b/yatexhlp.el index a49b2b3..a37c422 100644 --- a/yatexhlp.el +++ b/yatexhlp.el @@ -2,7 +2,7 @@ ;;; YaTeX helper with LaTeX commands and macros. ;;; yatexhlp.el ;;; (c )1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] -;;; Last modified Mon Jan 23 10:17:11 1995 on pajero +;;; Last modified Tue Dec 26 00:02:02 1995 on inspire ;;; $Id$ (let ((help-file (concat "YATEXHLP." @@ -261,6 +261,7 @@ ;;;###autoload (defun YaTeX-apropos (key) (interactive "sLaTeX apropos (regexp): ") + (if (string= "" key) (error "Nothing to show")) (or (YaTeX-apropos-file key YaTeX-help-file) (YaTeX-apropos-file key YaTeX-help-file-private t) (message "No matches found.")) diff --git a/yatexlib.el b/yatexlib.el index 376a5a9..db9b594 100644 --- a/yatexlib.el +++ b/yatexlib.el @@ -2,7 +2,7 @@ ;;; YaTeX library of general functions. ;;; yatexlib.el ;;; (c )1994-1995 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] -;;; Last modified Fri Apr 28 16:17:44 1995 on VFR +;;; Last modified Thu Feb 1 22:34:57 1996 on nsr ;;; $Id$ ;;;###autoload @@ -369,4 +369,11 @@ (or (featurep 'windows) (error "Why don't you use `windows.el'?")) (win-switch-to-window 1 (- last-command-char win:base-key))) +(defun bcf-and-exit () + "Byte compile rest of argument and kill-emacs." + (if command-line-args-left + (progn + (mapcar 'byte-compile-file command-line-args-left) + (kill-emacs)))) + (provide 'yatexlib) diff --git a/yatexm-o.el b/yatexm-o.el index 8826a47..fe8830f 100644 --- a/yatexm-o.el +++ b/yatexm-o.el @@ -1,7 +1,7 @@ ;;; -*- Emacs-Lisp -*- ;;; Sample startup file to invoke yatex-mode with outline-minor mode. ;;; (c )1993 by HIROSE Yuuji [yuuji@ae.keio.ac.jp] -;;; Last modified Wed May 4 19:44:53 1994 on 98fa +;;; Last modified Mon Jan 29 21:38:26 1996 on pajero ;;; ;; outline-minor-mode(�g�p���Ȃ��ꍇ�͕s�v�ł�) @@ -12,10 +12,11 @@ (setq default-outline-regexp "[*\^l]+") (make-variable-buffer-local 'outline-level-function) (setq-default outline-level-function 'outline-level-default) -(defvar LaTeX-outline-regexp +(setq LaTeX-outline-regexp (concat "[ \t]*" (regexp-quote "\\") "\\(appendix\\|documentstyle\\|part\\|chapter\\|section\\|" - "subsection\\|subsubsection\\|paragraph\\|subparagraph\\)")) + "subsection\\|subsubsection\\|paragraph\\|subparagraph\\)" + "\\*?[ \t]*[[{]")) ;;; ;; yatex-mode @@ -32,6 +33,9 @@ '(lambda () (setq-default outline-prefix-char (concat YaTeX-prefix "\C-o"));;@ (require 'min-out) ;;@ - (define-key outline-minor-keymap "\C-?" 'hide-subtree) ;;@ + ;;auctex �t���� min-out.el �̏ꍇ���ꁫ + ;(define-key outline-minor-keymap "\C-?" 'hide-subtree) ;;@ + ;;Emacs �t���� outline.el �̏ꍇ���ꁫ + (define-key outline-mode-prefix-map "\C-?" 'hide-subtree) (YaTeX-define-begend-key "ba" "abstract") )) diff --git a/yatexmth.el b/yatexmth.el index 244e76b..a118b15 100644 --- a/yatexmth.el +++ b/yatexmth.el @@ -2,7 +2,7 @@ ;;; YaTeX math-mode-specific functions. ;;; yatexmth.el rev.4 ;;; (c )1993-1995 by HIROSE Yuuji [yuuji@ae.keio.ac.jp] -;;; Last modified Wed Aug 16 12:45:55 1995 on inspire +;;; Last modified Thu Feb 1 13:04:16 1996 on supra ;;; $Id$ ;;; [Customization guide] @@ -439,11 +439,16 @@ (defun YaTeX-math-get-sign (list) (YaTeX-math-gets (car (cdr-safe (cdr-safe list)))) ) - (defun YaTeX-in-math-mode-p () "If current position is supposed to be in LaTeX-math-mode, return t." (or (YaTeX-quick-in-environment-p - '("math" "eqnarray" "equation" "eqnarray*" "displaymath")) + (append + '("math" "eqnarray" "equation" "eqnarray*" "displaymath");LaTeX + (if YaTeX-use-AMS-LaTeX + ;; And math modes of AMS-LaTeX + '("align" "align*" "split" "multline" "multline*" "gather" + "gather*" "aligned*" "gathered" "gathered*" "alignat" + "alignat*" "xalignat" "xalignat*" "xxalignat" "xxalignat*")))) (let*((p (point)) (nest 0) me0 (delim (concat YaTeX-sectioning-regexp "\\|^$\\|^\C-l")) (boundary @@ -473,7 +478,7 @@ (t (catch 'dollar (while ;(search-backward "$" boundary t);little bit fast. (YaTeX-re-search-active-backward ;;;;;; Too slow??? - "\\$" YaTeX-comment-prefix boundary t) + "\\$" (concat "[^\\\\]" YaTeX-comment-prefix) boundary t) (cond ((equal (char-after (1- (point))) ?$) ; $$ equation $$ (backward-char 1) diff --git a/yatexprc.el b/yatexprc.el index 4ef9741..86cfb4b 100644 --- a/yatexprc.el +++ b/yatexprc.el @@ -2,7 +2,7 @@ ;;; YaTeX process handler. ;;; yatexprc.el ;;; (c )1993-1995 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] -;;; Last modified Thu Nov 2 19:35:16 1995 on inspire +;;; Last modified Fri Feb 2 02:09:57 1996 on supra ;;; $Id$ (require 'yatex) @@ -350,7 +350,9 @@ (interactive (list (read-string-with-history - "Preview command: " dvi2-command 'YaTeX-preview-command-history) + "Preview command: " + (or (YaTeX-get-builtin "PREVIEW") dvi2-command) + 'YaTeX-preview-command-history) (read-string-with-history "Preview file[.dvi]: " (if (get 'dvi2-command 'region) @@ -386,6 +388,32 @@ " 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 diff --git a/yatexsec.el b/yatexsec.el index 49339e5..191ede1 100644 --- a/yatexsec.el +++ b/yatexsec.el @@ -2,7 +2,7 @@ ;;; YaTeX sectioning browser. ;;; yatexsec.el ;;; (c ) 1994 by HIROSE Yuuji [yuuji@ae.keio.ac.jp] -;;; Last modified Tue Jan 24 23:19:14 1995 on VFR +;;; Last modified Thu Jan 11 01:07:53 1996 on VFR ;;; $Id$ (defvar YaTeX-sectioning-level @@ -69,28 +69,79 @@ "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-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 "\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 () +(defun YaTeX-sectioning-buffer-jump-internal (&optional keep) + (let (ptn (p (point))) ;save-excursion is NG because + (beginning-of-line) ;this function should switch buffer + (if (re-search-forward YaTeX-sectioning-regexp) + (progn (setq ptn (buffer-substring + (1- (match-beginning 0)) + (progn (skip-chars-forward "^}") (1+ (point))))) + (goto-char p) + (YaTeX-showup-buffer YaTeX-sectioning-buffer-parent nil t) + (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)) - (let (ptn) - (beginning-of-line) - (if (re-search-forward YaTeX-sectioning-regexp) - (progn (setq ptn (buffer-substring - (1- (match-beginning 0)) - (progn (skip-chars-forward "^}") (1+ (point))))) - (YaTeX-showup-buffer YaTeX-sectioning-buffer-parent nil t) - (goto-char (point-max)) - (search-backward ptn)) - (message "No line number expression.")))) + (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) @@ -232,6 +283,9 @@ "\\(" YaTeX-sectioning-regexp "\\)\\*?{")) (cb (current-buffer))) (save-excursion + (set-buffer (get-buffer-create YaTeX-sectioning-buffer)) + (setq buffer-read-only nil) + (set-buffer cb) (YaTeX-showup-buffer YaTeX-sectioning-buffer) ;show buffer (goto-char (point-min)) (with-output-to-temp-buffer YaTeX-sectioning-buffer @@ -251,6 +305,7 @@ (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) @@ -258,15 +313,17 @@ 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 YaTeX-sectioning-buffer) (command "")) + secbuf (command "")) (save-excursion (setq secbuf (YaTeX-colloect-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 @@ -278,6 +335,8 @@ (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) @@ -297,4 +356,145 @@ (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 + (or (= (char-after (point)) ?\\ ) + (skip-chars-backward "^\\\\" (point-beginning-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))) + (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))) + (indent-to-column (cdr (assoc nsc YaTeX-sectioning-level))) + (delete-region + (1+ (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)