fix: Enable syd-repl-mode /before/ displaying the buffer

This ensures that display-buffer-alist predicates can test for repl buffers.
This commit is contained in:
Madeleine Sydney
2025-01-30 03:26:07 -07:00
parent 4a3551ed12
commit d27a3b60ce
3 changed files with 85 additions and 36 deletions

View File

@@ -67,7 +67,7 @@ adjustment.")
(when (featurep 'evil)
;; For maximum escape coverage in emacs state buffers; this only works in
;; GUI Emacs, in tty Emacs use C-g instead
(define-key map [escape] #'doom/escape))
(define-key map [escape] #'syd/escape))
map)
"Active keymap in popup windows. See `doom-popup-buffer-mode'.")

View File

@@ -53,9 +53,39 @@ are active.")
(evil-define-key* syd-alt-leader-key-states map (kbd syd-alt-leader-key) 'syd/leader))
(general-override-mode 1))
(defvar syd-escape-hook nil
"A hook run when C-g is pressed (or ESC in normal mode, for evil users).
More specifically, when `syd/escape' is pressed. If any hook returns non-nil,
all hooks after it are ignored.")
(defun syd/escape (&optional interactive)
"Run `syd-escape-hook'."
(interactive (list 'interactive))
(let ((inhibit-quit t))
(cond ((minibuffer-window-active-p (minibuffer-window))
;; quit the minibuffer if open.
(when interactive
(setq this-command 'abort-recursive-edit))
(abort-recursive-edit))
;; Run all escape hooks. If any returns non-nil, then stop there.
((run-hook-with-args-until-success 'syd-escape-hook))
;; don't abort macros
((or defining-kbd-macro executing-kbd-macro) nil)
;; Back to the default
((unwind-protect (keyboard-quit)
(when interactive
(setq this-command 'keyboard-quit)))))))
(with-eval-after-load 'eldoc
(eldoc-add-command 'syd/escape))
(defun syd-keybinds-initialise ()
(syd--initialise-leader)
(global-set-key [remap keyboard-quit] #'syd/escape)
;; Buffer
(require 'syd-buffers)
(general-def