From 7749a9778716fee0ad525fbd91e5c69563b92fba Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 16 Aug 2016 21:20:02 -0700 Subject: [PATCH] Show result of eval-last-sexp inline --- dotfiles/emacs.d/README.org | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/dotfiles/emacs.d/README.org b/dotfiles/emacs.d/README.org index d9265b46..d468a606 100644 --- a/dotfiles/emacs.d/README.org +++ b/dotfiles/emacs.d/README.org @@ -2615,6 +2615,35 @@ Reduce indentation for some functions (setq show-trailing-whitespace t))) (add-hook 'flycheck-mode-hook 'imalison:maybe-remove-flycheck-checkdoc-checker) #+END_SRC +***** Show result of eval-last-sexp inline +Taken from http://endlessparentheses.com/eval-result-overlays-in-emacs-lisp.html +#+BEGIN_SRC emacs-lisp +(autoload 'cider--make-result-overlay "cider-overlays") + +(defun imalison:eval-overlay (value point) + (cider--make-result-overlay (format "%S" value) + :where point + :duration 'command) + value) + +(advice-add 'eval-region :around + (lambda (f beg end &rest r) + (imalison:eval-overlay + (apply f beg end r) + end))) + +(advice-add 'eval-last-sexp :filter-return + (lambda (r) + (imalison:eval-overlay r (point)))) + +(advice-add 'eval-defun :filter-return + (lambda (r) + (imalison:eval-overlay + r + (save-excursion + (end-of-defun) + (point))))) +#+END_SRC ***** Keybinds #+BEGIN_SRC emacs-lisp (define-key lisp-mode-shared-map (kbd "C-c C-c") 'eval-defun)