branch: externals/exwm
commit 8904247778c86b982953711a04ac957fb6f858d9
Author: Steven Allen <[email protected]>
Commit: Steven Allen <[email protected]>

    exwm-randr: Prefer let-bindings over setq
    
    * exwm-randr.el (exwm-randr--on-Notify): Refactor to use when-let to
    bind `notify' instead of the previous combination of let, setq, and when.
---
 exwm-randr.el | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/exwm-randr.el b/exwm-randr.el
index d625e1e007..5ac180b805 100644
--- a/exwm-randr.el
+++ b/exwm-randr.el
@@ -306,18 +306,17 @@ Run `exwm-randr-screen-change-hook' (usually user scripts 
to configure RandR)."
 
 Refresh when any CRTC/output changes."
   (exwm--log)
-  (let ((evt (xcb:unmarshal-new 'xcb:randr:Notify data))
-        notify)
-    (with-slots (subCode u) evt
-      (cond ((= subCode xcb:randr:Notify:CrtcChange)
-             (setq notify (slot-value u 'cc)))
-            ((= subCode xcb:randr:Notify:OutputChange)
-             (setq notify (slot-value u 'oc))))
-      (when notify
-        (with-slots (timestamp) notify
-          (when (> timestamp exwm-randr--last-timestamp)
-            (exwm-randr-refresh)
-            (setq exwm-randr--last-timestamp timestamp)))))))
+  (with-slots (subCode u)
+      (xcb:unmarshal-new 'xcb:randr:Notify data)
+    (when-let* ((notify
+                 (with-slots (cc oc) u
+                   (cond
+                    ((= subCode xcb:randr:Notify:CrtcChange) cc)
+                    ((= subCode xcb:randr:Notify:OutputChange) oc)))))
+      (with-slots (timestamp) notify
+        (when (> timestamp exwm-randr--last-timestamp)
+          (exwm-randr-refresh)
+          (setq exwm-randr--last-timestamp timestamp))))))
 
 (defun exwm-randr--on-ConfigureNotify (data _synthetic)
   "Handle `ConfigureNotify' event with DATA.

Reply via email to