From 1de710aba20ad287c7e39d9b0b3804b339e6823a Mon Sep 17 00:00:00 2001 From: yonirabkin Date: Mon, 9 Jan 2006 08:38:00 +0000 Subject: add two macros, one to emms.el and the other to emms-playlist-mode.el. The former fixes a bug in which the software attempts to access a completely narrowed buffer and the latter because it looks nicer. darcs-hash:20060109083856-be80e-475149a8911856cab9d2dd6f5143381c53afdcae.gz --- emms.el | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'emms.el') diff --git a/emms.el b/emms.el index 5d3e656..3cbc48e 100644 --- a/emms.el +++ b/emms.el @@ -493,17 +493,23 @@ If no playlist exists, a new one is generated." (interactive) (emms-playlist-ensure-playlist-buffer) (let ((inhibit-read-only t)) - (widen) - (delete-region (point-min) - (point-max))) - (run-hooks 'emms-playlist-cleared-hook)) + (widen) + (delete-region (point-min) + (point-max))) + (run-hooks 'emms-playlist-cleared-hook)) + +(defmacro with-widened-buffer (&rest body) + `(save-restriction + (widen) + ,@body)) ;;; Point movement within the playlist buffer. (defun emms-playlist-track-at (&optional pos) "Return the track at POS (point if not given), or nil if none." (emms-playlist-ensure-playlist-buffer) - (get-text-property (or pos (point)) - 'emms-track)) + (with-widened-buffer + (get-text-property (or pos (point)) + 'emms-track))) (defun emms-playlist-next () "Move to the next track in the current buffer." @@ -757,7 +763,7 @@ This is supplying ARGS as arguments to the source." (emms-playlist-update-track) (setq pos (text-property-any (next-single-property-change (point) - 'emms-track) + 'emms-track) (point-max) 'emms-track track)))))))) -- cgit v1.2.3