#+END_SRC
*** use-package
-**** Install it
-This section is soon to be deprecated by the release of Emacs version 29.
-
-#+BEGIN_SRC emacs-lisp
-(unless (package-installed-p 'use-package)
- (package-refresh-contents)
- (package-install 'use-package))
-#+END_SRC
-
**** Default to ensure
A large majority of the configuration with use-package is on 3rd-party packages. It makes more sense to do =:ensure nil= on base packages than to do =:ensure t= on all the 3rd-party ones.
(interactive)
(visual-fill-column-mode 'toggle))
-(global-set-key (kbd "C-c v") 'toggle-visual-fill-column-mode)
+(keymap-global-set (kbd "C-c v") 'toggle-visual-fill-column-mode)
#+END_SRC
#+BEGIN_SRC emacs-lisp
(use-package expand-region)
-(global-set-key (kbd "C-=") 'er/expand-region)
+(keymap-global-set (kbd "C-=") 'er/expand-region)
#+END_SRC
*** magit
(args (push arg args)))
(apply #'org-roam-node-insert args)))
-(global-set-key (kbd "C-c n i") 'org-roam-insert-immediate)
+(keymap-global-set (kbd "C-c n i") 'org-roam-insert-immediate)
#+END_SRC
** org-roam-ui
#+BEGIN_SRC emacs-lisp
(set-face-attribute 'show-paren-match nil
- :background nil
+ :background unspecified
:underline t)
#+END_SRC
The usual bindings.
#+BEGIN_SRC emacs-lisp
-(global-set-key (kbd "C-c l") 'org-store-link)
-(global-set-key (kbd "C-c a") 'org-agenda)
-(global-set-key (kbd "C-c c") 'org-capture)
+(keymap-global-set (kbd "C-c l") 'org-store-link)
+(keymap-global-set (kbd "C-c a") 'org-agenda)
+(keymap-global-set (kbd "C-c c") 'org-capture)
#+END_SRC
*** Directories
(add-hook 'dired-mode-hook
(lambda ()
(dired-hide-details-mode t)
- (define-key dired-mode-map
+ (keymap-set dired-mode-map
(kbd "RET") 'dired-find-alternate-file)))
#+END_SRC
*** Binding to start eshell
#+BEGIN_SRC emacs-lisp
-(global-set-key (kbd "C-c s") 'eshell)
+(keymap-global-set (kbd "C-c s") 'eshell)
#+END_SRC
*** Make it play nice with corfu
#+BEGIN_SRC emacs-lisp
(add-hook 'eshell-mode-hook
(lambda ()
- (define-key eshell-mode-map (kbd ")") 'eshell-send-on-close-paren)
- (define-key eshell-mode-map (kbd "]") 'eshell-close-sexp)
- (define-key eshell-mode-map (kbd "C-d") 'eshell-quit-or-delete-char)))
+ (keymap-set eshell-mode-map (kbd ")") 'eshell-send-on-close-paren)
+ (keymap-set eshell-mode-map (kbd "]") 'eshell-close-sexp)
+ (keymap-set eshell-mode-map (kbd "C-d") 'eshell-quit-or-delete-char)))
#+END_SRC
** Defuns and Bindings
**** Visiting Files
Bind =find-file-at-point= and =bookmark-jump-other-window=.
#+BEGIN_SRC emacs-lisp
-(global-set-key (kbd "C-x M-f") 'find-file-at-point)
-(global-set-key (kbd "C-x rB") 'bookmark-jump-other-window)
+(keymap-global-set (kbd "C-x M-f") 'find-file-at-point)
+(keymap-global-set (kbd "C-x rB") 'bookmark-jump-other-window)
#+END_SRC
**** Undo/redo
I like putting redo on =C-\=. Easier for me to remember than the =C-M-_= default.
#+BEGIN_SRC emacs-lisp
-(global-set-key (kbd "C-\\") 'undo-redo)
+(keymap-global-set (kbd "C-\\") 'undo-redo)
#+END_SRC
**** Renaming Files
(message "File '%s' successfully renamed to '%s'"
name (file-name-nondirectory new-name)))))))
-(global-set-key (kbd "C-x C-r") 'rename-current-buffer-file)
+(keymap-global-set (kbd "C-x C-r") 'rename-current-buffer-file)
#+END_SRC
**** Buffer Handling
Usually I want the buffer menu in the same window I am already on. Occasionally I want it in a different window. Bind accordingly.
#+BEGIN_SRC emacs-lisp
-(global-set-key (kbd "C-x C-b") 'buffer-menu)
-(global-set-key (kbd "C-x M-b") 'buffer-menu-other-window)
+(keymap-global-set (kbd "C-x C-b") 'buffer-menu)
+(keymap-global-set (kbd "C-x M-b") 'buffer-menu-other-window)
#+END_SRC
I often want to bring up the scratch buffer in my current window, and sometimes I want only one window that is the scratch buffer.
#+BEGIN_SRC emacs-lisp
-(defun go-to-scratch ()
- "Bring up the scratch buffer."
- (interactive)
- (switch-to-buffer (get-buffer-create "*scratch*")))
-
(defun scratch-only ()
"Bring up the scratch buffer as the only visible buffer."
(interactive)
- (go-to-scratch)
+ (scratch-buffer)
(delete-other-windows))
-(global-set-key (kbd "<f5>") 'go-to-scratch)
-(global-set-key (kbd "S-<f5>") 'scratch-only)
+(keymap-global-set (kbd "<f5>") 'scratch-buffer)
+(keymap-global-set (kbd "S-<f5>") 'scratch-only)
#+END_SRC
**** Line joining
(interactive)
(join-line 0))
-(global-set-key (kbd "M-j") 'backward-join-line)
+(keymap-global-set (kbd "M-j") 'backward-join-line)
#+END_SRC
**** Line opening
I Bind the previous functions to =C-o= and =M-o=.
#+BEGIN_SRC emacs-lisp
-(global-set-key (kbd "C-o") 'open-line-below)
-(global-set-key (kbd "M-o") 'open-line-above)
+(keymap-global-set (kbd "C-o") 'open-line-below)
+(keymap-global-set (kbd "M-o") 'open-line-above)
#+END_SRC
**** Commenting
(comment-or-uncomment-region (line-beginning-position)
(line-end-position))))
-(global-set-key (kbd "M-;") 'my-comment-dwim)
+(keymap-global-set (kbd "M-;") 'my-comment-dwim)
#+END_SRC
**** Killing
Bind =kill-whole-line= to =C-S-K= for something somewhat pnemonic.
#+BEGIN_SRC emacs-lisp
-(global-set-key (kbd "C-S-K") 'kill-whole-line)
+(keymap-global-set (kbd "C-S-K") 'kill-whole-line)
#+END_SRC
Bind =C-z= to zap-up-to-char, sice zap-to-char is on =M-z=.
#+BEGIN_SRC emacs-lisp
-(global-set-key (kbd "C-z") 'zap-up-to-char)
+(keymap-global-set (kbd "C-z") 'zap-up-to-char)
#+END_SRC
=C-w= is very much engrained for killing back one word, as is =C-u= for killing back to the beginning of the line. [[http://unix-kb.cat-v.org/][These have been standard bindings since TENEX...]]
(call-interactively 'kill-region)
(call-interactively 'backward-kill-word)))
-(global-set-key (kbd "C-w") 'kill-bword-or-region)
+(keymap-global-set (kbd "C-w") 'kill-bword-or-region)
#+END_SRC
There is no pre-made function to kill backward to the beginning of line from point, so I made one that passes the correct argument to =kill-line=, and bound it to =C-u=.
(interactive)
(kill-line 0))
-(global-set-key (kbd "C-u") 'backward-kill-line)
+(keymap-global-set (kbd "C-u") 'backward-kill-line)
#+END_SRC
Since =C-u= is =universal-argument=, I put that functionality on =M-'=.
#+BEGIN_SRC emacs-lisp
-(global-set-key (kbd "M-'") 'universal-argument)
+(keymap-global-set (kbd "M-'") 'universal-argument)
#+END_SRC
**** Moving
I want =Home= and =End= to take me to the top and bottom of the file.
#+BEGIN_SRC emacs-lisp
-(global-set-key (kbd "<home>") 'beginning-of-buffer)
-(global-set-key (kbd "<end>") 'end-of-buffer)
+(keymap-global-set (kbd "<home>") 'beginning-of-buffer)
+(keymap-global-set (kbd "<end>") 'end-of-buffer)
#+END_SRC
I have the infamous =smart-beginning-of-line= command here.
Remap =move-beginning-of-line=, then remap =beginning-of-visual-line= when going into =visual-line-mode=. A simple remap would not work for =visual-line-mode=, so I explicitly set =C-a=.
#+BEGIN_SRC emacs-lisp
-(global-set-key [remap move-beginning-of-line] 'smart-beginning-of-line)
+(keymap-global-set [remap move-beginning-of-line] 'smart-beginning-of-line)
(add-hook 'visual-line-mode-hook (lambda ()
- (global-set-key (kbd "C-a") 'smart-beginning-of-visual-line)))
+ (keymap-global-set (kbd "C-a") 'smart-beginning-of-visual-line)))
#+END_SRC
I don't want line numbers in the margin unless I am actively trying to go to a line. I override =goto-line= with this function, which shows line numbers, asks me where I want to go, and then hides line numbers.
(call-interactively 'goto-line)
(display-line-numbers-mode -1))
-(global-set-key [remap goto-line] 'my-goto-line)
+(keymap-global-set [remap goto-line] 'my-goto-line)
#+END_SRC
I ripped this defun and binding from [[https://github.com/lem-project/lem][lem]]. Can't live without it now.
(funcall split-window-preferred-function window)
(other-window 1)))
-(global-set-key (kbd "M-C-o") 'other-window-or-split-window)
+(keymap-global-set (kbd "M-C-o") 'other-window-or-split-window)
#+END_SRC
**** Search and Replace
I made these bindings to put my more-used commands on better keys, and swap them with the less-used ones.
#+BEGIN_SRC emacs-lisp
-(global-set-key (kbd "M-s .") 'isearch-forward-thing-at-point)
-(global-set-key (kbd "M-s M-.") 'isearch-forward-symbol-at-point)
-(global-set-key (kbd "M-%") 'replace-regexp)
-(global-set-key (kbd "C-%") 'replace-string)
-(global-set-key (kbd "C-S-R") 'isearch-backward-regexp)
-(global-set-key (kbd "C-S-S") 'isearch-forward-regexp)
+(keymap-global-set (kbd "M-s .") 'isearch-forward-thing-at-point)
+(keymap-global-set (kbd "M-s M-.") 'isearch-forward-symbol-at-point)
+(keymap-global-set (kbd "M-%") 'replace-regexp)
+(keymap-global-set (kbd "C-%") 'replace-string)
+(keymap-global-set (kbd "C-S-R") 'isearch-backward-regexp)
+(keymap-global-set (kbd "C-S-S") 'isearch-forward-regexp)
#+END_SRC
**** Elisp/Eval bindings
Some old Emacs-like editor (Edwin?) used this binding, so I put it in here. Less used than the =M-C-x= =eval-defun= binding, but occasionally nice to have.
#+BEGIN_SRC emacs-lisp
-(global-set-key (kbd "M-C-z") 'eval-region)
+(keymap-global-set (kbd "M-C-z") 'eval-region)
#+END_SRC
*** *NIX