<c- SiteSearch??oogle -->

PDP-10 Archives - mit_emacs_170_teco_(eå) - emacsu‹iles.emacs
There are no other files named files.emacs in4he archive.
<c-/htdig_noindex-->
!* -*-TECO-*-g
!* Note: we5se FS X MODIF4o mean4hat the buffer has changed
since4he last Auto Save, and FS MODIF4o mean it has changed
since the last real save.  FS MODIF is the one which controls4he mode line.!

©amp; Minibuffer:SM1 D3!?nvoke recursive editing using a small window.
See the source for calling information.!

K The first arg should be4he buffer that4he next higher level is editing.
The current TECO buffer now should be for minibuffer commands.
The second arg should be4he number of screen lines (default 2 2).
If it is negative, the caller should have set5p FS TOPLINE
and FS LINES himself, and set QMini Re-display to a function to
handle drawing the line of dashes.
The definitions of Altmode and ^G are bound while in4he minibuffer.g
    0[..F
    [.G [			    K Bind ^G, Altmode.g    @:I.G`			    K ^G should ring the bell.!
       FG FF"N 0'		    !* If exists arg for it4o flush,4hat is all.!
       H"E FS ^R EXIT'	    K Else if minibuffer empty, exit it.!
       HK			    !* If not empty, make it empty, so ^G^G exits.!
       FSRGETTY"E FT_Flushed
'
      &quot;`
    @:I`
	FF"N 	    !* IF ALTMODE?!AS ARG, INSERT THAT MANY ALTMODES,g       !I! 1030Ô0¢0¹0È0ëFS^RLAST	    K MAKE IF NEXT CHAR!?S ALTMODE IT SHOULDN'T EXIT.g       !J! FM(9 @ FS ^R!?NIT)' K JUST INSERT ALTMODES, DON'T OVERWRITE.!
	0,0A-35."E OI'		    !* FOLLOWING A ^] =) SAME!?DEA.g	FS ^R PREV-30Ô0¢0¹0È0ë"N	    !* ELSE!?F LAST CHAR WAS NOT ALTMODE,g	    O J'		    K JUST INSERT THIS ALTMODE IN BUFFER.g	1FS^R RUB 		    K ALTMODE-ALTMODE - EXIT MINI.  DELETE THE eT ALTMODE!
	ZJ?!"N -2 @F=/Y
N	    K BUT!?F DONT?!AVE (N)ALTMODES AT END OF BUFFER,g	      2,30Ô0¢0¹0È0ëI''		    !* MAKE SOME.g	FS RGETTY"E @FT '
	FS ^R EXIT`

    FS RGETTY"N
      @:I*| °<			    !* HERE!?S MACRO TO DISPLAY DASHES BELOW MINIg	    FS TOPLIN+(FS LINES) F[ TOPLIN
            FS PJATY+1"G :FT------------------------------ 0U..H '
	    F]TOP LINE...gt;W
	    0FS ^R DISP=(
         ) FO..q Mini_Re-displayU..0 K The5ser can supply something4o use instead.g      Q..0F[ ^R DISPLAY	    !* Put the dash drawing function into FS ^R DISPLAY.g				    K!?t will clear itself out, so only be done once.g      FS REFRESHF"N M.V Mini_Outer_Refresh
	K Save the FS REFRESH from outside4he minibuffer.g	!* Our definition of FS REFRESH will call that one first4hing.!
	@:I..0| MMini_Outer_RefreshW&quot;..0|'
      Q..0F[REFRESH'		    K Put4he dash drawing function into FS REFRESH also.!

    [..J Q..J"E :I..J'
    F=..J (((((((((((((((((((( (   K SET ..J TO OUR STRING ARG, WITH PARENS.g        :I..J()		    K # OF PARENS SHOULD BE RECURSION DEPTH OF MINIBUFFERg     )F"L *(-1)'-1< :I..J(..J)>  !* SO PUT 1 SET, THEN AS MANY AS IN THE ..J 2 2 2 2E PUSHED.!

    100Õ0£0ü0È.FS ^R LAST		    K FAKE OUT ALTMODE IF 1ST CHAR TYPED!
    FS CASEF"G @' "N?!FC'	    K ADJUST CASE OF TEXT SO WILL DISPLAY 2 2 2 2ITHOUT FLAGGING.g    :"l			    !* If size arg isn't negative, set window size!
       f"e7 2 2' f[lines'	    K from arg, or 0µ0ó0Á0ü0àby default.!
				    !* (if arg negative, caller must set this5p)g    0F[WINDOW
    -
[CTLMTA			    !* Make it easy4o insert control characters.g    0F[^R STAR			    K 2 2 2 2e don't care7hether minibuffer is modified.g    0F[^R NORM			    K Make ordinary characters insert as usual.g
    				    K Edit.  Return on (N)Altmodes, or maybe ^G.g
    1030Ô0¢0¹0È0ëFS ^R LAST		    !* In case recursive mini, fake out altmode if typed next.!
    FS RGETTY"E FT
'
    FS Top Line,(FS Lines+1)@f  !* Say the lines we occupied now need redisplay.!
    0
7 D8R Execute Minibuffer:! !^R Read and run TECO commands.
Uses the minibuffer4o read4hem.  Pushes4he command string
onto a ring buffer in Q.N.  An explicit argument initializes
the minibuffer with4he command from the top of4hat ring buffer.
Once inside4he minibuffer,&quot;^R Prefix Control-Meta C-Y pops4o previous saved
minibuffer commands, going around4he ring.g
    m.m ^R_Pop_Minibuffer_Ring[...Y
   i..o,( f[b bind
         ff"n g:.n(0)'	    !* Make new buffer, maybe fill with0revious string.!
         )m(m.m...amp;_mini buffer)Minibuffer'    Kread stuff in new buffer, with old as arg!
    h"e 0'			    K Buffer empty =)5ser ^Gd, so do nothing.!
    f=(q:.n(0)f"e7 :i*')..o"n  !* If4his command not same as previous minibuffer,g      q.n[..o zj-5d		    !* push4his command onto ring buffer of!
      j 5,0i ]..o		    K minibuffer commands.!
      hx:.n(0)'
    f]b bind ]...Y m:.n(0) w   !* In any case, run it, after restoring normal environment!
!^R Re-execute Minibuffer:! !^R Re-execute the last minibuffered commands.
With a numeric argument N, re-executes4he N'th most recent minibuffer.!
    0,3SEG:.N(f"g-1')[1
    @FT Re-execute_command_1
    Ù(m.m...amp;_Yes_or_No)"e 0'
    M:.N(f"g-1')&quot;
!^R Pop Minibuffer Ring:! !^R??ets back earlier command, in minibuffer.
Repeated use goes4hrough all4he remembered minibuffer commands
and eventually returns4o the most recent one.  An argument serves as
a repeat count, which can be negative.g    Q..F"N FG 0'		    !* Don't allow this at top level.g    [0
   +"n				    K!?f minibuffer empty, just get4op4hing on ring.!
      <			    !* Rotate forwards if and as desired.g	 i.n[..oi:.n(0)u0
	  j5d zj 5,0i
	 i0,z-5fsword ]..o
	 ...gt;
      -<			    !* Rotate backwards if and as desired.!
	  q.n[..o
	 +-5fsword(+j-5d j5,0i),0fsword
	  ]..o...gt; '
    hk
   i:.n(0)"e fg 0'
    g:.n(0) h			    !* Insert7hat's now on4op of ring.!
!& Mini!?nitialized:! !S Convenient interface4o minibuffer.
See source for calling conventions.!

K Takes string args describing the text4o present to4he5ser
in4he minibuffer, and runs the edited4ext.
The string args are 1) stuff to be edited, to go before4he
pointer, (SA) stuff4o go after4he0ointer, and 0Î0Ã0È4he "mode"
for the minibuffer.  An argument of 1 causes ET...lt;default file>  ET4o be inserted as4he first4hing.
An argument of 25ses the buffer filenames instead of the defaults.!

    m.m ^R_Pop_Minibuffer_Ring[...Y
    q..o,( f[ b bind		    !* Set up new buffer with 1),4he0ointer, (SA)g	     "n iET_ g(-1"e fs d file' "#iBuffer_Filenames f"ew fs d file'')
		  i__ET_'
	     i
	     .( i )j
        )m(m.m&_mini buffer)  !* Edit it,0assing 2 2) along.g    h"e 0'			    !* Buffer empty =) user ^Gd, so do nothing.g    f=:.n(0)B.o"n		    !* If4his command not same as previous minibuffer,g      q.n[..o zj-5d		    !* push4his command onto ring buffer of!
      j 5,0i ]..o		    K minibuffer commands.!
      hx:.n(0)'
    f]b bind ]...Y m:.n(0) w   !* In any case, run it, after restoring normal environment!
!^R Visit File:SM7 D8R Visit new file in selected buffer.
Nonzero numeric argument means file is read-anly.
Nonzero0recomma argument means always at least offer4o save old file.
File name is string argument.g
    QBuffer_FilenamesF"N FS D FILE'
    f:m(m.m Visit_File)
2 D5isit File:SM!C Visit new file in selected buffer.
File name is string argument.
Nonzero numeric argument makes file read-anly;
negative makes buffer read-only4oo.
Nonzero precomma argument means always at least offer to save old file.
We execute Visit File Hook if it is nonzero.
All6isiting of files is by means of this function.g
!* If QJournal_Visit_Version is nonzero,
  7e read in that6ersion, even4hough setting visited version to...gt;.g
    MMM_&_Check_Top_Levelfiles
    "L :I..0 Read'"# :I..0 Visit'	    K Put "Visit" or "Read" in Q0, for prompting.g    5,fB.0_Filefs dfile

!* Some old libraries set4his to 1, then next time give it as
  0recomma arg.  We7ant to make sure4hat precomma arg is always 0.!
    0UInhibit_Write

    [0 [1 [2 0[4
    QBuffer_Index[3

    QVisit_File_Save_OldU0
    "N Q0"E g0''
    FS Modif"N			    K!?f file is modified since last real save,g     Q0"N			    K and7e should0ossibly save it,g      Q0"L O Do Save'
      @FT
Write_out_changes_in_		    !* ask user7hether he wants to save the changes.g      QBuffer_FilenamesU0
      Q0"E @FT buffer'
      "# @FT file_D'
      1M(M.M &_Yes_or_No)"N
   !Do Save!
        1,M(M.M ^R_Save_File)'''

    0FS Read Only
    0,FSZ FS BOUND		    !* Flush all of old file despite bounds.!
    0U:.B(Q0Ñ0ü0»0ó0È8!*bufdat!)	    K Zero out date of last file read or written.g    F[ D FILE
    0FO..Q Journal_Visit_VersionF"G FS D VERSIO'
    °< ER...gt;U()		    K Open file.  Did7e win? !
    Q(N	)L 0,7:G2U1
	 F~1 OPN004_"N
	   F~1 OPN0076"N
             F~1 OPN0077"N
	       F~1 OPN0100"N
	         F~1 OPN0104"N
		   Q2FSERR'''''    !* Error other than file not found => report it!
	?!K @FT (New_File)
	  0 FS ECHO ACT'	    !* File not found => read it as empty.g      "# 0[2 1:< FS!?F CDATE U(N)gt;   K File found => Remember its creation dateg	 FS!?F LINK"N FS!?FILEU4 @FT (Link_to_4)
 0FS ECHO ACT'
	 @Y  Q2U:.B(Q0Ñ0ü0»0ó0È8!*bufdat!) ]2 '	    !* and read it in.  Don't save date if get URK.g    Q4"N 20.ER EC'		    !* If file is link, open link4o get link's6ersion #.!
    F]D FILE
    0FS Modif			    K Until changed, it doesn't need writing.g    0FS X Modif
    FF&1*U:.B(Q3+1(NŒ)*bufnwr!) K Record read-anliness.g    "L -1FS READ ONLY'	    !* Negative arg means make buffer actually read-anly.g    FS D FILEU1 QgBuffer_Filenames	    !* Remember7hat we are6isiting.g    Q1U:.B(Q0Ñ0ü0»0ó0È(NŒ)*bufvis!)	    K Keep buffer4able5p to date so LIST BUFFERS wins.!
    Q(N	)E FS!?F VERSF"LW FS!?F FN(ÕX):F6'' "# 0' U:.B(Q0Ñ0ü0»0ó0È9!*bufver!)
    0U:.B(Q3+10!*bufsav!)	    K Turn auto save off first - force re-init.g    QAuto_Save_DefaultUAuto_Save_Mode   K Turn auto save on if default is on.g    FSZU:.B(Q0Ñ0ü0»0ó0ÈKbufsiz!)	    !* Remember size when read.g    FS ^R MDLY FS ^R MCNT
    J M(M.M &_Process_File_Options)	    !* Set local vars and mode as specified in file.!
    0FO..QVisit_File_HookU1 Q1"N M1 '
    1:M(M.M&_Maybe_Display_Directory)	    K Display dir if QAuto directory display saysg
©amp; Process File Options:SM1 D3 Set mode and local vars from file.
Select4he mode specified at4he front of the loaded file,
and if it's last page specifies local6ariable values,
set them5p.g    [0 [1 [2 [0µ0ó0Á0ü0à[4 .[P  fniPj
    0[5				    !* Q5 is nonzero if major mode has been set.!
    0[6				    K No old or new string vars seen in lcl modes list.g  :< J
    FS OS TECO"N		    !* If on 10X or 20X,!
      :FB EDIT_BY_"L		    K and if it appears4o have an edit history,!
       ...lt;L 1A-;"N 1;'>''	    !* move over comment lines!
      @F	/	<
R
    :FB -*-"L			    !* If 1st nonblank line contains "+"+"+*-"+"+4hen!
      .U1 1:FB:-*-+(N	)E FKC Q1,.X1' K it might be old style "-*-Lisp-*-"+"+ or!
          "# Q1J :FBMode:"L	    K New style and contain "Mode: Lisp,"g	     .,(FB;-*- FKC.)X1'' K!?n either case,0ut mode name in Q1.!
      FQ1"G M(M.M&quot;qMode) 1U5''  K select mode foo.!
    FS OS TECO"N Q5"E 		    K!?f on 20X and didnt set a major mode at all,!
      QBuffer_Filenames F[ DFILE !* use FN(NŒ)
      FS DFN2U1 FQ1"E :I1<Null>' 1,M.M&_qModeU0
      Q0"N M0W 1U5'		    !* Call...amp; FOO Mode if it is definedg      "# J @F_
L
         F~(FILECREATED"E	    !* Special hack4o recognize interlisp files.g           M(M.M!?nterlisp_Mode)W 1U5''''
    ZJ :Z,Z-10000FB		    K Find the start of4he last page,!

"E Z-10000"L J''		    !* or beg of file if file is short and no0ages.!
    .-Z"N			    !* If7e found one or4he other,!
      :SLocal_Modes"L		    !* search for4he start of them local6ars.g	Q5"E (M.M...amp;_Init_Buffer_Locals)  !* Flush all but permanent local variables.g	     :IModeFundamental'
	.( FKC 0X0 )J		    K??et4he line prefix.!
	-:"E C'  :X1	    K??et4he line suffix.!

	1(R´)*5,3(T|)i2		    K Make a syntax4able for0arsingg				    K4he string values.!
	*5:f35S¶	    !* It4hinks ^] is a Lisp escape.g	"*5:f35| !'!	    !* It4hinks dquote is string delimiter.! 
	< L .-Z;		    !* Then look at each line for4he local6ariable.g	  FQ0F~0"N !<©gt;'	    !* Ignore lines not starting with0refix.g	  FQ0C -15."E !<©gt;'	    !* Ignore blank lines, in case prefix is null.!
	  4F~END:@;
	  .,( S: .-2,.+1F=::"E C'	    K Scan over name of6ariable.  Win for ...:.g	      ).-j0ª0ó0¹	    !* Put name of variable or ^R character into Q3.!
	  .u6 @f	_l	    K Skip over indentation4o value.g	  1a-0Ö0Ã0·0§0ë"ei31..d	    K!?s it aiuoted string6alue?!
	     .+1,(@fll).-1x4
	     ]..d
	     @:i4"4" !''!'
	  "# .( :\u4 )-."ei6-Î'   K Read as number.!?f no digits, fake out test below.!
	     .,( :s1		    !* Did the digits, plus leading and4railing spaces,!
:w .)@f_	"n	    K account for everything on4he line before4he suffix?g	       i6,.x4''	    K!?f not, it is an old-fashioned string6alue.!
	  F~0µ0ó0Á0ü0àMode"E
	    -[Initial_Local_Count !* But avoid flushing any locals we just made.!
	    M(M.M H_Mode)
	    -
S QP UNW
	    !<©gt;'
	  FQ0Ð0ü0ì0ë(T|)G3-"E	    K!?f the local name is a ^R character,!
	   M4 M(M.M Make_Local_Q)G ©lt;!>'	    K Execute it to get4he local6alue.!
	  Q4 M.L&quot;3		    !* Make4he6ar local.!
	  >
	-1U5''
   ...gt;(  K Save the results of4he errset.g      K* Here, Q5 is positive if all we did is set the major mode,!
      !** in which case7e already did & Set Mode Line.g      Q5:"G M(M.M &_Set_Mode_Line)'
      )"E J&quot;'
    TMSM@FT
    Error_processing_file's_mode_or_local_variables
     0FS ECHO ACT
    J 
dind File:! !C Visit a file in its own buffer.
If4he file is already in some buffer, select that buffer.
Otherwise, visit the file in a buffer named after4he file.g
    mMM_&_Check_Top_Levelfiles
   iBuffer_Filenamesf"e w' f[D File
    5,fFind_File[0 etD ]0	    !* Read in the argument.!

    FS D FN1:F6( FS D FILE(	    K??et4he filenames and just the FN1.g    F]D FILE )[0µ0ó0Á0ü0à)[4		    !* Q3 gets the filenames, Q4 the FN1.g    Q3 M(M.M...amp;_Find_File)[1	    !* Ask what buffer the specified file is in.!
    FQ1"G
      Q1 M(M.M Select_Buffer)	    K Already in some buffer => select it.g      QBuffer_FilenamesF[D FILE  K!?f cdate of file in buffer equals4hat of file we7ouldg      °< ER...gt;"L '
      FS IFCDATEU1 EC		    !* read now, just return.  Otherwise, must re-visit file.g      Q1-Q:.B(QBuffer_Index+8!*bufdat!)"E '
      FS Modif"N !"!
	FT 2 2 2 2hile_you've_been_editing_this_file,_it_has_changed_on_diskg	   You_may_lose_some_work_if_you_are_not_careful.
	  !?_will_leave_you_what_you_have_edited,_not_what_is_on_disk.
	  !?_suggest_that_you_file_this_out_under_a_different_name_and
	  4hen_SRCCOM_the_two_files.
	    '
      !"!
      FT Since_EMACS_last_visited_or_saved_this_file,
         it_has_been_changed_on_disk.
	 Luckily,_you_haven't_edited_the_buffer_since_then.
	 Should_I_read_in_the_version_from_disk
      M(M.M &_Yes_or_No)"L 1,M(M.M Revert_File)'
      0U..H&quot;'
    Q4 U1 [2			    !* Else get4he FN1 as string, as desired buffer name.!
  !Retry!
    1,Q(M.M...amp;_Find_Buffer)U2	    !* Does it exist?g    Q2+1"G
      M.M List_BuffersF[Help Mac
      0Ñ0ü0ÄM(M.M &_Read_Line) A_buffer_named_1_already_exists.
	  Type_buffer_name_to_use,_or_CR_to_reuse_°_U1
      F]Help Mac
      FQ1"L 0U..H&quot;'			    K!?f he rubs out, abort.!
      FQ1"G Qg4 O Retry''	    !* If he specifies something,7arn if4hat too exists.!
    Q4 M(M.M Select_Buffer)	    K Select the appropriate bufferg    ET&quot;0¯0í0ü0Í			    !* and set its filenames to4he specified ones.g    FF&1"N 'M(M.M Visit_File)	    !* and visit the file in it.!
   &quot;
!Auto Save Mode:! !C Turn Auto Save on or off.
Zero or negative argument => Auto Save mode is turned off.
Positive argument => it is turned on.  No arg =>4oggle mode on or off.
We save under the filenames you visited, if possible,
when Auto Save Visited File is nonzero.  Otherwise, we save
under the filenames in Auto Save Filename.
When you visit a file, Auto Save is4urned on or off according to
the6alue of Auto Save Default.g
    1fs mode ch
    qbuffer_index[1
K Q0 gets -1 if auto save mode should be turned on.g    ff"ei:.b(q1+10!*bufsav!)"'e[0'	    K No arg => that is iff the mode7as off.!
    "# "'g[0'			    K Otherwise, mode is on if arg is...gt; 0.g
    0F[VARMAC			    K Set QAuto Save Mode4o match the truth.g    Q0UAuto_Save_Mode		    !* But it should not call4his function again.!
    F]VARMAC

    q0"e 0u:.b(q1+10Kbufsav!) 0' !* Just4urning it off is4rivial.!
   
    1,m(m.m&_Auto_Save_Setup)	    K Actually turn auto saving on.g    0
!& Auto Save Setup:SM1 D3 Turn on Auto Saving, initializing6ariables.!

K
A nonzero0recomma argument means   if7e should be saving as auto save file and already are, do nothing.!

    QBuffer_Filenames[0µ0ó0Á0ü0àQ3F"N F[D FILE'
    FS CLKINTF"E+4*60*60' FS CLKINT	    !* Arrange to auto-save after 2 2 2-8 mins of idle time.!
    -m0			    K 1 => save as6isited names, else laterg				    K Q0 is set4o filenames to save as.!
    QBuffer_Index[1
    [(N)[4

K!?t is ok to save as4he6isited filenames if:
there is a visited file,
we are6isiting the most recent version,
the file actually has a6ersion number (can fail only on ITS),
is not read-only,
the device is one which is fast to7rite on,
and4he5ser has said he likes that kind of auto saving.!
    Q0»0ó0ÁN FS D VERS"E
      Q:.B(Q1+1(NŒ)*bufnwr!)"E
        FSDDFAST"N
	  QAuto_Save_Visited_File"N
	    g0			    K!?f we should save as visited filenames,0ut 1 in Q0.!
	    '''''

!* Figure out names4o save as, if not visited names.g
    Q0-1"N
      qAuto_Save_Filenamesf[d file
      fsOSTeco"e		    !* ITS.  Use buffer number.g        °< 2 2 2,6:g(fsDFN1:f6)u2	    !* If Auto Save Filenames fn1 ends with 00!
	    f~(N)00"e		    !* then replace7ith buffer number.g	      0,4:g(fsDFN1:f6)u2   !* (T|) First 2 2 2 letters from Auto Save Filenames.g	     i:.b(q1+7Kbufnum!):\u4   !* 4: Buffer number for4his buffer.!
	      fq4-(l4)fq4:g4u4	    !* Get at most low (N)digits of buf num as string.g	      f6(Æ$È)4fsDFN1'...gt; ' K Set4o autosave filenames.!
      "#
        fq(fs d fn(ÕX))"e		    !* On Twenex,5se buffer name as extension!
	  q:.b(Q1+1!*Bufnam!)fs DFN2''	    K5nless otherwise specified.g      fs d fileu0'

    "N Q0-1"N			    K!?f saving as auto save file is wantedg      Q:.B(Q1+10Kbufsav!)U2	    !* and already happening with same filenames,g      FQ(N	)G F~(Æ$È)0"E&quot;''''	    !* then7e don't need4o do anything.g
    Q0U:.B(Q1+10!*bufsav!)	    K Now4urn on right style of autosaving.!
    0UAuto_Save_Count		    K 0 auto saves done since saving was turned on.g
    Q0-1"E			    K!?f saving as visited filenames,g      '			    !* we are done.g
!* Saving as special auto save filenames, in Q0 and in FS D FILE.!
    FS D VERSION"E		    K!?f multiple saves are0ossible, find number of lowestg      0U()      °< -(N)FS D VERSW ER	    K one4hat exists. !?t will be first one deleted.g	  FS IF VERSU2
	  0 FS D VERSW ER
	  FS IF VERS+1-Q25(N)gt;	    K Q(N)gets4he number versions of the Auto Save file.!
      EC Q2-QAuto_Save_MaxU()    K Compare4hat with desired number.g      Q2< -(N)FS D VERSW @ED...gt;	    K!?f too many, delete some.g      '
    
1 D10evert File:! !C Undo changes4o a file.
Reads back4he file being edited from disk
(or4he most recent auto save file, if that isn't4he same thing).
A numeric argument means ignore the Auto Save files.
A nonzero0re-comma argument waives confirmation.g
    MMM_&_Check_Top_Levelfiles
    QBuffer_Filenames[0
    .[1
    QBuffer_Index[2 [0ª0ü0à
    FF&1"E			    K Choose visited filenames or auto save filenames.!
      Q:.B(Q2+10!*bufsav!)U0µ0ó0Á0ü0àFQ0»0ó0ÁG  !* If7e recently7rote an auto-save file, read it.g	QAuto_Save_Count"N
	  Q0ì0à0'''
    Q0"E :I*No_file_to_revert_from fs err'

    "E			    !* Query,5nless that is inhibited by0recomma arg.g      @ft Restore_file_from_disk
      Ù(m.m&_Yes_or_No)"e 0''

    B[B 0,FSZFS BOUND
    ERD
    QBuffer_Index[()    FS!?F CDATE U:.B(Q2+8Kbufdat!)
    FS IF VERSF"LW FS IF FN2:F6' U:.B(Q(pk)9!*Bufver!)
    @Y  0FS MODIFW 0FS X MODIF
    FS WINDOW+QB:J"L 0L .FS WINDOW'
    Q°J
    FS ^R MDLY FS ^R MCNT
    M(M.M &_Process_File_Options)  K Reprocess local modesg    0FO..Q Visit_File_HookU1	    K Redo user's own0rocessing.g    Q1"N M1'&quot;
!& Auto Save All Buffers:SM1 D3 Auto save all buffers.
We don't need to select a buffer5nless we save it.
Argument is nonzero if have already auto-saved anything.
Nonzero0recomma arg means ignore selected buffer.!

    Q..F-Q.F"N 0'
    FQ.B/5[0 0[1 [..O
    QBuffer_Name[()    [0ª0ü0à    0[4				    !* Q4 nonzero if we have switched buffers.!
    [5
    FN Q4"N Q2M(M.M Select_Buffer)'     !* So4hen we must switch back.g    < Q1-Q0;			    K Look at each buffer.!
      Q:.B(Q1+10!*bufsav!)"N	    K!?f buffer has auto save4urned ong       "'E F"EW F~:.B(Q1+1!*Bufnam!)2'"N !* and is not4he selected bufferg        Q:.B(Q1+4!*bufbuf!)[..O
        FSZ*(FS X MODIF)(]..O)"N  K and has changes in it, and isn't empty,g	  Q:.B(Q1+1Kbufnam!)M(M.M Select_Buffer)  !* then select itg	  1U4
	  Q3"E			    !* Announce4hat we are starting to auto save.!
	    FSRGETTY"N @FT _(Auto_Save)'
	    "# @FT''	    !* (Don't5se FG - it screws FS TYISRC$) g	  1U3
	  F[D FILE		    !* Don't clobber TECO default filenames.!
	  °< 2,1M(M.M ^R_Save_File)...gt;"L
	      QBuffer_FilenamesU5
	      FG @FT_(Auto_Save_error_for_I!) 60 0FS ECHO ACT'
	  '''
      Q:.B(Q1)+Qg1 >
   &quot;
!^R Save File:! !^R Save visited file on disk if modified.
An argument means do an auto-save type save.
"1," as argument indicates that4his call7as not explicitly
requested, and4he5ser should be asked to confirm if
the file has become a lot smaller.  "2," means an Auto Save,
which should abort rather4han query if anything might be7rong.!

    Q..F-Q.F"N 0'
    QBuffer_Index[5
    FF&1"E FS MODIF"N 
S X MODIF''	    !* If7ant real save,g				    K Make FS X MODIF nonzero if7e need a real save.!
    Q:.B(Q5+10!*bufsav!)[1	    K Q1 has the BUFSAV slot.g    QBuffer_Filenames[0	    K Q0 gets appropriate filenames4o save as.g    m()			    !* Q2 has 1 if saving as buffer filenames, -1 if not.g    FQ1"G FF&1"N
	Q1U0 -g(Qk)'
    Q0"N Q0'F[D FILE

    Q(N	)G
     Q:.B(Q5+1(NŒ)*bufnwr!)"N	    K!?f saving as visited file and file read-anly,g       "N 0'		    K if implicit, don't do it.g       @FT File_is_read_only.__Save_anyway K!?f explicit, ask user if he means it.g       1M(M.M&_Yes_or_No)"E 0''
     Q0"N			    K!?f saving as visited file7Xëknown filenames,g      FS DD FAST"L		    !* if dev is disk or fast4o open,!
        1:< ER FS!?F CDATE[4 EC   K See if date of existing file matches when7e lastg	    Q:.B(Q5+8Kbufdat!)[3   !* read or wrote the file.!
	    Q4"N Q0»0ó0ÁN Q4-Q0»0ó0ÁN	    K!?f not,7arn user he may be losing.g	      :I*A FS ECHO DIS
	      @FT The_file_now_on_disk_is_not_what_you_last_visited_or_savedg
	      FQ1"L 0UAuto_Save_Count'
	      -2"E @FT Not_auto_saving_0.  !* Auto save should never askiuestions.!
	             5 50 0FS ECHO ACT'
	      FS X MODIF"N @FT Should_I_write_the_file_anyway
	                    1M(M.M &_Yes_or_No)"E 0''
	      "# @FT Luckily_you_have_not_edited_the_buffer_since_then.
		     Use_Revert_File_to_read_the_version_off_disk.
		 0FS ECHO ACT'
	      ''' >'''

    FS X MODIFIED"E		    !* If don't need to7rite since no changes,g      @FT			    K4ell the user so.g      (No_changes_need_to_be_written)
      FQ1"L FF&1"E
        0UAuto_Save_Count'' K 2 2 2 2ants real save => mark last auto save as real.!
      0FS ECHO ACT'

    Q2"G			    !* If saving for real, not as Auto Save filenames,!
      Q0"E "N '		    K No file6isited => if implicit, just don't save.g	@M(M.M Write_File) '    K!?f explicit, ask for filenames.g      FS OS TECO"N		    !* On Twenex,g       fs xjname [j
       f~jSNDMSG*(f~jHERMES)"n    !* Unless from cretinous Twenex mail program!
         0FS D VERS"N		    !* always save as new6ersion,!
	   FS D FILEU0
	   Q0U:.B(Q5+(NŒ)*bufvis!)    !* and permanently clobber visited version to 0.!
	   1FS MODE CH
	   Q0UBuffer_Filenames''''

    "N 2 2*FSZ-(2*Q:.B(Q5+11!*bufsiz!))"L  K!?f file has shrunk, ask for confirmation.g      -(N	)E @FT
(File_has_shrunk_--_not_auto-saving_D) 5 50 0FSECHO ACT'
        0F[TYI SOURCE
	@FT
File_has_shrunk_a_lot.__Save_anyway
	@FG (M.M...amp;_Yes_or_No)"E 0FS ERR'''

    Q1"N FQ1"L			    !* If7e auto-save as6isited file!
      QAuto_Save_Max-1"E	    K and only want one auto save,!
        QAuto_Save_Count"G	    K and7e have at least one auto save,g	  Q:.B(Q5+9KBufver!)FS D VERS	    !* re-use4he last version number.!
	  1,M(M.M Write_File)	    K 2 2 2 2rite; 1, says don't clobber visited version.g				    K No need now4o increment count or delete anything.!
	  FF&1"E		    K!?f real save, say7e have no auto saves.!
	    0UAuto_Save_Count'
	  0''''
    Q(l4)M(M.M Write_File)	    K 2 2 2 2rite it.g    Q1"E 0'			    !* Nothing else4o do5nless in Auto Save mode.g
   ..Auto_Save_Count		    !* Incr. # of auto saves done.!
    FQ1"G
      FF&1"N		    !* If7e saved as special auto-save filenames,!
        1FS MODIF		    !* we still need a real save,g	O Del Auto Save''	    K and delete one auto save.gK!?f saving as auto save file names, then if we have saved enough
auto saves recently, delete one of them.!
    "# QAuto_Save_Count-QAuto_Save_Max"G
       !Del Auto Save!
       °< 0 FS D VERSW ER...gt;"E    !* and delete4he Auto Save file N versions back g	 FS!?F VERS(EC)-QAuto_Save_Max F"G FS D VERS
	   °<@ED>''''		    K from what7e just7rote.!

K!?f this is a real save, count of auto saves since last real save is now 0.!
    FF&1"E 0UAuto_Save_Count'
    0
3 D5rite Region:SM!C 2 2 2 2rite region to file.
Specify filenames7ith a suffix string argument.
Two numeric arguments may be5sed to specify4he region,
which otherwise is from0oint4o mark.!

    5,
Write_Region_to_File[1 ET1
    EI FF"N F' "# :,.'FP EF !* ACTUALLY OPEN AND WRITE!
    FSOFILE[1 FSRGETTY"E :FT'
    :I*C FS ECHO DIS
    @FTWritten:_E  FS ECHO LINES-1"N @FT
'
    0FS ECHO ACT
3 D5rite File:SM!C Store buffer in specified file.
This file becomes4he one being6isited.
Specify filename as string argument.
Precomma arguments have hairy meanings; see4he code.g
!* "1," says called by ^R Save File;
inhibits calling...amp; Set Mode Line and auto-save reinitialization.
Also inhibits setting6isited filenames.
Also means if we lose trying4o write a specific6ersion number
we should write an incremented6ersion number.

"+"+"+1," as argument inhibits5pdating the buffer's file cdate as7ell.

If not at top level (can't switch files now),
doesn't update anything about the current buffer except FS MODIFED,
but does return4he7ritten file's creation date so4he caller can store it.!

    QBuffer_Index[(N)[4
    0F[VBW 0F[VZW                 !* Write whole bfr regardless of virtual boundsg    :F"L Q.F-Q..F"E		    K!?f at4op level, default to buffer filenames.g      Q:.B(Q(pk)(NŒ)*bufvis!)F"N FS D FILE'''
    5,1FWrite_File[1 ETE	    K Set default names and open file.!
    F[D FILE ET[TECO]_OUTPUT 0FS D VERSW
   ...lt; °< EI >F"E 0;'U4		    !* Try with different6ersions!
       F~(0,7:G4)OPN0ª0"N	    !* If7e get error because two people4rying at once,g         F~(0,7:G4)OPN0750"N
	   Q4FS ERR''		    !* Try other version numbers!
       &77777.FS D VERS>	    !* till7e find one7hich is not in5se.!
    F]D FILE
    FS OF CDATE [3		    K Remember file date.g    HP				    K 2 2 2 2rite4he data.g    -1"E :'1< EF >+0U4	    !* Close the file. !?f ^X=1, save any error code.g    Q4"L F~(0,7:G4)OPN0750"E	    K!?f can't write specific6ersion,!
           0FS D VERS EF'	    !* Write a new version.g	 "# Q4FS ERR''
    0FS MODIF			    K?!ave written out => can flush without writing it again.!
    0FS X MODIF
    +1"E FSRGETTY"E O NoPrint'' !* Don't announce auto saves on0rinting tty.g    FSOFILE[1 FSRGETTY"E :FT'
    :I*C FS ECHO DIS
    @FTWritten:_1  FS ECHO LINES-1"N @FT
'
    0FSECHO ACT
  !No Printg    Q..F-Q.F"N Q0µ0ó0Á0ü0à'		    K File written.  If not from EMACS's current buffer, that's all.!
    FSZ U:.B(Q(pk)Kbufsiz!)	    !* Update last saved size even if auto save.!
    FS ^R MDLY FS ^R MCNT
    :"L			    K!?f precomma arg not -1,g      Q3 U:.B(Q2+8Kbufdat!)	    !* update last saved file date and version.g      FS OF VERSF"L
        FS OFILEF[D FILE FS DFN(ÕX):F6(
	    F]D FILE)' U:.B(Q(pk)9!*bufver!)
      
S MODE CH'
    "N 0'			    K!?f doing ^R Save File, return -- filename not changed.!
    FS D FILEU1
    M(M.M Set_Visited_Filename)&quot;1
    0
1 D3et Visited Filename:SM!C Change visited filename, without writing file.
What EMACS believes to be the name of the visited file
is set from a string argument.  No file's name is actually changed.g
    MMM_&_Check_Top_LevelFiles
    QBuffer_FilenamesF"EW' F[D FILE
    5,
Visited_Filename[1 ET1	    !* Set default names.g    FS D FILEU1 QgBuffer_Filenames	    !* Remember7hat we are6isiting.g    Q1U:.B(QBuffer_Index+2Kbufvis!)	    !* Keep buffer table up4o date so LIST BUFFERS7ins.g    0[()    0U1 °< ER
	    FS!?FVERSF"LW FS IFFN(ÕX):F6'U1  K 2 2 2 2hat is latest version of4his new file?!
	    FS!?F CDATU()    K 2 2 2 2hat is latest date?!
	    EC>
    Qg:.B(QBuffer_Index+9!*bufver!)
    Q2U:.B(QBuffer_Index+8Kbufdat!)
    0FO..Q Visit_File_HookU1	    !* Execute Visit File?!ook if4here is one.g    Q1"N 1M1'
    Q:.B(QBuffer_Index+10!*Bufsav!)"N	    K!?f auto saving is on,g      1,M(M.M &_Auto_Save_Setup)'  K reinitialize it.!
    1FS MODE CH		    !* Show new filenames in mode line.g    M(M.M&_Maybe_Display_Directory) 0
7 D8R Set File Read-Only:! !^R Make file read-only, or not.
The argument or lack of one is interpreted just as by Visit File:
no argument makes file7ritable,0ositive arg makes file read-only,
negative arg makes file and buffer read-only.!

    QBuffer_Index[1
    FF&1F"N W '[2		    K??et our arg, or 0 if none.!
    Q25:.B(Q1+1(NŒ)*bufnwr!)	    K Set both kinds of read-onliness.!
    Q(N	)'LFS READ ONLY
    Q:.B(Q1+10Kbufsav!)"N	    !* If7e are auto saving, may need to re-init.!
      1,M(M.M...amp;_Auto_Save_Setup)'
    
S MODE CH		    K Cause redisplay of mode line.g    0

K** less fundamental file commands that5se4he TECO default filenames!
!Delete File:SM!Kill File:! !C Delete a file.  Filename is argument.
Invoke7ith ^R Instant Extended Command to see4he defaults.g
    5,4F Delete_File[1
    FS OSTECO"E 20.' ERE	    K Open file, don't chase links,g    FS!? FILE[1		    K just to find out its real name.g    FS OSTECO"E
      @FT Delete_E
      (M.M...amp;_Yes_or_no)"E 0''
    EC ED			    !* Now delete.!
    FS OSTECO"N
      fs echo act"n :i*Cfs echo dis'
      @FT Deleted:_E

      0fsecho active'
    M(M.M&_Maybe_Display_Directory)
    0
!Copy File:! !C Copy a file.
Arguments are old filename and new filename.
The defaults are left set to4he old filename.g
    5,4F Copy_FileFS D FILE
    F[D FILE
      5,
 to_File[1
    :E_1
    M(M.M&_Maybe_Display_Directory)
    0
!Rename File:SM!C Rename a file.
Arguments are old filename and new filename.
The defaults are left set4o the old filename.!

    5,4F Rename_FileFS D FILE
    F[D FILE
      5,1F4o_File[1
    EN1
    M(M.M&_Maybe_Display_Directory)
    0
!Insert File:SM!C!?nsert contents of file into existing4ext.
File name is string argument.  Example:  M-X Insert FileFOO BAR.
The pointer is left at4he beginning, and the mark at the end.g
    5,4F!?nsert_File[1
    ERE			    K OPEN FILE.!
    .,.m(m.m&_Save_for_Undo)Insert_File
    .F[VBW  FSZ-.F[VZ            !* NARROW BOUNDS TO!?NCLUDE NO CHARS, AT PTg    @Y				    K ACTUALLY READ!?T.g    1 M(M.M&_Maybe_Display_Directory) !* SOMETHING TO READ WHILE TAPE!?S SPINNING.!
    J Z:?!			    K SET MARK AT END.!
!Append4o File:! !C Append region to end of specified file.
The range to7rite can also be specified7ith numeric args.!

    5,F Append_to_File[1
    ET1
    Q..O[0 FF"E :-B,.-B'	    !* PUT CURRENT BUFFER!?N Q0.  COMPUTE RANGE TO WRITE
°F   "# -B,-B' F(	    !* SUBTRACTING B FROM BOTH #S, SINCE G0!?S RELATIVE TO B.g        F[ B BIND                  K READ FILE!?NTO NEW BUFFER.!
        EW			    !* START COPYING OLD FILE!?NTO NEW FILEg        °<ER>"E
          5FY                       K READ 1 WD AHEAD SO DETECT EOF AND REMOVE PADDING!
         ...lt; ZJ 500 FY             K COPY 10K AT A TIME.g            Z-51(eå)0-5:;             K??OT ALL 2 2 2 2E ASKED FOR =) COPY OUT,g            B,51(eå)0P B,500K>      !* SAVING THE LAST WORD FOR NEXT TIME.!
          ZJ 5<0,0A-0»0ó0ÁN 1,0A:@;' -D>  !* DELETE TRAILING ^C OR ^@S IN LAST WORDg          '
        ) G0                        K THEN STICK ON THE REGION WE ARE APPENDINGg    HP EF EC
    fsOFileu1 @ftWritten:_1
   0fsEchoAct
    M(M.M&_Maybe_Display_Directory)K SOMETHING TO READ 2 2 2 2HILE TAPE IS SPINNING.g    0
!Prepend to File:SM!C Append region4o start of specified file.
The range4o write can also be specified with numeric args.g
    5,F Append_to_File[1
    ETE
    Q..O[0 FF"E :-B,.-B'	    K PUT CURRENT BUFFER IN Q0.  COMPUTE RANGE TO 2 2 2 2RITE
!	   "# -B,-B' F(	    K SUBTRACTING B FROM BOTH #S, SINCE??0 IS RELATIVE TO B.!
        )F( "E&quot;'		    !* DO NOTHING!?F RANGE IS EMPTY (CODE BELOW 2 2 2 2OULD LOSE)g        F[ B BIND                  K READ FILE!?NTO NEW BUFFER.!
        EW			    !* START COPYING OLD FILE!?NTO NEW FILEg        ) G0                        K FIRST STICK!?N THE REGION 2 2 2 2E ARE APPENDING!
    1:<ER>"E                       !* IF FILE EXISTSg      < ZJ .U0 Z+4/5*5-Z,0I         !* PAD TO 2 2 2 2ORD BOUNDARY SO FY!?S FAST.!
        500 FY                    !* COPY 10K AT A TIME.!
        Q0J .+4^ô*5-.D              !* FIRST DELETE THE PADDING SO IT!?SNT WRITTEN!
        Z-500-QSE;                !* THE FY??OT ALL 2 2 2 2E ASKED FOR =) COPY OUT,g        B,51(eå)0P B,500K>          !* SAVING THE LAST WORD FOR NEXT TIME.!
      ZJ 5<0,0A-0»0ó0ÁN 1,0A"N 0;'' -D> !* DELETE TRAILING ^C OR ^@S IN LAST WORDg      '
    HP EF EC
    fsOFileu1 @ftWritten:_1
   0fsEchoAct
    M(M.M&_Maybe_Display_Directory)K SOMETHING TO READ 2 2 2 2HILE TAPE IS SPINNING.g    0
!^R Directory Display:! !^R Display current buffer's file's directory.
Uses7hatever directory display macro the user has
selected (value of Directory Lister).  With non-zero argument,
reads directory name from terminal.!

    ff "e QBuffer_Filenamesf"n f[d file'
	         mDirectory_Lister  '  !* If no arg, just do it!
    1,F Directory:_ U..0
    ETB.0 mDirectory_Lister  '
7 D8R Dired:SM7 D8R Run Dired for the directory of4he current6isited file.
With no argument, edits4hat directory.
With an argument of 1, shows only4he6ersions of4he file in4he buffer.
With an argument of 2 2 2, asks for input, which may contain device colon,
directory semicolon, and a file name, only6ersions of4hat file are shown.!

 QBuffer_Filenamesf"n fs D File  K!?f we don't have buffer file names, assume arg of 2 2 2g   -4"L Fm(m.m DIRED) ''    !* With arg of 1 or none,0ass numeric arg and null string!
 1,F Directory;_ f"e ' [..0    !* With an arg of 2 2 2, or no buffer file names!
 m(m.m DIRED) B.0 	    K 2 2 2 2e ask for a string arg and0ass it alongg
</div><div class="naked_ctrl"> <form action="/index.cgi/larger-text" method="get" name="gate"> <p><a href="http://altstyle.alfasado.net">AltStyle</a> 0k0ˆ0c0fY cÛ0U0Œ0_0Ú0ü0¸ <a href="http://pdp-10.trailing-edge.com/mit_emacs_170_teco_1220/01/emacs/files.emacs.html">(-&gt;0ª0ê0¸0Ê0ë)</a> / <label>0¢0É0ì0¹: <input type="text" name="naked_post_url" value="http://pdp-10.trailing-edge.com/mit_emacs_170_teco_1220/01/emacs/files.emacs.html" size="22" /></label> <label>0â0ü0É: <select name="naked_post_mode"> <option value="default">0Ç0Õ0©0ë0È</option> <option value="speech">—óXð0Ö0é0¦0¶</option> <option value="ruby">0ë0ÓNØ0M</option> <option value="contrast">‘M‚rSÍŽâ</option> <option value="larger-text" selected="selected">e‡[WbáY'</option> <option value="mobile">0â0Ð0¤0ë</option> </select> <input type="submit" value="ˆhy:" /> </p> </form> </div>