Emacs/EXWM: Init exwm-edit config.
parent
21c129b5cb
commit
ecc4974f41
|
@ -243,4 +243,7 @@
|
||||||
(add-hook 'exwm-randr-screen-change-hook 'ambrevar/exwm-change-screen-hook)
|
(add-hook 'exwm-randr-screen-change-hook 'ambrevar/exwm-change-screen-hook)
|
||||||
(exwm-randr-enable)
|
(exwm-randr-enable)
|
||||||
|
|
||||||
|
(when (require 'exwm-edit nil 'noerror)
|
||||||
|
(require 'patch-exwm-edit))
|
||||||
|
|
||||||
(provide 'init-exwm)
|
(provide 'init-exwm)
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
;; See https://github.com/agzam/exwm-edit/issues/7.
|
||||||
|
|
||||||
|
(defun exwm-edit--compose ()
|
||||||
|
"Edit text in an EXWM app."
|
||||||
|
(interactive)
|
||||||
|
;; flushing clipboard is required, otherwise `gui-get-selection` simply picks up what's in the clipboard (when nothing is actually selected in GUI)
|
||||||
|
(gui-set-selection nil nil)
|
||||||
|
(let* ((title (exwm-edit--buffer-title (buffer-name)))
|
||||||
|
(existing (get-buffer title))
|
||||||
|
(inhibit-read-only t)
|
||||||
|
(save-interprogram-paste-before-kill t)
|
||||||
|
(selection-coding-system 'utf-8) ; required for multilang-support
|
||||||
|
(sel (gui-get-selection))
|
||||||
|
(unmarked? (or (not sel)
|
||||||
|
(string= (substring-no-properties (or sel ""))
|
||||||
|
(substring-no-properties (or (car kill-ring) ""))))))
|
||||||
|
(when (derived-mode-p 'exwm-mode)
|
||||||
|
(setq exwm-edit--last-exwm-buffer (buffer-name))
|
||||||
|
(unless (bound-and-true-p global-exwm-edit-mode)
|
||||||
|
(global-exwm-edit-mode 1))
|
||||||
|
(if existing
|
||||||
|
(switch-to-buffer-other-window existing)
|
||||||
|
(progn
|
||||||
|
(when unmarked? (exwm-input--fake-key ?\C-a))
|
||||||
|
(let ((buffer (get-buffer-create title)))
|
||||||
|
(with-current-buffer buffer
|
||||||
|
(run-hooks 'exwm-edit-compose-hook)
|
||||||
|
(exwm-edit-mode 1)
|
||||||
|
(switch-to-buffer-other-window buffer)
|
||||||
|
(let ((sel (and (gui-get-selection) ; TODO: This is the fix, not sure why it works.
|
||||||
|
(gui-get-selection))))
|
||||||
|
(kill-new sel)
|
||||||
|
(insert sel))
|
||||||
|
(setq-local
|
||||||
|
header-line-format
|
||||||
|
(substitute-command-keys
|
||||||
|
"Edit, then exit with `\\[exwm-edit--finish]' or cancel with \ `\\[exwm-edit--cancel]'")))))))))
|
||||||
|
|
||||||
|
|
||||||
|
(provide 'patch-exwm-edit)
|
Loading…
Reference in New Issue