From af5fadf7987294acdab23d0ac84f8214ee2a7ace Mon Sep 17 00:00:00 2001 From: James Nguyen Date: Sun, 26 Nov 2017 12:01:07 -0800 Subject: [PATCH] Elisp: Use separate function to handle toggling or newlining Since the text properties only takes in one map at a time (as far as I know), the insert/normal state auxillery maps will conflict with each other. It's easier to have C-m trigger a function that checks its state and Does The Right Thing instead. --- evil-elisp-mode.el | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/evil-elisp-mode.el b/evil-elisp-mode.el index eb9b2d5..f92e7a7 100644 --- a/evil-elisp-mode.el +++ b/evil-elisp-mode.el @@ -36,11 +36,10 @@ BEG and END are the start and end of the output in current-buffer. VALUE is the Lisp value printed, ALT1 and ALT2 are strings for the alternative printed representations that can be displayed." (let ((map (make-sparse-keymap))) - (define-key map (kbd "C-m") 'elisp-last-sexp-toggle-display) + (define-key map (kbd "C-m") + 'evil-elisp-mode-return-or-last-sexp-toggle-display) (define-key map [down-mouse-2] 'mouse-set-point) (define-key map [mouse-2] 'elisp-last-sexp-toggle-display) - (evil-define-key 'insert map (kbd "C-m") - (lookup-key (current-global-map) (kbd ""))) (add-text-properties beg end `(printed-value (,value ,alt1 ,alt2) @@ -49,6 +48,15 @@ alternative printed representations that can be displayed." help-echo "RET, mouse-2: toggle abbreviated display" rear-nonsticky (mouse-face keymap help-echo printed-value))))) + +(defun evil-elisp-mode-return-or-last-sexp-toggle-display () + "Trigger RET or call `elisp-last-sexp-toggle-display'." + (interactive) + (if (eq evil-state 'insert) + (call-interactively + (lookup-key (current-global-map) (kbd "C-m"))) + (call-interactively 'elisp-last-sexp-toggle-display))) + (defun evil-elisp-mode-setup () "Set up `evil' bindings for `elisp-mode'." (advice-add 'last-sexp-setup-props