mirror of
https://github.com/correl/dotfiles.git
synced 2024-12-18 03:00:11 +00:00
[emacs] eval-and-replace
This commit is contained in:
parent
925f957405
commit
90b572a6b8
1 changed files with 11 additions and 0 deletions
|
@ -129,6 +129,17 @@
|
||||||
(file-writable-p buffer-file-name))
|
(file-writable-p buffer-file-name))
|
||||||
(find-alternate-file (concat "/sudo:root@localhost:" 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
|
||||||
;; custom-set-variables was added by Custom.
|
;; custom-set-variables was added by Custom.
|
||||||
;; If you edit it by hand, you could mess it up, so be careful.
|
;; If you edit it by hand, you could mess it up, so be careful.
|
||||||
|
|
Loading…
Reference in a new issue