From: Stefan Kangas Date: Wed, 29 Sep 2021 16:22:43 +0000 (+0200) Subject: Force volume to an integer divisible by mpc-volume-step X-Git-Tag: emacs-28.0.90~521 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e72a8c6426b1fa50b2f1554797877a35569bb246;p=emacs.git 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. --- 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)