* bug#68785: [PATCH] Fix volume refresh bug in mpc
@ 2024-01-28 20:17 john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
[not found] ` <handler.68785.B.170647308131160.ack@debbugs.gnu.org>
0 siblings, 1 reply; 3+ messages in thread
From: john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-01-28 20:17 UTC (permalink / raw)
To: 68785
Tags: patch
When mpd is stopped or paused the volume returned is nil which
causes the string-to-number in mpc-volume-refresh to error.
emacs -Q
M-x toggle-debug-on-error
M-: (setopt mpc-host "hifi.lan")
M-x mpc
…with something in the playlist
M-: (mpc-play)
M-: (mpc-stop)
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
string-to-number(nil)
(mpc-volume-widget (string-to-number (cdr (assq 'volume mpc-status))))
(setq mpc-volume (mpc-volume-widget (string-to-number (cdr (assq 'volume mpc-status)))))
mpc-volume-refresh()
funcall(mpc-volume-refresh)
(progn (funcall (cdr pair)))
(if (or (eq t (car pair)) (not (equal (cdr (assq (car pair) old-status)) (cdr (assq (car pair) mpc-status))))) (progn (funcall (cdr pair))))
(let ((pair (car tail))) (if (or (eq t (car pair)) (not (equal (cdr (assq (car pair) old-status)) (cdr (assq (car pair) mpc-status))))) (progn (funcall (cdr pair)))) (setq tail (cdr tail)))
(while tail (let ((pair (car tail))) (if (or (eq t (car pair)) (not (equal (cdr (assq ... old-status)) (cdr (assq ... mpc-status))))) (progn (funcall (cdr pair)))) (setq tail (cdr tail))))
(let ((tail mpc-status-callbacks)) (while tail (let ((pair (car tail))) (if (or (eq t (car pair)) (not (equal (cdr ...) (cdr ...)))) (progn (funcall (cdr pair)))) (setq tail (cdr tail)))))
(if (equal old-status mpc-status) nil (let ((tail mpc-status-callbacks)) (while tail (let ((pair (car tail))) (if (or (eq t (car pair)) (not (equal ... ...))) (progn (funcall (cdr pair)))) (setq tail (cdr tail))))))
(let ((old-status mpc-status)) (setq mpc-status (mpc-proc-buf-to-alist)) (progn (or mpc-status (cl--assertion-failed 'mpc-status)) nil) (if (equal old-status mpc-status) nil (let ((tail mpc-status-callbacks)) (while tail (let ((pair (car tail))) (if (or (eq t ...) (not ...)) (progn (funcall ...))) (setq tail (cdr tail)))))))
mpc--status-callback()
(closure ((cb)) nil (mpc--status-callback) (if cb (funcall cb)))()
funcall((closure ((cb)) nil (mpc--status-callback) (if cb (funcall cb))))
(let ((callback (process-get proc 'callback))) (process-put proc 'callback nil) (if error-text (process-put proc 'mpc-proc-error error-text)) (funcall callback))
(let ((error-text (match-string 1))) (delete-region (point) (point-max)) (let ((callback (process-get proc 'callback))) (process-put proc 'callback nil) (if error-text (process-put proc 'mpc-proc-error error-text)) (funcall callback)))
(progn (process-put proc 'ready t) (if (eq (match-end 0) (point-max)) nil (error "Unexpected trailing text")) (let ((error-text (match-string 1))) (delete-region (point) (point-max)) (let ((callback (process-get proc 'callback))) (process-put proc 'callback nil) (if error-text (process-put proc 'mpc-proc-error error-text)) (funcall callback))))
(if (and (< start (point)) (re-search-backward mpc--proc-end-re start t)) (progn (process-put proc 'ready t) (if (eq (match-end 0) (point-max)) nil (error "Unexpected trailing text")) (let ((error-text (match-string 1))) (delete-region (point) (point-max)) (let ((callback (process-get proc 'callback))) (process-put proc 'callback nil) (if error-text (process-put proc 'mpc-proc-error error-text)) (funcall callback)))))
(let ((start (or (marker-position (process-mark proc)) (point-min)))) (goto-char start) (insert string) (move-marker (process-mark proc) (point)) (beginning-of-line) (if (and (< start (point)) (re-search-backward mpc--proc-end-re start t)) (progn (process-put proc 'ready t) (if (eq (match-end 0) (point-max)) nil (error "Unexpected trailing text")) (let ((error-text (match-string 1))) (delete-region (point) (point-max)) (let ((callback (process-get proc ...))) (process-put proc 'callback nil) (if error-text (process-put proc 'mpc-proc-error error-text)) (funcall callback))))))
(save-excursion (let ((start (or (marker-position (process-mark proc)) (point-min)))) (goto-char start) (insert string) (move-marker (process-mark proc) (point)) (beginning-of-line) (if (and (< start (point)) (re-search-backward mpc--proc-end-re start t)) (progn (process-put proc 'ready t) (if (eq (match-end 0) (point-max)) nil (error "Unexpected trailing text")) (let ((error-text (match-string 1))) (delete-region (point) (point-max)) (let ((callback ...)) (process-put proc 'callback nil) (if error-text (process-put proc ... error-text)) (funcall callback)))))))
(if (process-get proc 'ready) (if nil nil (delete-process proc) (set-process-buffer proc nil) (pop-to-buffer (clone-buffer)) (error "MPD output while idle!?")) (save-excursion (let ((start (or (marker-position (process-mark proc)) (point-min)))) (goto-char start) (insert string) (move-marker (process-mark proc) (point)) (beginning-of-line) (if (and (< start (point)) (re-search-backward mpc--proc-end-re start t)) (progn (process-put proc 'ready t) (if (eq (match-end 0) (point-max)) nil (error "Unexpected trailing text")) (let ((error-text ...)) (delete-region (point) (point-max)) (let (...) (process-put proc ... nil) (if error-text ...) (funcall callback))))))))
(save-current-buffer (set-buffer (process-buffer proc)) (if (process-get proc 'ready) (if nil nil (delete-process proc) (set-process-buffer proc nil) (pop-to-buffer (clone-buffer)) (error "MPD output while idle!?")) (save-excursion (let ((start (or (marker-position ...) (point-min)))) (goto-char start) (insert string) (move-marker (process-mark proc) (point)) (beginning-of-line) (if (and (< start (point)) (re-search-backward mpc--proc-end-re start t)) (progn (process-put proc 'ready t) (if (eq ... ...) nil (error "Unexpected trailing text")) (let (...) (delete-region ... ...) (let ... ... ... ...))))))))
mpc--proc-filter(#<process MPC> "repeat: 0\nrandom: 1\nsingle: 0\nconsume: 0\npartition: default\nplaylist: 55708\nplaylistlength: 0\nmixrampdb: 0\nstate: stop\nOK\n")
In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.38, cairo version 1.18.0) of 2024-01-21 built on thelio
Repository revision: 9364c28959a5b00e8ffd5d0d283ff0c0042f1bb0
Repository branch: master
System Description: Fedora Linux 39 (Thirty Nine)
Configured using:
'configure --with-pgtk --prefix=/home/jm/.local'
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#68785: Acknowledgement ([PATCH] Fix volume refresh bug in mpc)
[not found] ` <handler.68785.B.170647308131160.ack@debbugs.gnu.org>
@ 2024-01-28 20:22 ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-10 8:23 ` bug#68785: [PATCH] Fix volume refresh bug in mpc Eli Zaretskii
0 siblings, 1 reply; 3+ messages in thread
From: john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-01-28 20:22 UTC (permalink / raw)
To: 68785
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-Fix-volume-refresh-bug-in-mpc.patch --]
[-- Type: text/x-patch, Size: 1295 bytes --]
From 52f94878d94a6a3b9d59b53e720230546d881a2a Mon Sep 17 00:00:00 2001
From: john muhl <jm@pub.pink>
Date: Thu, 25 Jan 2024 21:23:45 -0600
Subject: [PATCH] Fix volume refresh bug in mpc
* lisp/mpc.el (mpc-volume-refresh): Only refresh volume when mpd
is playing. When stopped or paused volume is nil. (bug#68785)
---
lisp/mpc.el | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/lisp/mpc.el b/lisp/mpc.el
index 9577e0f2f42..768c70c2e3a 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -1867,11 +1867,14 @@ mpc-volume-map
(defvar mpc-volume nil) (put 'mpc-volume 'risky-local-variable t)
(defun mpc-volume-refresh ()
- ;; Maintain the volume.
- (setq mpc-volume
- (mpc-volume-widget
- (string-to-number (cdr (assq 'volume mpc-status)))))
- (let ((status-buf (mpc-proc-buffer (mpc-proc) 'status)))
+ "Maintain the volume."
+ (let ((status-buf (mpc-proc-buffer (mpc-proc) 'status))
+ (status-vol (cdr (assq 'volume mpc-status))))
+ ;; If MPD is paused or stopped the volume is nil.
+ (when status-vol
+ (setq mpc-volume
+ (mpc-volume-widget
+ (string-to-number status-vol))))
(when (buffer-live-p status-buf)
(with-current-buffer status-buf (force-mode-line-update)))))
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#68785: [PATCH] Fix volume refresh bug in mpc
2024-01-28 20:22 ` bug#68785: Acknowledgement ([PATCH] Fix volume refresh bug in mpc) john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-02-10 8:23 ` Eli Zaretskii
0 siblings, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2024-02-10 8:23 UTC (permalink / raw)
To: john muhl; +Cc: 68785-done
> Date: Sun, 28 Jan 2024 14:22:16 -0600
> From: john muhl via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>
> >From 52f94878d94a6a3b9d59b53e720230546d881a2a Mon Sep 17 00:00:00 2001
> From: john muhl <jm@pub.pink>
> Date: Thu, 25 Jan 2024 21:23:45 -0600
> Subject: [PATCH] Fix volume refresh bug in mpc
>
> * lisp/mpc.el (mpc-volume-refresh): Only refresh volume when mpd
> is playing. When stopped or paused volume is nil. (bug#68785)
Thanks, installed on master, and closing the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-10 8:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-28 20:17 bug#68785: [PATCH] Fix volume refresh bug in mpc john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
[not found] ` <handler.68785.B.170647308131160.ack@debbugs.gnu.org>
2024-01-28 20:22 ` bug#68785: Acknowledgement ([PATCH] Fix volume refresh bug in mpc) john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-10 8:23 ` bug#68785: [PATCH] Fix volume refresh bug in mpc Eli Zaretskii
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.