Files
emacs-config/lisp/init-keybindings.el
Jens Luedicke 8644b5c469 Optimize configuration reload to prevent UI freezing
Implemented non-blocking reload mechanism that processes files
incrementally during idle time to prevent Emacs from freezing.

Changes:
- New default reload-emacs-config: Non-blocking with idle timers
- reload-emacs-config-blocking: Original blocking version
- reload-emacs-config-fast: Uses byte-compiled files for speed
- reload-emacs-config-smart: Only reloads recently changed files
- reload-current-file: Quick reload of current .el file only

Keybindings:
- C-c C-r: Non-blocking reload (new default)
- C-u C-c C-r: Blocking reload (old behavior)
- C-c r: Reload current file
- C-c R: Fast byte-compiled reload

This fixes the lag issue during configuration reload by loading
files one at a time with 0.01s idle gaps between them.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-10 14:59:43 +02:00

72 lines
2.3 KiB
EmacsLisp

;;; init-keybindings.el --- Global keybindings -*- lexical-binding: t -*-
;;; Commentary:
;;; Global keybinding configurations
;;; Code:
;;; Buffer management
(global-set-key (kbd "C-x k") 'kill-current-buffer-no-confirm)
;;; Configuration reload
;; Default: Non-blocking reload
(global-set-key (kbd "C-c C-r") 'reload-emacs-config)
;; C-u prefix: Blocking reload (old behavior)
(global-set-key (kbd "C-u C-c C-r") 'reload-emacs-config-blocking)
;; Quick reload for current file only
(global-set-key (kbd "C-c r") 'reload-current-file)
;; Fast reload using byte-compiled files
(global-set-key (kbd "C-c R") 'reload-emacs-config-fast)
;;; Portfolio tracker
(global-set-key (kbd "C-c $") 'portfolio-tracker)
;;; Window management
;; Consider adding ace-window or windmove keybindings here
;; (global-set-key (kbd "M-o") 'ace-window)
;; (windmove-default-keybindings)
;;; Better defaults
(global-set-key (kbd "C-x C-r") 'recentf-open-files)
(global-set-key (kbd "M-/") 'hippie-expand)
;;; Text manipulation helpers
(defun duplicate-current-line-or-region (arg)
"Duplicate current line, or region if active.
With argument ARG, make ARG copies."
(interactive "p")
(let (beg end (origin (point)))
(if (and mark-active (> (point) (mark)))
(exchange-point-and-mark))
(setq beg (line-beginning-position))
(if mark-active
(exchange-point-and-mark))
(setq end (line-end-position))
(let ((region (buffer-substring-no-properties beg end)))
(dotimes (i arg)
(goto-char end)
(newline)
(insert region)
(setq end (point)))
(goto-char (+ origin (* (length region) arg) arg)))))
(global-set-key (kbd "C-c C-d") 'duplicate-current-line-or-region)
;;; Quick buffer switching
(defun switch-to-previous-buffer ()
"Switch to the most recently used buffer."
(interactive)
(switch-to-buffer (other-buffer (current-buffer) 1)))
(global-set-key (kbd "C-c b") 'switch-to-previous-buffer)
;;; Alt-Tab style buffer cycling
;; Cycle through buffers with M-Tab (Alt-Tab)
(global-set-key (kbd "M-<tab>") 'next-buffer)
(global-set-key (kbd "M-S-<tab>") 'previous-buffer)
;; Alternative: Use C-Tab if M-Tab is captured by window manager
(global-set-key (kbd "C-<tab>") 'next-buffer)
(global-set-key (kbd "C-S-<tab>") 'previous-buffer)
(provide 'init-keybindings)
;;; init-keybindings.el ends here