Mercurial > hg > xemacs-beta
comparison lisp/extents.el @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 3ecd8885ac67 |
children | 0d43872986b6 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
1 ;;; extents.el --- miscellaneous extent functions not written in C | 1 ;;; extents.el --- miscellaneous extent functions not written in C |
2 | 2 |
3 ;; Copyright (C) 1993-4, 1997 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1993-4, 1997 Free Software Foundation, Inc. |
4 ;; Copyright (C) 2000 Ben Wing. | |
4 | 5 |
5 ;; Keywords: internal, dumped | 6 ;; Keywords: internal, dumped |
6 | 7 |
7 ;; This file is part of XEmacs. | 8 ;; This file is part of XEmacs. |
8 | 9 |
23 | 24 |
24 ;;; Synched up with: Not in FSF. | 25 ;;; Synched up with: Not in FSF. |
25 | 26 |
26 ;;; Commentary: | 27 ;;; Commentary: |
27 | 28 |
28 ;; some help from stig@hackvan.com here. | 29 ;;; Authorship: |
30 | |
31 ;; Created 1995 Ben Wing. | |
32 ;; mapcar-extents (and extent-list?) from stig@hackvan.com, c. 1996. | |
29 | 33 |
30 ;;; Code: | 34 ;;; Code: |
31 | 35 |
32 ;; an alternative to map-extents. | 36 ;; an alternative to map-extents. |
33 (defun mapcar-extents (function &optional predicate buffer-or-string from to | 37 (defun mapcar-extents (function &optional predicate buffer-or-string from to |
51 *result*)) | 55 *result*)) |
52 nil)) | 56 nil)) |
53 buffer-or-string from to nil flags property value) | 57 buffer-or-string from to nil flags property value) |
54 (nreverse *result*))) | 58 (nreverse *result*))) |
55 | 59 |
56 (defun extent-list (&optional buffer-or-string from to flags) | 60 (defun extent-list (&optional buffer-or-string from to flags property value) |
57 "Return a list of the extents in BUFFER-OR-STRING. | 61 "Return a list of the extents in BUFFER-OR-STRING. |
58 BUFFER-OR-STRING defaults to the current buffer if omitted. | 62 BUFFER-OR-STRING defaults to the current buffer if omitted. |
59 FROM and TO can be used to limit the range over which extents are | 63 FROM and TO can be used to limit the range over which extents are |
60 returned; if omitted, all extents in the buffer or string are returned. | 64 returned; if omitted, all extents in the buffer or string are returned. |
61 | 65 |
63 extents that overlap the range (i.e. begin or end inside of the range) | 67 extents that overlap the range (i.e. begin or end inside of the range) |
64 are included in the list. FROM and TO default to the beginning and | 68 are included in the list. FROM and TO default to the beginning and |
65 end of BUFFER-OR-STRING, respectively. | 69 end of BUFFER-OR-STRING, respectively. |
66 | 70 |
67 FLAGS controls how end cases are treated. For a discussion of this, | 71 FLAGS controls how end cases are treated. For a discussion of this, |
68 and exactly what ``overlap'' means, see `map-extents'. | 72 and exactly what ``overlap'' means, see `map-extents'. PROPERTY and VALUE |
73 are also as in `map-extents'. | |
69 | 74 |
70 If you want to map a function over the extents in a buffer or string, | 75 If you want to map a function over the extents in a buffer or string, |
71 consider using `map-extents' or `mapcar-extents' instead." | 76 consider using `map-extents' or `mapcar-extents' instead. |
72 (mapcar-extents 'identity nil buffer-or-string from to flags)) | 77 |
78 See also `extents-at'." | |
79 (mapcar-extents 'identity nil buffer-or-string from to flags property value)) | |
80 | |
81 (defun extent-at-event (event &optional property before at-flag) | |
82 "Return the smallest extent under EVENT, if any. | |
83 PROPERTY, BEFORE, and AT-FLAG are as in `extent-at'." | |
84 (let* ((win (event-window event)) | |
85 (p (event-point event))) | |
86 (and win p (extent-at p (window-buffer win) property before at-flag)))) | |
87 | |
88 (defun extents-at-event (event &optional property before at-flag) | |
89 "Return a list of all extents under EVENT. | |
90 PROPERTY, BEFORE, and AT-FLAG are as in `extent-at'." | |
91 (let* ((win (event-window event)) | |
92 (p (event-point event))) | |
93 (and win p (extents-at p (window-buffer win) property before at-flag)))) | |
73 | 94 |
74 (defun extent-string (extent) | 95 (defun extent-string (extent) |
75 "Return the string delimited by the bounds of EXTENT." | 96 "Return the string delimited by the bounds of EXTENT." |
76 (let ((object (extent-object extent))) | 97 (let ((object (extent-object extent))) |
77 (if (bufferp object) | 98 (if (bufferp object) |