   :interpreter ("node" . js2-mode)
   :config
   (when (fboundp 'sp-kill-whole-line)
-    (bind-key "C-k" 'sp-kill-whole-line js2-mode-map)))
+    (define-key js2-mode-map (kbd "C-k") 'sp-kill-whole-line)))
 
 (use-package rjsx-mode
   :mode ("\\.jsx?\\'" "\\.mjs\\'"))
 
 (use-package json-mode
   :config
-  (unbind-key "C-c C-f" json-mode-map)
-  (add-hook 'json-mode-hook (lambda ()
-                              (when (not (key-binding "C-c f"))
-                                (bind-key "C-c f" 'json-pretty-print-buffer 'json-mode-map)))))
+  (define-key json-mode-map (kbd "C-c C-f") nil)
+  (add-hook 'json-mode-hook
+            (lambda ()
+              (when (not (key-binding (kbd "C-c f")))
+                (define-key json-mode-map (kbd "C-c f") 'json-pretty-print-buffer)))))
 
 (use-package polymode
   ;; :after rjsx-mode

      (apply comment-dwim args)))
  (advice-add 'comment-dwim :around 'comment-dwim-advice))

(use-package bind-key)

;; I hate X mouse bindings
(when (and (display-graphic-p)
           (not (memq (window-system) '(x))))
  (bind-key "<mouse-3>" 'mouse-buffer-menu))

;; tab-bar mode can't be used on macOS, so rebinding it to something useful.
(bind-key "C-x t" 'display-time-world)

;; Completely unbind annoying abbrev, dabbrev, expand, hippie-expand. These
;; ancient completion commands are just too stupid for this day and age
(unbind-key "M-'")
(unbind-key "M-/")
(unbind-key "C-x '")
;; Always use M-g prefix to jump between errors
(unbind-key "C-x `")
;; Must there be 4 bindings to undo?
(unbind-key "C-x u")
(unbind-key "C-_")
(unbind-key "C-/")
(unbind-key "s-z")

;; Bind useful things to keys
(bind-keys ("<backtab>" . align)
           ("C-x f"     . follow-mode)
           ;; Replace default buffer menu with ibuffer
           ("C-x C-b"   . ibuffer)
           ("C-t"       . transpose-sexps)
           ("M-:"       . ielm)
           ("C-x ^"     . nil)
           ("C-{"       . enlarge-window)
           ("C-}"       . shrink-window)
           ("C-c l"     . browse-url-at-point)
           ("C-c n l"   . org-store-link)
           ("C-c n a"   . org-agenda)
           ("C-c n c"   . org-capture))

;; Replace zap-to-char with the hidden zap-up-to-char
(autoload 'zap-up-to-char "misc")

  :config (flycheck-yamllint-setup))

;; Emacs Lisp
(pcase-dolist (`(,key . ,command)
               `(("C-c e f" . byte-compile-file)
                 ("C-c e c" . emacs-lisp-byte-compile)
                 ("C-c e l" . emacs-lisp-byte-compile-and-load)
                 ("C-c e b" . eval-buffer)
                 ("C-c e r" . eval-region)))
  (define-key emacs-lisp-mode-map (kbd key) command))

(add-hook 'ielm-mode-hook (lambda () (ielm-change-working-buffer (window-buffer (selected-window)))))

