mirror of
https://github.com/correl/dotfiles.git
synced 2024-11-21 19:18:41 +00:00
[emacs] Add eval and replace
This commit is contained in:
parent
36da199c48
commit
02d14a5b75
1 changed files with 16 additions and 0 deletions
|
@ -795,3 +795,19 @@ Manage background services
|
|||
(use-package! uuidgen
|
||||
:commands (uuidgen))
|
||||
#+end_src
|
||||
* Eval and Replace
|
||||
Taken from [[http://emacsredux.com/blog/2013/06/21/eval-and-replace/][Emacs Redux]]
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(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)
|
||||
#+end_src
|
||||
|
|
Loading…
Reference in a new issue