[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/bluetooth 2ce2322 49/57: improves device info printing
From: |
Stefan Monnier |
Subject: |
[elpa] externals/bluetooth 2ce2322 49/57: improves device info printing |
Date: |
Thu, 7 Nov 2019 23:28:57 -0500 (EST) |
branch: externals/bluetooth
commit 2ce2322ed400d9f53675756bc022368703afe7c3
Author: Raffael Stocker <address@hidden>
Commit: Raffael Stocker <address@hidden>
improves device info printing
---
bluetooth.el | 100 +++++++++++++++++++++++++++++++++++++----------------------
1 file changed, 63 insertions(+), 37 deletions(-)
diff --git a/bluetooth.el b/bluetooth.el
index a8b91a7..86a0b7c 100644
--- a/bluetooth.el
+++ b/bluetooth.el
@@ -54,7 +54,23 @@
"D-Bus bus that Bluez is registered on.
This is usually `:system' if bluetoothd runs as a system service, or
`:session' if it runs as a user service."
- :type '(symbol))
+ :type '(symbol)
+ :group 'bluetooth)
+
+(defgroup bluetooth-faces nil
+ "Faces used by Bluetooth mode."
+ :group 'faces)
+
+(defface bluetooth-info-heading
+ '((t . (:foreground "royal blue" :weight bold)))
+ "Face for device info headings."
+ :group 'bluetooth-faces)
+
+(defface bluetooth-info-attribute
+ '((t . (:slant italic)))
+ "Face for device attribute names."
+ :group 'bluetooth-faces)
+
(defconst bluetooth-buffer-name "*Bluetooth*"
"Name of the buffer in which to list bluetooth devices.")
@@ -1391,42 +1407,52 @@ For documentation, see URL
`https://gitlab.com/rstocker/emacs-bluetooth'."
(defun bluetooth-show-device-info ()
"Show detail information on the device at point."
(interactive)
- (let ((dev-id (tabulated-list-get-id)))
- (when dev-id
- (bluetooth--with-alias dev-id
- (with-current-buffer-window
- "*Bluetooth device info*" nil nil
- (let* ((props (bluetooth--call-method
- (car (last (split-string dev-id "/"))) :device
- #'dbus-get-all-properties))
- (address (cdr (assoc "Address" props)))
- (rssi (cdr (assoc "RSSI" props)))
- (class (cdr (assoc "Class" props)))
- (uuids (cdr (assoc "UUIDs" props))))
- (insert "Alias:\t\t" alias "\n")
- (when address
- (insert "Address:\t" address "\n"))
- (when rssi
- (insert "RSSI:\t\t" (number-to-string rssi) "\n"))
- (when class
- (let ((p-class (bluetooth--parse-class class)))
- (insert "\nService and device classes:\n")
- (mapc (lambda (x)
- (insert (car x) ":\n")
- (if (listp (cadr x))
- (dolist (elt (cadr x))
- (insert "\t" elt "\n"))
- (insert "\t" (cadr x) "\n")))
- p-class)))
- (when uuids
- (insert "\nServices (UUIDs):\n")
- (dolist (id uuids)
- (insert (mapconcat #'identity
- (or (bluetooth--parse-service-class-uuid id)
- (list id))
- " -- ")
- "\n"))))
- (special-mode))))))
+ (cl-flet ((ins-heading (text)
+ (insert (propertize text 'face
+ 'bluetooth-info-heading)))
+ (ins-attr (attr value)
+ (insert (propertize (format "%10s" attr)
+ 'face
+ 'bluetooth-info-attribute))
+ (insert ": " value "\n")))
+ (let ((dev-id (tabulated-list-get-id)))
+ (when dev-id
+ (bluetooth--with-alias dev-id
+ (with-current-buffer-window
+ "*Bluetooth device info*" nil nil
+ (let ((props (bluetooth--call-method
+ (car (last (split-string dev-id "/"))) :device
+ #'dbus-get-all-properties)))
+ (ins-heading "Bluetooth device info\n\n")
+ (ins-attr "Alias" alias)
+ (when-let (address (cdr (assoc "Address" props)))
+ (ins-attr "Address" address))
+ (when-let (rssi (cdr (assoc "RSSI" props)))
+ (ins-attr "RSSI" (number-to-string rssi)))
+ (when-let (class (cdr (assoc "Class" props)))
+ (let ((p-class (bluetooth--parse-class class)))
+ (ins-heading "\nService and device classes\n")
+ (dolist (x p-class)
+ (insert (propertize
+ (format "%s:\n" (car x))
+ 'face 'bluetooth-info-attribute))
+ (if (listp (cadr x))
+ (dolist (elt (cadr x))
+ (insert (format "%15s %s\n" "" elt)))
+ (insert (format "%15s %s\n" "" (cadr x)))))))
+ (when-let (uuids (cdr (assoc "UUIDs" props)))
+ (ins-heading "\nSerives (UUIDs)\n")
+ (dolist (id uuids)
+ (let ((desc (or (bluetooth--parse-service-class-uuid id)
+ (list id))))
+ (when (car desc)
+ (insert (format "%30s " (car desc))))
+ (when (cadr desc)
+ (insert (format "%s " (cadr desc))))
+ (when (caddr desc)
+ (insert (format "(%s)" (caddr desc))))
+ (insert "\n")))))
+ (special-mode)))))))
(provide 'bluetooth)
- [elpa] externals/bluetooth 7714f6b 45/57: updates Readme, (continued)
- [elpa] externals/bluetooth 7714f6b 45/57: updates Readme, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 1f3b244 47/57: makes checkdoc and package-lint happy, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 9d79f61 46/57: puts the key bindings in their own defvar (as is usual), Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth fd39a17 50/57: cleans up movement to beginning/end of list, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 5387639 52/57: adds path loss to device info, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth ea7ccf7 53/57: fixes mode line update, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 21e6a14 34/57: adds hl-line-mode activation, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth cb5a39c 29/57: adds SDO UUIDs and simplifies the UUID handling functions, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 44e81ed 42/57: rearranges UUID data and functions, concentrates interface names, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 72f061d 48/57: updates commentary and cleans up whitespace, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 2ce2322 49/57: improves device info printing,
Stefan Monnier <=
- [elpa] externals/bluetooth e002888 27/57: updates Readme.org, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 15d1f53 37/57: adds a pointer to the source of assigned numbers data, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth d749581 41/57: removes unused `bluetooth--own-intf', Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 291e863 43/57: separates adapter api calls from device ids, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 398d361 44/57: ensures line highlighting after list display update, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 55304bb 57/57: signs copyright over to the FSF for inclusion in ELPA, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 49ca390 55/57: puts single-use stuff into using functions, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 920c308 56/57: updates comments, company IDs and cleans up, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 806b5e9 51/57: adds manufacturer names and more attributes to device info, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 5fa8c5f 54/57: changes all the larger UUID lists into hash tables and cleans up, Stefan Monnier, 2019/11/07