home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / mutt / markring.mut < prev    next >
Text File  |  1988-09-26  |  1KB  |  43 lines

  1. ; markring.mut : Maintain a ring of marks so it is easy to jump to 
  2. ;   often referenced places in a buffer.
  3. ; Notes:
  4. ;   Marking regions does not effect the que.
  5. ;   Each buffer has its own que.
  6. ;   When the que is full, the que wraps around.
  7. ;   Be sure to add (init-markring) to buffer-created-hook
  8. ;   Clearing the buffer (or reading in a file) clears all the marks
  9. ;     but does not reset the ring (a hook would be nice, hint hint).
  10. ; uses:
  11. ;   marks: 1..4
  12. ;   buffer-var 0: head of the que, buffer-var 1: tail,
  13. ;   buffer-var 2: items in que
  14. ;   See me.h for the definations.
  15. ; C Durland
  16.  
  17. (include me.h)
  18.  
  19. (defun
  20.   init-markring MAIN
  21.     { (buffer-var Qhead MARK1)(buffer-var Qtail MARK1) (buffer-var Qsize 0) }
  22.   push-mark    ; Put a mark in the que
  23.   {
  24.     (int x)
  25.  
  26.     (arg-prefix (x (buffer-var Qhead)))(set-mark)
  27.     (msg "Mark qued.")
  28.     (if (> (+= x 1) MARKn)(x MARK1))(buffer-var Qhead x)
  29.     (x (buffer-var Qsize))(if (> (+= x 1) MARKn)(x MARKn))
  30.     (buffer-var Qsize x)
  31.   }
  32.   pop-mark    ; Cycle through the que
  33.   {
  34.     (int size x)
  35.  
  36.     (x (buffer-var Qtail))(size (buffer-var Qsize))
  37.     (if (== size 0) { (msg "Mark que empty")(done) } )
  38.     (arg-prefix x)(exchange-dot-and-mark)
  39.     (if (or (> (+= x 1) MARKn) (> x size)) (x 1))
  40.     (buffer-var Qtail x)
  41.   }
  42. )
  43.