home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 21 / CD_ASCQ_21_040595.iso / dos / prg / c / freedos3 / source / emacs16d / _utils.min < prev    next >
Encoding:
Text File  |  1991-07-19  |  12.1 KB  |  509 lines

  1.  
  2.  
  3.  
  4. Name:Fall-but-last
  5. Return all but the last argument concatenated together.
  6. [*]#(==,arg2,,,(
  7.     arg1
  8.     #(SELF,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)
  9. ))[*]
  10.  
  11.  
  12. Name:Fand
  13. If arg1 returns yes and arg2 returns yes, return arg3 else arg4.
  14. [*]#(==,#(arg1,(#(arg2,yes,no)),no),yes,(arg3),(arg4))[*]
  15.  
  16.  
  17. Name:Fbreak-first
  18. [*]
  19. #(==,##(arg1),,,(
  20.     #(ds,bf-t,#(fm,arg1,(arg2)))
  21.     #(ds,arg1,##(arg1))
  22.     #(==,##(bf-t),,(#(SELF,(arg1),(arg2))),(##(bf-t)#(es,bf-t)))
  23. ))
  24. [*]
  25.  
  26.  
  27. Name:Fbreak-last
  28. [*][*]
  29.  
  30.  
  31. Name:Fbreak-last-do
  32. [*][*]
  33.  
  34.  
  35. Name:Fexecute-and-mark
  36. Evaluates arg1 and creates a mark around anything it may have put in the text
  37. buffer.
  38. [*]
  39. #(pm,2)
  40. #(is,!)
  41. #(sm,0,<)
  42. arg1
  43. #(sp,0)
  44. #(dm,>)
  45. #(Fset-new-mark,.)
  46. #(sp,1)
  47. #(pm)
  48. [*]
  49.  
  50.  
  51. Name:Ffind-a-string
  52. Find all the strings that match arg1.
  53. [*]#(Ffind-a-match,
  54.     #(Flist-all-strings,arg1)
  55.     #(Fmultiple,(Fprefix-matches,arg1,2),##(ls,(,),F!),SELF)
  56. ,(arg2),(arg3),(arg4),1)[*]
  57.  
  58.  
  59. Name:Ffirst
  60. Given a list of arguments, return only the first.
  61. [*]arg1[*]
  62.  
  63.  
  64. Name:Fflush-input-buffer
  65. Ring the bell and wait one second for the user to stop typing.  Used to prevent
  66. the user from typing ahead when he has already made a mistake.  The first time
  67. give them 250 ms to react.
  68. [*]#(bl)
  69. #(==,##(it,100),Timeout,(
  70.     #(bl)
  71. ),(
  72.     #(SELF)
  73. ))[*]
  74.  
  75.  
  76. Name:Ffourth
  77. Return the fourth argument.
  78. [*]arg4[*]
  79.  
  80.  
  81. Name:Fhead
  82. Return the string that is the head of the ring specified by arg1.
  83. [*]##(gn,##(arg1.head),10000)
  84. #(rs,##(arg1.head))[*]
  85.  
  86.  
  87. Name:Fisupper
  88. #(Fisupper,CHAR,YES,NO) tests the ASCII value of char and executes YES
  89. if the character is an upper case letter or NO if not.
  90. [*]#(g?,65,arg1,(arg3),(
  91.     #(g?,arg1,90,(arg3),(arg2))
  92. ))[*]
  93.  
  94.  
  95. Name:Fleave
  96. Used by redefine and unredefine to position the string pointer.
  97. [*]
  98. #(ds,arg1,(arg3))
  99. #(..,##(gn,arg1,##(--,##(nc,##(gs,arg1)),arg2)))
  100. [*]
  101.  
  102.  
  103. Name:Flist-all-strings
  104. List all strings beginning with arg1 in all libraries.
  105. [*]#(Ffor-all-libs,(SELF-do,arg1),SELF)[*]
  106.  
  107.  
  108. Name:Flongest-prefix
  109. Find the longest common prefix in the comma-terminated list of strings given in
  110. arg1.  Ignore arg2 characters at the beginning of each string.  Define the
  111. string "longest-matched" if one of the strings is equal to the prefix.
  112. Tests:
  113. #(Flongest-prefix,(abc,abc,))##(temp) should be abc#(n?,longest-matched, and longest matched)
  114. #(Flongest-prefix,(abc,abd,))##(temp) should be ab#(n?,longest-matched, and longest matched)
  115. #(Flongest-prefix,(abc,ab,))##(temp) should be ab#(n?,longest-matched, and longest matched)
  116. End of tests.
  117. [*]#(ds,temp,#(Ffirst,arg1))
  118. #(es,longest-matched,temp1)
  119. #(Fmultiple,(SELF-do,arg2),(arg1),SELF)[*]
  120.  
  121.  
  122. Name:Flongest-prefix-do
  123. Find the longest common prefix in arg2 and ##(temp).  Ignore arg1 characters
  124. at the beginning of each string.
  125. Tests:
  126. #(es,longest-matched)#(ds,temp,abcd)#(Flongest-prefix-do,,abc)##(gs,temp) should be abc#(n?,longest-matched, and longest matched)
  127. #(es,longest-matched)#(ds,temp,abc)#(Flongest-prefix-do,,abcd)##(gs,temp) should be abc#(n?,longest-matched, and longest matched)
  128. #(es,longest-matched)#(ds,temp,abc)#(Flongest-prefix-do,,abc)##(gs,temp) should be abc#(n?,longest-matched, and longest matched)
  129. End of tests.
  130. [*]#(ds,temp1,arg2)
  131. #(..,##(gn,temp1,arg1,!!!))
  132. #(ds,temp,##(gn,temp,arg1)#(SELF-do))
  133. #(==,##(go,temp1,!!!),!!!,(
  134.     #(rs,temp1)
  135.     #(..,##(gn,temp,arg1,!!!))
  136.     #(ds,temp,##(gn,temp1,arg1)#(temp))
  137. ))[*]
  138.  
  139.  
  140. Name:Flongest-prefix-do-do
  141. Compare the prefix and the new candidate, character by character.  If this one
  142. matches exactly, define longest-matched.  If this one made the prefix shorter,
  143. undefine longest-matched.
  144. Tests:
  145. #(es,longest-matched)#(ds,temp,)#(ds,temp1,)#(Flongest-prefix-do-do,a,b) should be #(n?,longest-matched, and longest matched)
  146. #(es,longest-matched)#(ds,temp,)#(ds,temp1,)#(Flongest-prefix-do-do,b,a) should be #(n?,longest-matched, and longest matched)
  147. #(es,longest-matched)#(ds,temp,)#(ds,temp1,)#(Flongest-prefix-do-do,a,a) should be a#(n?,longest-matched, and longest matched)
  148. #(es,longest-matched)#(ds,temp,b)#(ds,temp1,b)#(Flongest-prefix-do-do,a,a) should be ab#(n?,longest-matched, and longest matched)
  149. #(es,longest-matched)#(ds,temp,a)#(ds,temp1,b)#(Flongest-prefix-do-do,a,a) should be a#(n?,longest-matched, and longest matched)
  150. #(es,longest-matched)#(ds,temp,a)#(ds,temp1,)#(Flongest-prefix-do-do,a,a) should be a#(n?,longest-matched, and longest matched)
  151. #(es,longest-matched)#(ds,temp,)#(ds,temp1,a)#(Flongest-prefix-do-do,a,a) should be a#(n?,longest-matched, and longest matched)
  152. [*]#(==,(arg1),(arg2),(
  153.     #(==,(arg1),!!!,(
  154.         #(ds,longest-matched)
  155.     ),(
  156.         (arg1)
  157.         #(SELF,##(go,temp,!!!),##(go,temp1,!!!))
  158.     ))
  159. ),(
  160.     #(==,(arg2),!!!,(
  161.         #(ds,longest-matched)
  162.     ),(
  163.         #(==,(arg1),!!!,,(
  164.             #(es,longest-matched)
  165.         ))
  166.     ))
  167. ))[*]
  168.  
  169.  
  170. Name:Flooking-at
  171. Args:(regexp,if-yes,if-no)
  172. [wjm 4/7/90]
  173.     Return <if-yes> if the string after point matches <regexp>, else 
  174. return <if-no>.  Mark 0 is the initial point, and mark 2 is the end of the
  175. match.
  176. [*]
  177. #(pm,3)
  178. #(sp,$>)
  179. #(sm,1)
  180. #(sp,0)
  181. #(lp,(regexp),,y)
  182. #(==,#(l?,.,1,1,2,(#(==,#(rc,1),0,y))),y,(if-yes),(if-no))
  183. #(pm)
  184. [*]
  185.  
  186.  
  187. Name:Flookup
  188. Search through the string named in arg1 for arg2 (callers
  189. responsibility to ensure that the match is complete), and execute
  190. everything up to the next arg3.  If there is no arg2 in the list,
  191. execute arg4.
  192. [*]#(..,##(fm,arg1,(arg2),(
  193.     #(gn,arg1,1000)
  194. )))
  195. #(fm,arg1,(arg3),(arg4))
  196. #(rs,arg1)
  197. [*]
  198.  
  199.  
  200. Name:Floop
  201. Return arg2 copies of arg1, active
  202. [*]#(g?,arg2,0,(arg1#(SELF,(arg1),#(--,arg2,1))))[*]
  203.  
  204.  
  205. Name:Fmax
  206. #(Fmax,A,B) returns the numerically greater of A and B.
  207. [*]#(g?,arg1,arg2,arg1,arg2)[*]
  208.  
  209.  
  210. Name:Fmodulus
  211. #(Fmodulus,ARG) Returns ARG if ARG is positive,
  212. else -ARG if ARG is negative (special cases: 1 for void and `-').
  213. [*]#(==,(arg1),,1,(
  214.     #(==,(arg1),-,1,(
  215.         #(g?,0,(arg1),(#(--,0,(arg1))),(arg1))
  216.     ))
  217. ))[*]
  218.  
  219.  
  220. Name:Fmore
  221. Given a list of items, show them on the screen, one per line, pausing every
  222. #(lv,b) lines to let the user press a key.  If they quit in the middle, force
  223. a redisplay because that's what #(Fhit-any-key) does
  224. [*]#(ds,line,1)
  225. #(==,#(Fmultiple,SELF-do,##(temp,(,)),SELF),q,(
  226.     #(rd)
  227. ),(
  228.     #(Fhit-any-key)
  229. ))[*]
  230.  
  231.  
  232. Name:Fmore-do
  233. [*]#(ds,line,##(++,##(line),1))
  234. #(g?,##(line),##(lv,bl),(
  235.     #(ow,([More?]
  236. [More?]))
  237.     #(Fcase,#(g),
  238.         (C-m,(#(ds,line,##(lv,bl)))),
  239.         (Return,(#(ds,line,##(lv,bl)))),
  240.         (q,(q#(ds,list.Fmore,(,)))),
  241.         (#(ds,line,2))
  242.     )
  243.     #(ow,(
  244. ))
  245. ))
  246. #(ow,arg1(
  247. ))[*]
  248.  
  249.  
  250. Name:Fmultiple
  251. #(Fmultiple,STRING,LIST,LISTNAME) will execute #(STRING,LIST ELEMENT) where LIST
  252. consists of LIST ELEMENTS seperated by commas.  Note that LIST can not be
  253. scanned, otherwise the commas will be converted to argument seperators.  Use
  254. parentheses to protect LIST, or use a neutral function to return its results
  255. unscanned.
  256.     Fmultiple can be used recursively if you specify different
  257. LISTNAMES for each list.  #(Fmultiple,foo,bar,SELF) works nicely.
  258.  
  259. [*]#(ds,list.arg3,(arg2))
  260. #(SELF-do,(arg1),##(fm,list.arg3,(,),!!!),arg3)
  261. [*]
  262.  
  263.  
  264. Name:Fmultiple-do
  265. [*]#(==,arg2,!!!,(#(es,list.arg3)),(
  266.     #(==,arg2,,,(#(arg1,arg2)))
  267.     #(Fbreak,,(
  268.     #(SELF,(arg1),##(fm,list.arg3,(,),!!!),arg3)))))[*]
  269.  
  270.  
  271. Name:Fmv
  272. Rename a function definition to another name.
  273. [*]#(n?,arg1,(
  274.     #(ds,arg2,##(gs,arg1,#(Farglist)))
  275.     #(mp,arg2,#(Farglist))
  276.     #(es,arg1)
  277. ))[*]
  278.  
  279.  
  280. Name:Fonly-last
  281. [*]#(==,arg2arg3arg4arg5arg6arg7arg8arg9,,(
  282.     arg1
  283. ),(
  284.     #(SELF,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)
  285. ))[*]
  286.  
  287.  
  288. Name:For
  289. If arg1 returns yes or arg2 returns yes, return arg3 else arg4.
  290. [*]#(==,#(arg1,yes,(#(arg2,yes,no))),yes,(arg3),(arg4))[*]
  291.  
  292.  
  293. Name:Fpad-to-column
  294. #(Fpad-to-column,COL) will insert enough spaces into the line to
  295. put the point at the given column.
  296. [*]#(For,(==,##(F-indent-tabs-mode),),(g?,##(lv,cs),(arg1)),(
  297.     #(==,##(rm,<),(    ),(#(dm,<)))
  298.     #(is,#(Floop, ,##(--,(arg1),##(lv,cs))))
  299. ),(
  300.     #(is,(    ))
  301.     #(SELF,(arg1))
  302. ))[*]
  303.  
  304.  
  305. Name:Fpad-with
  306. Pad a string arg2 with arg1 on the left and arg3 on the right until it is
  307. arg4 long.
  308. [*]#(g?,arg4,##(nc,arg2),(
  309.     #(SELF,(arg1),(arg1arg2arg3),(arg3),(arg4))
  310. ),(
  311.     arg2
  312. ))[*]
  313.  
  314.  
  315. Name:Fparens
  316. Surround arg1 with parens.
  317. [*](arg1)[*]
  318.  
  319.  
  320. Name:Fprefix-matches
  321. If arg1 matches arg3 starting at the third character, and the string whose
  322. name starts at the second character doesn't exist, return arg3 starting
  323. at the arg2th character.
  324. [*]#(ds,temp,arg3)
  325. #(..,##(gn,temp,3))
  326. #(==,##(fm,temp,arg1,no good),,(
  327.     #(rs,temp)
  328.     #(..,##(gn,temp,2))
  329.     #(n?,##(gs,temp),,(
  330.         #(rs,temp)
  331.         #(..,##(gn,temp,arg2))
  332.         ##(temp)(,)
  333.     ))
  334. ))
  335. [*]
  336.  
  337.  
  338. Name:Fr
  339. Make arg1 into a string, and substitute parameters arg2 for ARG1, arg3 for ARG2,
  340. etc...  Obviously this is a kludge that will only work to one level, but it's
  341. very handy.
  342. [*]#(ds,temp,(arg1))
  343. #(mp,temp,,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8,ARG9)
  344. #(temp,(arg2),(arg3),(arg4),(arg5),(arg6),(arg7),(arg8),(arg9))
  345. [*]
  346.  
  347.  
  348. Name:Fredefine
  349. Redefine the string arg1 so that it appears to contain only arg2.
  350. [*]
  351. #(Fleave,arg1,##(nc,(arg2)),
  352.     ##(nc,##(arg1))
  353.     /^/
  354.     #(rs,arg1)
  355.     ##(gs,arg1)
  356.     (arg2)
  357. )
  358. [*]
  359.  
  360.  
  361. Name:Fregexp-quote
  362. Quote an ordinary string so that any metacharacters will be interpreted as
  363. ordinary characters.
  364. #(Fregexp-quote,^$.*[]\)
  365. [*]#(ds,temp,arg1)
  366. #(mp,temp,,^,$,.,*,+,[,],\)
  367. ##(temp,\^,\$,\.,\*,\+,\[,\],\\)[*]
  368.  
  369.  
  370. Name:Freplace-head
  371. [*]#(ds,##(arg1.head),##(gn,value,10000)#(rs,value))[*]
  372.  
  373.  
  374. Name:Fresolve-name
  375. Given a string name in arg1, make sure that it is non-ambiguous and execute arg2
  376. if it is.  If arg3 is non-null, use it as the prefix character.
  377. [*]#(Ffind-a-string,#(==,arg3,,:,arg3)arg1,(
  378.     #(bl)
  379.     #(an,"arg1" not found)
  380. ),(
  381.     arg2
  382. ),(
  383.     #(n?,##(temp),(
  384.         arg2
  385.     ),(
  386.         #(bl)
  387.         #(an,"arg1" is ambiguous)
  388.     ))
  389. ))
  390. [*]
  391.  
  392.  
  393. Name:Fright
  394. Return the rightmost arg2 characters of arg1.
  395. [*]#(ds,SELF temp,(arg1))
  396. #(..,##(gn,SELF temp,##(--,##(nc,(arg1)),arg2)))
  397. ##(SELF temp)
  398. #(es,SELF temp)
  399. [*]
  400.  
  401.  
  402. Name:Fring
  403. [*]#(ds,arg1.size,arg2)
  404. #(ds,arg1.head,arg1.0)[*]
  405.  
  406.  
  407. Name:Frotate
  408. [*]#(ds,arg1.head,#(%%,##(++,##(arg1.head),1),##(arg1.size)))[*]
  409.  
  410.  
  411. Name:Frun-some-functions
  412. Run functions given in the args until one of them fails to return "again".
  413. [*]#(==,#(arg1),again,(
  414.     #(SELF,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)
  415. ))
  416. [*]
  417.  
  418.  
  419. Name:Fsecond
  420. Return the second argument.
  421. [*]arg2[*]
  422.  
  423.  
  424. Name:Fsignum
  425. #(Fsignum,ARG,PLUS,MINUS) Returns PLUS if ARG is positive or void,
  426. else MINUS if ARG is negative or `-'.
  427. [*]#(==,(arg1),,(arg2),(
  428.     #(==,(arg1),-,(arg3),(
  429.         #(g?,0,(arg1),(arg3),(arg2))
  430.     ))
  431. ))[*]
  432.  
  433.  
  434. Name:Fskip-chars-forward
  435. Args:(class,end)
  436. Skips past all characters in the given character class.  If end is non-null,
  437. then it is the mark to stop searching.  Otherwise the search stops at the
  438. end of the buffer.
  439. [*]#(pm,1)
  440. #(lp,[class]*,,R)
  441. #(l?,.,##(==,end,,],end),,0,(
  442.     #(sp,0)
  443. ))
  444. #(pm)[*]
  445.  
  446.  
  447. Name:Ftail
  448. Return the rest of the arguments.
  449. [*]arg2(,)arg3(,)arg4(,)arg5(,)arg6(,)arg7(,)arg8(,)arg9[*]
  450.  
  451.  
  452. Name:Fthird
  453. Return the third argument.
  454. [*]arg3[*]
  455.  
  456.  
  457. Name:Funredefine
  458. Undo the effects of the previous redefine.
  459. [*]
  460. #(ds,temp,##(nc,##(arg1)))
  461. #(rs,arg1)
  462. #(Fleave,arg1,##(fm,arg1,/^/),##(gn,arg1,
  463.     #(--,##(nc,##(arg1)),##(temp))
  464. ))
  465. #(==,##(arg1),,(#(es,arg1)))[*]
  466.  
  467.  
  468. Name:Funrotate
  469. Back up a ring.
  470. [*]#(ds,arg1.head,#(%%,
  471.     ##(++,
  472.         ##(++,##(arg1.head),-1),
  473.         ##(arg1.size)),
  474.     ##(arg1.size)))[*]
  475.  
  476.  
  477. Name:Fwhile-yes
  478. Repeatedly execute arg1 so long as it returns 'yes'.
  479. [*]#(==,arg1,yes,(#(SELF,(arg1))))[*]
  480.  
  481.  
  482. Name:Fwhitespace
  483. Return arg1 if the character to the right is space, tab, or newline else arg2.
  484. If arg3 is non-null, don't match newline.
  485. [*]#(==,##(rm,>), ,(arg1),(
  486.     #(==,##(rm,>),(    ),(arg1),(
  487.         #(==,##(rm,>),(arg3
  488. ),(arg1),(
  489.             #(==,##(rm,>),,(arg1),(arg2))
  490.         ))
  491.     ))
  492. ))[*]
  493.  
  494.  
  495. Name:Fyes-or-no
  496. #(Fyes-or-no,PROMPT,YES,NO) will read a line and execute YES if
  497. that line is 'yes'.  It will execute NO if the line is 'no'.
  498. It keeps trying until a recognized word is entered.
  499. [*]#(ds,value)
  500. #(Freadline,(arg1 ((yes/no)) ),(
  501.     #(Fcase,##(value),
  502.         (yes,(arg2)),
  503.         (no,(arg3)),
  504.         (
  505.             #(an,Please enter 'yes' or 'no'.)
  506.             #(ds,temp,##(it,200))
  507.             #(==,##(temp),Timeout,,(#(Fkbd-in,##(temp))))
  508.             #(SELF,(arg1),(arg2),(arg3))
  509.         )
  510.     )
  511. ))[*]