branch: externals/exwm
commit 23293df58415b5ccbfeac2e301be74dedb2889fc
Author: Steven Allen <[email protected]>
Commit: Steven Allen <[email protected]>
Collapse lets with with-slots
Now that we no longer have (xcb:unmarshal ...) statements, we can
replace:
(let ((obj (xcb:unmarshal-new ...)))
(with-slots (...) obj
With:
(with-slots (...) (xcb:unmarshal-new ...)
* exwm-input.el (exwm-input--on-KeyPress): Combine let/with-slots.
* exwm-manage.el (exwm-manage--on-MapRequest):
(exwm-manage--on-UnmapNotify):
(exwm-manage--on-MapNotify): Combine let/with-slots.
* exwm-randr.el (exwm-randr--on-ConfigureNotify): Combine let/with-slots.
* exwm-systemtray.el (exwm-systemtray--on-DestroyNotify):
(exwm-systemtray--on-ReparentNotify): Combine let/with-slots.
---
exwm-input.el | 5 ++--
exwm-manage.el | 76 +++++++++++++++++++++++++++---------------------------
exwm-randr.el | 7 +++--
exwm-systemtray.el | 18 ++++++-------
4 files changed, 52 insertions(+), 54 deletions(-)
diff --git a/exwm-input.el b/exwm-input.el
index fe10e6d6f9..c84a489ff1 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -477,9 +477,8 @@ attempt later."
(defun exwm-input--on-CreateNotify (data _synthetic)
"Handle CreateNotify events with DATA."
(exwm--log)
- (let ((evt (xcb:unmarshal-new 'xcb:CreateNotify data)))
- (with-slots (window) evt
- (exwm-input--grab-global-prefix-keys window))))
+ (with-slots (window) (xcb:unmarshal-new 'xcb:CreateNotify data)
+ (exwm-input--grab-global-prefix-keys window)))
(defun exwm-input--update-global-prefix-keys ()
"Update `exwm-input--global-prefix-keys'."
diff --git a/exwm-manage.el b/exwm-manage.el
index 5171d5bf76..ec1a090f3b 100644
--- a/exwm-manage.el
+++ b/exwm-manage.el
@@ -753,55 +753,55 @@ border-width: %d; sibling: #x%x; stack-mode: %d"
(defun exwm-manage--on-MapRequest (data _synthetic)
"Handle MapRequest event.
DATA contains unmarshalled MapRequest event data."
- (let ((obj (xcb:unmarshal-new 'xcb:MapRequest data)))
- (with-slots (parent window) obj
- (exwm--log "id=#x%x parent=#x%x" window parent)
- (if (assoc window exwm--id-buffer-alist)
- (with-current-buffer (exwm--id->buffer window)
- (if (exwm-layout--iconic-state-p)
- ;; State change: iconic => normal.
- (when (eq exwm--frame exwm-workspace--current)
- (pop-to-buffer-same-window (current-buffer)))
- (exwm--log "#x%x is already managed" window)))
- (if (/= exwm--root parent)
- (progn (xcb:+request exwm--connection
- (make-instance 'xcb:MapWindow :window window))
- (xcb:flush exwm--connection))
- (exwm--log "#x%x" window)
- (exwm-manage--manage-window window))))))
+ (with-slots (parent window)
+ (xcb:unmarshal-new 'xcb:MapRequest data)
+ (exwm--log "id=#x%x parent=#x%x" window parent)
+ (if (assoc window exwm--id-buffer-alist)
+ (with-current-buffer (exwm--id->buffer window)
+ (if (exwm-layout--iconic-state-p)
+ ;; State change: iconic => normal.
+ (when (eq exwm--frame exwm-workspace--current)
+ (pop-to-buffer-same-window (current-buffer)))
+ (exwm--log "#x%x is already managed" window)))
+ (if (/= exwm--root parent)
+ (progn (xcb:+request exwm--connection
+ (make-instance 'xcb:MapWindow :window window))
+ (xcb:flush exwm--connection))
+ (exwm--log "#x%x" window)
+ (exwm-manage--manage-window window)))))
(defun exwm-manage--on-UnmapNotify (data _synthetic)
"Handle UnmapNotify event.
DATA contains unmarshalled UnmapNotify event data."
- (let ((obj (xcb:unmarshal-new 'xcb:UnmapNotify data)))
- (with-slots (window) obj
- (exwm--log "id=#x%x" window)
- (exwm-manage--unmanage-window window t))))
+ (with-slots (window)
+ (xcb:unmarshal-new 'xcb:UnmapNotify data)
+ (exwm--log "id=#x%x" window)
+ (exwm-manage--unmanage-window window t)))
(defun exwm-manage--on-MapNotify (data _synthetic)
"Handle MapNotify event.
DATA contains unmarshalled MapNotify event data."
- (let ((obj (xcb:unmarshal-new 'xcb:MapNotify data)))
- (with-slots (window) obj
- (when (assoc window exwm--id-buffer-alist)
- (exwm--log "id=#x%x" window)
- ;; With this we ensure that a "window hierarchy change" happens after
- ;; mapping the window, as some servers (XQuartz) do not generate it.
- (with-current-buffer (exwm--id->buffer window)
- (if exwm--floating-frame
- (xcb:+request exwm--connection
- (make-instance 'xcb:ConfigureWindow
- :window window
- :value-mask xcb:ConfigWindow:StackMode
- :stack-mode xcb:StackMode:Above))
+ (with-slots (window)
+ (xcb:unmarshal-new 'xcb:MapNotify data)
+ (when (assoc window exwm--id-buffer-alist)
+ (exwm--log "id=#x%x" window)
+ ;; With this we ensure that a "window hierarchy change" happens after
+ ;; mapping the window, as some servers (XQuartz) do not generate it.
+ (with-current-buffer (exwm--id->buffer window)
+ (if exwm--floating-frame
(xcb:+request exwm--connection
(make-instance 'xcb:ConfigureWindow
:window window
- :value-mask (logior xcb:ConfigWindow:Sibling
- xcb:ConfigWindow:StackMode)
- :sibling exwm--guide-window
- :stack-mode xcb:StackMode:Above))))
- (xcb:flush exwm--connection)))))
+ :value-mask xcb:ConfigWindow:StackMode
+ :stack-mode xcb:StackMode:Above))
+ (xcb:+request exwm--connection
+ (make-instance 'xcb:ConfigureWindow
+ :window window
+ :value-mask (logior xcb:ConfigWindow:Sibling
+ xcb:ConfigWindow:StackMode)
+ :sibling exwm--guide-window
+ :stack-mode xcb:StackMode:Above))))
+ (xcb:flush exwm--connection))))
(defun exwm-manage--on-DestroyNotify (data synthetic)
"Handle DestroyNotify event.
diff --git a/exwm-randr.el b/exwm-randr.el
index 6fb5e3bbe9..de31251255 100644
--- a/exwm-randr.el
+++ b/exwm-randr.el
@@ -324,10 +324,9 @@ Refresh when any CRTC/output changes."
Refresh when any RandR 1.5 monitor changes."
(exwm--log)
- (let ((evt (xcb:unmarshal-new 'xcb:ConfigureNotify data)))
- (with-slots (window) evt
- (when (eq window exwm--root)
- (exwm-randr-refresh)))))
+ (with-slots (window) (xcb:unmarshal-new 'xcb:ConfigureNotify data)
+ (when (eq window exwm--root)
+ (exwm-randr-refresh))))
(cl-defun exwm-randr--init ()
"Initialize RandR extension and EXWM RandR module."
diff --git a/exwm-systemtray.el b/exwm-systemtray.el
index 32e2da1055..242221f1e1 100644
--- a/exwm-systemtray.el
+++ b/exwm-systemtray.el
@@ -349,20 +349,20 @@ indicate how to support actual transparency."
"Unembed icons on DestroyNotify.
Argument DATA contains the raw event data."
(exwm--log)
- (let ((obj (xcb:unmarshal-new 'xcb:DestroyNotify data)))
- (with-slots (window) obj
- (when (assoc window exwm-systemtray--list)
- (exwm-systemtray--unembed window)))))
+ (with-slots (window)
+ (xcb:unmarshal-new 'xcb:DestroyNotify data)
+ (when (assoc window exwm-systemtray--list)
+ (exwm-systemtray--unembed window))))
(defun exwm-systemtray--on-ReparentNotify (data _synthetic)
"Unembed icons on ReparentNotify.
Argument DATA contains the raw event data."
(exwm--log)
- (let ((obj (xcb:unmarshal-new 'xcb:ReparentNotify data)))
- (with-slots (window parent) obj
- (when (and (/= parent exwm-systemtray--embedder-window)
- (assoc window exwm-systemtray--list))
- (exwm-systemtray--unembed window)))))
+ (with-slots (window parent)
+ (xcb:unmarshal-new 'xcb:ReparentNotify data)
+ (when (and (/= parent exwm-systemtray--embedder-window)
+ (assoc window exwm-systemtray--list))
+ (exwm-systemtray--unembed window))))
(defun exwm-systemtray--on-ResizeRequest (data _synthetic)
"Resize the tray icon on ResizeRequest.