From c76c23699179fd69060f005d1ba43e001972abc6 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 11 Apr 2023 20:20:57 -0700 Subject: [PATCH] [oni-elisp] Fix keybindings for IELM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ‘paredit-mode’ appears to have added keybindings for ‘C-j’ and ‘RET’ that weren't there before (or did I enable ‘paredit-mode’ in IELM recently?) and that interfere with executing code. This way of removing the keybindings works in a buffer-local only way so that in other buffers the ‘RET’ and ‘C-j’ keybindings remain untouched. --- oni-elisp/oni-elisp.el | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/oni-elisp/oni-elisp.el b/oni-elisp/oni-elisp.el index 80834f3..30475ef 100644 --- a/oni-elisp/oni-elisp.el +++ b/oni-elisp/oni-elisp.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2023.0314.001059 +;; Version: 2023.0411.133217 ;; Package-Requires: (oni-company oni-flycheck oni-paredit oni-yasnippet oni-hydra rainbow-delimiters nameless erefactor flycheck-relint handle elisp-format) ;; This program is free software; you can redistribute it and/or modify @@ -84,6 +84,16 @@ (:eval (buffer-name ielm-working-buffer)) mode-line-end-spaces))) +(defun oni-elisp-ielm-remove-paredit-newline-keys () + "Disable ‘C-j’ and ‘RET’ keybindings from ‘paredit-mode’." + (let ((oldmap (map-elt minor-mode-map-alist 'paredit-mode)) + (newmap (make-sparse-keymap))) + (set-keymap-parent newmap oldmap) + (define-key newmap (kbd "RET") nil) + (define-key newmap (kbd "C-j") nil) + (make-local-variable 'minor-mode-overriding-map-alist) + (push `(paredit-mode . ,newmap) minor-mode-overriding-map-alist))) + (defhydra oni-elisp-hydra (:color teal :hint nil) " ^Eval^ @@ -102,6 +112,7 @@ _eb_: Buffer (add-hook 'emacs-lisp-mode-hook 'paredit-mode) (add-hook 'emacs-lisp-mode-hook 'rainbow-delimiters-mode) +(add-hook 'ielm-mode-hook #'oni-elisp-ielm-remove-paredit-newline-keys) (add-hook 'ielm-mode-hook #'oni-elisp-setup-ielm-mode-line) (add-hook 'ielm-mode-hook 'company-mode) (add-hook 'ielm-mode-hook 'paredit-mode)