;; Remap some default emacs keybindings to adapt to bepo
;; We try to minimize the number of remappings: only 0,1...9 keys

;; No need for general.el if we only use vanilla emacs
(defun remap-global (s f)
  (define-key global-map (kbd s) f))

;; Window : remap 0,1...9
(remap-global "C-x 0" nil)
(remap-global "C-x *" 'delete-window)
(remap-global "C-x 1" nil)
(remap-global "C-x \"" 'delete-other-windows)
(remap-global "C-x 2" nil)
(remap-global "C-x «" 'split-window-below)
(remap-global "C-x 3" nil)
(remap-global "C-x »" 'split-window-right)

;; Tab-bar: remap 0,1...
(remap-global "C-x t 0" nil)
(remap-global "C-x t *" 'tab-close)
(remap-global "C-x t 1" nil)
(remap-global "C-x t \"" 'tab-close-other)
(remap-global "C-x t 2" nil)
(remap-global "C-x t «" 'tab-new)

;; Navigation with bepo
(remap-global "M-«" 'backward-paragraph)
(remap-global "M-»" 'forward-paragraph)

;; ";" is harder to reach
(remap-global "M-;" nil)
(remap-global "M-ç" 'comment-dwim)
(remap-global "C-x C-ç" 'comment-line)

;; Swap : and , for evaluating lisp
(remap-global "M-:" 'xref-pop-marker-stack)
(remap-global "M-," 'eval-expression)

;; Not bepo specific
(remap-global "C-x x e" 'eval-buffer) ; Emacs 28

;; Avoid typing ^ twice by remapping it to è
(remap-global "M-è" 'delete-indentation) ; Same as join-line