diff --git a/tp.el b/tp.el index d2e9142..7121d47 100644 --- a/tp.el +++ b/tp.el @@ -1755,85 +1755,6 @@ Unlike `tp-regexp', this deeply merges nested properties." (properties (cdr parsed))) (tp--regexp-apply pattern properties #'tp--deep-merge-apply object))) -;;; Utility functions - -(defun tp-in (property &optional value start end) - "Get all regions with PROPERTY in current buffer. -If VALUE is specified, only return regions where PROPERTY equals VALUE. -If START and END are specified, limit search to that region. -Returns list of (START END PROPERTIES) for each match." - (let ((beg (or start (point-min))) - (finish (or end (point-max))) - (regions nil)) - (save-excursion - (goto-char beg) - (while (< (point) finish) - (let* ((props (tp-at (point))) - (prop-val (plist-get props property))) - (when (and prop-val - (or (null value) - (equal prop-val value))) - (let ((region-start (point)) - (region-end (next-single-property-change (point) property nil finish))) - (push (list region-start region-end props) regions) - (goto-char region-end))) - (goto-char (next-single-property-change (point) property nil finish))))) - (nreverse regions))) - -(defun tp-all (&optional start end) - "Get all regions with any text properties in current buffer. -If START and END are specified, limit search to that region. -Returns list of (START END PROPERTIES)." - (let ((beg (or start (point-min))) - (finish (or end (point-max))) - (regions nil)) - (save-excursion - (goto-char beg) - (while (< (point) finish) - (let* ((props (tp-at (point))) - (region-start (point)) - (region-end (next-property-change (point) nil finish))) - (when props - (push (list region-start region-end props) regions)) - (goto-char (or region-end finish))))) - (nreverse regions))) - -(defun tp-next (&optional point property value) - "Get the next position with text properties after POINT. -If PROPERTY is specified, find next position with that property. -If VALUE is also specified, the property must equal that value." - (let ((pos (or point (point)))) - (if property - (save-excursion - (goto-char pos) - (when-let ((match (tp-forward property value))) - (prop-match-beginning match))) - (next-property-change pos)))) - -(defun tp-prev (&optional point property value) - "Get the previous position with text properties before POINT. -If PROPERTY is specified, find previous position with that property. -If VALUE is also specified, the property must equal that value." - (let ((pos (or point (point)))) - (if property - (save-excursion - (goto-char pos) - (when-let ((match (tp-backward property value))) - (prop-match-beginning match))) - (previous-property-change pos)))) - -(defun tp-goto-next (&optional property value) - "Move point to next text with PROPERTY (optionally equal to VALUE)." - (interactive) - (when-let ((pos (tp-next (point) property value))) - (goto-char pos))) - -(defun tp-goto-prev (&optional property value) - "Move point to previous text with PROPERTY (optionally equal to VALUE)." - (interactive) - (when-let ((pos (tp-prev (point) property value))) - (goto-char pos))) - ;;; Layer reset functions (defun tp-layer-reset ()