-
Notifications
You must be signed in to change notification settings - Fork 0
/
tex-functions.el
executable file
·3215 lines (2869 loc) · 103 KB
/
tex-functions.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
;; tex-functions.el
;; Created by Laurence D. Finston (LDF).
;; * Copyright and License.
;; This file is part of songlist, a package for keeping track of songs.
;; Copyright (C) 2021, 2022, 2023 Laurence D. Finston
;; songlist is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3 of the License, or
;; (at your option) any later version.
;; songlist is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with songlist; if not, write to the Free Software
;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
;; Please send bug reports to Laurence.Finston@gmx.de
;; This is the general delimiter function that is called by
;; tex-insert-braces, and the other specific delimiter functions.
;; It is autoloaded, because functions in el-tex-functions.el call it.
(defun tgdf
(beg-delim end-delim prompt-string arg)
"tgdf is the general delimiter function
that is called by tex-insert-braces, and the other
specific delimiter functions.
Also called by el-tex functions. If I type <RET> in order to put in the
string by hand, it returns the string, otherwise it returns nil.
Changed 11/24/97. Now it's possible to have the arg be a string, for
calling non-interactively. Used in umlaut. The documentation for functions
that use this function have not been changed to reflect this fact."
(let ((end-delim-length (length end-delim)))
(cond
;; no argument
((eq arg nil)
(progn
(let (a)
(setq a (read-string prompt-string))
(insert beg-delim a)
(push-mark (point) t)
(insert end-delim)
(if (string= a "")
(progn
(push-mark (point) t)
(backward-char end-delim-length)
;; This is a kludge for the functions italics and
;; old-norse
(if (not (or (string= beg-delim "{\\ON ")
(string= beg-delim "{\\it ")))
(progn
(message "mark set after closing delimiter")
(sit-for 1)
(message nil))))
;; else
(ignore))
(identity a)
)))
;; argument unspecified
((listp arg)
(progn
(insert beg-delim end-delim)
(backward-char end-delim-length)
(yank)
(forward-char end-delim-length)))
;; argument -
((symbolp arg)
(progn
(insert beg-delim end-delim)
(backward-char end-delim-length)
(let (here there a b c)
(setq here (point))
(setq b nil)
(setq c 2)
(yank)
(setq there (point))
(while (eq b nil)
(setq a
(y-or-n-p "Type \"y\" to cycle through kill ring or \"n\" to exit: "))
(cond
((eq a t)
(progn
(delete-region here there)
(yank c)
(setq there (point))
(1+ c)))
((eq a nil)
(progn
(setq b t)
(message nil)
(forward-char end-delim-length)))
(t
(progn
(message "Invalid response.")
(sit-for 1))))))))
;; argument integer
((integerp arg)
(progn
(insert beg-delim end-delim)
(backward-char end-delim-length)
(yank arg)
(forward-char end-delim-length)
))
((stringp arg)
(insert beg-delim arg end-delim))
;; Any other argument. (not possible).
(t (message "Invalid argument"))
) ;; cond
) ;; let
) ;; defun tgdf
;; This is like tex-insert-braces except that it gets the text from the
;; minibuffer and puts the cursor after the closing brace.
;; It works for both tex files and el files
;; that write tex files:
(defun tex-insert-braces (arg)
"tex-insert-braces inserts {} and prompts for a string to put between them.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
It functions differently depending on the prefix argument.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg, it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(tgdf "{" "}" "What goes between the braces? " arg))
;; ***********************************
;; LDF 2004.03.17.
;; Added `insert-single_quotes'.
;; LDF 2005.05.08. Changed this defun so that '' is used instead of `'.
;; LDF 2005.08.19.
;; Now using `' instead of '' again. This is due to a decision
;; by the GNU Project.
(defun insert-single-quotes (arg)
"insert-single-quotes inserts \"`'\" and prompts for a string to put between them.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
It functions differently depending on the prefix argument.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg, it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(tgdf "`" "'" "What goes inside the single quotes? " arg))
;; ***********************************
;; Changed to use * * rather than \begincomment and \end~. Just switch
;; the lines that are commented out to change back.
(defun begin-comment (arg)
"begin-comment inserts
;;\\begincomment{ and }\\n\\endcomment
* *
and prompts for a string to put between them.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
It functions differently depending on the prefix argument.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg, it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(if (or (string= mode-name "Emacs-Lisp") (string= mode-name "Lisp"))
(tgdf
;; "\\\\begincomment{" "}\\\\endcomment "
"*" "*"
"What's your comment? " arg)
;; else
(tgdf
;; "\\begincomment{" "}\\endcomment "
"*" "*"
"What's your comment? " arg)))
(defun begin-commentary (arg)
"begin-commentary inserts code for commentaries.
It puts \\BC and \\EC on two separate lines, puts the cursor on a
blank line between them and prompts for a string to put between them.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
It functions differently depending on the prefix argument.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg, it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(tgdf
"\\BC\n" "\n\\EC\n"
"What's your commentary? " arg)
)
;;;; This function makes {\sc{}}
;;;; for small caps for tex files
;;;; and {\\sc{}} for el-tex files.
;;;; and is set to C-c v
(defun small-caps (arg)
"small-caps inserts {\\sc } and prompts for a string to put inside.
It works for tex and el-tex files and inserts \\\\ for the latter.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
It functions differently depending on the prefix argument.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg, it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(if (or (string= mode-name "Emacs-Lisp") (string= mode-name "Lisp"))
(tgdf "{\\\\sc " "}"
"What should be in small caps? " arg)
;;else
(tgdf "{\\sc " "}"
"What should be in small caps? " arg)))
(defun tt (arg)
"tt inserts {\\tt } and prompts for a string to put inside.
It works for tex and el-tex files and inserts \\\\ for the latter.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
It functions differently depending on the prefix argument.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg, it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(let (tt-string)
(cond ((or (string= mode-name "Emacs-Lisp") (string= mode-name "Lisp"))
(setq tt-string "{\\\\tt ")
)
((string= mode-name "CWEB")
(setq tt-string "\\.{"))
((string= mode-name "Texinfo")
(setq tt-string "@t{"))
(t
(setq tt-string "{\\tt "))
) ;; Matches cond.
(tgdf tt-string "}"
"What should be in typewriter font? " arg)
;; Matches let
)
;; Matches tt
)
(defun bold-face (arg)
"bold-face inserts code for bold-face type.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
It functions differently depending on the prefix argument.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg, it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(let (pre-string post-string)
(cond ((or (string= mode-name "Emacs-Lisp") (string= mode-name "Lisp"))
(setq bold-face-string "{\\\\bf ")
(setq pre-string "{\\\\bf ")
(setq post-string "}")
)
((string= mode-name "HTML")
(setq pre-string "<b>")
(setq post-string "</b>"))
(t
(setq pre-string "{\\bf ")
(setq post-string "}")
)
)
(tgdf pre-string post-string "What should be in bold face? " arg)
;; Matches let
)
;; Matches bold-face
)
;;;; This works for both el-tex and tex files:
(defun put-in-tex-quotes (arg)
"put-in-tex-quotes inserts ``'' and prompts for a string to put inside.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
It functions differently depending on the prefix argument.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg, it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(tgdf "``" "''"
"What should be in Tex quotes? " arg))
(defun german-tex-quotes (arg)
"german-tex-quotes inserts \"`\"' and prompts for a string to put inside.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
It functions differently depending on the prefix argument.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg, it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(tgdf "\"`" "\"'"
"What should be in German quotes? " arg))
;;;; This works for both el-tex and tex files:
(defun square-brackets (arg)
"square-bracets inserts [] and prompts for a string to put between them.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
It functions differently depending on the prefix argument.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg, it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(tgdf "[" "]"
"What goes between the square brackets? "
arg))
;; This works for both tex and el-tex:
(defun make-parentheses (arg)
"make-parentheses-tex inserts \(\) and prompts for a string to put between them.
It works for tex and el-tex files. For the latter, it inserts \\(\\).
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
It functions differently depending on the prefix argument.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg, it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(if (or (string= mode-name "Emacs-Lisp") (string= mode-name "Lisp"))
(tgdf "\\(" "\\)"
"What goes between the parentheses? "
arg)
;; else
(tgdf "\(" "\)"
"What goes between the parentheses? "
arg)))
;; This works for both tex and el-tex:
(defun dollar-signs (arg)
"dollar-signs inserts $$ and prompts for a string to put between them.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
It functions differently depending on the prefix argument.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg, it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(tgdf "$" "$"
"What goes between the dollar signs? "
arg))
;;;; This gets text from the minibuffer and puts it
;;;; inside of "{\}", and then put the cursor after the
;;;; backslash. Set to C-c m in tex-mode:
;;; ******************************
;; This queries the user and enters the appropriate text for a tex-macro.
(defun simple-tex-macro ()
"simple-tex-macro puts in the code for a tex macro inside {}.
It sets the mark at point before doing so. It queries for a string or <RET>.
If <RET> is entered, or the string ends in a <SPACE>,
point is left between the curly braces and mark is set after the closing curly
brace. Otherwise, point is left after the closing brace."
(interactive)
(let (macro-string backslashes mode counter)
(if (or (string= mode-name "Lisp")
(string= mode-name "Emacs-Lisp"))
(progn
(setq mode t)
(setq backslashes "\\\\"))
;; else
(progn
(setq mode nil)
(setq backslashes "\\")))
(setq macro-string
(read-string "Enter a string or <RET> to enter by hand: "))
(set-mark-command nil)
;; This gets the last char out of macro-string
(setq counter (length macro-string))
(if (not (eq counter 0))
(setq counter (substring macro-string (- counter 1) counter)))
(insert "{" backslashes macro-string "}")
(if (or (string= macro-string "") (string= counter " "))
(progn
(set-mark-command nil)
(backward-char 1)
(message "Mark set after closing }")
(sit-for 2)
(message nil)
)
)
;; Matches let
)
;; Matches defun
)
;;; ******************************
(defun setup-tex-macro ()
(interactive)
(message "setup-tex-macro is currently indisposed")
(sit-for 2)
(message nil)
)
(defun tex-macro-args (&optional empty)
"tex-macro-args queries for arguments for tex macros."
(interactive)
(let (response query-string here)
(setq query-string
"Enter an argument \(a string\), - for an empty one, or <RET> to quit: ")
(setq response (read-string query-string))
(cond ((string= response "")
nil)
((string= response "-")
(insert "{")
(if (and (not here) (not empty))
(setq here (point)))
(insert "}")
(message "Do you want more arguments?")
(sit-for 1.5)
(if here
(tex-macro-args t)
;; else
(tex-macro-args))
)
(t
(insert "{" response "}")
(message "Do you want more arguments?")
(sit-for 1.5)
(tex-macro-args)
;; Matches t
)
;; Matches cond
)
(if here
(progn
(message "Do you want to fill the empty argument?")
(sit-for 1.5)
(setq response (read-string "Enter <RET> for no, any other char for yes: "))
(if (not (equal response ""))
(goto-char here))))
;; Matches let
)
;; Matches defun tex-macro-args
)
(defun tex-macro-with-args ()
"tex-macro-with-args puts in a tex-macro without braces and queries for
macro arguments, which it surrounds with braces."
(interactive)
(let (response)
(setq response (read-string "What's your macro? "))
(insert "\\" response)
(tex-macro-args)
;; Matches let
)
;; Matches defun tex-macro-with-args
)
(defun putontop ()
"Prompts for letters to be put on top of one another.
Works for tex and el-tex."
(interactive)
(let (a b (backslashes
(if (or (string= mode-name "Emacs-Lisp")
(string= mode-name "Lisp"))
"\\\\" "\\"))
;; Matches let-argument
)
(setq a
(read-string "What goes underneath? or type <RET> to type in by hand: "))
(if (equal a "")
(progn
(insert backslashes "putontop{}{}{}{}{}")
(backward-char 9)
)
;; else
(progn
(setq b (read-string "Okay. What goes on top? "))
(insert backslashes "putontop{" a "}{" b "}{}{}{}")
)
;; Matches if
)
;; Matches let
)
;; Matches defun putontop
)
(defun overstroke ()
"Prompts for string, puts an overstroke over it.
For tex and el-tex."
(interactive)
(let (a)
(setq a (read-string "What has an overstroke? or type <RET> \
to type in by hand: "))
(insert "{\\")
(if (or (string= mode-name "Emacs-Lisp") (string= mode-name "Lisp"))
(insert "\\"))
(insert "overstroke")
(if (not (string= a ""))
(insert (concat "{" a "}}"))
;; else
(progn
(insert "{}}")
(backward-char 2)))))
;;;; **********************************************************************
(defun upcircle (arg)
"Makes an upcircle."
(interactive "P")
(let (a backslashes)
(if (or (string= mode-name "Emacs-Lisp") (string= mode-name "Lisp"))
(setq backslashes "\\\\")
(setq backslashes "\\"))
(tgdf (concat backslashes "upcircle{")
"}{}{}{}"
"What needs an upcircle? "
arg)
;; Matches let
)
;; Matches defun
)
(defun decor (arg)
"decor prompts for a string and makes it the argument of the tex macro decor.
It works for tex and el-tex.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
It functions differently depending on the prefix argument.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg, it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(if (or (string= mode-name "Emacs-Lisp") (string= mode-name "Lisp"))
(tgdf "{\\\\decor " "}" "What should be decorative? " arg)
;; else
(tgdf "{\\decor " "}" "What should be decorative? " arg)))
(defun italics (arg)
"italics prompts for a string and makes it the argument of the tex macro it.
It works for tex and el-tex files.
It also queries for adding the italic correction.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
It functions differently depending on the prefix argument.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg,
it inserts the argth item from the kill ring.
Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(let (a return-value)
(cond
((or (string= mode-name "Emacs-Lisp") (string= mode-name "Lisp"))
(setq return-value
(tgdf
"{\\\\it " "}" "What should be in italics? " arg))
)
(t
(setq return-value
(tgdf
"{\\it " "}" "What should be in italics? " arg))))
;; This queries for the italic correction
(setq a (y-or-n-p "Do you want the italic correction? "))
(message nil)
(if (eq a t)
(progn
;; This is if I typed return to enter the string by hand,
;; which causes tgdf to
;; do a (backward-char 1), so I don't want to do one here.
(if (not (string= return-value ""))
(backward-char 1)
)
(insert (if (or (string= mode-name "Emacs-Lisp")
(string= mode-name "Lisp"))
"\\\\/"
;; else
"\\/"))
(if (not (string= return-value ""))
(forward-char 1)
;; else
(progn
(backward-char (if (or (string= mode-name "Emacs-Lisp")
(string= mode-name "Lisp"))
3 2))
(message "mark set after closing delimiter.")
(sit-for 1.5)
(message nil)
) ;; Matches else progn
) ;; Matches if
) ;; Matches progn
;; else
;; (message "It's not return, not adding the italic correction.")
;; Matches if
)
;; Matches let
)
;; Matches defun italics
)
;; (local-set-key [f8] 'italics)
(defun umlaut (arg)
"Prompts for character \(actually a string\) to be umlauted.
Inserts {\\\"<arg>}.
For tex files.
umlaut behaves differently, depending on the prefix
argument.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg,
it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(cond
((or (string= mode-name "Emacs-Lisp") (string= mode-name "Lisp"))
(tgdf "{\\\\\\\"" "}"
"What needs an umlaut? "
arg))
(t
(tgdf "{\\\"" "}"
"What needs an umlaut? "
arg))))
(defun circumflex (arg)
"Prompts for character \(actually a string\) to be circumflexed.
Inserts {\\\"<arg>}.
For tex files.
circumflex behaves differently, depending on the prefix
argument.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg,
it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(cond
((or (string= mode-name "Emacs-Lisp") (string= mode-name "Lisp"))
(tgdf "{\\\\\\\\^" "}"
"What needs an circumflex? "
arg))
(t
(tgdf "{\\^" "}"
"What needs an circumflex? "
arg))))
(defun make-tex-message (arg)
"Prompts for a string and inserts \\message{<arg>}.
For tex files.
make-tex-message behaves differently, depending on the prefix
argument.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg,
it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(tgdf "\\message{" "}"
"What's your message? "
arg))
(defun make-tex-show (arg)
"Prompts for a string and inserts \\show{<arg>}.
For tex files.
make-tex-show behaves differently, depending on the prefix
argument.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg,
it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(tgdf "\\show\\" " "
"What should I show? "
arg))
(defun make-tex-showthe (arg)
"Prompts for a string and inserts \\showthe\\<arg>.
For tex files.
make-tex-showthe behaves differently, depending on the prefix
argument.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg,
it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(tgdf "\\showthe\\" " "
"What \\the should I show? "
arg))
(defun begin-division (arg)
"begin-division queries the user and enters the necessary text for
a division, like \\beginchapter{}{}{}, \\beginsection{}{}{} etc.
For tex files."
(interactive "P")
(let (a query-string)
(setq a
(read-string
"What should I begin? Type a string or ? for info. "))
(cond ((string= a "?")
(progn
(message "Type c, s, ss, or sss. See help for more info")
(sit-for 1)
(begin-division nil)))
((string= a (or "c" "C"))
(progn
(insert "\\beginchapter")
(setq a "chapter")))
((string= a (or "s" "S"))
(progn
(insert "\\beginsection")
(setq a "section")))
((string= a (or "ss" "SS"))
(progn
(insert "\\beginsubsection")
(setq a "subsection")))
((string= a (or "sss" "SSS"))
(progn
(insert "\\beginsubsubsection")
(setq a "subsubsection")))
(t (progn
(message "Invalid entry")
(sit-for 1)
(begin-division nil))))
(setq query-string (concat "What's the name of your " a "? "))
(tgdf "{" "}{}{}" query-string arg)
(message "Enter additional arguments by hand.")
(sit-for 2)
))
(defun fnote (arg)
"Prompts for a string and inserts \\fnote{<arg>}.
Changed for use with my miracle translation. It used to insert
\\fnote{*}{<arg>} or \\\\fnote{}{<arg>}. This was for the old Mariu stuff.
Can be changed back, if necessary.
fnote-tex behaves differently, depending on the prefix
argument.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg,
it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(tgdf "\\fnote{" "}" "What goes in the fnote? " arg)
)
(defun ufnote (arg)
"Prompts for a string and inserts \\ufnote{<int>}{}.
Used for my Marienmirakel. For Unger's footnotes."
(interactive "P")
(if (not unger-ctr)
(setq unger-ctr 0)
)
(cond ((eq arg nil)
(setq unger-ctr (+ unger-ctr 1)))
((listp arg)
(setq unger-ctr 1))
((symbolp arg)
(setq unger-ctr
(string-to-int
(read-string "What number Unger footnote? "))))
)
(insert "\\ufnote{" (int-to-string unger-ctr) "}{}")
)
(defun footnote (arg)
"Prompts for a string and inserts \\footnote{}{<arg>}.
For tex files and el-tex files.
footnote-tex behaves differently, depending on the prefix
argument.
If the user types <RET> without entering a string, it leaves point between the
delimiters. Otherwise, it leaves point outside the delimiters.
With an unspecified prefix, just C-u, it inserts the last kill and then
leaves point outside the delimiters. With an integer prefix arg,
it inserts the
argth item from the kill ring. Negative integers are also allowed. With the
argument -, \(a dash\), it inserts the last kill, leaves point between the
delimiters and prompts the user to cycle through the kill ring or exit."
(interactive "P")
(let ((backslashes
(if (or (string= mode-name "Emacs-Lisp") (string= mode-name "Lisp"))
"\\\\" "\\")))
(tgdf (concat backslashes "footnote{}{") "}"
"What goes in the footnote? "
arg)
(message "Add other arguments by hand, if needed.")
(sit-for 1.5)
)
) ;; Matches defun footnote
;(defun fnote (arg)
; "Prompts for a string and inserts \\fnote{<arg>}{} or \\\\fnote{<arg>}{}.
;For tex files and el-tex files.
;fnote-tex behaves differently, depending on the prefix
;argument.
;If the user types <RET> without entering a string, it leaves point between the
;delimiters. Otherwise, it leaves point outside the delimiters.
;With an unspecified prefix, just C-u, it inserts the last kill and then
;leaves point outside the delimiters. With an integer prefix arg,
;it inserts the
;argth item from the kill ring. Negative integers are also allowed. With the
;argument -, \(a dash\), it inserts the last kill, leaves point between the
;delimiters and prompts the user to cycle through the kill ring or exit."
; (interactive "P")
; (let ((backslashes
; (if (or (string= mode-name "Emacs-Lisp") (string= mode-name "Lisp"))
; "\\\\" "\\")))
; (tgdf (concat backslashes "fnote{}{") "}{}"
; "What goes in the fnote? "
; arg)
; (message "Add other arguments by hand, if needed.")
; (sit-for 1.5)
; )
; )
(defun marginal-note (arg)
(interactive "P")
(if (or (string= mode-name "Emacs-Lisp") (string= mode-name "Lisp"))
(tgdf "\\\\marginalnote{" "}"
"What goes in the marginalnote? "
arg)
;; else
(tgdf "\\marginalnote{" "}"
"What goes in the marginalnote? "
arg)))
(defun index-entry ()
"index-entry puts in text for \\indexentry{}{}{}{}{}{} or \\\\indexentry{}{}{}{}{}{} and queries for arguments.
For tex and el-tex."
(interactive)
(let (a by-hand-flag
(backslashes (if (or (string= mode-name "Emacs-Lisp")
(string= mode-name "Emacs-Lisp"))
"\\\\" "\\")))
(catch 'get-me-out-of-here
(message "What name do you want? ")
(sit-for 1)
(setq a
(read-string "Enter a string or <RET> to enter by hand: "))
(if (string= a "")
(progn
(setq by-hand-flag t)
(message "Okay, you'll have to enter name by hand.")
(sit-for 1)))
(insert backslashes "indexentry{" a)
(set-mark-command nil)
(insert "}")
(setq a
(read-string "Enter Text or <RET> for nil or % to end now: "))
(if (string= a "%")
(progn
(message "Okay, the other args are all empty")
(insert "{}{}{}{}{}")
(if (eq by-hand-flag t)
(progn
(message
(concat
"Enter name by hand. Mark is set at end of " backslashes
"indexentry"))
(exchange-point-and-mark)))
(throw 'get-me-out-of-here t)
)
)
(insert (concat "{" a "}"))
(setq a
(read-string
"Enter string to suppress page no or <RET> for nil or % to end now: "))
(if (string= a "%")
(progn
(message "Okay, the other args are all empty")
(insert "{}{}{}{}")
(if (eq by-hand-flag t)
(progn
(message
(concat
"Enter name by hand. Mark is set at end of " backslashes
"indexentry"))
(exchange-point-and-mark)))
(throw 'get-me-out-of-here t)
)
)
(if (not (string= a ""))
(setq a "np"))
(insert (concat "{" a "}"))
(setq a
(read-string "Enter string for crossref or <RET> for nil or % to end now: "))
(if (string= a "%")
(progn
(message "Okay, the other args are all empty")
(insert "{}{}{}")
(if (eq by-hand-flag t)
(progn
(message
(concat
"Enter name by hand. Mark is set at end of " backslashes
"indexentry"))
(exchange-point-and-mark)))
(throw 'get-me-out-of-here t)
)
)
(insert (concat "{" a "}"))
(setq a