[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/bluetooth 0ca89cf 24/33: clean up the connect and disco
From: |
Stefan Monnier |
Subject: |
[elpa] externals/bluetooth 0ca89cf 24/33: clean up the connect and disconnect functions |
Date: |
Sat, 19 Sep 2020 08:43:24 -0400 (EDT) |
branch: externals/bluetooth
commit 0ca89cfaccf97d94e080724001b8fb995a861c54
Author: Raffael Stocker <r.stocker@mnet-mail.de>
Commit: Raffael Stocker <r.stocker@mnet-mail.de>
clean up the connect and disconnect functions
allows connecting to different UUIDs of the same profile
new function: bluetooth--choose-uuid
---
bluetooth.el | 39 +++++++++++++++++++++------------------
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/bluetooth.el b/bluetooth.el
index 75dc404..d5e93e8 100644
--- a/bluetooth.el
+++ b/bluetooth.el
@@ -149,20 +149,31 @@ The generated function name has the form
`bluetoothPREFIX-NAME'."
(lambda (x) (concat "-" (downcase x)))
name t)))))
+(defun bluetooth--choose-uuid ()
+ "Ask for a UUID and return it in a form suitable for ‘interactive’."
+ (if current-prefix-arg
+ (let* ((dev-id (tabulated-list-get-id))
+ (uuids (bluetooth--device-uuids
+ (bluetooth--device-properties dev-id)))
+ (profile (completing-read "Profile: "
+
(mapcar (lambda (x)
+
(concat (caadr x)
+
", "
+
(cadadr x)))
+
uuids)
+ nil
t)))
+ (list (cl-rassoc profile uuids
+ :key (lambda (x)
+ (concat (caar
x) ", " (cadar x)))
+ :test #'string=)))
+ '(nil)))
+
(defun bluetooth-connect (uuid)
"Connect to the Bluetooth device at point.
When called with a prefix argument, ask for a profile and
connect only this profile. Otherwise, or when called
non-interactively with UUID set to nil, connect to all profiles."
- (interactive
- (if current-prefix-arg
- (let* ((dev-id (tabulated-list-get-id))
- (uuids (bluetooth--device-uuids
- (bluetooth--device-properties
dev-id)))
- (profile (completing-read "Profile: "
-
(mapcar #'cadadr uuids) nil t)))
- (list (cl-rassoc profile uuids :key #'cadar :test #'string=)))
- '(nil)))
+ (interactive (bluetooth--choose-uuid))
(if uuid
(bluetooth--dbus-method "ConnectProfile" :device (car uuid))
(bluetooth--dbus-method "Connect" :device)))
@@ -173,15 +184,7 @@ When called with a prefix argument, ask for a profile and
disconnect only this profile. Otherwise, or when called
non-interactively with UUID set to nil, disconnect to all
profiles."
- (interactive
- (if current-prefix-arg
- (let* ((dev-id (tabulated-list-get-id))
- (uuids (bluetooth--device-uuids
- (bluetooth--device-properties
dev-id)))
- (profile (completing-read "Profile: "
-
(mapcar #'cadadr uuids) nil t)))
- (list (cl-rassoc profile uuids :key #'cadar :test #'string=)))
- '(nil)))
+ (interactive (bluetooth--choose-uuid))
(if uuid
(bluetooth--dbus-method "DisconnectProfile" :device (car uuid))
(bluetooth--dbus-method "Disconnect" :device)))
- [elpa] externals/bluetooth e86e01f 12/33: add local variable for flycheck mode, (continued)
- [elpa] externals/bluetooth e86e01f 12/33: add local variable for flycheck mode, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth f107d6f 13/33: Add menu entries to bluetooth-mode-map, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth eb4b158 15/33: Merge commit 'f107d6f', Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth b12caf1 16/33: update author list, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 5d72618 17/33: add page breaks and section headings, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 8e8b6d0 19/33: bump up the copyright year, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 943ddf3 21/33: Clean up the UUID and class descriptions, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 98afd71 22/33: add property and uuid functions, update info display, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 518ebdf 29/33: update company ids (bluetooth--manufacturer-ids), Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 2746c62 23/33: change connect and disconnect functions to handle single profiles, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 0ca89cf 24/33: clean up the connect and disconnect functions,
Stefan Monnier <=
- [elpa] externals/bluetooth 7bb793f 26/33: remove unneeded hydra reference from Makefile, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 950cc77 27/33: add more menu entries, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth b5fc5c2 28/33: correct docstring in bluetooth-disconnect, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 28d16f6 33/33: set version number to 0.2, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth dc4b63b 30/33: correct docstrings, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 6599093 31/33: update list of member UUIDs (bluetooth--member-uuid-alist)., Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 2ae073b 25/33: update readme with single profile connect information, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth eebb593 32/33: refactor variable names of hash tables (were: -alist), Stefan Monnier, 2020/09/19