From 0620ed55b6be2fbebea7acc2d1bd0d3186609809 Mon Sep 17 00:00:00 2001 From: Rich Alesi Date: Wed, 25 Mar 2015 22:42:58 -0700 Subject: [PATCH] More eval bindings for elisp. --- spacemacs/funcs.el | 18 ++++++++++++++++-- spacemacs/keybindings.el | 3 +++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/spacemacs/funcs.el b/spacemacs/funcs.el index 36af815a0..dda5f1654 100644 --- a/spacemacs/funcs.el +++ b/spacemacs/funcs.el @@ -220,6 +220,21 @@ the current state and point position." (setq p2 (point)))) (set-mark p1))) +;; eval lisp helpers +(defun spacemacs/eval-region () + (interactive) + (eval-region (region-beginning) (region-end)) + (evil-normal-state)) + +;; idea from http://www.reddit.com/r/emacs/comments/312ge1/i_created_this_function_because_i_was_tired_of/ +(defun spacemacs/eval-current-form () + "Looks for the current def* or set* command then evaluates, unlike `eval-defun', does not go to topmost function" + (interactive) + (save-excursion + (search-backward-regexp "(def\\|(set") + (forward-list) + (call-interactively 'eval-last-sexp))) + ;; from magnars (defun eval-and-replace () "Replace the preceding sexp with its value." @@ -798,8 +813,7 @@ If ASCII si not provided then UNICODE is used instead." ((system-is-mswindows) (w32-shell-execute "open" (replace-regexp-in-string "/" "\\" file-path))) ((system-is-mac) (shell-command (format "open \"%s\"" file-path))) ((system-is-linux) (let ((process-connection-type nil)) - (start-process "" nil "xdg-open" file-path))) - ))) + (start-process "" nil "xdg-open" file-path)))))) (defun spacemacs/next-error (&optional n reset) "Dispatch to flycheck or standard emacs error." diff --git a/spacemacs/keybindings.el b/spacemacs/keybindings.el index 4e341ad86..075180b04 100644 --- a/spacemacs/keybindings.el +++ b/spacemacs/keybindings.el @@ -293,7 +293,10 @@ Ensure that helm is required before calling FUNC." ;; emacs-lisp ----------------------------------------------------------------- (evil-leader/set-key-for-mode 'emacs-lisp-mode "me$" 'lisp-state-eval-sexp-end-of-line + "meb" 'eval-buffer + "mec" 'spacemacs/eval-current-form "mee" 'eval-last-sexp + "mer" 'spacemacs/eval-region "mef" 'eval-defun "mel" 'lisp-state-eval-sexp-end-of-line "m," 'lisp-state-toggle-lisp-state