80 lines
2.5 KiB
EmacsLisp
80 lines
2.5 KiB
EmacsLisp
;;; funcs.el --- Slime Layer functions File for Spacemacs
|
||
;;
|
||
;; Copyright (c) 2012-2020 Sylvain Benner & Contributors
|
||
;;
|
||
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
||
;; URL: https://github.com/syl20bnr/spacemacs
|
||
;;
|
||
;; This file is not part of GNU Emacs.
|
||
;;
|
||
;;; License: GPLv3
|
||
|
||
|
||
;; Helm integration
|
||
|
||
(defun spacemacs//slime-helm-source (&optional table)
|
||
(or table (setq table slime-lisp-implementations))
|
||
`((name . "Slime")
|
||
(candidates . ,(mapcar #'car table))
|
||
(action . (lambda (candidate)
|
||
(car (helm-marked-candidates))))))
|
||
|
||
(defun spacemacs/helm-slime ()
|
||
(interactive)
|
||
(let ((command (helm :sources (spacemacs//slime-helm-source))))
|
||
(and command (slime (intern command)))))
|
||
|
||
|
||
;; Evil integration
|
||
|
||
(defun spacemacs/slime-eval-sexp-end-of-line ()
|
||
"Evaluate current line."
|
||
(interactive)
|
||
(move-end-of-line 1)
|
||
(slime-eval-last-expression))
|
||
|
||
|
||
|
||
;; Functions are taken from the elisp layer `eval-last-sexp' was replaced with
|
||
;; its slime equivalent `slime-eval-last-expression'
|
||
|
||
(defun spacemacs/cl-eval-current-form ()
|
||
"Find and evaluate the current def* or set* command.
|
||
Unlike `eval-defun', this does not go to topmost function."
|
||
(interactive)
|
||
(save-excursion
|
||
(search-backward-regexp "(def\\|(set")
|
||
(forward-list)
|
||
(call-interactively 'slime-eval-last-expression)))
|
||
|
||
|
||
(defun spacemacs/cl-eval-current-form-sp (&optional arg)
|
||
"Call `eval-last-sexp' after moving out of one level of
|
||
parentheses. Will exit any strings and/or comments first.
|
||
An optional ARG can be used which is passed to `sp-up-sexp' to move out of more
|
||
than one sexp.
|
||
Requires smartparens because all movement is done using `sp-up-sexp'."
|
||
(interactive "p")
|
||
(require 'smartparens)
|
||
(let ((evil-move-beyond-eol t))
|
||
;; evil-move-beyond-eol disables the evil advices around eval-last-sexp
|
||
(save-excursion
|
||
(let ((max 10))
|
||
(while (and (> max 0)
|
||
(sp-point-in-string-or-comment))
|
||
(decf max)
|
||
(sp-up-sexp)))
|
||
(sp-up-sexp arg)
|
||
(call-interactively 'slime-eval-last-expression))))
|
||
|
||
|
||
(defun spacemacs/cl-eval-current-symbol-sp ()
|
||
"Call `eval-last-sexp' on the symbol around point.
|
||
Requires smartparens because all movement is done using `sp-forward-symbol'."
|
||
(interactive)
|
||
(require 'smartparens)
|
||
(let ((evil-move-beyond-eol t))
|
||
;; evil-move-beyond-eol disables the evil advices around eval-last-sexp
|
||
(save-excursion
|
||
(sp-forward-symbol)
|
||
(call-interactively 'slime-eval-last-expression))))
|