diff options
author | Michael Olson <mwolson@gnu.org> | 2006-06-07 21:51:00 +0000 |
---|---|---|
committer | Michael Olson <mwolson@gnu.org> | 2006-06-07 21:51:00 +0000 |
commit | db63cada789bce562c80d9db3a941deb32cb4ef0 (patch) | |
tree | 166506e53dd04faf6fedbea4749ef4ee639a36e8 | |
parent | 1fc051476607215c26a353e80b1f45b564415a4f (diff) |
Make emms-property-region bulletproof.
darcs-hash:20060607215113-1bfb2-1d5710b9112fb1ed36d1a65d4ed432d643bdd863.gz
-rw-r--r-- | emms.el | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -1025,10 +1025,21 @@ ignore this." ;;; Helper functions (defun emms-property-region (pos prop) - "Return a pair of the beginning and end of the property PROP at POS." - ;; This +/-1 stuff DTRT, but _is_ it TRT? - (let ((begin (previous-single-property-change (+ pos 1) prop)) - (end (next-single-property-change (- pos 1) prop))) + "Return a pair of the beginning and end of the property PROP at POS. +If POS does not contain PROP, try to find PROP just before POS." + (let (begin end) + (if (and (> pos (point-min)) + (get-text-property (1- pos) prop)) + (setq begin (previous-single-property-change (1- pos) prop)) + (if (get-text-property pos prop) + (setq begin pos) + (error "Cannot find the %s property at the given position" prop))) + (if (get-text-property pos prop) + (setq end (next-single-property-change pos prop)) + (if (and (> pos (point-min)) + (get-text-property (1- pos) prop)) + (setq end pos) + (error "Cannot find the %s property at the given position" prop))) (cons (or begin (point-min)) (or end (point-max))))) |