mirror of
https://github.com/PDP-10/its.git
synced 2026-03-20 16:38:16 +00:00
1609 lines
56 KiB
Plaintext
Executable File
1609 lines
56 KiB
Plaintext
Executable File
!~Filename~:! !Library for renumbering references, sections, equations, figures, and tables!
|
||
RENUM
|
||
|
||
!& Setup RENUM Library:! !S Sets up default variables for & Renumber Text and Renumber References.
|
||
|
||
If arg, load into qRenumber Text Formatter. This is useful
|
||
if you load the RENUM library in your init. If no arg, try to
|
||
determine the type of formatter used and load into qRenumber Text
|
||
Formatter. TEX is assumed otherwise.
|
||
|
||
Then load the default variables depending on the formatter used
|
||
and run qRENUM Setup Hook (if exists) for any user customization.
|
||
!
|
||
|
||
:i*TEX M.V Renumber_Text_Formatter !* default !
|
||
ff-1"e !* was one argument given?!
|
||
fuRenumber_Text_Formatter !* put in as formatter name!
|
||
'"#
|
||
!* test for other formatters.!
|
||
'
|
||
!******************************************************************
|
||
FORMATTER INDEPENDENT DEFINITIONS
|
||
******************************************************************!
|
||
M.C Renumber_Draft_Mode1=>in_draft_mode
|
||
M.C Renumber_Whole_File1=>ignore_narrowing
|
||
M.C Renumber_Section_SeparatorsText_separating_indexing_levels
|
||
M.C Renumber_Section_Default_SeparatorIn_case_user_forgets_one_at
|
||
the_end_of_his_new_section_number.
|
||
M.C Renumber_New_SectionText_for_identifying_new_section--case_is_
|
||
significant.__Start_with_a_<NL>_if_you_require_it
|
||
to_start_on_a_new_line.
|
||
M.C Renumber_New_ChapterText_for_identifying_new_chapter--case_is_NOT_
|
||
significant.__Start_with_a_<NL>_if_you_require_it
|
||
to_start_on_a_new_line.
|
||
M.C Renumber_WhitespaceText_preceding_first_significant_character
|
||
of_a_figure_or_table_or_second_pass_equation.
|
||
M.C Reference_Output_FilenameBibliography_table_is_stored_here_when_Renumber
|
||
References_is_given_an_arg_of_1
|
||
M.C Reference_DashText_for_replacing_consecutive_numbers_(references).
|
||
Used_by_Reference_Sort_Macro.
|
||
M.C Reference_Bibliography_BeginText_denoting_start_of_bibliography.
|
||
M.C Reference_Bibliography_EndText_on_the_1st_line_after_the_last_reference
|
||
in_the_bibliography.__Should_probably_start_with_<NL>.
|
||
M.C Reference_Bibliography_SeparatorText_between_references_in_the_bibliography.
|
||
The_exact_point_records_are_broken_up_is_at_the_beginning
|
||
of_the_line_that_a_search_for_this_text_would_leave_the_
|
||
pointer.
|
||
M.C Reference_Auto_TextText_preceding_filename_to_yank_references_from.__
|
||
Must_be_on_the_same_line_as_the_last_character_of_the_
|
||
text_in_q$Reference_Bibliography_Begin$
|
||
M.C Renumber_References_Default_OptionsOptions_to_use_if_not_specified_in
|
||
file
|
||
M.C Section_Search_Pass_1Contains_macro_to_move_pointer_to_the_start
|
||
of_a_section_to_renumber_on_1st_pass
|
||
M.C Section_Search_Pass_2Contains_macro_to_move_pointer_to_the_start
|
||
of_a_section_to_renumber_on_2nd_pass
|
||
M.C Section_Renumber_Pass_11=>actually_do_renumbering_on_the_1st_pass
|
||
|
||
M.C Equation_Search_Pass_1Contains_macro_to_move_pointer_to_the_start
|
||
of_a_equation_to_renumber_on_1st_pass
|
||
M.C Equation_Search_Pass_2Contains_macro_to_move_pointer_to_the_start
|
||
of_a_equation_to_renumber_on_2nd_pass
|
||
M.C Equation_Renumber_Pass_11=>actually_do_renumbering_on_the_1st_pass
|
||
|
||
M.C Figure_Search_Pass_1Contains_macro_to_move_pointer_to_the_start
|
||
of_a_figure_to_renumber_on_1st_pass
|
||
M.C Figure_Search_Pass_2Contains_macro_to_move_pointer_to_the_start
|
||
of_a_figure_to_renumber_on_2nd_pass
|
||
M.C Figure_Renumber_Pass_11=>actually_do_renumbering_on_the_1st_pass
|
||
|
||
|
||
M.C Table_Search_Pass_1Contains_macro_to_move_pointer_to_the_start
|
||
of_a_table_to_renumber_on_1st_pass
|
||
M.C Table_Search_Pass_2Contains_macro_to_move_pointer_to_the_start
|
||
of_a_table_to_renumber_on_2nd_pass
|
||
M.C Table_Renumber_Pass_11=>actually_do_renumbering_on_the_1st_pass
|
||
|
||
M.C Reference_Search_MacroSearch_macro_for_next_reference
|
||
M.C Reference_Sort_MacroSort_macro_to_run_when_finished_renumbering_
|
||
a_group_of_references._This_macro_is_run_
|
||
by_Reference_Search_Macro_by_doing_m0
|
||
M.C Reference_Bibliography_Sort_MacroSort_to_do_on_bibliography.
|
||
|
||
!*********** Variables used by all macros******!
|
||
0 M.V Renumber_Draft_Mode !* default is draft mode!
|
||
!* this is complemented below!
|
||
1 M.V Renumber_Whole_File !* ignore narrowing is default!
|
||
:i*.- M.V Renumber_Section_Separators
|
||
:i*. M.V Renumber_Section_Default_Separator
|
||
|
||
m(m.m Renumber_Complement_Draft_Mode) !* Print the current mode!
|
||
|
||
|
||
!*********** Variables used by Sections **************************!
|
||
|
||
:@i*/
|
||
!* The first pass of renumber sections does the following:
|
||
If qs#-1, this is the second time we are called so return 0.
|
||
This is because there will only be ONE section number in each section
|
||
to be renumbered on the first pass.
|
||
If qo contains the null string, set qo to qn
|
||
and set qt to qn without the . at the end.
|
||
This is so when narrow, the first non-null section
|
||
won't be renumbered. Also, sections after a null
|
||
section won't be renumbered. Return -1.
|
||
Count the number of dots in n and o.
|
||
Insert the old number in scratch buffer.
|
||
If old number has x more dots (x can be pos, neg, or zero),
|
||
move back (x+2) periods from the end of the buffer.
|
||
Move over dot.
|
||
Convert number to the right of the dot to a number.
|
||
Replace this number with 1+<this number>
|
||
Insert in qt the whole buffer. Add a . on the end.
|
||
Insert in qo the whole buffer.
|
||
qu contains the starting location of the section number;
|
||
any asterisk flag has been skipped over.
|
||
Move pointer here.
|
||
|
||
Return -1.
|
||
|
||
The net effect of all this is that sections are renumbered
|
||
the way you think they should be (on the basis of the previous
|
||
section number and the number of .'s in the new number)
|
||
and .'s at the end
|
||
are conserved since a dot at the end isn't significant and
|
||
the table doesn't contain .'s at the end of the values.
|
||
Hence, % Section 2.1. will go to, say, Section 1.1.
|
||
and % Section 2.1 will go to, say, Section 1.1
|
||
!
|
||
|
||
qs+1"n !* second time called!
|
||
0 !* so don't do table lookup!
|
||
'
|
||
fqn"e qnuo 0' !* if current chapt null, accept & do nothing!
|
||
!* (don't enter in table)!
|
||
|
||
qd"e !* does current section start with letter?!
|
||
:io !* set old chapter to null since can't !
|
||
!* renumber based on a letter!
|
||
0 !* we aren't going to change anything,!
|
||
!* so don't bother putting in table.!
|
||
'
|
||
fqo"e !* does qo contain null?!
|
||
qnuo !* accept current chapter!
|
||
0,fqn-1:gn ut !* strip separator at end and put in qt!
|
||
quj -1 !* return!
|
||
'
|
||
0[1 0[2 !* scratch q-reg!
|
||
qRenumber_Section_Separators[3!* load in dot and dash!
|
||
qb[..o !* get scratch buffer created!
|
||
hk !* before & Renumber Text called!
|
||
gn !* insert new number!
|
||
j<s3;%2> !* count number of dots!
|
||
hk go !* insert old number!
|
||
j<s3;%1> !* count number of dots!
|
||
q1-q2+2u2 !* q2 is number of periods to move back!
|
||
-q2f"l :s3"e j '"#c'' !* Move back if x+2 is positive!
|
||
!* Moving to start if too big!
|
||
|
||
.u2
|
||
\+1u1
|
||
|
||
q2j k !* move back to start of number!
|
||
!* and kill all old text!
|
||
:g1 u1 !* convert to text!
|
||
g1 !* insert number!
|
||
hxt !* new num in qt!
|
||
i.hxo !* insert a dot and put in qo!
|
||
]..o !* restore user buffer!
|
||
]3]2]1 !* and scratch regs!
|
||
quj -1 !* return -1 with ptr at sec num!
|
||
/M.V Section_Search_Pass_1
|
||
|
||
1 M.V Section_Renumber_Pass_1 !* renumber on pass 1 since!
|
||
!* section headings are!
|
||
!* chopped off (by fs boundaries)!
|
||
!* o 2nd pass!
|
||
|
||
:@i*/
|
||
1f[bothcase !* ignore case !
|
||
!srchsect!
|
||
:ssection"e' !* search for next section!
|
||
!* don't search for appendix since!
|
||
!* these are user re-lettered.!
|
||
s
|
||
_ !* search for first significant char!
|
||
!* don't just search for a digit.!
|
||
r3 |