[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/exwm f14bd2a 1/2: Set the current buffer before handlin
From: |
Chris Feng |
Subject: |
[elpa] externals/exwm f14bd2a 1/2: Set the current buffer before handling key events |
Date: |
Mon, 7 Oct 2019 08:22:33 -0400 (EDT) |
branch: externals/exwm
commit f14bd2a110af927293c23e8ff7aa1e2287120b0d
Author: Steven Allen <address@hidden>
Commit: Steven Allen <address@hidden>
Set the current buffer before handling key events
There's no guarantee that the global current buffer matches the selected
window's buffer. For example, the following will output "*Messages*"
regardless
of the actual current buffer:
(progn
(run-at "1 sec" nil (lambda ()
(with-current-buffer (get-buffer "*Messages*")
(sit-for 5))))
(run-at "2 sec" nil (lambda () (message (buffer-name)))))
* exwm-input.el (exwm-input--on-KeyPress): Set the current buffer to
selected
window's current buffer.
---
exwm-input.el | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/exwm-input.el b/exwm-input.el
index 2d3b481..8cd54c6 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -441,18 +441,19 @@ ARGS are additional arguments to CALLBACK."
(defun exwm-input--on-KeyPress (data _synthetic)
"Handle KeyPress event."
- (let ((obj (make-instance 'xcb:KeyPress)))
- (xcb:unmarshal obj data)
- (exwm--log "major-mode=%s buffer=%s"
- major-mode (buffer-name (current-buffer)))
- (if (derived-mode-p 'exwm-mode)
- (cl-case exwm--input-mode
- (line-mode
- (exwm-input--on-KeyPress-line-mode obj data))
- (char-mode
- (exwm-input--on-KeyPress-char-mode obj data)))
- (exwm-input--on-KeyPress-char-mode obj)))
- (run-hooks 'exwm-input--event-hook))
+ (with-current-buffer (window-buffer (selected-window))
+ (let ((obj (make-instance 'xcb:KeyPress)))
+ (xcb:unmarshal obj data)
+ (exwm--log "major-mode=%s buffer=%s"
+ major-mode (buffer-name (current-buffer)))
+ (if (derived-mode-p 'exwm-mode)
+ (cl-case exwm--input-mode
+ (line-mode
+ (exwm-input--on-KeyPress-line-mode obj data))
+ (char-mode
+ (exwm-input--on-KeyPress-char-mode obj data)))
+ (exwm-input--on-KeyPress-char-mode obj)))
+ (run-hooks 'exwm-input--event-hook)))
(defun exwm-input--on-CreateNotify (data _synthetic)
"Handle CreateNotify events."