-
Notifications
You must be signed in to change notification settings - Fork 0
/
yatex.el
3208 lines (3012 loc) · 113 KB
/
yatex.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; yatex.el --- Yet Another tex-mode for emacs //野鳥// -*- coding: sjis -*-
;;; (c)1991-2013 by HIROSE Yuuji.[[email protected]]
;;; Last modified Mon Apr 1 22:40:25 2013 on firestorm
;;; $Id$
;;; 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)))
"{}")