summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--emacs/init.el54
1 files changed, 36 insertions, 18 deletions
diff --git a/emacs/init.el b/emacs/init.el
index a6e2512..03bfef3 100644
--- a/emacs/init.el
+++ b/emacs/init.el
@@ -19,7 +19,7 @@
;; To disable collection of benchmark data after init is done.
(add-hook 'after-init-hook 'benchmark-init/deactivate))
-(defun toggle-frame-transparency ()
+(defun my/toggle-frame-transparency ()
"Toggle transparency."
(interactive)
(let ((alpha-transparency 90))
@@ -27,7 +27,7 @@
(set-frame-parameter nil 'alpha-background 100)
(set-frame-parameter nil 'alpha-background alpha-transparency))))
-(defun wrap-region-paren ()
+(defun my/wrap-region-paren ()
"Wraps the region in parens. Similar to pressing ( with the region active."
(interactive)
(let ((beg (region-beginning))
@@ -38,7 +38,7 @@
(goto-char (+ end 1))
(insert ")"))))
-(defun zap-whitespace ()
+(defun my/zap-whitespace ()
"Zaps (deletes) the whitespace around the point in both directions."
(interactive)
(push-mark)
@@ -50,7 +50,7 @@
(goto-char (mark))
(pop-mark))
-(defun wrap-sexp (&optional arg)
+(defun my/wrap-sexp (&optional arg)
"Wraps the following sexp in a pair of parens.
Places inside the new pair, with prefix arg do the same backwards, pushing the
mark. Does the same of ARG number sexps if given"
@@ -62,7 +62,7 @@ mark. Does the same of ARG number sexps if given"
(insert-pair arg ?\( ?\)))
(insert-pair 1 ?\( ?\))))
-(defun close-or-kill ()
+(defun my/close-or-kill ()
"If this is the sole frame, kill emacs. Otherwise close the frame."
(interactive)
(if (eq 1 (length (frame-list)))
@@ -85,7 +85,7 @@ mark. Does the same of ARG number sexps if given"
(while (re-search-forward " +$" nil t)
(replace-match "" nil nil)))))
-(defun open-window-by-buffer (buffer)
+(defun my/open-window-by-buffer (buffer)
"Move focus to an extant window by the buffer it contains."
(interactive "bBuffer: ")
(let ((win (get-buffer-window buffer t)))
@@ -93,7 +93,7 @@ mark. Does the same of ARG number sexps if given"
(select-window win)
(switch-to-buffer buffer))))
-(defun shorten-path (path)
+(defun my/shorten-path (path)
"Shortens each directory in PATH except for the last directory to
its first character."
(let* ((components (split-string path "/"))
@@ -106,7 +106,7 @@ its first character."
components)))
(mapconcat 'identity shortened-components "/")))
-(defun swap-other-window-buffer ()
+(defun my/swap-other-window-buffer ()
"Try to switch the buffer contents of the current window and the
next in the cyclic ordering. Don't involve windows that are
dedicated."
@@ -126,6 +126,19 @@ dedicated."
(with-selected-window cw
(switch-to-buffer ob)))))))
+(require 'range)
+(defun my/c-x-n-to-m-n (&optional keymap)
+ "Rebind the keys starting with C-x [number] to M-[number] in the
+given keymap or in the global keymap."
+ (unless keymap (setq keymap global-map))
+ (range-map (lambda (n)
+ (let* ((from (concat "C-x " (format "%d" n)))
+ (to (concat "M-" (format "%d" n)))
+ (bind (keymap-lookup keymap from)))
+ (keymap-set keymap to bind)))
+ '((0 . 9))))
+(my/c-x-n-to-m-n)
+
(use-package server ; allow emacsclient
:demand t
:config
@@ -184,12 +197,12 @@ dedicated."
(corfu-quit-no-match t)
:bind (("M-/" . completion-at-point))
:init
- (defun corfu-commit-single ()
+ (defun my/corfu-commit-single ()
"Complete without asking if there is only one candidate."
(when (and (corfu--popup-visible-p)
(= (length corfu--candidates) 1))
(corfu-accept)))
- :hook (corfu-post-command . corfu-commit-single)
+ :hook (corfu-post-command . my/corfu-commit-single)
:config
(global-corfu-mode 1))
@@ -758,7 +771,13 @@ changes."
([?\M-D] . my/dmenu)
([?\M-E] . my/browser)
([M-return] . eshell)
- ))
+
+ ,@(mapcar (lambda (n)
+ (let* ((from (concat "C-x " (format "%d" n)))
+ (to (concat "M-" (format "%d" n)))
+ (bind (keymap-lookup global-map from)))
+ (cons (kbd to) bind)))
+ (number-sequence 0 9))))
(exwm-input-simulation-keys
'(;; movement
([?\C-b] . [left])
@@ -921,19 +940,19 @@ BEG and END define the region."
:hook
(text-mode . 'ispell-minor-mode)
:config
- (setq text-mode-hook (remove 'ispell-mode text-mode-hook)))
+ (setq-default text-mode-hook (remove 'ispell-mode text-mode-hook)))
(electric-pair-mode 1)
;; (setq x-super-keysym 'meta)
(global-set-key (kbd "C-x C-C") 'save-buffers-kill-terminal)
-(global-set-key (kbd "C-x C-c") 'close-or-kill)
+(global-set-key (kbd "C-x C-c") 'my/close-or-kill)
(global-set-key (kbd "M-w") 'copy-region-as-kill) ; make copying not flash cursor
-(global-set-key (kbd "C-x -") 'swap-other-window-buffer)
-(global-set-key (kbd "M-(") 'wrap-region-paren)
-(global-set-key (kbd "M-z") 'zap-whitespace)
-(global-set-key (kbd "C-M-z") 'wrap-sexp)
+(global-set-key (kbd "C-x -") 'my/swap-other-window-buffer)
+(global-set-key (kbd "M-(") 'my/wrap-region-paren)
+(global-set-key (kbd "M-z") 'my/zap-whitespace)
+(global-set-key (kbd "C-M-z") 'my/wrap-sexp)
(global-set-key (kbd "M-o") 'other-window)
(global-set-key (kbd "M-c") 'calc)
(global-set-key (kbd "M-U") 'scroll-lock-mode)
@@ -942,7 +961,6 @@ BEG and END define the region."
(global-set-key (kbd "C-x w o") 'my/toggle-window-other-reachability)
-
;; (use-package single-header
;; :ensure nil
;; :demand t