!* -*- Teco -*- ! !~Filename~:! !Macros for doing special saving to an alternate filename! SAVMAC !& Setup SAVMAC Library:! !& Things to do to set us up ! m.mSmart_Write_Fileu:.x() 1,m(m.m &_Get_Library_Pointer)TeX"e m(m.m Load_Library)TeX' !Smart Write File:! !^R Write file being smart about -*- Save-Hook:...; -*- ! ff"e @:m(m.m Write_File)' !* Maybe just call Write File ! [1[2[F !* Get temp qregs ! qBuffer_FilenamesuF !* Buffer filenames initially default! .:\u1 fn1j !* Save the cursor ! f[vb f[vz 0,(fsz) fsbound !* Bind virtual buffers open ! j 1:fb-*-:"l oAbort' !* Exit if no file property list ! .,(1:fb-*-:"l oAbort'fkc.)fsboundwj !* Narrow bounds to prop list ! :sSave-Hook::"l oAbort' !* Find save hook if any ! .,(:s;:"lzj-s_c'"#r'.)x1 !* Get save hook name in q1 ! 1,m.m &_1_Save-Hooku2 !* Macro Save-Hook instead ! 0,(fsz) fsbound !* Re-widen buffer bounds ! q1"e fsrgetty"n@'!"!ft Can't_find_&_1_Save-Hook !* Mention if no macro definition ! m(m.m Write_File)F' !* and just call MM Write File ! "# 1:<@m2(w>"n !* Else macro the definition ! !"!ft Error_generated_in_macro'ing_&_1_Save-Hook !* Mention errors ! m(m.m Write_File)F' !* And call write file if err ! "# )f"e -1,m(m.m Write_File)F''' !* Else call write file if no val! !* Note: No updating of file ! !* defaults should be done here ! !* gets returned by macro ! 0 !* Pop and return ! !Abort! !* Come here to abort ! fsrgetty"n@'ft(No_Save_Hook_--_File_not_Saved) !* Say we are aborting ! 0fsecho active !* Preserve echo area display ! 0 !* Pop and return ! !& TEX Save-Hook:! !S Process and save a TEX file Find occurences of %Character-Translation: and make that translation in rest of file ! [1[2[3 !* Bind temp qregs ! f[dfile !* Bind Teco default filenames ! [Buffer_Filenames !* Bind Emacs default filenames ! qBuffer_Filenamesfsdfile !* Merge Emacs defaults with Teco ! !* ! g( hx*( f[bbind ) ) j .u3 !* Save whole buffer in a temp buffer ! !* ! > !* Replace ochar with newchar ! !* ! j [0[1[2 !* Bind qregs 0 and 1 ! <:s%_Switch:_; !* Toggle-able switches ! :fll flx0 fll !* Get alternative in q0 ! :fll flx1 fll 1,(fq1-1):g1u1 !* Get query in q1 ! 0l s\def !* Go back and find \def ! :fll flx2 1,(fq2-1):g2u2 !* Get default in q2 ! <:i*C1_fsechodisplayout !* Ask the question ! 1,1m(m.m &_Yes_or_No)f(:; !* Do nothing if answers yes ! )"e i_%Default:_ fkc g0 0;' !* If no, use alternative and exit ! > !* Go back and ask again ! l > !* Loop looking for switches ! !* ! j :s%_UnTabify:"l !* If he requested untabify ! j m(m.m UnTabify)' !* Changes tabs to spaces ! !* ! j < :s%_Begin_TeX-Display:; fkd k !* Convert TeX displays ! .,(s%_End_TeX-Display:fkd.)m(m.m Setup_Indented_TeX_Display)' > et _TEX  !* Change Teco default filename ! 0 uBuffer_filenames !* Flush Emacs default filename ! !* Let caller write and pop ! 5,m(m.m&_Read_Filename)Write_TeX_FileuF