]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
bound bba/eval-last-sexp-replace to C-c E to replace the last s-expression with its...
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Sun, 2 Nov 2014 17:46:38 +0000 (18:46 +0100)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Sun, 2 Nov 2014 17:46:38 +0000 (18:46 +0100)
Signed-off-by: Andreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
bba.org

diff --git a/bba.org b/bba.org
index f416ad50004b010a3a316a32655825e015e32410..3758359d4274f4b0308e7a12c31da3e6640add00 100644 (file)
--- a/bba.org
+++ b/bba.org
@@ -1016,6 +1016,22 @@ window-total-height.
 
 #+END_SRC
 
+*** [[http://stackoverflow.com/questions/3035337/in-emacs-can-you-evaluate-an-emacs-lisp-expression-and-replace-it-with-the-resul][eval emacs lisp expression and replace it]]
+    [2014-11-02 Sun 18:21]
+
+Use =C-c E= to evaluate and replace the last s-expression.
+
+#+BEGIN_SRC emacs-lisp
+  (defun bba/eval-last-sexp-replace ()
+    "replace the last s-expression with its evaluated result"
+    (interactive)
+    (backward-kill-sexp)
+    (prin1 (eval (read (current-kill 0)))
+           (current-buffer)))
+
+  (define-key global-map "\C-c\S-e" 'bba/eval-last-sexp-replace)
+#+END_SRC
+
 *** goto-match-paren
 #+BEGIN_SRC emacs-lisp
       (defun goto-match-paren (arg)