diff options
| author | Craig Jennings <c@cjennings.net> | 2026-01-23 22:42:10 -0600 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-01-23 22:42:10 -0600 |
| commit | 7854ad74addd9bcae905def8fe4f844fb5c08678 (patch) | |
| tree | fb1849fc4ebece45697c844eac4047a76ad984d1 /modules | |
| parent | b62a9a792707581243b15116910d8aef33220d3f (diff) | |
fix(terminal): add console/mosh compatibility
- Create terminal-compat.el for arrow key escape sequences
- Fix M-uppercase keybindings (M-O → M-S-o, etc.) that conflicted
with terminal escape sequences ESC O A/B/C/D
- Add GUI-only guards for emojify and icon rendering
- 18 keybindings updated across 13 modules with override comments
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/calibredb-epub-config.el | 2 | ||||
| -rw-r--r-- | modules/chrono-tools.el | 2 | ||||
| -rw-r--r-- | modules/dwim-shell-config.el | 2 | ||||
| -rw-r--r-- | modules/elfeed-config.el | 2 | ||||
| -rw-r--r-- | modules/eww-config.el | 2 | ||||
| -rw-r--r-- | modules/font-config.el | 33 | ||||
| -rw-r--r-- | modules/keybindings.el | 2 | ||||
| -rw-r--r-- | modules/show-kill-ring.el | 2 | ||||
| -rw-r--r-- | modules/terminal-compat.el | 54 | ||||
| -rw-r--r-- | modules/text-config.el | 2 | ||||
| -rw-r--r-- | modules/ui-navigation.el | 12 | ||||
| -rw-r--r-- | modules/ui-theme.el | 2 | ||||
| -rw-r--r-- | modules/undead-buffers.el | 4 | ||||
| -rw-r--r-- | modules/weather-config.el | 2 |
14 files changed, 90 insertions, 33 deletions
diff --git a/modules/calibredb-epub-config.el b/modules/calibredb-epub-config.el index cf4b65ba..33767d5e 100644 --- a/modules/calibredb-epub-config.el +++ b/modules/calibredb-epub-config.el @@ -55,7 +55,7 @@ :defer 1 :commands calibredb :bind - ("M-B" . calibredb) + ("M-S-b" . calibredb) ;; was M-B, overrides backward-word ;; use built-in filter by tag, add clear-filters (:map calibredb-search-mode-map ("l" . calibredb-filter-by-tag) diff --git a/modules/chrono-tools.el b/modules/chrono-tools.el index ab3a9890..110da187 100644 --- a/modules/chrono-tools.el +++ b/modules/chrono-tools.el @@ -18,7 +18,7 @@ (use-package time-zones :defer :commands time-zones - :bind ("M-C" . time-zones)) + :bind ("M-S-c" . time-zones) ;; was M-C, overrides capitalize-word) ;; Commented out old world-clock config while testing time-zone package above ;; (use-package time diff --git a/modules/dwim-shell-config.el b/modules/dwim-shell-config.el index 1881f791..98159ec3 100644 --- a/modules/dwim-shell-config.el +++ b/modules/dwim-shell-config.el @@ -811,7 +811,7 @@ gpg: decryption failed: No pinentry" ;; Bind menu to keymaps after function is defined (with-eval-after-load 'dired - (keymap-set dired-mode-map "M-D" #'dwim-shell-commands-menu)) + (keymap-set dired-mode-map "M-S-d" #'dwim-shell-commands-menu)) ;; was M-D, overrides kill-word (with-eval-after-load 'dirvish (keymap-set dirvish-mode-map "M-D" #'dwim-shell-commands-menu))) diff --git a/modules/elfeed-config.el b/modules/elfeed-config.el index 52c5b8f1..58d961f9 100644 --- a/modules/elfeed-config.el +++ b/modules/elfeed-config.el @@ -22,7 +22,7 @@ (use-package elfeed :bind - ("M-R" . cj/elfeed-open) + ("M-S-r" . cj/elfeed-open) ;; was M-R (:map elfeed-show-mode-map ("w" . eww-open-in-new-buffer)) (:map elfeed-search-mode-map diff --git a/modules/eww-config.el b/modules/eww-config.el index 7d990f3a..16a1f5eb 100644 --- a/modules/eww-config.el +++ b/modules/eww-config.el @@ -59,7 +59,7 @@ (use-package eww :ensure nil ;; built-in :bind - (("M-E" . eww) + (("M-S-e" . eww) ;; was M-E, overrides forward-sentence :map eww-mode-map ("<" . eww-back-url) (">" . eww-forward-url) diff --git a/modules/font-config.el b/modules/font-config.el index 25026efc..8f673f94 100644 --- a/modules/font-config.el +++ b/modules/font-config.el @@ -42,13 +42,15 @@ ;; ;;; Code: +(require 'host-environment) + ;; ----------------------- Font Family And Size Selection ---------------------- ;; preset your fixed and variable fonts, then apply them to text as a set (use-package fontaine :demand t :bind - ("M-F" . fontaine-set-preset) + ("M-S-f" . fontaine-set-preset) ;; was M-F, overrides forward-word :config (setq fontaine-presets '( @@ -126,7 +128,7 @@ If FRAME is nil, uses the selected frame." (let ((target-frame (or frame (selected-frame)))) (unless (member target-frame cj/fontaine-configured-frames) (with-selected-frame target-frame - (when (display-graphic-p target-frame) + (when (env-gui-p target-frame) (fontaine-set-preset 'default) (push target-frame cj/fontaine-configured-frames)))))) @@ -143,7 +145,7 @@ If FRAME is nil, uses the selected frame." ;; Clean up deleted frames from tracking list (add-hook 'delete-frame-functions #'cj/cleanup-frame-list)) ;; Apply immediately in non-daemon mode - (when (display-graphic-p) + (when (env-gui-p) (cj/apply-font-settings-to-frame)))) ;; ----------------------------- Font Install Check ---------------------------- @@ -164,7 +166,7 @@ If FRAME is nil, uses the selected frame." ;; Check for font installation after frame creation (defun cj/maybe-install-all-the-icons-fonts (&optional _frame) "Install all-the-icons fonts if needed and we have a GUI." - (when (and (display-graphic-p) + (when (and (env-gui-p) (not (cj/font-installed-p "all-the-icons"))) (all-the-icons-install-fonts t) ;; Remove this hook after successful installation @@ -190,16 +192,17 @@ If FRAME is nil, uses the selected frame." ;; ----------------------------- Emoji Fonts Per OS ---------------------------- ;; Set emoji fonts in priority order (first found wins) -(cond - ;; Prefer Noto Color Emoji (Linux) - ((member "Noto Color Emoji" (font-family-list)) - (set-fontset-font t 'symbol (font-spec :family "Noto Color Emoji") nil 'prepend)) - ;; Then Apple Color Emoji (macOS) - ((member "Apple Color Emoji" (font-family-list)) - (set-fontset-font t 'symbol (font-spec :family "Apple Color Emoji") nil 'prepend)) - ;; Finally Segoe UI Emoji (Windows) - ((member "Segoe UI Emoji" (font-family-list)) - (set-fontset-font t 'symbol (font-spec :family "Segoe UI Emoji") nil 'prepend))) +(when (env-gui-p) + (cond + ;; Prefer Noto Color Emoji (Linux) + ((member "Noto Color Emoji" (font-family-list)) + (set-fontset-font t 'symbol (font-spec :family "Noto Color Emoji") nil 'prepend)) + ;; Then Apple Color Emoji (macOS) + ((member "Apple Color Emoji" (font-family-list)) + (set-fontset-font t 'symbol (font-spec :family "Apple Color Emoji") nil 'prepend)) + ;; Finally Segoe UI Emoji (Windows) + ((member "Segoe UI Emoji" (font-family-list)) + (set-fontset-font t 'symbol (font-spec :family "Segoe UI Emoji") nil 'prepend)))) ;; ---------------------------------- Emojify ---------------------------------- ;; converts emoji identifiers into emojis; allows for easy emoji entry. @@ -216,7 +219,7 @@ If FRAME is nil, uses the selected frame." :config (setq emojify-show-help nil) (setq emojify-point-entered-behaviour 'uncover) - (setq emojify-display-style 'image) + (setq emojify-display-style (if (env-gui-p) 'image 'unicode)) (setq emojify-emoji-styles '(ascii unicode github)) ;; Disable emojify in programming and gptel modes diff --git a/modules/keybindings.el b/modules/keybindings.el index 1eff621c..9d5ba454 100644 --- a/modules/keybindings.el +++ b/modules/keybindings.el @@ -113,7 +113,7 @@ Errors if VAR is unbound, not a non-empty string, or the file does not exist." ;; Add commonly-used general keybindings (keymap-global-set "M-*" #'calculator) -(keymap-global-set "M-Y" #'yank-media) +(keymap-global-set "M-S-y" #'yank-media) ;; was M-Y, overrides yank-pop ;; Normally bound to ESC ESC ESC, hit ESC once to get out of unpleasant situations. (keymap-global-set "<escape>" #'keyboard-escape-quit) diff --git a/modules/show-kill-ring.el b/modules/show-kill-ring.el index d5217719..a6c59e26 100644 --- a/modules/show-kill-ring.el +++ b/modules/show-kill-ring.el @@ -116,7 +116,7 @@ If it's too long, truncate it first." (setq kill-ring nil) (garbage-collect)) -(keymap-global-set "M-K" #'show-kill-ring) +(keymap-global-set "M-S-k" #'show-kill-ring) ;; was M-K, overrides kill-sentence (provide 'show-kill-ring) ;;; show-kill-ring.el ends here diff --git a/modules/terminal-compat.el b/modules/terminal-compat.el new file mode 100644 index 00000000..f959646d --- /dev/null +++ b/modules/terminal-compat.el @@ -0,0 +1,54 @@ +;;; terminal-compat.el --- Terminal compatibility fixes -*- lexical-binding: t; coding: utf-8; -*- +;; author: Craig Jennings <c@cjennings.net> + +;;; Commentary: + +;; Fixes for running Emacs in terminal/console mode, especially over mosh. +;; - Arrow key escape sequence handling +;; - Disable graphical icons that show as unicode artifacts + +;;; Code: + +(require 'host-environment) + +(defun cj/terminal-compat-setup () + "Set up terminal compatibility after init completes." + (when (env-terminal-p) + ;; Fix arrow key escape sequences for various terminal types + (define-key input-decode-map "\e[A" [up]) + (define-key input-decode-map "\e[B" [down]) + (define-key input-decode-map "\e[C" [right]) + (define-key input-decode-map "\e[D" [left]) + + ;; Application mode arrows (sent by some terminals) + (define-key input-decode-map "\eOA" [up]) + (define-key input-decode-map "\eOB" [down]) + (define-key input-decode-map "\eOC" [right]) + (define-key input-decode-map "\eOD" [left]))) + +;; Run after init completes to override any package settings +(add-hook 'emacs-startup-hook #'cj/terminal-compat-setup) + +;; Icon disabling only in terminal mode +(when (env-terminal-p) + ;; Disable nerd-icons display (shows as \uXXXX artifacts) + (with-eval-after-load 'nerd-icons + (defun nerd-icons-icon-for-file (&rest _) "") + (defun nerd-icons-icon-for-dir (&rest _) "") + (defun nerd-icons-icon-for-mode (&rest _) "") + (defun nerd-icons-icon-for-buffer (&rest _) "")) + + ;; Disable dashboard icons + (with-eval-after-load 'dashboard + (setq dashboard-display-icons-p nil) + (setq dashboard-set-file-icons nil) + (setq dashboard-set-heading-icons nil)) + + ;; Disable all-the-icons + (with-eval-after-load 'all-the-icons + (defun all-the-icons-icon-for-file (&rest _) "") + (defun all-the-icons-icon-for-dir (&rest _) "") + (defun all-the-icons-icon-for-mode (&rest _) ""))) + +(provide 'terminal-compat) +;;; terminal-compat.el ends here diff --git a/modules/text-config.el b/modules/text-config.el index 29db9e0b..30f63aa2 100644 --- a/modules/text-config.el +++ b/modules/text-config.el @@ -60,7 +60,7 @@ ;; edit selection in new buffer, C-c to finish; replaces with modifications (use-package edit-indirect - :bind ("M-I" . edit-indirect-region)) + :bind ("M-S-i" . edit-indirect-region) ;; was M-I) ;; ------------------------------ Prettify Symbols ----------------------------- ;; replacing the word l-a-m-b-d-a with a symbol, just because diff --git a/modules/ui-navigation.el b/modules/ui-navigation.el index 0a9864e6..8248bab6 100644 --- a/modules/ui-navigation.el +++ b/modules/ui-navigation.el @@ -60,7 +60,7 @@ (split-window-right) (other-window 1) (consult-buffer)) -(keymap-global-set "M-V" #'cj/split-and-follow-right) +(keymap-global-set "M-S-v" #'cj/split-and-follow-right) ;; was M-V, overrides scroll-down (defun cj/split-and-follow-below () "Split window vertically and select a buffer to display." @@ -68,7 +68,7 @@ (split-window-below) (other-window 1) (consult-buffer)) -(keymap-global-set "M-H" #'cj/split-and-follow-below) +(keymap-global-set "M-S-h" #'cj/split-and-follow-below) ;; was M-H ;; ------------------------- Split Window Reorientation ------------------------ @@ -101,10 +101,10 @@ This function won't work with more than one split window." (set-window-buffer (next-window) next-win-buffer) (select-window first-win) (if this-win-2nd (other-window 1)))))) -(keymap-global-set "M-T" #'toggle-window-split) +(keymap-global-set "M-S-t" #'toggle-window-split) ;; was M-T, overrides transpose-words ;; SWAP WINDOW POSITIONS -(keymap-global-set "M-S" #'window-swap-states) +(keymap-global-set "M-S-s" #'window-swap-states) ;; was M-S ;; ---------------------------- Buffer Manipulation ---------------------------- @@ -140,7 +140,7 @@ This function won't work with more than one split window." (find-file (if arg (nth arg recently-killed-list) (car recently-killed-list)))))) -(keymap-global-set "M-Z" #'cj/undo-kill-buffer) +(keymap-global-set "M-S-z" #'cj/undo-kill-buffer) ;; was M-Z, overrides zap-to-char ;; ---------------------------- Undo Layout Changes ---------------------------- ;; allows you to restore your window setup with C-c left-arrow @@ -148,7 +148,7 @@ This function won't work with more than one split window." (use-package winner :ensure nil ;; built-in - :bind ("M-U" . winner-undo) + :bind ("M-S-u" . winner-undo) ;; was M-U, overrides upcase-word :config (winner-mode 1)) diff --git a/modules/ui-theme.el b/modules/ui-theme.el index 1575257a..bc526f38 100644 --- a/modules/ui-theme.el +++ b/modules/ui-theme.el @@ -43,7 +43,7 @@ Unloads any other applied themes before applying the chosen theme." (load-theme (intern chosentheme) t)) (cj/save-theme-to-file)) -(keymap-global-set "M-L" #'cj/switch-themes) +(keymap-global-set "M-S-l" #'cj/switch-themes) ;; was M-L, overrides downcase-word ;; ----------------------------- Theme Persistence ----------------------------- ;; persistence utility functions used by switch themes. diff --git a/modules/undead-buffers.el b/modules/undead-buffers.el index fa09e04a..f79afb4b 100644 --- a/modules/undead-buffers.el +++ b/modules/undead-buffers.el @@ -75,7 +75,7 @@ ARG is passed to `save-some-buffers'." (unless (one-window-p) (delete-window)) (cj/kill-buffer-or-bury-alive buf))) -(keymap-global-set "M-O" #'cj/kill-other-window) +(keymap-global-set "M-S-o" #'cj/kill-other-window) (defun cj/kill-all-other-buffers-and-windows () "Kill or bury all other buffers, then delete other windows." @@ -84,7 +84,7 @@ ARG is passed to `save-some-buffers'." (delete-other-windows) (mapc #'cj/kill-buffer-or-bury-alive (delq (current-buffer) (buffer-list)))) -(keymap-global-set "M-M" #'cj/kill-all-other-buffers-and-windows) +(keymap-global-set "M-S-m" #'cj/kill-all-other-buffers-and-windows) ;; was M-M (provide 'undead-buffers) ;;; undead-buffers.el ends here diff --git a/modules/weather-config.el b/modules/weather-config.el index 0259d4a9..bf71ef9c 100644 --- a/modules/weather-config.el +++ b/modules/weather-config.el @@ -19,7 +19,7 @@ ;; Change this to t to enable debug logging ;; (setq wttrin-debug t) :bind - ("M-W" . wttrin) + ("M-S-w" . wttrin) ;; was M-W, overrides kill-ring-save :config (setopt wttrin-unit-system "u") (setopt wttrin-favorite-location "New Orleans, LA") |
