emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/bluetooth 8cac69d 26/57: checks list-id for nil to avoi


From: Stefan Monnier
Subject: [elpa] externals/bluetooth 8cac69d 26/57: checks list-id for nil to avoid errors at actions w/o list item
Date: Thu, 7 Nov 2019 23:28:53 -0500 (EST)

branch: externals/bluetooth
commit 8cac69d85fa63bf948a7cea2fa00d3cc4f2a245b
Author: Raffael Stocker <address@hidden>
Commit: Raffael Stocker <address@hidden>

    checks list-id for nil to avoid errors at actions w/o list item
---
 bluetooth.el | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/bluetooth.el b/bluetooth.el
index 9ea275d..53c7ca7 100644
--- a/bluetooth.el
+++ b/bluetooth.el
@@ -300,25 +300,30 @@ devices, as well as setting properties."
 ;;; Invoke a D-Bus method with or without parameters.
 (defun bluetooth--dbus-method (method api &rest args)
   "Invoke METHOD on D-Bus API with ARGS."
-  (apply #'bluetooth--call-method (tabulated-list-get-id) api
-        #'dbus-call-method-asynchronously method
-        #'bluetooth--update-list :timeout bluetooth--timeout args))
+  (let ((dev-id (tabulated-list-get-id)))
+    (when dev-id
+      (apply #'bluetooth--call-method dev-id api
+            #'dbus-call-method-asynchronously method
+            #'bluetooth--update-list :timeout bluetooth--timeout args))))
 
 ;;; Toggle a property.
 (defun bluetooth--dbus-toggle (property api)
   "Toggle boolean PROPERTY on D-Bus API."
-  (let* ((dev-id (tabulated-list-get-id))
-        (value (bluetooth--call-method dev-id api
-                                       #'dbus-get-property property)))
-    (bluetooth--call-method dev-id api #'dbus-set-property property (not 
value))
-    (bluetooth--update-list)))
+  (let ((dev-id (tabulated-list-get-id)))
+    (when dev-id
+      (let ((value (bluetooth--call-method dev-id api
+                                          #'dbus-get-property property)))
+       (bluetooth--call-method dev-id api #'dbus-set-property property
+                               (not value))
+       (bluetooth--update-list)))))
 
 ;;; Set a property.
 (defun bluetooth--dbus-set (property arg api)
   "Set PROPERTY to ARG on D-Bus API."
-  (bluetooth--call-method (tabulated-list-get-id)
-                         api #'dbus-set-property property arg)
-  (bluetooth--update-list))
+  (let ((dev-id (tabulated-list-get-id)))
+    (when dev-id
+      (bluetooth--call-method dev-id api #'dbus-set-property property arg)
+      (bluetooth--update-list))))
 
 ;;; end of worker function definitions
 



reply via email to

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