From 0987c5a3e0524c37653455965b8bf86d68940b39 Mon Sep 17 00:00:00 2001 From: yonirabkin Date: Sat, 24 Dec 2005 10:57:00 +0000 Subject: make emms-playlist-mode emacs21.4 compatible darcs-hash:20051224105738-be80e-6312a9a6858f8bf4f101176f2e4b9b5e9b6f3950.gz --- emms-playlist-mode.el | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/emms-playlist-mode.el b/emms-playlist-mode.el index 554bed7..aa681a9 100644 --- a/emms-playlist-mode.el +++ b/emms-playlist-mode.el @@ -155,6 +155,43 @@ function switches back to the remembered buffer." (let ((inhibit-read-only t)) (newline))) +;;; -------------------------------------------------------- +;;; Overlay compatability +;;; -------------------------------------------------------- + +(defun find-overlay-emms-track () + "Return the position of the next emms track." + (save-excursion + (while (and (not (eobp)) + (not (get-char-property (point) 'emms-track))) + (goto-char (min (next-overlay-change (point)) + (next-single-property-change (point) 'emms-track)))) + (point))) + +;; Taken from CVS Emacs (2005-12-24) and modified to support Emms2 on +;; Emacs 21.4. The modifications make this function not equivalent to +;; the original `remove-overlays' from which it was copied, so don't +;; try to use it in the same way. +(defun remove-all-overlays (&optional beg end) + "Clear BEG and END of overlays." + (unless beg (setq beg (point-min))) + (unless end (setq end (point-max))) + (if (< end beg) + (setq beg (prog1 end (setq end beg)))) + (save-excursion + (dolist (o (overlays-in beg end)) + (when (eq (overlay-get o nil) nil) + (if (< (overlay-start o) beg) + (if (> (overlay-end o) end) + (progn + (move-overlay (copy-overlay o) + (overlay-start o) beg) + (move-overlay o end (overlay-end o))) + (move-overlay o (overlay-start o) beg)) + (if (> (overlay-end o) end) + (move-overlay o end (overlay-end o)) + (delete-overlay o))))))) + ;;; -------------------------------------------------------- ;;; Killing and yanking ;;; -------------------------------------------------------- @@ -182,7 +219,7 @@ function switches back to the remembered buffer." (when (and emms-player-playing-p (equal (emms-playlist-selected-track) track)) (emms-stop)) - (remove-overlays (point-at-bol) (point-at-eol)) + (remove-all-overlays (point-at-bol) (point-at-eol)) (kill-region (car track-region) (cdr track-region))) (kill-line)))) @@ -259,8 +296,8 @@ FACE should be a... face." (when (not (null emms-playlist-mode-selected-overlay-marker)) (save-excursion (goto-char emms-playlist-mode-selected-overlay-marker) - (remove-overlays (point-at-bol) - (point-at-eol)) + (remove-all-overlays (point-at-bol) + (point-at-eol)) (emms-playlist-mode-overlay-at-point 'emms-playlist-track-face 1)))) @@ -274,8 +311,8 @@ FACE should be a... face." ;; not graceful, but avoids growing as the number of tracks grow. (defun emms-playlist-mode-overlay-refresh () "Remove and re-apply all the overlays in the buffer." - (remove-overlays (point-min) - (point-max)) + (remove-all-overlays (point-min) + (point-max)) (emms-playlist-mode-overlay-all) (setq emms-playlist-mode-selected-overlay-marker nil) (emms-playlist-mode-overlay-selected)) -- cgit v1.2.3