home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / Programming / Source / winterp-1.13 / contrib / doc / rolo-simple.el < prev    next >
Encoding:
Text File  |  1991-10-06  |  3.2 KB  |  86 lines

  1. ;;!emacs
  2. ;;
  3. ;; FILE:         rolo-simple.el
  4. ;; SUMMARY:      Very simple routines to display entries matching a string
  5. ;;                 from a rolodex file.  For those who find "rolo.el" too
  6. ;;                 intimidating.
  7. ;; USAGE:        GNU Emacs Lisp Library
  8. ;;
  9. ;; AUTHOR:       Bob Weiner
  10. ;; ORG:          Motorola, Inc., Communications Sector, Applied Research
  11. ;; E-MAIL:       USENET:  weiner@novavax.UUCP
  12. ;;
  13. ;; ORIG-DATE:     7-Jun-89 at 22:08:29
  14. ;; LAST-MOD:     16-Jun-89 at 00:27:20 by Bob Weiner
  15. ;;
  16. ;; Copyright (C) 1991 Bob Weiner
  17. ;; WINTERP Copyright 1989, 1990, 1991 Hewlett-Packard Company (by Niels Mayer).
  18. ;; XLISP version 2.1, Copyright (c) 1989, by David Betz.
  19. ;;
  20. ;; Permission to use, copy, modify, distribute, and sell this software and
  21. ;; its documentation for any purpose is hereby granted without fee,
  22. ;; provided that the above copyright notice appear in all copies and that
  23. ;; both that copyright notice and this permission notice appear in
  24. ;; supporting documentation, and that the name of Hewlett-Packard, Niels
  25. ;; Mayer, Brown University and Bob Weiner not be used in advertising or
  26. ;; publicity pertaining to distribution of the software without specific,
  27. ;; written prior permission.  Hewlett-Packard, Niels Mayer, Brown University
  28. ;; and Bob Weiner makes no representations about the suitability of this
  29. ;; software for any purpose.  It is provided "as is" without express or
  30. ;; implied warranty.
  31. ;;
  32. ;; This file is not part of GNU Emacs.
  33. ;;
  34. ;; DESCRIPTION:  
  35. ;; DESCRIP-END.
  36.  
  37. (defconst rolo-file "~/.rolodex.otl"
  38.   "User-specific file in which rolodex entries are stored.")
  39.  
  40. (defconst rolo-entry-regexp "^\*+"
  41.   "Regular expression to match the beginning of a rolodex entry.")
  42.  
  43. (defconst rolo-hdr-regexp "^==="
  44.   "Regular expression to match the last line of the rolodex file header.
  45. This header is inserted into rolo-display-buffer before any entries are
  46. added.")
  47.  
  48. (defconst rolo-display-buffer "*Rolodex*"
  49.   "Buffer used to display set of last matching rolodex entries.")
  50.  
  51. (defun rolo-fgrep (string)
  52.   "Find entries in rolo-file matching STRING.
  53. The rolo-file consists of a header terminated by a line which matches
  54. rolo-hdr-regexp.  And rolodex entries beginning with rolo-entry-regexp."
  55.   (interactive "sRolodex string to match: ")
  56.   (let ((obuf (current-buffer)))
  57.     (save-excursion
  58.       (set-buffer (get-buffer-create rolo-display-buffer))
  59.       (erase-buffer)
  60.       (find-file rolo-file)
  61.       (goto-char (point-min))
  62.       (save-excursion
  63.     (if (re-search-forward rolo-hdr-regexp nil t)
  64.         (progn (forward-line)
  65.            (append-to-buffer rolo-display-buffer
  66.                      (point-min) (point)))))
  67.       (re-search-forward rolo-entry-regexp nil t)
  68.       (beginning-of-line)
  69.       (while (search-forward string nil t)
  70.     (re-search-backward rolo-entry-regexp nil t)
  71.     (let ((start (point)))
  72.       (if (re-search-forward rolo-entry-regexp nil t 2)
  73.           (beginning-of-line)
  74.         (goto-char (point-max)))
  75.       (append-to-buffer rolo-display-buffer start (point)))))
  76.     (pop-to-buffer rolo-display-buffer)
  77.     (set-buffer-modified-p nil)
  78.     (select-window (get-buffer-window obuf))))
  79.  
  80. (defun rolo-edit ()
  81.   "Display user-specific rolodex file for editing."
  82.   (interactive)
  83.   (find-file rolo-file))
  84.  
  85. (provide 'rolo)
  86.