dev: merge branch 'master'

This commit is contained in:
Matt Nish-Lapidus 2024-08-31 10:36:01 -04:00
commit cf4462683f
5 changed files with 64 additions and 32 deletions

View file

@ -55,27 +55,23 @@ and Emacs states, and for non-evil users.")
(setq w32-lwindow-modifier 'super (setq w32-lwindow-modifier 'super
w32-rwindow-modifier 'super))) w32-rwindow-modifier 'super)))
;; HACK: Emacs cannot distinguish between C-i from TAB. This is largely a ;; HACK: Emacs can't distinguish C-i from TAB in either GUI or TTY frames. This
;; byproduct of its history in the terminal, which can't distinguish them ;; is a byproduct of its history with the terminal, which can't distinguish
;; either, however, when GUIs came about Emacs created separate input events ;; them either, however, Emacs has separate input events for many contentious
;; for more contentious keys like TAB and RET. Therefore [return] != RET, ;; keys like TAB and RET (like [tab] and [return], aka "<tab>" and
;; [tab] != TAB, and [backspace] != DEL. ;; "<return>"), 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
;; In the same vein, this keybind adds a [C-i] event, so users can bind to it ;; workaround for that though.
;; independently of TAB. Otherwise, it falls back to keys bound to C-i. (define-key input-decode-map
(define-key key-translation-map [?\C-i] [?\C-i] (cmd! (if (when-let ((keys (this-single-command-raw-keys)))
(cmd! (if (let ((keys (this-single-command-raw-keys))) (and (display-graphic-p)
(and keys (not (cl-position 'tab keys))
(not (cl-position 'tab keys)) (not (cl-position 'kp-tab keys))
(not (cl-position 'kp-tab keys)) ;; Fall back if no <C-i> keybind can be found,
(display-graphic-p) ;; otherwise we've broken all pre-existing C-i
;; Fall back if no <C-i> keybind can be found, otherwise ;; keybinds.
;; we've broken all pre-existing C-i keybinds. (key-binding (vconcat (cl-subseq keys 0 -1) [C-i]) nil t)))
(let ((key [C-i] [?\C-i])))
(doom-lookup-key
(vconcat (cl-subseq keys 0 -1) [C-i]))))
(not (or (numberp key) (null key))))))
[C-i] [?\C-i])))
;; ;;

View file

@ -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 command will throw an error if a parent of DIR is a valid project (which would
mask DIR)." mask DIR)."
(interactive "D") (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))) (let ((short-dir (abbreviate-file-name dir)))
(unless (file-equal-p (doom-project-root dir) dir) (when (projectile-ignored-project-p dir)
(with-temp-file (doom-path dir ".project"))) (user-error "ERROR: Directory is in projectile's ignore list: %s" short-dir))
(let ((proj-dir (doom-project-root dir))) (dolist (proj projectile-known-projects)
(unless (file-equal-p proj-dir dir) (when (file-in-directory-p proj dir)
(user-error "Can't add %S as a project, because %S is already a project" (user-error "ERROR: Directory contains a known project: %s" short-dir))
short-dir (abbreviate-file-name proj-dir))) (when (file-equal-p proj dir)
(message "%S was not a project; adding .project file to it" (user-error "ERROR: Directory is already a known project: %s" short-dir)))
short-dir (abbreviate-file-name proj-dir)) (with-temp-file (doom-path dir ".project"))
(projectile-add-known-project dir)))) (message "Added directory as a project: %s" short-dir)
(projectile-add-known-project dir)))
;; ;;

View file

@ -59,7 +59,14 @@ Fixes #3939: unsortable dired entries on Windows."
(not (eq revert-buffer-function #'dired-virtual-revert))) (not (eq revert-buffer-function #'dired-virtual-revert)))
;; To be consistent with vertico/ivy/helm+wgrep integration ;; 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 (use-package! dirvish

View file

@ -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 . +latex-TeX-fold-buffer-h)
:hook (TeX-mode . TeX-fold-mode) :hook (TeX-mode . TeX-fold-mode)
:config :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 () (defun +latex-TeX-fold-buffer-h ()
(run-with-idle-timer 0 nil 'TeX-fold-buffer)) (run-with-idle-timer 0 nil 'TeX-fold-buffer))
;; Fold after all AUCTeX macro insertions. ;; Fold after all AUCTeX macro insertions.

View file

@ -46,4 +46,25 @@
;; Add support for the Kitty keyboard protocol. ;; Add support for the Kitty keyboard protocol.
(use-package! kkp (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"))
;; 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]))))