emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master e72a8c6: Force volume to an integer divisible by mpc-volume-step


From: Stefan Kangas
Subject: master e72a8c6: Force volume to an integer divisible by mpc-volume-step
Date: Wed, 29 Sep 2021 12:23:47 -0400 (EDT)

branch: master
commit e72a8c6426b1fa50b2f1554797877a35569bb246
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    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 ad32ce8..c7ae08b 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]