diff options
| author | James Nguyen <james@jojojames.com> | 2017-11-26 12:01:07 -0800 |
|---|---|---|
| committer | James Nguyen <james@jojojames.com> | 2017-11-26 12:01:07 -0800 |
| commit | af5fadf7987294acdab23d0ac84f8214ee2a7ace (patch) | |
| tree | 2320cd58662ded2ba45de667f65cab2b30519162 | |
| parent | 30d3144048239f429da235d0c44bb03718ba6bb8 (diff) | |
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.
| -rw-r--r-- | evil-elisp-mode.el | 14 |
1 files 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 "<return>"))) (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 |
