From e72a8c6426b1fa50b2f1554797877a35569bb246 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Wed, 29 Sep 2021 18:22:43 +0200 Subject: [PATCH] Force volume to an integer divisible by mpc-volume-step * lisp/mpc.el (mpc-volume-mouse-set): Force volume to an integer divisible by 'mpc-volume-step'. (mpc-volume-step): Add docstring. --- lisp/mpc.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/mpc.el b/lisp/mpc.el index ad32ce8d331..c7ae08baee1 100644 --- a/lisp/mpc.el +++ b/lisp/mpc.el @@ -1881,7 +1881,8 @@ A value of t means the main playlist.") (when (buffer-live-p status-buf) (with-current-buffer status-buf (force-mode-line-update))))) -(defvar mpc-volume-step 5) +(defvar mpc-volume-step 5 + "Change volume in increments of this integer.") (defun mpc-volume-mouse-set (&optional event) "Change volume setting." @@ -1895,7 +1896,7 @@ A value of t means the main playlist.") '(?◁ ?<)) (- mpc-volume-step) mpc-volume-step)) (curvol (string-to-number (cdr (assq 'volume mpc-status)))) - (newvol (max 0 (min 100 (+ curvol diff))))) + (newvol (max 0 (min 100 (+ (- curvol (mod curvol diff)) diff))))) (if (= newvol curvol) (progn (message "MPD volume already at %s%%" newvol) -- 2.39.5