;;; mf-lisp.el --- Common configuration for lisp programming modes. -*- lexical-binding: t -*- ;;; Commentary: ;; Setup Lisps separately from other blub languages. ;;; Code: (defun mf/disable--indent-tabs-mode () "Disable `indent-tabs-mode'." (indent-tabs-mode -1)) ;; Paredit (mf/install rainbow-delimiters) (mf/install paredit (define-key paredit-mode-map (kbd "RET") nil) (define-key paredit-mode-map (kbd "C-j") #'paredit-newline)) (dolist (mode '(lisp-mode-hook emacs-lisp-mode-hook lisp-interaction-mode-hook geiser-mode-hook geiser-repl-mode-hook inferior-emacs-lisp-mode)) (add-hook mode #'paredit-mode) (add-hook mode #'rainbow-delimiters-mode) (with-eval-after-load 'evil (add-hook mode #'lispyville-mode)) (add-hook mode #'mf/disable--indent-tabs-mode) (defvar mf/paredit-no-space-prefixes (list ",@" "#p" "#P")) (defun mf/paredit-space-for-delimiter (endp delimiter) (let ((point (point))) (or endp (seq-every-p (lambda (prefix) (and (> point (length prefix)) (let ((start (- point (length prefix))) (end point)) (not (string= (buffer-substring start end) prefix))))) mf/paredit-no-space-prefixes)))) (defun mf/init-paredit-space-for-delimiter () (add-to-list 'paredit-space-for-delimiter-predicates 'mf/paredit-space-for-delimiter)) (add-hook 'paredit-mode-hook 'mf/init-paredit-space-for-delimiter)) ;; Guile (mf/install geiser-guile) (setq geiser-default-implementation 'guile) ;; Common Lisp (setq inferior-lisp-program "sbcl") (unless (eq mf/os 'guix) (mf/install sly) (mf/install sly-asdf) (mf/install sly-quicklisp)) (with-eval-after-load 'sly (message "loaded sly") (defun sly--dwim () (interactive) (if (> (length (sly--purge-connections)) 0) (call-interactively #'sly-mrepl) (call-interactively #'sly))) (mf/add-hooks sly-mrepl-mode-hook paredit-mode company-mode lispyville-mode) (setq sly-common-lisp-style-default 'sbcl) ;; local hyperspec (setq common-lisp-hyperspec-root (concat "file://" (getenv "HOME") "/src/git/HyperSpec/HyperSpec/")) (add-to-list 'sly-contribs 'sly-asdf 'append) (add-to-list 'sly-contribs 'sly-quicklisp 'append) (define-key lisp-mode-map (kbd "C-c C-z") #'sly--dwim) (define-key sly-mode-map (kbd "C-c C-z") #'sly--dwim) (defun mf/sly-quickload (system) "Interactive command made available in lisp-editing files." (interactive (list (completing-read "QL system? " (sly-eval '(slynk-quicklisp:available-system-names))))) (sly-eval-async `(slynk-quicklisp:quickload ,system) (lambda (retval) (setq sly-quicklisp--enabled-dists retval) (sly-message "%s is ready to use!" system))) (sly-message "ql:quickloading %s..." system)(sly-eval-async `(slynk-quicklisp:quickload ,system) (lambda (retval) (setq sly-quicklisp--enabled-dists retval) (sly-message "%s is ready to use!" system))) (sly-message "ql:quickloading %s..." system)) (with-eval-after-load 'sly-quicklisp (advice-add 'sly-quickload :override #'mf/sly-quickload))) (provide 'mf-lisp) ;;; mf-lisp.el ends here