[:ui layout bepo] Fix notmuch, C-, M- mappings

WIP:
- Add fixme for evil-org remaps

Misc changes:
- Remove notmuch-search binding
  (Unmap the bare "s" keymap from notmuch)
- Remap [] evil-org bindings to ()
- Fix org-capture not finalizing with C-c
- Remap evilem-map
- Add more triggers to minibuffer rotations
- Unmap C-c and C-r from evil-org

Meta:
- Specify bepo layout in maintainer status
- Add basic troubleshooting

In the remapping functions:
- Add operator maps
- Remap C- and M- bindings in normal mode

Respect evil-org-movement-bindings:
This allow non-qwerty users to keep the correct bindings. The additional
let-binding is done to force evaluation of the concatenations and avoid
`void-variable concat` when the map! gets evaluated

Avoid double rotation on magit maps

- Reorder properly magit-mode-map like done on notmuch
  (evil-collection PR#428)
This commit is contained in:
Gerry Agbobada 2020-12-10 01:21:25 +01:00 committed by Gerry Agbobada
parent 3f4cc77d2a
commit 065b26e0c5
No known key found for this signature in database
GPG Key ID: 53F94866E84818F6
4 changed files with 232 additions and 77 deletions

View File

@ -81,7 +81,7 @@
:n "C-#" #'+popup/raise))
(after! treemacs
(doom-bepo-rotate-ts-bare-keymap '(evil-treemacs-state-map)))
(after! (:or helm ivy)
(after! (:or helm ivy selectrum icomplete)
(doom-bepo-rotate-bare-keymap
'(minibuffer-local-map
minibuffer-local-ns-map
@ -127,11 +127,44 @@
(t
(kbd "C-h !")))
'org-time-stamp-inactive)
(apply #'completing-read args))))
(apply #'completing-read args)))
;; Finalizing an Org-capture become `C-l C-c` (or `C-r C-c`) on top of `ZZ`
(doom-bepo-rotate-bare-keymap '(org-capture-mode-map) doom-bepo-cr-rotation-style))
(after! (evil org evil-org)
;; FIXME: This map! call is being interpreted before the
;; map! call in (use-package! evil-org :config) in modules/lang/org/config.el
;; Therefore, this map! needs to be reevaluated to have effect.
;; Need to find a way to call the code below after the :config block
;; in :lang org code
;; Direct access for "unimpaired" like improvements
(map! :map evil-org-mode-map
;; evil-org-movement bindings having "c" and "r" means
;; C-r gets mapped to `org-shiftright' in normal and insert state.
;; C-c gets mapped to `org-shiftleft' in normal and insert state.
:ni "C-r" nil
:ni "C-c" nil
:ni "C-»" #'org-shiftright
:ni "C-«" #'org-shiftleft
:m ")" nil
:m "(" nil
:m "]" #'evil-org-forward-sentence
:m "[" #'evil-org-backward-sentence
:m ")h" #'org-forward-heading-same-level
:m "(h" #'org-backward-heading-same-level
:m ")l" #'org-next-link
:m "(l" #'org-previous-link
:m ")c" #'org-babel-next-src-block
:m "(c" #'org-babel-previous-src-block))
(after! (evil org evil-org-agenda)
(doom-bepo-rotate-bare-keymap '(org-agenda-keymap) doom-bepo-cr-rotation-style)
(doom-bepo--evil-collection-hook nil '(evil-org-agenda-mode-map)))
(after! (evil magit evil-collection-magit)
(after! notmuch
;; Without this, "s" is mapped to 'notmuch-search and
;; takes precedence over the evil command to go up one line
(map! :map notmuch-common-keymap :n "s" nil)
(map! :map notmuch-common-keymap "s" nil))
(after! (evil magit)
(doom-bepo-rotate-ts-bare-keymap
'(magit-mode-map
magit-diff-section-base-map
@ -140,21 +173,40 @@
magit-untracked-section-map))
;; Without this, "s" is mapped to 'magit-delete-thing (the old "k" for "kill") and
;; takes precedence over the evil command to go up one line
;; :nv doesn't work on this, needs to be the bare map.
;; This is the output of `describe-function 'magit-delete-thing` when we add :nv or :nvm
;; Key Bindings
;; evil-collection-magit-mode-map-backup-map <normal-state> x
;; evil-collection-magit-mode-map-backup-map <visual-state> x
;; evil-collection-magit-mode-map-backup-map k
;; evil-collection-magit-mode-map-normal-state-backup-map x
;; evil-collection-magit-mode-map-visual-state-backup-map x
;; magit-mode-map <normal-state> x
;; magit-mode-map <visual-state> x
;; magit-mode-map s
(map! :map magit-mode-map "s" nil)
;; Even though magit bindings are part of evil-collection now,
;; the hook only runs on `evil-collection-magit-maps`, which is
;; way to short to cover all usages.
;; The hook is run manually on other maps
;; NOTE: magit-mode-map is last because other keymaps inherit from it.
;; Therefore to prevent a "double rotation" issue, magit-mode-map is
;; changed last
(doom-bepo--evil-collection-hook
nil
'(magit-mode-map
magit-cherry-mode-map
magit-mode-map
'(magit-cherry-mode-map
magit-blob-mode-map
magit-diff-mode-map
magit-log-mode-map
magit-log-select-mode-map
magit-reflog-mode-map
magit-status-mode-map
magit-file-mode-map
magit-log-read-revs-map
magit-process-mode-map
magit-refs-mode-map)))
magit-refs-mode-map
magit-mode-map)))
(after! evil-easymotion
;; instead of using gs as the evilem-map we use gé to avoid conflicts with org-mode
;; down the road
(map! :nvm "" evilem-map)
(doom-bepo-rotate-bare-keymap '(evilem-map) doom-bepo-cr-rotation-style))))

View File

@ -11,18 +11,21 @@
- [[#prerequisites][Prerequisites]]
- [[#features][Features]]
- [[#bépo][Bépo]]
- [[#easymotion][Easymotion]]
- [[#leaving-mnemonics-alone-when-possible][Leaving mnemonics alone when possible]]
- [[#possible-contributions][Possible contributions]]
- [[#org-mode][Org-mode]]
- [[#configuration][Configuration]]
- [[#bépo-1][Bépo]]
- [[#troubleshooting][Troubleshooting]]
- [[#how-to-investigate-an-issue-][How to investigate an issue ?]]
- [[#how-to-deactivate-the-new-bindings-and-go-back-to-the-old-ones-][How to deactivate the new bindings and go back to the old ones ?]]
* Description
This module provides barebones support for using Doom with non-qwerty layouts.
** Maintainers
+ @gagbo (Author)
+ @gagbo (Author, Bépo)
** Module Flags
+ =+bepo= Enables modifications for the BÉPO layout (customized with version 1.1 in mind)
@ -43,15 +46,24 @@ Support for the bépo layout includes:
- Setting Avy keys to the correct home row keys
- Changing navigation keys to =ctsr=
+ old =t= is mapped to =j=
+ old =s= is mapped to =k= (i.e. staging in the magit status buffer is done with =k=)
+ old =s= is mapped to =k= (i.e. staging in the magit status buffer is done
with =k=)
+ See [[*Configuration][Configuration]] to see where old =c= and =r= functions
are remapped
- Bind =<>= functions to =«»= keys when possible
- Bind =[]= functions to =()= keys when possible
- Bind =[]= functions to =()= keys when possible (the "unimpaired-like"
bindings)
- Bind =é= key to =w= functions when possible
- Bind =è= key to useful functions when possible
- Bind =`~= functions to =$#= keys when possible
*** Easymotion
If you use =evil-easymotion=, then all the bindings that were on =gs= have been
moved to =gé=.
In short : =g s j= -> =g é t= (evilem-motion-next-line). And so on.
*** Leaving mnemonics alone when possible
Exchanging =hjkl= to =ctsr= has the effect of destroying a few mnemonics: the
change operator becomes =l= for example, or the window split becomes =SPC é k=.
@ -73,6 +85,16 @@ bindings. This is *not* implemented for the time being.
Also, implementing all those changes as a minor we could flip on and off would
help with adoption
*** Org-mode
=evil-org= allows to define =evil-org-movement-bindings= to automatically map
movement bindings on non-hjkl keys. It maps automatically keys to =C-c= and
=C-r= in normal and insert states though, and it's not really user friendly in
Emacs to remap those.
Therefore, in org-mode:
- =org-shiftright= is bound to =C-»=
- =org-shiftleft= is bound to =C-«=
* Configuration
** Bépo
=doom-bepo-cr-rotation-style= controls whether:
@ -86,6 +108,17 @@ actually put all the =c= functions on the key that does not need a curl.
* Troubleshooting
# Common issues and their solution, or places to look for help.
** How to investigate an issue ?
If a key is misbehaving, use =describe-key= (=C-h k= or =SPC h k= or =F1 k=) to
see the functions bound to the key, and more importantly in which map it is
bound.
You should ignore all =evil-collection-...-backup-map= keymaps, as they are
artifacts from =evil-collection-translate-key= and those maps are actually not
active.
Most likely the solution is to call one of the "key rotation" functions on the
relevant keymaps.
** How to deactivate the new bindings and go back to the old ones ?
If you are learning a new layout you might want to go back to tho old one to
"get work done". Sadly the only way is to comment out the module, run =doom

View File

@ -117,7 +117,7 @@ See `doom-bepo-cr-rotation-style' for the meaning of CR-STYLE"
"Remap evil-{normal,operator,motion,...}-state-map
to be more natural with Bépo keyboard layout.
See `doom-bepo-cr-rotation-style' for the meaning of CR-STYLE."
(evil-collection-translate-key nil '(evil-normal-state-map evil-motion-state-map evil-visual-state-map)
(evil-collection-translate-key nil '(evil-normal-state-map evil-motion-state-map evil-visual-state-map evil-operator-state-map)
"c" "h"
"C" "H"
"t" "j"
@ -131,13 +131,13 @@ See `doom-bepo-cr-rotation-style' for the meaning of CR-STYLE."
"k" "s"
"K" "S")
(cond ((eq cr-style 'ergodis)
(evil-collection-translate-key nil '(evil-normal-state-map evil-motion-state-map evil-visual-state-map)
(evil-collection-translate-key nil '(evil-normal-state-map evil-motion-state-map evil-visual-state-map evil-operator-state-map)
"h" "r"
"H" "R"
"l" "c"
"L" "C"))
(t
(evil-collection-translate-key nil '(evil-normal-state-map evil-motion-state-map evil-visual-state-map)
(evil-collection-translate-key nil '(evil-normal-state-map evil-motion-state-map evil-visual-state-map evil-operator-state-map)
"h" "c"
"H" "C"
"l" "r"
@ -171,18 +171,18 @@ See `doom-bepo-cr-rotation-style' for the meaning of CR-STYLE."
;; <> as direct access
(evil-collection-translate-key nil '(evil-normal-state-map evil-motion-state-map)
(evil-collection-translate-key nil '(evil-normal-state-map evil-motion-state-map evil-operator-state-map)
"«" "<"
"»" ">")
;; " è replaces ^0 to go at BOL
(evil-collection-translate-key nil '(evil-normal-state-map evil-motion-state-map)
(evil-collection-translate-key nil '(evil-normal-state-map evil-motion-state-map evil-operator-state-map)
"è" "^"
"È" "0")
;; [W] -> [É]
;; [C-W] -> [W]
(evil-collection-translate-key nil '(evil-normal-state-map evil-motion-state-map evil-operator-state-map)
(evil-collection-translate-key nil '(evil-normal-state-map evil-motion-state-map evil-operator-state-map evil-operator-state-map)
"é" "w"
"É" "W"
"w" (kbd "C-w")
@ -195,7 +195,7 @@ See `doom-bepo-cr-rotation-style' for the meaning of CR-STYLE."
(let* ((cr-style (or cr-style 'ergodis))
(doom-bepo-hook (lambda (_mode mode-keymaps &rest _rest)
(dolist (keymap mode-keymaps)
(evil-collection-translate-key '(normal motion visual) keymap
(evil-collection-translate-key '(normal motion visual operator) keymap
"c" "h"
"C" "H"
"t" "j"
@ -207,19 +207,59 @@ See `doom-bepo-cr-rotation-style' for the meaning of CR-STYLE."
"j" "t"
"J" "T"
"k" "s"
"K" "S")
"K" "S"
(kbd "C-c") (kbd "C-h")
(kbd "C-C") (kbd "C-H")
(kbd "C-t") (kbd "C-j")
(kbd "C-T") (kbd "C-J")
(kbd "C-s") (kbd "C-k")
(kbd "C-S") (kbd "C-K")
(kbd "C-r") (kbd "C-l")
(kbd "C-R") (kbd "C-L")
(kbd "C-j") (kbd "C-t")
(kbd "C-J") (kbd "C-T")
(kbd "C-k") (kbd "C-s")
(kbd "C-K") (kbd "C-S")
(kbd "M-c") (kbd "M-h")
(kbd "M-C") (kbd "M-H")
(kbd "M-t") (kbd "M-j")
(kbd "M-T") (kbd "M-J")
(kbd "M-s") (kbd "M-k")
(kbd "M-S") (kbd "M-K")
(kbd "M-r") (kbd "M-l")
(kbd "M-R") (kbd "M-L")
(kbd "M-j") (kbd "M-t")
(kbd "M-J") (kbd "M-T")
(kbd "M-k") (kbd "M-s")
(kbd "M-K") (kbd "M-S"))
(cond ((eq cr-style 'ergodis)
(evil-collection-translate-key '(normal motion visual) keymap
(evil-collection-translate-key '(normal motion visual operator) keymap
"h" "r"
"H" "R"
"l" "c"
"L" "C"))
"L" "C"
(kbd "C-h") (kbd "C-r")
(kbd "C-H") (kbd "C-R")
(kbd "C-l") (kbd "C-c")
(kbd "C-L") (kbd "C-C")
(kbd "M-h") (kbd "M-r")
(kbd "M-H") (kbd "M-R")
(kbd "M-l") (kbd "M-c")
(kbd "M-L") (kbd "M-C")))
(t
(evil-collection-translate-key '(normal motion visual) keymap
(evil-collection-translate-key '(normal motion visual operator) keymap
"h" "c"
"H" "C"
"l" "r"
"L" "R")))
"L" "R"
(kbd "C-h") (kbd "C-c")
(kbd "C-H") (kbd "C-C")
(kbd "C-l") (kbd "C-r")
(kbd "C-L") (kbd "C-R")
(kbd "M-h") (kbd "M-c")
(kbd "M-H") (kbd "M-C")
(kbd "M-l") (kbd "M-r")
(kbd "M-L") (kbd "M-R"))))
(evil-collection-translate-key '(insert) keymap
@ -234,27 +274,48 @@ See `doom-bepo-cr-rotation-style' for the meaning of CR-STYLE."
(kbd "C-j") (kbd "C-t")
(kbd "C-J") (kbd "C-T")
(kbd "C-k") (kbd "C-s")
(kbd "C-K") (kbd "C-S"))
(kbd "C-K") (kbd "C-S")
(kbd "M-c") (kbd "M-h")
(kbd "M-C") (kbd "M-H")
(kbd "M-t") (kbd "M-j")
(kbd "M-T") (kbd "M-J")
(kbd "M-s") (kbd "M-k")
(kbd "M-S") (kbd "M-K")
(kbd "M-r") (kbd "M-l")
(kbd "M-R") (kbd "M-L")
(kbd "M-j") (kbd "M-t")
(kbd "M-J") (kbd "M-T")
(kbd "M-k") (kbd "M-s")
(kbd "M-K") (kbd "M-S"))
(cond ((eq cr-style 'ergodis)
(evil-collection-translate-key '(insert) keymap
(kbd "C-h") (kbd "C-r")
(kbd "C-H") (kbd "C-R")
(kbd "C-l") (kbd "C-c")
(kbd "C-L") (kbd "C-C")))
(kbd "C-L") (kbd "C-C")
(kbd "M-h") (kbd "M-r")
(kbd "M-H") (kbd "M-R")
(kbd "M-l") (kbd "M-c")
(kbd "M-L") (kbd "M-C")))
(t
(evil-collection-translate-key '(insert) keymap
(kbd "C-h") (kbd "C-c")
(kbd "C-H") (kbd "C-C")
(kbd "C-l") (kbd "C-r")
(kbd "C-L") (kbd "C-R"))))
(kbd "C-L") (kbd "C-R")
(kbd "M-h") (kbd "M-c")
(kbd "M-H") (kbd "M-C")
(kbd "M-l") (kbd "M-r")
(kbd "M-L") (kbd "M-R")
)))
;; <> en direct
(evil-collection-translate-key '(normal motion visual) keymap
(evil-collection-translate-key '(normal motion visual operator) keymap
"«" "<"
"»" ">")
;; è pour aller au début de ligne
(evil-collection-translate-key '(normal motion visual) keymap
(evil-collection-translate-key '(normal motion visual operator) keymap
"è" "^"
"È" "0")

View File

@ -975,60 +975,69 @@ compelling reason, so..."
#'+org-cycle-only-current-subtree-h
;; Clear babel results if point is inside a src block
#'+org-clear-babel-results-h)
(map! :map evil-org-mode-map
:ni [C-return] #'+org/insert-item-below
:ni [C-S-return] #'+org/insert-item-above
;; navigate table cells (from insert-mode)
:i "C-l" (cmds! (org-at-table-p) #'org-table-next-field
(let-alist evil-org-movement-bindings
(let ((Cright (concat "C-" .right))
(Cleft (concat "C-" .left))
(Cup (concat "C-" .up))
(Cdown (concat "C-" .down))
(CSright (concat "C-" (capitalize .right)))
(CSleft (concat "C-" (capitalize .left)))
(CSup (concat "C-" (capitalize .up)))
(CSdown (concat "C-" (capitalize .down))))
(map! :map evil-org-mode-map
:ni [C-return] #'+org/insert-item-below
:ni [C-S-return] #'+org/insert-item-above
;; navigate table cells (from insert-mode)
:i Cright (cmds! (org-at-table-p) #'org-table-next-field
#'org-end-of-line)
:i "C-h" (cmds! (org-at-table-p) #'org-table-previous-field
:i Cleft (cmds! (org-at-table-p) #'org-table-previous-field
#'org-beginning-of-line)
:i "C-k" (cmds! (org-at-table-p) #'+org/table-previous-row
:i Cup (cmds! (org-at-table-p) #'+org/table-previous-row
#'org-up-element)
:i "C-j" (cmds! (org-at-table-p) #'org-table-next-row
:i Cdown (cmds! (org-at-table-p) #'org-table-next-row
#'org-down-element)
:ni "C-S-l" #'org-shiftright
:ni "C-S-h" #'org-shiftleft
:ni "C-S-k" #'org-shiftup
:ni "C-S-j" #'org-shiftdown
;; more intuitive RET keybinds
:n [return] #'+org/dwim-at-point
:n "RET" #'+org/dwim-at-point
:i [return] (cmd! (org-return electric-indent-mode))
:i "RET" (cmd! (org-return electric-indent-mode))
:i [S-return] #'+org/shift-return
:i "S-RET" #'+org/shift-return
;; more vim-esque org motion keys (not covered by evil-org-mode)
:m "]h" #'org-forward-heading-same-level
:m "[h" #'org-backward-heading-same-level
:m "]l" #'org-next-link
:m "[l" #'org-previous-link
:m "]c" #'org-babel-next-src-block
:m "[c" #'org-babel-previous-src-block
:n "gQ" #'org-fill-paragraph
;; sensible vim-esque folding keybinds
:n "za" #'+org/toggle-fold
:n "zA" #'org-shifttab
:n "zc" #'+org/close-fold
:n "zC" #'outline-hide-subtree
:n "zm" #'+org/hide-next-fold-level
:n "zM" #'+org/close-all-folds
:n "zn" #'org-tree-to-indirect-buffer
:n "zo" #'+org/open-fold
:n "zO" #'outline-show-subtree
:n "zr" #'+org/show-next-fold-level
:n "zR" #'+org/open-all-folds
:n "zi" #'org-toggle-inline-images
:ni CSright #'org-shiftright
:ni CSleft #'org-shiftleft
:ni CSup #'org-shiftup
:ni CSdown #'org-shiftdown
;; more intuitive RET keybinds
:n [return] #'+org/dwim-at-point
:n "RET" #'+org/dwim-at-point
:i [return] (cmd! (org-return electric-indent-mode))
:i "RET" (cmd! (org-return electric-indent-mode))
:i [S-return] #'+org/shift-return
:i "S-RET" #'+org/shift-return
;; more vim-esque org motion keys (not covered by evil-org-mode)
:m "]h" #'org-forward-heading-same-level
:m "[h" #'org-backward-heading-same-level
:m "]l" #'org-next-link
:m "[l" #'org-previous-link
:m "]c" #'org-babel-next-src-block
:m "[c" #'org-babel-previous-src-block
:n "gQ" #'org-fill-paragraph
;; sensible vim-esque folding keybinds
:n "za" #'+org/toggle-fold
:n "zA" #'org-shifttab
:n "zc" #'+org/close-fold
:n "zC" #'outline-hide-subtree
:n "zm" #'+org/hide-next-fold-level
:n "zM" #'+org/close-all-folds
:n "zn" #'org-tree-to-indirect-buffer
:n "zo" #'+org/open-fold
:n "zO" #'outline-show-subtree
:n "zr" #'+org/show-next-fold-level
:n "zR" #'+org/open-all-folds
:n "zi" #'org-toggle-inline-images
:map org-read-date-minibuffer-local-map
"C-h" (cmd! (org-eval-in-calendar '(calendar-backward-day 1)))
"C-l" (cmd! (org-eval-in-calendar '(calendar-forward-day 1)))
"C-k" (cmd! (org-eval-in-calendar '(calendar-backward-week 1)))
"C-j" (cmd! (org-eval-in-calendar '(calendar-forward-week 1)))
"C-S-h" (cmd! (org-eval-in-calendar '(calendar-backward-month 1)))
"C-S-l" (cmd! (org-eval-in-calendar '(calendar-forward-month 1)))
"C-S-k" (cmd! (org-eval-in-calendar '(calendar-backward-year 1)))
"C-S-j" (cmd! (org-eval-in-calendar '(calendar-forward-year 1)))))
:map org-read-date-minibuffer-local-map
Cleft (cmd! (org-eval-in-calendar '(calendar-backward-day 1)))
Cright (cmd! (org-eval-in-calendar '(calendar-forward-day 1)))
Cup (cmd! (org-eval-in-calendar '(calendar-backward-week 1)))
Cdown (cmd! (org-eval-in-calendar '(calendar-forward-week 1)))
CSleft (cmd! (org-eval-in-calendar '(calendar-backward-month 1)))
CSright (cmd! (org-eval-in-calendar '(calendar-forward-month 1)))
CSup (cmd! (org-eval-in-calendar '(calendar-backward-year 1)))
CSdown (cmd! (org-eval-in-calendar '(calendar-forward-year 1)))))))
(use-package! evil-org-agenda