* lisp/mpc.el (mpc-volume-mouse-set): Don't burp at the boundaries.
authorStefan Monnier <monnier@iro.umontreal.ca>
Thu, 1 May 2014 01:08:08 +0000 (21:08 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Thu, 1 May 2014 01:08:08 +0000 (21:08 -0400)
lisp/ChangeLog
lisp/mpc.el

index 769d060..6694676 100644 (file)
@@ -1,3 +1,7 @@
+2014-05-01  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * mpc.el (mpc-volume-mouse-set): Don't burp at the boundaries.
+
 2014-04-30  Eli Zaretskii  <eliz@gnu.org>
 
        * dired.el (dired-initial-position-hook, dired-initial-position):
index d89231e..d569610 100644 (file)
@@ -1811,9 +1811,14 @@ A value of t means the main playlist.")
                         (char-after (posn-point posn))))
                     '(?◁ ?<))
               (- mpc-volume-step) mpc-volume-step))
-         (newvol (+ (string-to-number (cdr (assq 'volume mpc-status))) diff)))
-    (mpc-proc-cmd (list "setvol" newvol) 'mpc-status-refresh)
-    (message "Set MPD volume to %s%%" newvol)))
+         (curvol (string-to-number (cdr (assq 'volume mpc-status))))
+         (newvol (max 0 (min 100 (+ curvol diff)))))
+    (if (= newvol curvol)
+        (progn
+          (message "MPD volume already at %s%%" newvol)
+          (ding))
+      (mpc-proc-cmd (list "setvol" newvol) 'mpc-status-refresh)
+      (message "Set MPD volume to %s%%" newvol))))
 
 (defun mpc-volume-widget (vol &optional size)
   (unless size (setq size 12.5))