diff options
author | 2000-12-14 18:55:02 +0000 | |
---|---|---|
committer | 2000-12-14 18:55:02 +0000 | |
commit | 031631335dc6f338fd9db9f735325bd2e728aeb3 (patch) | |
tree | 3162062901276d79b7b97a937cb34641fc5552c1 | |
parent | 14de42b72e90aa314b086d3a790e4b21ccb40ec4 (diff) |
Add span-object, mapcar-spans
-rw-r--r-- | generic/span-extent.el | 9 | ||||
-rw-r--r-- | generic/span-overlay.el | 22 |
2 files changed, 24 insertions, 7 deletions
diff --git a/generic/span-extent.el b/generic/span-extent.el index 58494a48..d80848d7 100644 --- a/generic/span-extent.el +++ b/generic/span-extent.el @@ -62,9 +62,13 @@ "Delete SPAN." (delete-extent span)) +(defsubst mapcar-spans (fn start end prop &optional val) + "Apply function FN to all spans between START and END with property PROP set" + (mapcar-extents fn nil (current-buffer) start end nil prop val)) + (defsubst delete-spans (start end prop) "Delete all spans between START and END with property PROP set." - (mapcar-extents 'delete-extent nil (current-buffer) start end nil prop)) + (mapcar-spans 'delete-extent start end prop)) (defsubst span-at (pt prop) "Return the smallest SPAN at point PT with property PROP." @@ -101,4 +105,7 @@ A span is before PT if it covers the character before PT." "Function added for FSF Emacs compatibility. Do nothing here." nil) +(defalias 'span-object 'extent-object) + + (provide 'span-extent) diff --git a/generic/span-overlay.el b/generic/span-overlay.el index e3243e52..ea91bbb7 100644 --- a/generic/span-overlay.el +++ b/generic/span-overlay.el @@ -183,12 +183,16 @@ elements = S0 S1 S2 .... [tl-seq.el]" (t (lambda (spans span) (cons span spans)))))) (foldl f nil (spans-at-point pt)))) -(defun spans-at-region-prop (start end prop) +(defun spans-at-region-prop (start end prop &optional val) (let ((f (cond - (prop (lambda (spans span) - (if (span-property span prop) (cons span spans) - spans))) - (t (lambda (spans span) (cons span spans)))))) + (prop + (lambda (spans span) + (if (if val (eq (span-property span prop) val) + (span-property span prop)) + (cons span spans) + spans))) + (t + (lambda (spans span) (cons span spans)))))) (foldl f nil (spans-at-region start end)))) (defun span-at (pt prop) @@ -225,9 +229,13 @@ Re-attaches SPAN if it was removed from the buffer." "Set the end point of SPAN to VALUE." (set-span-endpoints span (span-start span) value)) +(defsubst mapcar-spans (fn start end prop &optional val) + "Apply function FN to all spans between START and END with property PROP set" + (mapcar fn (spans-at-region-prop start end prop val))) + (defsubst delete-spans (start end prop) "Delete all spans between START and END with property PROP set." - (mapcar 'delete-span (spans-at-region-prop start end prop))) + (mapcar-spans 'delete-span start end prop)) (defun map-spans-aux (f l) (cond (l (cons (funcall f l) (map-spans-aux f (span-property l 'before)))) @@ -298,4 +306,6 @@ FIXME: new hack added nov 99 because of disappearing overlays. Behaviour is still worse than before." (set-span-property span 'priority 100)) +(defalias 'span-object 'overlay-object) + (provide 'span-overlay) |