Files
.emacs.d/lisp/init-terminal-kbd.el
User e2a352709c chore(config): Refactor Emacs config for cross-platform compatibility
Add Android/Termux support with `*is-android*` constant and
conditional GUI/terminal initialization. Remove maximized frame
defaults and custom.el. Replace corfu with corfu-terminal in
TTY. Add god-mode to terminal config with line number sync. Update
org agenda to use org-ql blocks with super-agenda grouping. Switch
solarized-theme to fork. Clean up redundant functions and unify
keyboard bindings across environments.
2026-05-18 20:46:26 +08:00

98 lines
2.2 KiB
EmacsLisp

;;; init-terminal-kbd.el --- keybindings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(defun open-init-file()
"Open user's init.el file in ~/.emacs.d ."
(interactive)
(find-file "~/.emacs.d/init.el"))
(defun duplicate-and-move-to-next-line()
"Duplicate current line and move to next line."
(interactive)
(progn
(duplicate-line)
(next-line)))
;; scratch buffer
(if *is-mac*
(general-def "C-c <f12>" 'scratch-buffer)
(general-def "C-c <delete>" 'scratch-buffer))
;; god-mode
(general-def god-local-mode-map
"i" 'god-mode-all
"<escape>" 'god-mode-all
"[" 'backward-paragraph
"]" 'forward-paragraph
"." 'repeat
"y" 'yank
"C-c C-<f12>" 'scratch-buffer
"z" 'avy-goto-char
"'" 'avy-goto-word-1
"<f2>" 'open-init-file)
;; global map with C-c prefix
(general-def
:prefix "C-c"
"e" 'er/expand-region
"k" 'comment-line
"f r" 'recentf
"i" 'imenu)
;; global map
(general-def
;; god-mode
"<escape>" 'god-mode-all
"M-i" 'god-mode-all
;; buffer, file, and window
"<f2>" 'open-init-file
"M-[" 'previous-buffer
"M-]" 'next-buffer
"C-x C-b" 'ibuffer-other-window
"C-x K" 'crux-kill-other-buffers
"C-x C-b" 'ibuffer-other-window
;; edit
"M-c" 'capitalize-dwim
"M-u" 'upcase-dwim
"M-l" 'downcase-dwim
"C-," 'duplicate-and-move-to-next-line
"C-k" 'crux-smart-kill-line
"C-<backspace>" 'crux-kill-line-backwards
"C-a" 'crux-move-beginning-of-line
"M-y" 'yank-from-kill-ring
"C-c DEL" 'hungry-delete-backward
"C-c C-DEL" 'hungry-delete-forward
"M-P" 'drag-stuff-up
"M-N" 'drag-stuff-down
;; undo
"C-/" 'undo-fu-only-undo
"C-?" 'undo-fu-only-redo
;; navigate
"M-p" 'backward-paragraph
"M-n" 'forward-paragraph
;; window
"M-<left>" 'shrink-window-horizontally
"M-<right>" 'enlarge-window-horizontally
"M-<down>" 'shrink-window
"M-<up>" 'enlarge-window
"M-o" 'other-window)
;; save-some-buffer时diff更改
(add-to-list 'save-some-buffers-action-alist
(list "d"
(lambda (buffer) (diff-buffer-with-file (buffer-file-name buffer)))
"show diff between the buffer and its file"))
(provide 'init-terminal-kbd)
;;; init-terminal-kbd.el ends here