From 78f8026620a7045014f6d42e5851b8370b6d92b2 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 30 Aug 2024 18:45:00 -0400 Subject: [PATCH 1/5] fix(latex): auto-reveal folded regions at point Fix: #8031 --- modules/lang/latex/config.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index fdcfc5e15..066be1492 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -128,6 +128,9 @@ If no viewer is found, `latex-preview-pane-mode' is used.") :hook (TeX-mode . +latex-TeX-fold-buffer-h) :hook (TeX-mode . TeX-fold-mode) :config + ;; Reveal folds when moving cursor into them. This saves us the trouble of + ;; having to whitelist all motion commands in `TeX-fold-auto-reveal-commands'. + (setq TeX-fold-auto-reveal t) (defun +latex-TeX-fold-buffer-h () (run-with-idle-timer 0 nil 'TeX-fold-buffer)) ;; Fold after all AUCTeX macro insertions. From 34cc0c9d8658ba0906f77bb1b87bce13ed6f9bf4 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 30 Aug 2024 18:56:44 -0400 Subject: [PATCH 2/5] tweak(dired): ESC to exit wdired-mode Fix: #8004 --- modules/emacs/dired/config.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/emacs/dired/config.el b/modules/emacs/dired/config.el index ea2f76900..f88f0c555 100644 --- a/modules/emacs/dired/config.el +++ b/modules/emacs/dired/config.el @@ -59,7 +59,14 @@ Fixes #3939: unsortable dired entries on Windows." (not (eq revert-buffer-function #'dired-virtual-revert))) ;; To be consistent with vertico/ivy/helm+wgrep integration - (define-key dired-mode-map (kbd "C-c C-e") #'wdired-change-to-wdired-mode)) + (define-key dired-mode-map (kbd "C-c C-e") #'wdired-change-to-wdired-mode) + + ;; On ESC, abort `wdired-mode' (will prompt) + (add-hook! 'doom-escape-hook + (defun +dired-wdired-exit-h () + (when (eq major-mode 'wdired-mode) + (wdired-exit) + t)))) (use-package! dirvish From 0a38eeef4cbf27bf3f98a39f48f752e0dd3a1a72 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 30 Aug 2024 20:04:12 -0400 Subject: [PATCH 3/5] fix(tty): meta keybinds in KKP supported terminals In a KKP supported terminal, Emacs now receives a number of new input events from the terminal, like [M-return] and [M-tab], but if they aren't bound to, they don't fall through to bindings on "M-RET" and "M-TAB", like [return], [tab], and others do, thus rendering those keybinds inaccessible. Rather than play whack-a-mole with all the keymaps out there, I just teach Emacs to let them fall through. X->Y remappings on `local-function-key-map` do not apply if anything is bound explicitly to X, so this change bows out if you (or packages, in the future) do, for some reason, want to bind to them directly. --- modules/os/tty/config.el | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/os/tty/config.el b/modules/os/tty/config.el index 93cbc1a4f..8acc88848 100644 --- a/modules/os/tty/config.el +++ b/modules/os/tty/config.el @@ -46,4 +46,15 @@ ;; Add support for the Kitty keyboard protocol. (use-package! kkp - :hook (after-init . global-kkp-mode)) + :hook (after-init . global-kkp-mode) + :config + ;; HACK: Emacs falls back to RET, TAB, and/or DEL if [return], [tab], and/or + ;; [backspace] are unbound, but this isn't the case for all input events, + ;; like these, which don't fall back to M-RET, M-TAB, etc. Therefore making + ;; these keybinds inaccessible in KKP supported terminals. + ;; REVIEW: See benjaminor/kkp#13. + (define-key! local-function-key-map + [M-return] (kbd "M-RET") + [M-tab] (kbd "M-TAB") + [M-backspace] (kbd "M-DEL") + [M-delete] (kbd "M-DEL"))) From 538ddf5e66afb20f2dba6e4e06b134572c020c7d Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 30 Aug 2024 21:35:15 -0400 Subject: [PATCH 4/5] fix: C-i in KKP supported terminals "C-i" and "TAB" are equivalent to Emacs. In GUI Emacs, we can bind to [tab] instead of "TAB", permitted users to treat the two keys differently. However, [tab] is unavailable in TTY frames, so there was no avoiding sacrificing C-i keybinds there. With KKP support, though, that's no longer the case. --- lisp/doom-keybinds.el | 38 +++++++++++++++++--------------------- modules/os/tty/config.el | 12 +++++++++++- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/lisp/doom-keybinds.el b/lisp/doom-keybinds.el index 69d5250d9..9c797eaf8 100644 --- a/lisp/doom-keybinds.el +++ b/lisp/doom-keybinds.el @@ -50,27 +50,23 @@ and Emacs states, and for non-evil users.") (setq w32-lwindow-modifier 'super w32-rwindow-modifier 'super))) -;; HACK: Emacs cannot distinguish between C-i from TAB. This is largely a -;; byproduct of its history in the terminal, which can't distinguish them -;; either, however, when GUIs came about Emacs created separate input events -;; for more contentious keys like TAB and RET. Therefore [return] != RET, -;; [tab] != TAB, and [backspace] != DEL. -;; -;; In the same vein, this keybind adds a [C-i] event, so users can bind to it -;; independently of TAB. Otherwise, it falls back to keys bound to C-i. -(define-key key-translation-map [?\C-i] - (cmd! (if (let ((keys (this-single-command-raw-keys))) - (and keys - (not (cl-position 'tab keys)) - (not (cl-position 'kp-tab keys)) - (display-graphic-p) - ;; Fall back if no keybind can be found, otherwise - ;; we've broken all pre-existing C-i keybinds. - (let ((key - (doom-lookup-key - (vconcat (cl-subseq keys 0 -1) [C-i])))) - (not (or (numberp key) (null key)))))) - [C-i] [?\C-i]))) +;; HACK: Emacs can't distinguish C-i from TAB in either GUI or TTY frames. This +;; is a byproduct of its history with the terminal, which can't distinguish +;; them either, however, Emacs has separate input events for many contentious +;; keys like TAB and RET (like [tab] and [return], aka "" and +;; ""), which are only triggered in GUI frames, so here, I create one +;; for C-i. Won't work in TTY frames, though. Doom's :os tty module has a +;; workaround for that though. +(define-key input-decode-map + [?\C-i] (cmd! (if (when-let ((keys (this-single-command-raw-keys))) + (and (display-graphic-p) + (not (cl-position 'tab keys)) + (not (cl-position 'kp-tab keys)) + ;; Fall back if no keybind can be found, + ;; otherwise we've broken all pre-existing C-i + ;; keybinds. + (key-binding (vconcat (cl-subseq keys 0 -1) [C-i]) nil t))) + [C-i] [?\C-i]))) ;; diff --git a/modules/os/tty/config.el b/modules/os/tty/config.el index 8acc88848..36a69a188 100644 --- a/modules/os/tty/config.el +++ b/modules/os/tty/config.el @@ -57,4 +57,14 @@ [M-return] (kbd "M-RET") [M-tab] (kbd "M-TAB") [M-backspace] (kbd "M-DEL") - [M-delete] (kbd "M-DEL"))) + [M-delete] (kbd "M-DEL")) + + ;; HACK: Allow C-i to function independently of TAB in KKP-supported + ;; terminals. Requires the `input-decode-map' entry in + ;; lisp/doom-keybinds.el. + (define-key! key-translation-map + [?\C-i] (cmd! (if-let (((kkp--terminal-has-active-kkp-p)) + (keys (this-single-command-raw-keys)) + ((> (length keys) 2)) + ((equal (cl-subseq keys -3) [27 91 49]))) + [C-i] [?\C-i])))) From 22fc36dba7078f1b6938b2c06abc82e073ff3688 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 31 Aug 2024 00:45:43 -0400 Subject: [PATCH 5/5] fix(lib): doom/add-directory-as-project If the target directory wasn't in a project, this command would throw a type error (see #8032). This also adds more checks and informative error handling to the command. Fix: #8032 --- lisp/lib/projects.el | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lisp/lib/projects.el b/lisp/lib/projects.el index 3a38750d9..b320f8a14 100644 --- a/lisp/lib/projects.el +++ b/lisp/lib/projects.el @@ -79,16 +79,21 @@ file will be created within it so that it will always be treated as one. This command will throw an error if a parent of DIR is a valid project (which would mask DIR)." (interactive "D") + (when-let ((proj-dir (doom-project-root dir))) + (if (file-equal-p proj-dir dir) + (user-error "ERROR: Directory is already a project: %s" proj-dir) + (user-error "ERROR: Directory is already inside another project: %s" proj-dir))) (let ((short-dir (abbreviate-file-name dir))) - (unless (file-equal-p (doom-project-root dir) dir) - (with-temp-file (doom-path dir ".project"))) - (let ((proj-dir (doom-project-root dir))) - (unless (file-equal-p proj-dir dir) - (user-error "Can't add %S as a project, because %S is already a project" - short-dir (abbreviate-file-name proj-dir))) - (message "%S was not a project; adding .project file to it" - short-dir (abbreviate-file-name proj-dir)) - (projectile-add-known-project dir)))) + (when (projectile-ignored-project-p dir) + (user-error "ERROR: Directory is in projectile's ignore list: %s" short-dir)) + (dolist (proj projectile-known-projects) + (when (file-in-directory-p proj dir) + (user-error "ERROR: Directory contains a known project: %s" short-dir)) + (when (file-equal-p proj dir) + (user-error "ERROR: Directory is already a known project: %s" short-dir))) + (with-temp-file (doom-path dir ".project")) + (message "Added directory as a project: %s" short-dir) + (projectile-add-known-project dir))) ;;