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

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

[elpa] externals/bluetooth 4133a10 13/57: makes mode idempotent


From: Stefan Monnier
Subject: [elpa] externals/bluetooth 4133a10 13/57: makes mode idempotent
Date: Thu, 7 Nov 2019 23:28:50 -0500 (EST)

branch: externals/bluetooth
commit 4133a108e2dc0d62617de50751fabc87a951b941
Author: Raffael Stocker <address@hidden>
Commit: Raffael Stocker <address@hidden>

    makes mode idempotent
---
 bluetooth.el | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/bluetooth.el b/bluetooth.el
index 2450738..383b2f4 100644
--- a/bluetooth.el
+++ b/bluetooth.el
@@ -365,15 +365,18 @@ This function only uses the first adapter reported by 
Bluez."
 (defun list-bluetooth-devices ()
   "Display a list of Bluetooth devices that are available."
   (interactive)
+  ;; make sure D-Bus is (made) available
   (dbus-ping :system bluetooth--service bluetooth--timeout)
-  (with-current-buffer (switch-to-buffer bluetooth-buffer-name)
-    (erase-buffer)
-    (bluetooth-mode)
-    (bluetooth--register-agent)
-    (add-hook 'kill-buffer-hook #'bluetooth--cleanup nil t)
-    (set (make-local-variable 'mode-line-misc-info)
-        (cl-pushnew bluetooth--mode-info mode-line-misc-info))
-    (tabulated-list-print)))
+  (let ((buffer-exists (get-buffer bluetooth-buffer-name)))
+   (with-current-buffer (switch-to-buffer bluetooth-buffer-name)
+     (unless buffer-exists
+       (erase-buffer)
+       (bluetooth-mode)
+       (bluetooth--register-agent)
+       (add-hook 'kill-buffer-hook #'bluetooth--cleanup nil t)
+       (setq-local mode-line-misc-info
+                  (cl-pushnew bluetooth--mode-info mode-line-misc-info)))
+     (tabulated-list-print))))
 
 ;;; Bluetooth pairing agent code
 



reply via email to

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