branch: externals/mpdired commit c13adb90c38a0750de486b73776636cad990b897 Author: Manuel Giraud <man...@ledu-giraud.fr> Commit: Manuel Giraud <man...@ledu-giraud.fr>
ensure (mpdired--bol) boundaries more --- mpdired.el | 116 ++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 61 insertions(+), 55 deletions(-) diff --git a/mpdired.el b/mpdired.el index 0d0c84cee6..ada49ede16 100644 --- a/mpdired.el +++ b/mpdired.el @@ -362,31 +362,32 @@ used for mark followed by a space." string)) (defun mpdired--reset-face () - (let* ((bol (mpdired--bol)) - (eol (line-end-position)) - (type (get-text-property bol 'type)) - (mark (get-text-property bol 'mark))) - (remove-text-properties bol eol '(face)) - (cond ((and mark (= mark ?D)) - (put-text-property bol eol 'face 'mpdired-flagged)) - ((and mark (= mark ?*)) - (put-text-property bol eol 'face 'mpdired-marked)) - ((eq type 'directory) - (put-text-property bol eol 'face 'mpdired-directory)) - ((eq type 'playlist) - (put-text-property bol eol 'face 'mpdired-playlist)) - ((eq type 'song) - (put-text-property bol eol 'face 'mpdired-song) - ;; Add "progress bar" back - (when mpdired--song - (let* ((currid (get-text-property bol 'id)) - (songid (car mpdired--song)) - (elapsed (cadr mpdired--song)) - (duration (caddr mpdired--song)) - (x (/ (* elapsed (- eol bol)) duration))) - (when (and (= currid songid) (> eol (+ bol x))) - (put-text-property (+ bol x) eol 'face 'mpdired-progress)))))) - (set-buffer-modified-p nil))) + (let ((bol (mpdired--bol))) + (unless (>= bol (point-max)) + (let ((eol (line-end-position)) + (type (get-text-property bol 'type)) + (mark (get-text-property bol 'mark))) + (remove-text-properties bol eol '(face)) + (cond ((and mark (= mark ?D)) + (put-text-property bol eol 'face 'mpdired-flagged)) + ((and mark (= mark ?*)) + (put-text-property bol eol 'face 'mpdired-marked)) + ((eq type 'directory) + (put-text-property bol eol 'face 'mpdired-directory)) + ((eq type 'playlist) + (put-text-property bol eol 'face 'mpdired-playlist)) + ((eq type 'song) + (put-text-property bol eol 'face 'mpdired-song) + ;; Add "progress bar" back + (when mpdired--song + (let* ((currid (get-text-property bol 'id)) + (songid (car mpdired--song)) + (elapsed (cadr mpdired--song)) + (duration (caddr mpdired--song)) + (x (/ (* elapsed (- eol bol)) duration))) + (when (and (= currid songid) (> eol (+ bol x))) + (put-text-property (+ bol x) eol 'face 'mpdired-progress)))))) + (set-buffer-modified-p nil))))) (defun mpdired--insert-entry (entry) "Insert ENTRY in MPDired browser view." @@ -820,7 +821,7 @@ an optional communication buffer that would be used instead of (defun mpdired--save-point () (cond ((eq mpdired--view 'queue) (let ((bol (mpdired--bol))) - (unless (> bol (point-max)) + (unless (>= bol (point-max)) (setf mpdired--songid-point (get-text-property bol 'id))))) ((eq mpdired--view 'browser) (setf mpdired--browser-point (point))))) @@ -846,19 +847,22 @@ an optional communication buffer that would be used instead of (mpdired--save-point)) (defun mpdired-listall-at-point () - (let* ((bol (mpdired--bol)) - (type (get-text-property bol 'type)) - (uri (get-text-property bol 'uri))) - (cond ((eq type 'directory) - (mpdired-listall-internal uri)) - ((eq type 'playlist) - (mpdired-listplaylist-internal uri)) - ((eq type 'file) - (message "Cannot browse a file."))))) + (let ((bol (mpdired--bol))) + (unless (>= bol (point-max)) + (let ((type (get-text-property bol 'type)) + (uri (get-text-property bol 'uri))) + (cond ((eq type 'directory) + (mpdired-listall-internal uri)) + ((eq type 'playlist) + (mpdired-listplaylist-internal uri)) + ((eq type 'file) + (message "Cannot browse a file."))))))) (defun mpdired-playid-at-point () - (let ((id (get-text-property (mpdired--bol) 'id))) - (when id (mpdired-playid-internal id)))) + (let ((bol (mpdired--bol))) + (unless (>= bol (point-max)) + (let ((id (get-text-property bol 'id))) + (when id (mpdired-playid-internal id)))))) (defun mpdired-enter () "In the browser view, browses the entry at point. @@ -1052,8 +1056,7 @@ otherwise." (push (cons id (cons type uri)) result))) (forward-line))) ;; No marked, get the entry at point except for the deletion flag. - (unless (or result - (= want ?D)) + (unless (or result (= want ?D)) (let* ((bol (mpdired--bol)) (id (get-text-property bol 'id)) (type (get-text-property bol 'type)) @@ -1122,24 +1125,27 @@ otherwise." (mpdired-next-line))))) (defun mpdired-delete-at-point () - (let ((id (get-text-property (mpdired--bol) 'id))) - (when id - (save-excursion - (forward-line) - (let ((bol (mpdired--bol))) - (unless (>= bol (point-max)) - (setq mpdired--songid-point - (get-text-property bol 'id))))) - (mpdired-delete-or-move-internal id nil)))) + (let ((bol (mpdired--bol))) + (unless (>= bol (point-max)) + (let ((id (get-text-property bol 'id))) + (when id + (save-excursion + (forward-line) + (let ((bol (mpdired--bol))) + (unless (>= bol (point-max)) + (setq mpdired--songid-point + (get-text-property bol 'id))))) + (mpdired-delete-or-move-internal id nil)))))) (defun mpdired-remove-playlist-at-point () - (let* ((bol (mpdired--bol)) - (uri (get-text-property bol 'uri)) - (type (get-text-property bol 'type))) - (when (and type uri - (eq type 'playlist)) - (mpdired--append-message (format "Removing %S..." uri)) - (mpdired-remove-playlist-internal uri)))) + (let ((bol (mpdired--bol))) + (unless (>= bol (point-max)) + (let ((uri (get-text-property bol 'uri)) + (type (get-text-property bol 'type))) + (when (and type uri + (eq type 'playlist)) + (mpdired--append-message (format "Removing %S..." uri)) + (mpdired-remove-playlist-internal uri)))))) (defun mpdired-delete () "Removes song at point from the queue or playlist at point from the