Google
 

Trailing-Edge - PDP-10 Archives - mit_emacs_170_teco_1220 - emacs/fjw.emacs
There are no other files named fjw.emacs in the archive.
!* -*- TECO -*-!
!~FILENAME~:! !FJW's EMACS macros for general use!
FJWMAC
!& Babyl Command Hook:! !S Modeline displays before message.!

 -1"e					!* Before message redisplay.!
	fr'				!* Display mode line before message.!
!# Babyl _:!  !C# Label msg with RemindNow!

f@m(m.m Remind Me Of This Message)w

!# Babyl %:! !C# Move to nth previous message with some label.!

-@m(m.mNext Labeled Message)w	!* Be sure to return NO value that!
					!* the Babyl arg gets flushed.!
!& Ask Yes/No:! !S Read in a yes or no answer.
Clears echo area and prompts with STRARG (Y or N)?
!

[0				    !* Push 0!
:i0			    !* 0: Prompt!

!Retry!				    !* Retry tag!
:i*C0 (Y or N): fsEchoDisplayw	!* Display prompt!
fi:fc[1				    !* 1: Response character!
@ft
				    !* Display CRLF!
q1f YN"l @fg oRetry'	    !* If not a Y or N, reprompt.!
q1-Y"e -1'0
!^R Redisplay Window:! !^R without moving it.
Without argument simply redisplays the window.
With an argument, tries to choose new window putting point on numargth line.
Negative args count from the bottom.
C-U as argument redisplays the line containing point.!

ff"efswindow(f+)fswindoww'

FSRGETTY"E
M(
FS^RINIT)'
FS^RARGP&6"E
-1,(FS^RVPOS)FSTYOHASHWH'
@:F
0
!& Get Form Name:!  !S Get Form Name, what else?!

[1[2
m.m & Form Help Macrof[HelpMacro
:i1Form name (or ? for list): 
7fsEchoDisplay			    !* Ring Bell!
3,m(m.m & Read Line)1u2
q2
!& Form Help Macro:!  !S List of Forms libraries available.!

fsQPPtr( f[BBind f[DFile erEMACS:FORMS.TYPES @y ht
	      )fsQPUnwindw		!* Display the whole list!
:i*CfsEchoDisplayw  0 fsEchoActivew    !* Clear echo area!
@ftForm name: 

!& Get Terminal Description:! !S Get terminal type and speed (Twenex Only)!

fsTTYNbr-1"e m(m.mSet Terminal)TVI912'
fsTTYNbr-2"e m(m.mSet Terminal)DM1520'
fsTTYNbr-3"e m(m.mSet Terminal)HP2645'
fsTTYNbr-4"e m(m.mSet Terminal)DM1520'
fsTTYNbr-5"e m(m.mSet Terminal)PRINTING'
fsTTYNbr-6"e m(m.mSet Terminal)TK4025'
fsTTYNbr-7"e m(m.mSet Terminal)PRINTING'
fsTTYNbr-10"e m(m.mSet Terminal)PRINTING'
fsTTYNbr-16"e m(m.mSet Terminal)VT132'

0fo..qTerminal Type"n
      qTerminal Type[2w
      m(m.mSet Terminal)2w'

m(m.mSet Terminal)GLASS	    !* Start out as GLASS!

[1[2[3				    !* Push needed q-regs!
fsXUName			    !* J: Username!
:i3VT100			    !* 3: Default terminal type!

0fo..qDefault Terminal Type"n
      qDefault Terminal Typeu3w'
q3u2
0f[HelpMac			    !* Temporarily disable this!

7fsEchoDisplay			    !* Ring Bell!
< m(m.m& Ask Yes/No)Use 3 for Terminal Type?"e	!* Ask user!
				    !* If no, !
	m.m& TRMTYP Help MacrofsHelpMac   !* A "?" will list choices!
	:i1Terminal Type (or ? for list):  !* 1: Prompt !
	7fsEchoDisplay		    !* Ring Bell!
	3,m(m.m& Read Line)1u3' !* 3: Type !

1:< m(m.mSet Terminal)3 >;		!* Set it.!
:i*3  Unknown terminal type name
 fg q2u3>

!& TRMTYP Help Macro:!  !S Gives the list of terminal-type choices.!

fsQPPtr( f[BBind f[DFile erEMACS:EMACS.TERMINALS @y ht
	      )fsQPUnwindw		!* Display the whole list!
:i*CfsEchoDisplayw  0 fsEchoActivew    !* Clear echo area!
@ftTerminal Type: 

!& TRMSPD Help Macro:!  !S Gives list of terminal speed choices.!

:ft
One of the following:

300       1200       2400       9600

:i*CfsEchoDisplayw  0 fsEchoActivew   !* Clear echo area!
@ftTerminal Speed: 

!IVORY Setup:! !C Setup for hacking Ivory-based macro libraries!

0m(m.mAuto Fill Mode)		    !* Turn it off!
m(m.mLoad Library)IVORY	    !* and load IVORY!

!^R Flush Multiple CRLFs:! !^R Remove Multiple CRLFs from region.
!

F[VB F[VZ			    !* Save bounds!
FF"N FF FS BOUND'
"# .,(W).F FS BOUND'	    !* Set bounds to region, for the moment.!
b,zm(m.m& Save for Undo)Flush Multiple CRLFs	!* Make us undoable.!
zj 0a-12."n i
'				    !* Make sure it ends with CRLF!
m.m^R Delete Blank Linesui	    !* Set this.!
j <.-z;
    mi				    !* Delete any blanks around this line!
    l >				    !* and move to next line!
    J Z:			    !* Go to top and restore previous bounds!
    H				    !* Widen bounds to whole buffer!

!^R Display FS Flag Contents:!  !^R in echo area!

[1[2
7fsEchoDisplay			    !* Ring Bell!
1,m(m.m& Read Line)Flag name: u1  !* 1: Flag name.!
1u2				    !* 2: Contents of flag.!
fq2"l 1:\u2'			    !* If neg, then was a string!
				    !* to begin with.!
:i*C2fsEchoDisplayw	    !* Clear echo area!
0fsEchoActivew

!^R DM Return to Superior:! !^R Clears the screen first.!

f+				    !* that was easy enough.!
f m(m.m^R Return to Superior) 
!Flush Duplicate Lines:! !C Sorts buffer and removes duplicate lines.!

[1
 bj
 l bj			    !* Sort so duplicate lines are together.!
 < .-z; x1			    !* 1: Next non-duplicate line with CRLF.!
   <				    !* Point is within non-duplicate line.!
     :s
1; -k 0:l >		    !* Remove duplicates of it.!
   l >

!Fix Buffer Garbage:! !C Reformat a losing region containing ^J's, ^H's, etc.
Replace them with their visual counterparts...
 ^H deletes character before it,
 ^J inserts carriage return + whitespace
 ^M becomes CRLF.
This is undoable.  (I.e. M-X Undo<cr> brings back old region.)!

 [0[1
 bj					!* Go to top of buffer.!
 .u1 fnq1j				!* 1: Auto-restoring point.!
 hm(m.m& Save for Undo)character fix	!* Make this command undoable.!

 !* Convert LF to CRLF + whitespace: !
 j <:s
   ; rd				!* Delete stray linefeeds.!
    fsHPosu0				!* 0: Current column.  Not SHPos since!
					!* wrapping should be handled as is!
					!* visually.!
    i
   q0, i r >				!* Put in CRLF, indentation.!

 !* Backspaces delete themselves and previous character (unless at beginning!
 !* of line): !
 j <:s; 0f-1"g -2d'>		!* ...!


 !* Convert CRs to CRLFs: !
j <  :s
;			!* Find stray ^M.!
      -d i
     >					!* Convert to CR LF.!

 
!^R Kill Top To Here (ECC):! !^R Into ..K.!

1[9				    !* Kill forwards !
b,. m(m.m & Kill Text )
.,. 				    !* better redisplay !
!^R Kill Here To Bottom (ECC):! !^R Into ..K.!

1[9				    !* Kill forwards !
.,z m(m.m & Kill Text )
.,. 				    !* better redisplay !
!^R Fill Indented Region (ECC):! !^R Find minimum indentation in region.
Binds Fill Prefix to the minimum indentation of the lines in region.
Does an Untabify over the region before, and a Tabify afterward, so that
            indentation is canonicalized and treated rigidly.!
!* 1, NUMARG means justify instead of fill.  Note:  the ..k-saved region is
 * not really the original one, but will have been untabified.!

 fsWidth[1[2			    !* 1: minimum indentation so far.!
 f[VZ f[VB :,.ffsBoundariesw !* Bounds narrowed around region.!
 j m(m.mUntabify)		    !* All tabs to spaces.!
 j <.-z; @f l		    !* Next line, past indentation.!
    fsSHPos,q1fu1u1 l>	    !* 1: Minimum indentation so far.!
 z: j				    !* Reset region to untabbed buffer.!
 q1,32:i*[Fill Prefix		    !* Bind prefix to space indentation.!
 "n 1,'@m(m.m^R Fill Region)w    !* Fill or justify.!
 j m(m.mTabify)		    !* Back to tabs.!
 z: j				    !* Leave region around final one.!
 h
!^R Justify Indented Region (ECC):! !^R Find minimum indentation in region.!
!* See ^R Fill Indented Region (ECC) for more details.!

 1,@:m(m.m^R Fill Indented Region)
!^R Next Real Line Beginning (ECC):! !^R Inserts CRLF if end of buffer.!

 :l .-z"E			    !* If no CRLF after this line, !
    .,(<i
         > ). '		    !* ...Put one in.!
 l w 1 			    !* Else just down ARG lines.!
!^R Jump to End of Screen Text (ECC):! !^R Last non-blank line on screen.
ARG means go down from point to end of line before blank.
No ARG:
If screen is full, and last line is non-blank, then searches back for a
    blank line, and from there back to non-blank to try to put cursor on
    last non-blank line before a blank region.!

 ff"N :s


	  "L wfkcc w1 ''	    !* No next before-blank, use last line.!

 f[ vbw f[ vzw		    !* Save virtual buffer boundaries.!
 fs lines f"E fs height-(fs echolines+1)' [.0    !* .0: Height of window.!
 :f				    !* Ensure a valid window.!
 fs window [.1			    !* .1: Buffer position of window top.!
 q.1+bj				    !* Go to top of window.!
 .,z fs boundariesw		    !* Set buf boundary at window top.!
 1:< q.0-1,0 :fm :l >		    !* Go to end of last screen line.!
 fs hposu.1			    !* .1: Hpos of last line on screen.!
 .-z"E q.1"G w 1 ''		    !* Last buf line is non-blank, on screen.!
 q.1"G				    !* Last screen line is non-blank, !
    -:s

   "E  w 1 ' l'		    !* ...so look back for a blank line to!
				    !* start searching from.!
 -:s

"L c '				    !* Go back to end last non-blank line.!
				    !* If no last nonblank, stay.!
 w 1 				    !* Exit.!
!^R Paragraph To Screen Top (ECC):! !^R First line of para is put on top line.
If an ARG is given the first line of the ARGth para back is used.
MARK is left at the end of the current para.
In Lisp or InterLisp Modes, put first line of DEFUN at top line.!

 .( (f~ModeLisp)*(f~ModeInterLisp)"E  !* A Lisp mode.!
       .:F[SSTRING		    !* Using C-M-A code...!
       -:S
(()"L"L0'L''		    !* Point at defun.!

    "#				    !* Not LISP mode.!
       f^m(m.m^R Mark Paragraph)w	    !* . at first line, MARK last.!
       2f=
      "E l''			    !* Non-blank line at top.!

    0^m(m.m^R New Window)w	    !* Put that line at top.!
    )j				    !* Point back where was.!
 w 1 
!^R Send Mail Using Babylm:!  ! AutoLoads BABYLM!

F:m(m.aBabylm& Mail Message)

!& Common Startup:!  !S Common Startup stuff.!

0fo..qDumped EMACS fsTTYMacrof"nfsTTYMacro'w

fsTTYMacrof"n[1 m1 ]1'w

0fo..qInit Vars Processed"e		!* If not yet done it, process!
      M(M.M & Process Init Vars)	!* EMACS.VARS.!
      1m.vInit Vars Processedw'	!* Do not do it again.!

m(m.m & Get Terminal Description)	!* Get terminal type.!

fsXUName :f6 [6			!* Get user's home directory name!

:i*6m.vBabyl CC Tow		    !* Force auto-Cc of these!
:i*6m.vCC Tow		    !* Same for SEND!
etDSK:fsHSnamefsDSnamew	    !* Make sure directory defaults to user!

!* On non-meta keyboards, allow Alt 1 2 to mean an arg of 12.!

FS %TOFCI"E			    !* If terminal has Meta-key...!
      M.M ^R Autoarg[0 460.-1[1
      10< Q0,%1^ FS ^R CMAC>  Q0U..-'

!& Make Auto-Save Filename:!  !S Inserts buffer name to save name.!

0FO..QAuto Save Same Filename"E    !* Create new autosave!
				    !* filename for this buffer !
      fsDFN1:f6[4			!* Get FN1 (Buffer name)!
      fsMSName:F6[5			!* Get user name !
      :I*DSK:5AUTOSAVE.4.0M.LAuto Save Filenames'

!& Startup EMACS:!  !S Startup for EMACS!

m(m.m & Common Startup)
m(m.m Kill Variable)MM & Slow Old Minibuffer
m(m.m & SetUp SLOWLY Library)	    !* For some reason...!
m(m.m Load Library)MODLIN	    !* and load TNX version!

1:<QFind File Inhibit Write m.vInhibit Write>

FQ(0FO..QAuto Save Filenames)-1"L
      fsMSName:F6[0
      :I*DSK:0AUTOSAVE.MAIN;0 m.vAuto Save Filenames ]0'

@:i*| m(m.m& Make Auto-Save Filename) |m.vBuffer Creation Hookw

fsXUName:F6[J
ETJ.;0 ]J
fsMSNamefsDSName

0[0 0[1 0[2

fsXJName:f6[J				!* J: Job name, as a string.!
F[DFILE

f~jHERMES"E
    f=Editor Typeermes]"N 
        1,m(m.m & Get Library Pointer)HERMES"e
            m(m.m Load Library)HERMES''
    '

F~jMM"E
    f=Editor TypeMMAIL"N 
        1, m(m.m & Get Library Pointer)MMAIL"e
            M(M.M Load Library)MMAIL'''

F]DFILE

!* Process the JCL!

Z"E					!* Get JCL, or use whatever previous!
    FJ J @F				!*  init file left in buffer.!
    K'
					!* Flush leading spaces and CRLF!
					!* if line is empty.!

ZJ ."N					!* Process JCL command -!
					!*  extract filenames and commands!
       0,0A-
"E -D'			!* REMOVE CR AND LF AT END IF ANY *!
"E -D' 0,0A-
       J :S"N .,Z@FX1 -D'		!* IF COMMANDS TO EXECUTE,!
					!*  PUT THEM IN Q1!

       J 7F~(FILE) "E 7D'		!* Delete stupid noise word.!
       J < :S !; -D .,(S! .)K >	!* Delete stupid confirmations.!
					!* Printing them out is reasonable,!
					!* passing them to EMACS is stupid.!

       :S  B,.FX0			!* If name of file to read, put in Q0.!

       < @F K
         11F~(OUTPUT AS)"E 11D'	!* Delete (OUTPUT AS) if stupid EXEC!
					!*  fed it to us.!
	 "# 0,1A-["E .,(S] .)K'	!* Delete any confirmation string!
	    "# 0;'' >			!* If we delete one, check for others.!

       Z"N HFX2'			!* If name of file to output as,!
					!*  put in Q2.!
       '

    HK 0FS MODIFIEDw 0FS XMODIFIED
    0FO..Q Inhibit Help Message"E
      Q0"E Q1"E				!* If no commands or file to read,!
					!*  offer help.!

      m(m.m Print FJWMAC Greeting)	!* Stolen from ECC!
      0fsModifiedw			!* Mark buffer as not modified.!
      FR				!* Show ModeLine now!
      '''
      FQ0-1"L Q1"N M1'			!* No file specified => execute!
      '				!*  commands from JCL and return.!

    1:<					!* maybe we got an unwanted version #.!
      Q0F[ DFILE 0 FS DVERSU3		!* So open to the highest version,!
      ER EC
      FS IF VERS-Q3"N Q3 FS DVERS'	!* and if it is the version we got,!
      FS DFILE U0 F]D FILE'		!* return the file with!
      >					!*  a zero version.!

    0fo..qTags Find File"e
	QInhibit Write,M(M.M Visit File)0'      !* Visit specified file.!
    "# m(m.mFind File)0'		!* unless user usually!
					!*  likes Find File,!
					!* in which case use that instead.!

    Q2"N Q2F[ DFILE 0 FS DVERS
         FS DFILEU2 F]D FILE		!* Reset version number defaults.!
	 M(M.M Set Visited Filename)2'	!* Set filename as specified.!

    Q1"N M1'				!* If JCL held commands, execute them.!
    
!Print FJWMAC Greeting:! !C Salutations and such, saved...
... in Greeting Message. 
Probably ought to print stuff other parts of startup have put in some
variable, e.g. Accumulated Greeting Message.???

Sample greeting:
Teco.1394  EMACS.129  Uptime = 5 days, 2:27:54.  Run-time = 377.688 secs.!

 f[BBindw			    !* Temporary buffer.!

 iTECO. fsVersion\ i  	    !* TECO Version.!
 iEMACS. qEMACS Version\ i      !* EMACS Version.!
 (fsUpTime)-(1000*60*60*1)"l iWatch out!!
 7fsEchoDisplay '		    !* Warning if uptime under 1 hr.!
 iUp:  fsUpTimeu4		    !* 4: Up time in 1000ths!
 q4/(1000*60*60*24)u5		    !* 5: Up time days.!
 q5-1"g q5\ i days,  '		    !* Show days if 1 or more.!
 q5-1"e i1 day,  '		    !* ...!
 q4-(q5*1000*60*60*24)u4	    !* 4: Up time h/m/s in 1000ths!
 q4/(1000*60*60)u5 q5\		    !* 5: Insert up time hours.!
 i: (q4-(q5*1000*60*60))u4	    !* 4: Up time m/s in 1000ths!
 q4/(1000*60)u5 q5\		    !* 5: Insert up time minutes.!
 -1a-:"e r i0 c'		    !* Ensure minutes takes 2 digits.!
 i: (q4-(q5*1000*60))/1000\	    !* Insert up time seconds.!
 -1a-:"e ri0w c'		    !* Ensure seconds takes 2 digits.!
 i.  Run-time: 
 fsRunTime m(m.m& Insert Seconds)
 i secs.  LD:  fsLoadAvu5 i5
				    !* Insert RunTime and Load Average!
 hx* m.vGreeting Messagew	    !* Save and...!
 ht				    !* ...print the greeting.!
 
!& Insert Seconds (ECC):! !S Insert in seconds an ARG in milliseconds.!

 .f[VB fsZ-.f[VZ		    !* Bound buffer to nothing.!
 3,\				    !* Insert millisecs, at least 3 chars.!
 3r i.				    !* Now seconds with decimals.!
 r <0,0a- "E -d'"# b-.; r'>	    !* All spaces before dot are deleted.!
 <:s ;0>			    !* All spaces after dot become 0s.!
 zj 
!C Mode:! !C Set up to edit C code.!

    m(m.mLoad Library)CMODE
    0m(m.mAuto Fill Mode)w		!* Turn Auto Fill off!
    :m(m.mC Mode)
!& C Mode:! !S set up for editing C files.!
    :m(m.mC Mode)
!Sort Mailing List:!  !C Sorts a region containing a mailing list.
Assumes no comments are contained within the region.!

 f[VZ f[VB .,zfsBoundariesw		!* Bounds narrowed from point to end!
 j m(m.mReplace String),-w		!* Remove continuation!
 1f[^p casew				!* Ignore case!
 j :llw				!* First sort the region to!
					!* get the usernames in order!
 j s@$:llw				!* then sort the hostnames!
 j m(m.mReplace String)
,-
w
 zj -4c 2d				!* Kill the last continuation!
 j					!* ends up at the top of region!
 h					!* Widen to whole buffer!

!^R Go To Line:!  !^R Go to arg line in buffer!

 1[0					!* Save qreg; set default to 1!
 ff"nu0'				!* Set qreg to arg, if any!
 j q0-1@l				!* Go to that line, counting!
					!* only CRLFs!
!& Setup FJWMAC Library:! !S Do initial hackery for User
Change some defaults

^X^Z = ^R DM Return to Superior
^XM  = ^R Send Mail Using BABYLM
^X^Y = ^R Display FS Flag Contents
^XT  = ^R Kill Top to Here (ECC)
^XZ  = ^R Kill Here to Bottom (ECC)
^XJ  = ^R Fill Indented Region (ECC)
^XS  = ^R Jump to End of Screen (ECC)
^X^A = ^R Paragraph to Screen Top (ECC)
^XV  = ^R Next Real Line Beginning (ECC)
M-SP = ^R Set/Pop Mark
M-O  = ^R Flush Multiple CRLFs
M-Z  = ^R Go To Line
!