branch: externals/listen commit 2357aadce6730a1f528248e041ef5fe40121874a Author: Adam Porter <a...@alphapapa.net> Commit: Adam Porter <a...@alphapapa.net>
Fix: (listen-queue-play) Workaround vtable limitations --- README.org | 4 ++++ docs/README.org | 4 ++++ listen-queue.el | 23 +++++++++++++++++------ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/README.org b/README.org index fe6c28eea6..e47c40c877 100644 --- a/README.org +++ b/README.org @@ -352,3 +352,7 @@ Feedback and patches are welcome. ** Copyright assignment Listen.el is published in GNU ELPA and is considered part of GNU Emacs. Therefore, cumulative contributions of more than 15 lines of code require that the author assign copyright of such contributions to the FSF. Authors who are interested in doing so may contact [[mailto:ass...@gnu.org][ass...@gnu.org]] to request the appropriate form. + +** Known issues + +- Queue buffers that are not visible during playback are not updated automatically (i.e. to show the currently playing track). This is due to a limitation of the ~vtable~ library (see [[https://debbugs.gnu.org/cgi/bugreport.cgi?bug=69837][bug #69837]]). diff --git a/docs/README.org b/docs/README.org index 0e63ca81d2..45efd3063e 100644 --- a/docs/README.org +++ b/docs/README.org @@ -365,6 +365,10 @@ Feedback and patches are welcome. Listen.el is published in GNU ELPA and is considered part of GNU Emacs. Therefore, cumulative contributions of more than 15 lines of code require that the author assign copyright of such contributions to the FSF. Authors who are interested in doing so may contact [[mailto:ass...@gnu.org][ass...@gnu.org]] to request the appropriate form. +** Known issues + ++ Queue buffers that are not visible during playback are not updated automatically (i.e. to show the currently playing track). This is due to a limitation of the ~vtable~ library (see [[https://debbugs.gnu.org/cgi/bugreport.cgi?bug=69837][bug #69837]]). + * COMMENT Export setup :noexport: :PROPERTIES: :TOC: :ignore this diff --git a/listen-queue.el b/listen-queue.el index b2c5b18e64..38c846510b 100644 --- a/listen-queue.el +++ b/listen-queue.el @@ -353,12 +353,19 @@ select track as well." (setf (listen-queue-current queue) track (map-elt (listen-player-etc player) :queue) queue) (listen-queue-with-buffer queue - (listen-save-position - (goto-char (point-min)) - (when previous-track - (listen-queue--vtable-update-object (vtable-current-table) previous-track previous-track)) - (listen-queue--vtable-update-object (vtable-current-table) track track)) - (listen-queue--highlight-current)))) + ;; HACK: Only update the vtable if its buffer is visible. + (when-let ((buffer-window (get-buffer-window (current-buffer)))) + (with-selected-window buffer-window + (listen-save-position + (goto-char (point-min)) + (ignore-errors + ;; HACK: Ignore errors, because if the window size has changed, the vtable's cache + ;; will miss and it will signal an error. + (when previous-track + (listen-queue--vtable-update-object (vtable-current-table) + previous-track previous-track)) + (listen-queue--vtable-update-object (vtable-current-table) track track))) + (listen-queue--highlight-current)))))) (unless listen-mode (listen-mode)) queue) @@ -970,6 +977,10 @@ Delay according to `listen-queue-delay-time-range', which see." (error "Can't find the old object")) (setcar (cdr objects) object)) ;; Then update the cache... + ;; NOTE: This only works if the vtable's buffer is visible and its window has the same + ;; width, or if the selected window happens to have the same width as the one last used to + ;; display the vtable; otherwise, the cache will always be empty, so the old-object will + ;; never be found, and an error will be signaled. (if-let ((line-number (seq-position (car (vtable--cache table)) old-object (lambda (a b) (equal (car a) b))))