Switch to using keymap-global-set' and keymap-set'

This commit is contained in:
Gerard Vermeulen 2023-02-26 14:37:33 +01:00
parent 402f89d7fe
commit ed91d44303

View File

@ -612,7 +612,7 @@ and [[lst:3rd-window-management]] implement a selection of his recommendations.
(lambda (buffer-name action)
(with-current-buffer buffer-name (apply #'derived-mode-p major-modes))))
(global-set-key (kbd "M-o") #'other-window))
(keymap-global-set "M-o" #'other-window))
#+end_src
#+caption[Window management modes]:
@ -812,8 +812,8 @@ by experienced Emacs users.
;; Finally, switch to that window.
(other-window 1)))
(define-key dired-mode-map (kbd "E") #'dired-eww-open-file)
(define-key dired-mode-map (kbd "Y") #'dired-rsync))
(keymap-set dired-mode-map "E" #'dired-eww-open-file)
(keymap-set dired-mode-map "Y" #'dired-rsync))
#+end_src
* [[info:emacs#Completion Styles][Minibuffer completion styles (info)]]
@ -907,7 +907,7 @@ defined in this Org file.
#+name: lst:configure-shortdoc
#+begin_src emacs-lisp -n :results silent
(when (fboundp 'shortdoc-display-group)
(define-key help-map (kbd "y") #'shortdoc-display-group)
(keymap-set help-map "y" #'shortdoc-display-group)
(with-eval-after-load 'shortdoc
;; Ensure defining the functions before documenting them.
(define-short-documentation-group init
@ -1040,7 +1040,7 @@ Enable it and re-execute it."
(not (get-buffer-window ilog-buffer-name)))
(display-buffer (get-buffer ilog-buffer-name))))
(define-key help-map (kbd "C-l") #'interaction-log-mode)
(keymap-set help-map "C-l" #'interaction-log-mode)
(advice-add 'ilog-timer-function :after #'ilog-ensure-ilog-buffer-window))
#+end_src
@ -1294,9 +1294,9 @@ file.
(fboundp 'vertico-mode))
(vertico-mode +1))
(with-eval-after-load 'vertico
(define-key vertico-map (kbd "RET") #'vertico-directory-enter)
(define-key vertico-map (kbd "DEL") #'vertico-directory-delete-char)
(define-key vertico-map (kbd "M-DEL") #'vertico-directory-delete-word))
(keymap-set vertico-map "RET" #'vertico-directory-enter)
(keymap-set vertico-map "DEL" #'vertico-directory-delete-char)
(keymap-set vertico-map "M-DEL" #'vertico-directory-delete-word))
#+end_src
#+attr_latex: :booktabs yes :float table
@ -1376,11 +1376,11 @@ Listing [[lst:bind-embark-commands][bind =embark= commands]] binds =embark= comm
#+begin_src emacs-lisp -n :results silent
(when (ensure-package-installation 'embark 'embark-consult)
(when (fboundp 'embark-act)
(global-set-key (kbd "C-,") #'embark-act))
(keymap-global-set "C-," #'embark-act))
(when (fboundp 'embark-dwim)
(global-set-key (kbd "C-:") #'embark-dwim))
(keymap-global-set "C-:" #'embark-dwim))
(when (fboundp 'embark-bindings)
(global-set-key (kbd "C-h B") #'embark-bindings))
(keymap-global-set "C-h B" #'embark-bindings))
(when (fboundp 'embark-prefix-help-command)
(setq prefix-help-command #'embark-prefix-help-command)))
#+end_src
@ -1463,32 +1463,32 @@ completion function [[info:elisp#Minibuffer Completion][completing-read]]. List
#+begin_src emacs-lisp -n :results silent
(when (ensure-package-installation 'consult)
;; C-c bindings (current-global-map)
(global-set-key (kbd "C-c h") #'consult-history)
(global-set-key (kbd "C-c m") #'consult-mode-command)
(keymap-global-set "C-c h" #'consult-history)
(keymap-global-set "C-c m" #'consult-mode-command)
;; C-x bindings (ctl-x-map)
(define-key ctl-x-map (kbd "M-:") #'consult-complex-command)
(define-key ctl-x-map (kbd "b") #'consult-buffer)
(define-key ctl-x-4-map (kbd "b") #'consult-buffer-other-window)
(define-key ctl-x-5-map (kbd "b") #'consult-buffer-other-frame)
(define-key ctl-x-r-map (kbd "x") #'consult-register)
(define-key ctl-x-r-map (kbd "b") #'consult-bookmark)
(keymap-set ctl-x-map "M-:" #'consult-complex-command)
(keymap-set ctl-x-map "b" #'consult-buffer)
(keymap-set ctl-x-4-map "b" #'consult-buffer-other-window)
(keymap-set ctl-x-5-map "b" #'consult-buffer-other-frame)
(keymap-set ctl-x-r-map "x" #'consult-register)
(keymap-set ctl-x-r-map "b" #'consult-bookmark)
;; M-g bindings (goto-map)
(define-key goto-map (kbd "g") #'consult-goto-line)
(define-key goto-map (kbd "M-g") #'consult-goto-line)
(define-key goto-map (kbd "o") #'consult-outline)
(define-key goto-map (kbd "m") #'consult-mark)
(define-key goto-map (kbd "k") #'consult-global-mark)
(define-key goto-map (kbd "i") #'consult-imenu)
(define-key goto-map (kbd "e") #'consult-compile-error)
(keymap-set goto-map "g" #'consult-goto-line)
(keymap-set goto-map "M-g" #'consult-goto-line)
(keymap-set goto-map "o" #'consult-outline)
(keymap-set goto-map "m" #'consult-mark)
(keymap-set goto-map "k" #'consult-global-mark)
(keymap-set goto-map "i" #'consult-imenu)
(keymap-set goto-map "e" #'consult-compile-error)
;; M-s bindings (search-map)
(define-key search-map (kbd "g") #'consult-git-grep)
(define-key search-map (kbd "f") #'consult-find)
(define-key search-map (kbd "k") #'consult-keep-lines)
(define-key search-map (kbd "l") #'consult-line)
(define-key search-map (kbd "m") #'consult-multi-occur)
(define-key search-map (kbd "u") #'consult-focus-lines)
(keymap-set search-map "g" #'consult-git-grep)
(keymap-set search-map "f" #'consult-find)
(keymap-set search-map "k" #'consult-keep-lines)
(keymap-set search-map "l" #'consult-line)
(keymap-set search-map "m" #'consult-multi-occur)
(keymap-set search-map "u" #'consult-focus-lines)
;; Other bindings (current-global-map)
(global-set-key (kbd "M-y") #'consult-yank-pop))
(keymap-global-set "M-y" #'consult-yank-pop))
#+end_src
** [[https://company-mode.github.io/][Company: a modular complete anything framework for Emacs]]
@ -1567,9 +1567,9 @@ the current [[https://en.wikipedia.org/wiki/Version_control][VCS]] directory tre
#+begin_src emacs-lisp -n :results silent
(when (and (ensure-package-installation 'deadgrep)
(fboundp 'deadgrep))
(define-key search-map (kbd "d") #'deadgrep)
(keymap-set search-map "d" #'deadgrep)
(with-eval-after-load 'deadgrep
(define-key deadgrep-mode-map (kbd "C-c C-w") #'deadgrep-edit-mode)))
(keymap-set deadgrep-mode-map "C-c C-w" #'deadgrep-edit-mode)))
#+end_src
** [[https://www.genivia.com/get-ugrep.html][Ugrep]]
@ -1803,8 +1803,8 @@ rebuild the =epdfinfo= executable that serves the [[https://en.wikipedia.org/wik
(with-eval-after-load 'pdf-outline
;; Unmask the `image-save' key binding in `pdf-view-mode-map' and
;; in `image-mode-map' (by parenthood).
(define-key pdf-outline-minor-mode-map (kbd "o") nil)
(define-key pdf-outline-minor-mode-map (kbd "O") #'pdf-outline))
(keymap-set pdf-outline-minor-mode-map "o" nil)
(keymap-set pdf-outline-minor-mode-map "O" #'pdf-outline))
(with-eval-after-load 'pdf-view
(setopt pdf-view-display-size 'fit-page
@ -2189,12 +2189,10 @@ When called twice, replace the previously inserted \\(\\) by one $."
(with-eval-after-load 'org
(setopt org-return-follows-link t)
(define-key org-mode-map
(kbd "C-c <SPC>") #'org-inactive-current-time-stamp)
(define-key org-mode-map
(kbd "C-c C-<SPC>") #'org-active-current-time-stamp)
(define-key org-mode-map (kbd "$") #'org-electric-dollar)
(define-key org-mode-map (kbd "M-q") #'org-fill-paragraph)))
(keymap-set org-mode-map "C-c <SPC>" #'org-inactive-current-time-stamp)
(keymap-set org-mode-map "C-c C-<SPC>" #'org-active-current-time-stamp)
(keymap-set org-mode-map "$" #'org-electric-dollar)
(keymap-set org-mode-map "M-q" #'org-fill-paragraph)))
#+end_src
#+caption[Setup =org-src=]:
@ -2439,7 +2437,7 @@ processor, text to product convertor) to an Emacs setup. Listing
(require 'oc-csl)))
(with-eval-after-load 'org
(define-key org-mode-map (kbd "C-c b") #'org-cite-insert))
(keymap-set org-mode-map "C-c b" #'org-cite-insert))
(when (ensure-package-installation 'citar 'citar-embark)
(with-eval-after-load 'embark
@ -3820,9 +3818,9 @@ configuration:
("ruff-lsp")))))))))
(with-eval-after-load 'eglot
(define-key eglot-mode-map (kbd "C-c n") 'flymake-goto-next-error)
(define-key eglot-mode-map (kbd "C-c p") 'flymake-goto-prev-error)
(define-key eglot-mode-map (kbd "C-c r") 'eglot-rename))
(keymap-set eglot-mode-map "C-c n" 'flymake-goto-next-error)
(keymap-set eglot-mode-map "C-c p" 'flymake-goto-prev-error)
(keymap-set eglot-mode-map "C-c r" 'eglot-rename))
#+end_src
#+caption[Help to setup any =org-src-mode= buffers for =eglot=]:
@ -4047,7 +4045,7 @@ Listing [[lst:sbcl-core-for-sly]] tangles to a script to dump such a [[http://ww
"file:///usr/share/doc/hyperspec-7.0/HyperSpec/"))
(t (message "Default Common Lisp HyperSpec access")))
(define-key sly-prefix-map (kbd "M-h") #'sly-documentation-lookup)))
(keymap-set sly-prefix-map "M-h" #'sly-documentation-lookup)))
#+end_src
#+caption[Script to dump a SBCL core for the Sly Common Lisp IDE]:
@ -5233,9 +5231,9 @@ configures =code-cells=.
(when (ensure-package-installation 'code-cells)
(with-eval-after-load 'code-cells
(let ((map code-cells-mode-map))
(define-key map (kbd "M-p") #'code-cells-backward-cell)
(define-key map (kbd "M-n") #'code-cells-forward-cell)
(define-key map (kbd "C-c C-c") #'code-cells-eval))))
(keymap-set map "M-p" #'code-cells-backward-cell)
(keymap-set map "M-n" #'code-cells-forward-cell)
(keymap-set map "C-c C-c" #'code-cells-eval))))
#+end_src
*** TODO Look into: editing facilities
@ -5632,8 +5630,8 @@ narrowed."
(t
(narrow-to-defun))))
(define-key ctl-x-map (kbd "n t") #'org-narrow-to-table)
(define-key ctl-x-map (kbd "C-n") #'narrow-or-widen-dwim))
(keymap-set ctl-x-map "n t" #'org-narrow-to-table)
(keymap-set ctl-x-map "C-n" #'narrow-or-widen-dwim))
#+end_src
** [[https://jblevins.org/log/rainbow-mode][Visualize color codes and names]]
@ -5920,7 +5918,7 @@ sets the =webjump-sites= option.
#+name: lst:set-webjump-options
#+begin_src emacs-lisp -n :results silent
(when (fboundp 'webjump)
(global-set-key (kbd "C-c j") 'webjump)
(keymap-global-set "C-c j" 'webjump)
(with-eval-after-load 'webjump
(setopt
webjump-sites
@ -6123,7 +6121,7 @@ command, and makes a minimal attempt to enable =emms=.
#+begin_src emacs-lisp -n :results silent
(when (and (ensure-package-installation 'elfeed)
(fboundp 'elfeed))
(global-set-key (kbd "C-x w") #'elfeed)
(keymap-global-set "C-x w" #'elfeed)
(with-eval-after-load 'elfeed
(setopt