[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/emms e21bcd7da2 6/8: * emms-volume.el: use functional s
From: |
ELPA Syncer |
Subject: |
[elpa] externals/emms e21bcd7da2 6/8: * emms-volume.el: use functional style to get the volume |
Date: |
Sun, 5 Mar 2023 08:57:46 -0500 (EST) |
branch: externals/emms
commit e21bcd7da2988bea93672725a41b27f9ebb48ec4
Author: Yoni Rabkin <yrk@gnu.org>
Commit: Yoni Rabkin <yrk@gnu.org>
* emms-volume.el: use functional style to get the volume
We want to avoid making the user need to define both the setter and
getter function. Once the the volume change function has been
selected, we use that to determine the correct getter function.
---
emms-volume.el | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/emms-volume.el b/emms-volume.el
index 557d062014..101185f4cb 100644
--- a/emms-volume.el
+++ b/emms-volume.el
@@ -59,7 +59,6 @@
"Volume setting for EMMS."
:group 'emms)
-;; General volume setting related code.
(defcustom emms-volume-change-function
(cond
;; check for sndioctl first to avoid picking up mixerctl or pactl
@@ -78,19 +77,6 @@ If you have your own functions for changing volume, set
this."
(const :tag "Sndioctl" emms-volume-sndioctl-change)
(function :tag "Lisp function")))
-;; The function referenced by `emms-volume-get-function' must return
-;; an integer in the range [0-100]. This explicitly ignores
-;; over-amplification settings.
-(defcustom emms-volume-get-function
- (cond
- ;; check for sndioctl first to avoid picking up mixerctl or pactl
- ;; on OpenBSD.
- ((executable-find "pactl") #'emms-volume-pulse-get)
- (t #'(lambda (_amount) (user-error "%s" "No supported mixer found. Please,
define ‘emms-volume-get-function’."))))
- "The function to use to get the volume."
- :type '(choice (const :tag "PulseAudio" emms-volume-pulse-get)
- (function :tag "Lisp function")))
-
(defcustom emms-volume-change-amount 2
"The amount to use when raising or lowering the volume using the
emms-volume interface.
@@ -98,9 +84,20 @@ emms-volume interface.
This should be a positive integer."
:type 'integer)
+(defun emms-volume-select-get-function ()
+ "Return the corresponding get function."
+ (cond ((not emms-volume-change-function)
+ (error "`emms-volume-change-function' is not set"))
+ ((eq emms-volume-change-function #'emms-volume-amixer-change)
+ #'emms-volume-amixer-get)
+ ((eq emms-volume-change-function #'emms-volume-pulse-change)
+ #'emms-volume-pulse-get)
+ (t (error "could not find corresponding volume getter function for %s"
+ emms-volume-change-function))))
+
(defun emms-volume-get ()
"Return the volume as an integer in the range [0-100]."
- (funcall emms-volume-get-function))
+ (funcall (emms-volume-select-get-function)))
;;;###autoload
(defun emms-volume-raise ()
- [elpa] externals/emms updated (43c6141249 -> 4136e8bbfa), ELPA Syncer, 2023/03/05
- [elpa] externals/emms e21bcd7da2 6/8: * emms-volume.el: use functional style to get the volume,
ELPA Syncer <=
- [elpa] externals/emms 1b3c36ef5f 4/8: * emms-volume.el: define `emms-volume-get' to return the volume., ELPA Syncer, 2023/03/05
- [elpa] externals/emms b48b55c748 5/8: * emms-volume.el: update copyright notice, ELPA Syncer, 2023/03/05
- [elpa] externals/emms a6ed8c5218 1/8: * emms-volume-pulse.el: update copyright for file, ELPA Syncer, 2023/03/05
- [elpa] externals/emms 4136e8bbfa 8/8: * emms-volume-amixer.el: implement `emms-volume-amixer-get', ELPA Syncer, 2023/03/05
- [elpa] externals/emms d45fd671d2 7/8: * emms-volume-amixer.el: update copyright notice, ELPA Syncer, 2023/03/05
- [elpa] externals/emms 3cb99a9d72 3/8: * emms-volume-pulse.el: define `emms-volume-pulse-get', ELPA Syncer, 2023/03/05
- [elpa] externals/emms e02eaa784a 2/8: * emms-volume-pulse.el: reorganize `emms-volume--pulse-get-volume', ELPA Syncer, 2023/03/05