home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / freemacs / history.min < prev    next >
Internet Message Format  |  1994-03-07  |  4KB

  1. Date:    04/02/90 03:59:21 GMT+1
  2. From: TD12%DDAGSI3@clvm.clarkson.edu
  3. To: Freemacs users discussion list <freemacs@sun.soe.clarkson.edu>
  4. Subject: command history
  5.  
  6. ========================================================================
  7.  
  8. Here's a quick and dirty history package for Freemacs.  It defines M-n and
  9. M-p to scroll the history stack in the minibuffer.  (Up and Down Arrow do
  10. the same job).  Other commands: list-command-history,
  11. edit-command-history, and read-command-history.
  12.  
  13. It's not quite the same as the similar thing in GNU Emacs, it rather works
  14. like the command line editors from the PC world.  But it should be quite
  15. useful anyway. It does not only record extended commands but all
  16. (accepted) input from the minibuffer. This was the easiest thing to do and
  17. is surely useful for extensive query-replace sessions.
  18.  
  19. I hope it doesn't interfere with something Russ has in his mind for future
  20. releases ... :-}.
  21.  
  22. *Please* report bugs and feel free to make suggestions.
  23.  
  24. Enjoy it!
  25. -Thorsten
  26.  
  27. Remark: Since I had to intercept the Freadline.XXX functions anyway, I saw
  28. no point in putting the stuff in the User library.
  29.  
  30.  
  31. Name:Freadline.C-m
  32. Accept the input.
  33. [*]#(ds,value,##(value)##(2nd-half))
  34. #(Fhistory-save,##(value))
  35. #(an)arg1
  36. [*]
  37.  
  38.  
  39. Name:Freadline.Return
  40. Return accepts the input.
  41. [*]#(ds,value,##(value)##(2nd-half))
  42. #(Fhistory-save,##(value))
  43. #(an)arg1
  44. [*]
  45.  
  46.  
  47. Name:Freadline.M-p
  48. [*]#(Fhistory-previous)
  49. #(ds,value,#(history.##(history-ptr)))
  50. again
  51. [*]
  52.  
  53.  
  54. Name:Freadline.Up Arrow
  55. [*]#(Freadline.M-p)[*]
  56.  
  57.  
  58. Name:Freadline.M-n
  59. [*]#(Fhistory-next)
  60. #(ds,value,#(history.##(history-ptr)))
  61. again
  62. [*]
  63.  
  64. Name:Freadline.Down Arrow
  65. [*]#(Freadline.M-n)[*]
  66.  
  67.  
  68. Name:Fhistory-previous
  69. Go down the history stack.
  70. [*]#(g?,##(history-ptr),0,(
  71.     #(ds,history-ptr,#(--,##(history-ptr),1))
  72. ),(
  73.     #(ds,history-ptr,0)
  74.     #(bl)
  75. ))[*]
  76.  
  77.  
  78. Name:Fhistory-next
  79. Go up the history stack.
  80. [*]#(g?,##(F-history-tos),##(history-ptr),(
  81.     #(ds,history-ptr,#(++,##(history-ptr),1))
  82. ),(
  83.     #(ds,history-ptr,##(F-history-tos))
  84.     #(bl)
  85. ))[*]
  86.  
  87.  
  88. Name:Fhistory-save
  89. Store argument on top of the history stack, but only if it's longer than two
  90. characters and distinct from TOS. Go to TOS in any case.
  91. [*]#(ds,history-ptr,##(F-history-tos))
  92. #(g?,##(nc,arg1),2,(
  93.     #(==,#(history.##(history-ptr)),arg1,,(
  94.         #(ds,F-history-tos,#(++,##(F-history-tos),1))
  95.         #(ds,history-ptr,##(F-history-tos))
  96.         #(ds,history.##(history-ptr),arg1)
  97.     ))
  98. ))[*]
  99.  
  100. Name:F-history-tos
  101. Initialize top of history stack.
  102. [*]-1[*]
  103.  
  104. Name:F:list-command-history
  105. [*]#(ds,history-ptr,0)
  106. #(ds,temp)
  107. #(Flist-command-history)
  108. #(Fmore)
  109. [*]
  110.  
  111. Name:Flist-command-history
  112. [*]#(ds,temp,##(temp)#(history.##(history-ptr))(,))
  113. #(g?,##(F-history-tos),##(history-ptr),(
  114.     #(Fhistory-next)
  115.     #(SELF)
  116. ))[*]
  117.  
  118. Name:F:edit-command-history
  119. Write command history in buffer.
  120. [*]#(ds,history-ptr,0)
  121. #(Ffind-or-make-buffer,*command-history*)
  122. #(Flocal-bind-key,K.C-c C-c,F:read-command-history)
  123. #(an,(To install changes, type C-c C-c))
  124. #(Fedit-command-history)
  125. [*]
  126.  
  127. Name:Fedit-command-history
  128. [*]#(is,#(history.##(history-ptr))(
  129. ))
  130. #(g?,##(F-history-tos),##(history-ptr),(
  131.     #(Fhistory-next)
  132.     #(SELF)
  133. ))[*]
  134.  
  135. Name:F:read-command-history
  136. Read command history from the current buffer.
  137. [*]#(sp,[)
  138. #(ds,history.0,##(rm,$))
  139. #(ds,history-ptr,0)
  140. #(ds,F-history-tos,0)
  141. #(Fread-command-history)
  142. #(ds,F-history-tos,##(history-ptr))
  143. [*]
  144.  
  145. Name:Fread-command-history
  146. [*]#(Fhistory-save,##(rm,$))
  147. #(sp,$>)
  148. #(==,##(rm,>),,,(
  149.     #(SELF)
  150. ))[*]
  151.  
  152.