diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 75ffa59..a005fec 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -129,6 +129,17 @@ (file-writable-p buffer-file-name)) (find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name)))) +(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))))) +(global-set-key (kbd "C-)") 'eval-and-replace) + (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful.