<c- SiteSearch??oogle -->

PDP-10 Archives - mit_emacs_170_teco_(eå) - emacs6lisp.emacs
There are no other files named xlisp.emacs in4he archive.
<c-/htdig_noindex-->
!* -*- Teco -*-		Library created and maintained by KMP@MC !

K Bugs, feature requests, etc...					gK									!
!* [Source: KMP (07]þ6/80)]						gK This needs to be sure it has a good ..D or else floating point	gK numbers and other screws will happen -- eg, PRINC+T function in	!
!* RAB;OUTMIS7ill get mistaken for a PRINC if not careful. -kmp	!
!*									gK [Source: CWH]							!
!*  (cond (condition then-clause) (t else-clause))			gK    <=> (IF condition then-clause else-clause)			!
!*									gK [Source: KMP]							!
!*  (and exp1 exp(SA)...lt;=> (IF exp1 exp2)					gK  (or exp1 exp(SA)  <=> (IF (NOT exp1) exp(SA)<span class="naked_sign"> ;</span><span class="naked_aural">(lèŠ)</span> Maybe!?FN, too?		gK  Old-DO          <=> New-DO						gK  (PROG (...) ...) => (LET (..) ...) ; if no RETURN or GOs		!
!*	; Maybe find leading SETQs and move into4he BVL. Super-tricky	!
!*	; due to4he evaluation environment differences.		gK  (TERPRI), (TYO ...), (PRIN1 ...), (PRINC ...), ...<span class="naked_sign"> ;</span><span class="naked_aural">(lèŠ)</span> Sequences only	gK    ...lt;=> (FORMAT ...)							gK									!
!* [Source: RWK (07]þ6/80)						!
!*  Do these allow one to do M-X Undo?					gK									!
!* [Source: CWH (07]þ6/80)]						gK  You may also7ant to include 2 2 2 2HEN and UNLESS. !? have been5sing	!
!* 4hese recently after RWK convinced me4hey were7inners.  You may	!
!*  also want4o write one completely hairy macro7hich figures out	!
!* 7hich of the above transformations you want applied.  As long as it	!
!*  can be undone7ith M-X Undo, such a frob wouldn't be too dangerous.	!
!*									gK [Source: CWH (07/(h*)_0)] Re: LAMBDA->LET				gK!?7ould0refer it if ((LAMBDA (X) Z) NIL) became			gK (LET ((X NIL)) Z) instead of (LET (X) Z).  Perhaps a switch?		!
!* Also, modernizing ((LAMBDA (X Y) Z) 0 0) inserts a spurious		!
!* space after the first 0.						g
!~Filename~:! !Macros for4ransforming Lisp Code!
XLISP
!& Query Loop:! !& Loop doing4hings and asking for confirmation!

:i*QuerySã[..J[C[0[P

<m();w			    !* Execute Entry Condition		!
 :i* C Change?_  fsechodispw @v K Prompt for input			g @:fi uC			    !* Peek for command			!
 qC-40."e ?uC '"# :fiuC '	    K??et ascii in qC			!
 @ft C_... 		    !* Tell4he5ser we saw input	!
 qC-^"e fi			    !* If cmd = ^			!
  .:ww1:<> oPause'	    K  ??o to0revious			giC f  , . :"l fi		    K!?f cmd = Space or Comma,		!
  .u0 m() q0j			    K   Run change macro		!
 iC-,"e			    !*   If comma, show result		!
    !Pause!			    !*     Come here to0ause		g    :i* C Ok?_ fsechodisp7 @v  !*     Wait7hile (s)he approves	g    :fi uC			    !*     Peek for command		g    qC-40."e ?uC '"# :fiuC '    !*     Get ascii iniC		!
    @ft&quot;C_... 		    K     Tell the user7e saw input	g    qC-_ "e fi		    !*     If space,			g       oLoop'			    !*       4hen go on		!
   iC f QqXx :"l fi		    !*     If Q or X,			!
	'			    !*       4hen Exit			!
   iC-^"e fi			    K    !?f ^,			!
       .:ww°<> oPause'	    !*     Go4o previous		g    qC-"e fi		    K    !?f Control-R,		g        oPause'		    !*       4hen edit and re-pause	g    qC-
"e fi		    !*     If Control-L,		!
        @m(m.m^R_New_Window)	    !*        Redisplay			!
        oPause '		    K        and then0ause		g    qC-?"e  fi		    !*     If ? or Help,		!
       ft Space__=_Continue____C-L_=_Redisplay____C-R____=_Edit
	  Q_or_X_=_Exit________Anything_else_aborts_and_is
	  ______________________reread_as_a_command.
	  --Pause-- oPause'	    K        Show help info		g    '				    K     No Such Option. Exit.	!
 iC-."e&quot;'			    K   Return if dot			!
  oLoop'			    !*   Continue looking if not comma	gqC-"e fi			    !* If cmd = Control-R,		!
  oLoop '			    !*   Edit and Loop			gqC-"e fi			    !* If cmd = Rubout			g :-."n .' fkr oSkipLoop '	    !*   Skip4his entry and find next	gqC-
"e fi		    !* If cmd = Control-L,		!
 @m(m.m^R_New_Window)w oLoop'	    !*   Redisplay and loop		SM qC f ?  :"l fi		    K!?f cmd = ? or?!elp		!
!"! ft Space__=_Replace_entry_and_move_on__________C-L_=_Redisplay
       Comma__=_Replace_entry_and_await_approval___C-R_=_Edit
       Rubout_=_Don't_replace_this_entry
       Period_=_Replace_and_exit___________________Anything_else_exits
       Q_or_X_=_Exit________________________________and_is_reread_as_a_command.
       --Pause-- oLoop '	    !*    Show help info		!
qC f XxQq "l fi		    K!?f cmd = Q or X,			g  &quot;'				    !*    Just exit, eating char	g'				    K Exit if5nknown command		g!Loop! :-."n.' !SkipLoop©gt;	    K Continue looping			g:i*CEnd_of_..Jfsechodisplay
0fsechoactive

!Modernize FUNCTION References:! !S Change (FUNCTION form)  =>  #'form	g
@:i*| :s(FUNCTION( fkc )|,(    !* Search for (FUNCTION		g@:i*| .[0 fll [noquitw -d	    !* Go kill ending0aren		g      q0j 9d @f_
	k  !* Kill (FUNCTION...amp;7hitespace	g      .u0 TMSMi#' 2r		    !* Insert #'			g      m(m.m &_XLISP_Indent_SEXP)   K Re-Indent S-Expression		!
     &quot; 		    K??o to4op of S-Expression	!
   =) TM<SMm(m.m &_Query_Loop)Modernize:_(FUNCTION_exp)_=>_#'exp
				    !* Loop asking about this stuff	!

!Modernize Old CATCH/THROW References:! !S CATCH/THROW => *CATCH\"THROW g
@:i*| :s(CATCH(THROW(	    !* Search for (CATCH or (THROW	g      fkc )|,(		    !*  and hop back over it		!
@:i*| .[0[1 1f[noquitw c @fll	    K!?nsert missing star		g      <:@fll s-;:@; l> @fll	    K Pas first arg			!
      :@fll 1a-;"e !"! :i*CH;	Can't_hack_comment fserr '
      @m(m.m ^R_Transpose_Sexps)   !* Interchange			g      -2@fll !"! i'i0+Î i*	    !* Back5p and quote arg1		g       			    !* Go4o top of S-Expression	g    |) !"<! m(m.m...amp;_Query_Loop)Modernize:_(CATCHl4HROW_form_tag)_=>_(*CATCH\"THROW_'tag_form)
				    K Loop asking about4his stuff	g
!Modernize QUOTE References:SM1 D3 Change (QUOTE form)  =>  'form	!

@:i*| :s(QUOTE( fkc )|,(	    K Search for (QUOTE		g@:i*| .[0 fll [noquitw -d	    !* Go kill ending0aren		g      q0j 6d @f_
	k  !* Kill (QUOTE & whitespace		g      .u0 TMSMi' ¹È		    K!?nsert #'			!
      m(m.m...amp;_XLISP_Indent_SEXP)   !* Re-Indent S-Expression		g       			    !* Go4o top of S-Expression	g    |) !"<! m(m.m...amp;_Query_Loop)Modernize:_(QUOTE_exp)_=>_'exp
				    K Loop asking about4his stuff	g
!Modernize LAMBDA References:! !S Change '(LAMBDA ...)	=> #'(LAMBDA ...) g
@:i*| !"! :s#'(LAMBDA( fkcc )|,( K Search for '(LAMBDA		g@:i*| i# r m(m.m&_XLISP_Indent_SEXP)
   =) TM<"! m(m.m...amp;_Query_Loop)Modernize:_'(LAMBDA_...)_=>_#'(LAMBDA_...)
				    K Loop asking about4his stuff	g
!Modernize MAP References:SM1 D3 Change (MAPxxx '... ...) => (MAPxxx #'... ...)g
@:i*| [0<:s(MAP"e 0'		    K Look for MAP, fail if none	g         .-4u0			    !* Remember0lace7e started from	!
         s:"b @fll '		    K??o to end of printname if not MAPg         @f_	
l	    K Move to beginning of next object	g         !"! 1a-'"ei0j -1 '>     |,(				    !* If just singlequote,7in		g
@:i*| c @fll TMSMs' r i# r m(m.m&_XLISP_Indent_SEXP)
 =) TM<"! m(m.m...amp;_Query_Loop)Modernize:_(MAPx_'fun_...)_=>_(MAPx_#'fun_...)
!Modernize Strings:! !S Search for4hings in=...| => "..."g
@:i*~ :s€"e 0' r -1 ~,(	    K Look for |			g@:i*~ [noquit		    K Defer interrupts			g      f[vbwf[vz		    !* Bind buffer bounds		g      TMSM0,0a-'"e -d '	    !* Maybe delete singlequote		g      .,( s€ -d . )fsbound	    !* Narrow bounds			g      j d <.-z; 1a-/"e c'	    K Loop, skip slashed things	!
	   "# sf"|!'!:"l i/ '' !* Slashify " or |			g           c...gt;			    K Move forward			g      j i"!'!+j i"!'! j	    !* Insert Doublequotes		!
     &quot;			    !* Return				g    ~) !<SMm(m.m &_Query_Loop)Modernize:_|...|_=>_"..." !''!
!Lowercase Lisp Buffer:SM1 D3 Lowercase a buffer of lisp text
respecting things4hat should not get lowercased.g

1 D5ppercase Lisp Buffer:! !S Uppercase a buffer of lisp4ext
respecting4hings that should not get uppercased.!

[S				    K State Register			gj 0uS				    !* Initial state 0			g< .-z;				    !* Stop at end of6irtual buffer	g  qS"e 1af"|!'!:"l 1auS ' '	    !* Complement state on | or "	!
    "# s-qS"e 0uS ' '		    !*  Unless in a= or " already...	!
 iS"e 1@fc '		    K Force case if appropriate	!
  1a-/"e c '			    !* Slash says skip next char	g"ezj'''"# 1a-;"ed:s comments			!
  :c				    !* Go forward			!
>				    !* Loop				gj z				    K Set region around4ext changed	gh				    K Return				!
!Lowercase Lisp Region:SM1 D3 Lowercase a region of Lisp textg
f[vbf[vz			    K Bind buffer bounds	g.,(w.)ffsbound		    !* Narrow bounds		!
m(m.m Lowercase_Lisp_Buffer)	    K Call aux macro		!
!Uppercase Lisp Region:SM1 D3 Uppercase a region of Lisp textg
f[vbf[vz			    K Bind buffer bounds	g.,(w.)ffsbound		    !* Narrow bounds		!
m(m.m Uppercase_Lisp_Buffer)	    K Call aux macro		!
!Change LAMBDA Combination to LET:! !& The name says it, man...g

<0[m()			    !* Bind4emp qregs		!

!Modernize LAMBDA Combinations:SM1 D3 Change ((LAMBDA ...)...) => (LET (...)...)g
@:i*| :s((LAMBDA(fkc)|  ,( 
m.m Change_LAMBDA_Combination_to_LET (
) ) m(m.m...amp;_Query_Loop)LAMBDA_Combinations:_((LAMBDA_...)_...)_to_(LET_(...)_...)
!Modernize NIL Occurrences:SM1 D3 Change NIL to ()!

@:i*| :sNIL( fkcc )=,(
@:i*| 2 2d i()=) m(m.m &_Query_Loop)NIL:_NIL_=>_()
!& XLISP Indent Sexp:SM©amp; Like ^R!?ndent SEXP but4ries not4o err out!

[0				    K Push q0			   g.( 1:<@fll>w .u0 )j		    !* Find end of SEXP		   !
.( °<:fll>w .-q0"g )j 0' 	    !* See if next list is farther g   0,1a-("n )j 0'		    !* Don't fill if no close0areng )j				    !* Resume state and0roceed	   g]0				    K Popi0			   !
f:m(m.m ^R_Indent_Sexp)	    !* Jump4o ^R!?ndent SEXP	   g
!Change Xëto \:! !S Update buffer for the new Lisp backslash syntax!

j @f
l			    !* Jump over blank lines		!
1:fb-*-"e			    K!?f there's no file prop list	g  i;;;-*-Mode:Lisp;-*-
    K  Make a default one		g  js-*-'			    K Search for start of -*-		g°fbEscape:"e			    !* If no escape marked		!
  i_Escape:_Slash;'		    !*  Make a default setting		!
"# :fwl				    K  Go4o head of field		!
   .,(s;-:fwl.)f~slash"n	    K  Compare escape char with slash	!
     :i*CBuffer_not_using_slash_escape_charfsechodisplay
     0fsechoactive l 0,.( j )''  K  Maybe return early		g				    K					!

jnterchange slash and backslash:! !S Swap slash and backslash !

j
@:i*| :< :s57"e zj 0;' 0,-:"d 0,-2a:"a 0,1a:"d 2r 0;''' > .-z= ,(
@:i*|  i#/S¶= (
) ) m(m.m...amp;_Query_Loop)Change_s‰to_\:__Maybe_change_octal_57_to_#/S¶

j
@:i*| :< :s47"e zj 0;' 0,-:"d 0,-2a:"a 0,1a:"d 2r 0;''' > .-z= ,(
@:i*|  0,1a-."e d' i#]å | (
) ) m(m.m &_Query_Loop)Change_/_to_\:__Maybe_change_decimal_47_to_#]å

j
@:i*| :< :s#o57"e+j 0;' 0,s:"d 0;' > .-z= ,(
@:i*|  i#/S¶= (
) ) m(m.m...amp;_Query_Loop)Change_s‰to_\:__Maybe_change_#o57_to_#/S¶

j
@:i*| :s slash = ,(
@:i*| 5r -4f~BACK"e -4d '
		    "# 1a-s"e iback'
			     "# -L"e iBACK'
				      "# iBack fs''' 5c= (
) ) !""""SMm(m.m &_Query_Loop)Change_/_to_\:__Maybe_interchange_``slash''_and_``backslash

j z
h

<kÔre>