Emacs config utilizing prelude as a base
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
4.1 KiB

  1. ;;; prelude-common-lisp.el --- Emacs Prelude: lisp-mode and SLIME config.
  2. ;;
  3. ;; Copyright (c) 2011 Bozhidar Batsov
  4. ;;
  5. ;; Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
  6. ;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude
  7. ;; Version: 1.0.0
  8. ;; Keywords: convenience
  9. ;; This file is not part of GNU Emacs.
  10. ;;; Commentary:
  11. ;; Configuration for lisp-mode and SLIME.
  12. ;;; License:
  13. ;; This program is free software; you can redistribute it and/or
  14. ;; modify it under the terms of the GNU General Public License
  15. ;; as published by the Free Software Foundation; either version 3
  16. ;; of the License, or (at your option) any later version.
  17. ;;
  18. ;; This program is distributed in the hope that it will be useful,
  19. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. ;; GNU General Public License for more details.
  22. ;;
  23. ;; You should have received a copy of the GNU General Public License
  24. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  25. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  26. ;; Boston, MA 02110-1301, USA.
  27. ;;; Code:
  28. (defgroup common-lisp nil
  29. "Prelude's Common Lisp support"
  30. :group 'prelude)
  31. (defcustom prelude-start-slime-automatically t
  32. "Start SLIME automatically the first time a .list file is opened."
  33. :type 'boolean
  34. :group 'common-lisp)
  35. (defcustom prelude-enable-common-lisp-hook t
  36. "Enable Prelude's Common Lisp hook"
  37. :type 'boolean
  38. :group 'common-lisp)
  39. (defcustom prelude-load-common-lisp-slime-automatically nil
  40. "Load Common Lisp's SLIME by default. Setting this to `t' is not a
  41. very good idea if you're programming on occasion in both Clojure and
  42. Common Lisp."
  43. :type 'boolean
  44. :group 'common-lisp)
  45. (require 'prelude-lisp)
  46. ;; the SBCL configuration file is in Common Lisp
  47. (add-to-list 'auto-mode-alist '("\\.sbclrc$" . lisp-mode))
  48. ;; Use SLIME from Quicklisp
  49. (defun prelude-load-common-lisp-slime ()
  50. (interactive)
  51. ;; Common Lisp support depends on SLIME being installed with Quicklisp
  52. (if (file-exists-p (expand-file-name "~/quicklisp/slime-helper.el"))
  53. (load (expand-file-name "~/quicklisp/slime-helper.el"))
  54. (message "%s" "SLIME is not installed. Use Quicklisp to install it.")))
  55. ;; a list of alternative Common Lisp implementations that can be
  56. ;; used with SLIME. Note that their presence render
  57. ;; inferior-lisp-program useless. This variable holds a list of
  58. ;; programs and if you invoke SLIME with a negative prefix
  59. ;; argument, M-- M-x slime, you can select a program from that list.
  60. (setq slime-lisp-implementations
  61. '((ccl ("ccl"))
  62. (clisp ("clisp" "-q"))
  63. (cmucl ("cmucl" "-quiet"))
  64. (sbcl ("sbcl" "--noinform") :coding-system utf-8-unix)))
  65. ;; select the default value from slime-lisp-implementations
  66. (if (string= system-type "darwin")
  67. ;; default to Clozure CL on OS X
  68. (setq slime-default-lisp 'ccl)
  69. ;; default to SBCL on Linux and Windows
  70. (setq slime-default-lisp 'sbcl))
  71. (when prelude-enable-common-lisp-hook
  72. (add-hook 'lisp-mode-hook 'prelude-lisp-coding-hook)
  73. (add-hook 'slime-repl-mode-hook 'prelude-interactive-lisp-coding-hook))
  74. ;; start slime automatically when we open a lisp file
  75. (defun prelude-start-slime ()
  76. (unless (slime-connected-p)
  77. (save-excursion (slime))))
  78. (when prelude-start-slime-automatically
  79. (add-hook 'slime-mode-hook 'prelude-start-slime))
  80. ;; Stop SLIME's REPL from grabbing DEL,
  81. ;; which is annoying when backspacing over a '('
  82. (defun prelude-override-slime-repl-bindings-with-paredit ()
  83. (define-key slime-repl-mode-map
  84. (read-kbd-macro paredit-backward-delete-key) nil))
  85. (add-hook 'slime-repl-mode-hook 'prelude-override-slime-repl-bindings-with-paredit)
  86. (eval-after-load "slime"
  87. '(progn
  88. (setq slime-complete-symbol-function 'slime-fuzzy-complete-symbol
  89. slime-fuzzy-completion-in-place t
  90. slime-enable-evaluate-in-emacs t
  91. slime-autodoc-use-multiline-p t)
  92. (define-key slime-mode-map (kbd "TAB") 'slime-indent-and-complete-symbol)
  93. (define-key slime-mode-map (kbd "C-c i") 'slime-inspect)
  94. (define-key slime-mode-map (kbd "C-c C-s") 'slime-selector)))
  95. (provide 'prelude-common-lisp)
  96. ;;; prelude-common-lisp.el ends here