summary refs log tree commit diff stats
path: root/emacs
diff options
context:
space:
mode:
Diffstat (limited to 'emacs')
-rw-r--r--emacs/init.el12
1 files changed, 12 insertions, 0 deletions
diff --git a/emacs/init.el b/emacs/init.el
index 43a1314b..26defe92 100644
--- a/emacs/init.el
+++ b/emacs/init.el
@@ -972,6 +972,18 @@ Also returns nil if pid is nil."
 
 (add-hook 'emacs-lisp-mode-hook 'imenu-elisp-sections)
 
+(defun eval-and-replace ()
+  "Replace the preceding sexp with its value."
+  (interactive)
+  (backward-kill-sexp)
+  (condition-case nil
+      (prin1 (eval (read (current-kill 0)))
+             (current-buffer))
+    (error (message "Invalid expression")
+           (insert (current-kill 0)))))
+
+(bind-key "C-c e" #'eval-and-replace)
+
 ;;;; Programming
 
 (use-package auto-compile