home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / prim / extents.el < prev    next >
Encoding:
Text File  |  1995-06-01  |  2.2 KB  |  52 lines

  1. ;;; extents.el --- miscellaneous extent functions not written in C
  2.  
  3. ;;;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
  4.  
  5. ;; Keywords: internal
  6.  
  7. ;; This file is part of XEmacs.
  8.  
  9. ;; XEmacs is free software; you can redistribute it and/or modify it
  10. ;; under the terms of the GNU General Public License as published by
  11. ;; the Free Software Foundation; either version 2, or (at your option)
  12. ;; any later version.
  13.  
  14. ;; XEmacs is distributed in the hope that it will be useful, but
  15. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17. ;; General Public License for more details.
  18.  
  19. ;; You should have received a copy of the GNU General Public License
  20. ;; along with XEmacs; see the file COPYING.  If not, write to the Free
  21. ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23. ;; an alternative to map-extents.
  24. (defun mapcar-extents (function &optional predicate buffer from to flags
  25.                 property value)
  26.   "Applies FUNCTION to all extents which overlap a region in BUFFER.
  27. The region is is delimited by FROM and TO.  A list of the values returned
  28. by FUNCTION is returned.  An optional PREDICATE may be used to further
  29. limit the extents over which FUNCTION is mapped.  The optional arguments
  30. FLAGS, PROPERTY, and VALUE may also be used to control the extents passed
  31. to PREDICATE or FUNCTION.  See also `map-extents'."
  32.   (let (*result*)
  33.     (map-extents (if predicate
  34.                      #'(lambda (ex junk)
  35.                          (and (funcall predicate ex)
  36.                               (setq *result* (cons (funcall function ex)
  37.                                                    *result*)))
  38.                          nil)
  39.                    #'(lambda (ex junk)
  40.                          (setq *result* (cons (funcall function ex)
  41.                                               *result*))
  42.                          nil))
  43.                  buffer from to nil flags property value)
  44.     (nreverse *result*)))
  45.  
  46. (defun extent-string (extent)
  47.   "Return the string delimited by the bounds of EXTENT."
  48.   ;; by Stig@hackvan.com
  49.   (buffer-substring (extent-start-position extent)
  50.             (extent-end-position extent)
  51.             (extent-buffer extent)))
  52.