Skip to content

Commit 0109f0b

Browse files
committed
fix meow-esc in emacsclient -t
fixes #514. If a emacs server is started from graphical, meow-esc-mode is never called. Therefore, meow-init-esc does not get added to the make frame hook, and it never gets enabled for emacsclient -t. This commit always enables meow-esc-mode, and checks whether we are graphical inside the init and deinit functions instead of in the global init/deinit functions.
1 parent b47d1fa commit 0109f0b

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

meow-core.el

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ there's no chance for meow to call an init function."
180180

181181
(meow--enable-shims)
182182
;; meow-esc-mode fix ESC in TUI
183-
(unless window-system
184-
(meow-esc-mode 1))
183+
(meow-esc-mode 1)
185184
;; raise Meow keymap priority
186185
(add-to-ordered-list 'emulation-mode-map-alists
187186
`((meow-motion-mode . ,meow-motion-state-keymap)))
@@ -213,8 +212,7 @@ there's no chance for meow to call an init function."
213212
(when meow-use-cursor-position-hack
214213
(setq redisplay-highlight-region-function meow--backup-redisplay-highlight-region-function)
215214
(setq redisplay-unhighlight-region-function meow--backup-redisplay-unhighlight-region-function))
216-
(unless window-system
217-
(meow-esc-mode -1))
215+
(meow-esc-mode -1)
218216
(advice-remove 'enable-theme 'meow--enable-theme-advice))
219217

220218
(provide 'meow-core)

meow-esc.el

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,35 @@
2929
((> arg 0)
3030
(unless meow-esc-mode
3131
(setq meow-esc-mode t)
32-
(add-hook 'after-make-frame-functions #'meow-init-esc)
33-
(mapc #'meow-init-esc (frame-list))))
32+
(add-hook 'after-make-frame-functions #'meow--init-esc-if-tui)
33+
(mapc #'meow--init-esc-if-tui (frame-list))))
3434
((< arg 0)
3535
(when meow-esc-mode
36-
(remove-hook 'after-make-frame-functions #'meow-init-esc)
37-
(mapc #'meow-deinit-esc (frame-list))
36+
(remove-hook 'after-make-frame-functions #'meow--init-esc-if-tui)
37+
(mapc #'meow--deinit-esc-if-tui (frame-list))
3838
(setq meow-esc-mode nil)))))
3939

4040
(defvar meow--escape-key-seq [?\e])
4141

42-
(defun meow-init-esc (frame)
42+
(defun meow--init-esc-if-tui (frame)
4343
(with-selected-frame frame
44-
(let ((term (frame-terminal frame)))
45-
(when (not (terminal-parameter term 'meow-esc-map))
46-
(let ((meow-esc-map (lookup-key input-decode-map [?\e])))
47-
(set-terminal-parameter term 'meow-esc-map meow-esc-map)
48-
(define-key input-decode-map meow--escape-key-seq
49-
`(menu-item "" ,meow-esc-map :filter ,#'meow-esc)))))))
44+
(unless window-system
45+
(let ((term (frame-terminal frame)))
46+
(when (not (terminal-parameter term 'meow-esc-map))
47+
(let ((meow-esc-map (lookup-key input-decode-map [?\e])))
48+
(set-terminal-parameter term 'meow-esc-map meow-esc-map)
49+
(define-key input-decode-map meow--escape-key-seq
50+
`(menu-item "" ,meow-esc-map :filter ,#'meow-esc))))))))
5051

51-
(defun meow-deinit-esc (frame)
52+
(defun meow--deinit-esc-if-tui (frame)
5253
(with-selected-frame frame
53-
(let ((term (frame-terminal frame)))
54-
(when (terminal-live-p term)
55-
(let ((meow-esc-map (terminal-parameter term 'meow-esc-map)))
56-
(when meow-esc-map
57-
(define-key input-decode-map meow--escape-key-seq meow-esc-map)
58-
(set-terminal-parameter term 'meow-esc-map nil)))))))
54+
(unless window-system
55+
(let ((term (frame-terminal frame)))
56+
(when (terminal-live-p term)
57+
(let ((meow-esc-map (terminal-parameter term 'meow-esc-map)))
58+
(when meow-esc-map
59+
(define-key input-decode-map meow--escape-key-seq meow-esc-map)
60+
(set-terminal-parameter term 'meow-esc-map nil))))))))
5961

6062
(defun meow-esc (map)
6163
(if (and (let ((keys (this-single-command-keys)))

0 commit comments

Comments
 (0)