]> git.eshelyaron.com Git - emacs.git/commitdiff
Force volume to an integer divisible by mpc-volume-step
authorStefan Kangas <stefan@marxist.se>
Wed, 29 Sep 2021 16:22:43 +0000 (18:22 +0200)
committerStefan Kangas <stefan@marxist.se>
Wed, 29 Sep 2021 16:23:32 +0000 (18:23 +0200)
* 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

index ad32ce8d33161869174220002b79dc651ac7c5cb..c7ae08baee1219a0d793d54251cdcbcf4e6deb05 100644 (file)
@@ -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)