Add function replace-last-sexp

This replaces the last sexp with its value.  Useful when abusing
emacs to do quick computations, for instance
master
Jacopo De Simoi 8 years ago
parent 6663b150f2
commit 3c7a195b46
  1. 12
      global.org

@ -389,6 +389,18 @@
;;(require 'atomic-chrome)
;;(atomic-chrome-start-server)
#+END_SRC
* Settings for important major modes
** elisp
*** Replace last sexp
I use this a lot to evaluate (e.g.) quick computations in files
#+BEGIN_SRC emacs-lisp
(defun replace-last-sexp ()
(interactive)
(let ((value (eval (preceding-sexp))))
(kill-sexp -1)
(insert (format "%S" value))))
(global-set-key (kbd "C-c C-x C-e") 'replace-last-sexp)
#+END_SRC
* Leftovers
#+BEGIN_SRC emacs-lisp
;; * include other files

Loading…
Cancel
Save