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.

119 lines
3.9 KiB

13 years ago
  1. ;;; prelude-emacs-lisp.el --- Emacs Prelude: Nice config for Elisp programming.
  2. ;;
  3. ;; Copyright © 2011-2015 Bozhidar Batsov
  4. ;;
  5. ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
  6. ;; URL: https://github.com/bbatsov/prelude
  7. ;; Version: 1.0.0
  8. ;; Keywords: convenience
  9. ;; Package-Requires: ((prelude-lisp "1.0.0"))
  10. ;; This file is not part of GNU Emacs.
  11. ;;; Commentary:
  12. ;; Nice config for Elisp Programming.
  13. ;;; License:
  14. ;; This program is free software; you can redistribute it and/or
  15. ;; modify it under the terms of the GNU General Public License
  16. ;; as published by the Free Software Foundation; either version 3
  17. ;; of the License, or (at your option) any later version.
  18. ;;
  19. ;; This program is distributed in the hope that it will be useful,
  20. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. ;; GNU General Public License for more details.
  23. ;;
  24. ;; You should have received a copy of the GNU General Public License
  25. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  26. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  27. ;; Boston, MA 02110-1301, USA.
  28. ;;; Code:
  29. (require 'prelude-lisp)
  30. (prelude-require-packages '(elisp-slime-nav rainbow-mode))
  31. (defun prelude-recompile-elc-on-save ()
  32. "Recompile your elc when saving an elisp file."
  33. (add-hook 'after-save-hook
  34. (lambda ()
  35. (when (and
  36. (string-prefix-p prelude-dir (file-truename buffer-file-name))
  37. (file-exists-p (byte-compile-dest-file buffer-file-name)))
  38. (emacs-lisp-byte-compile)))
  39. nil
  40. t))
  41. (defun prelude-visit-ielm ()
  42. "Switch to default `ielm' buffer.
  43. Start `ielm' if it's not already running."
  44. (interactive)
  45. (prelude-start-or-switch-to 'ielm "*ielm*"))
  46. (define-key emacs-lisp-mode-map (kbd "C-c C-z") 'prelude-visit-ielm)
  47. (define-key emacs-lisp-mode-map (kbd "C-c C-c") 'eval-defun)
  48. (define-key emacs-lisp-mode-map (kbd "C-c C-b") 'eval-buffer)
  49. (defun prelude-conditional-emacs-lisp-checker ()
  50. "Don't check doc style in Emacs Lisp test files."
  51. (let ((file-name (buffer-file-name)))
  52. (when (and file-name (string-match-p ".*-tests?\\.el\\'" file-name))
  53. (setq-local flycheck-checkers '(emacs-lisp)))))
  54. (defun prelude-emacs-lisp-mode-defaults ()
  55. "Sensible defaults for `emacs-lisp-mode'."
  56. (run-hooks 'prelude-lisp-coding-hook)
  57. (eldoc-mode +1)
  58. (prelude-recompile-elc-on-save)
  59. (rainbow-mode +1)
  60. (setq mode-name "EL")
  61. (prelude-conditional-emacs-lisp-checker))
  62. (setq prelude-emacs-lisp-mode-hook 'prelude-emacs-lisp-mode-defaults)
  63. (add-hook 'emacs-lisp-mode-hook (lambda ()
  64. (run-hooks 'prelude-emacs-lisp-mode-hook)))
  65. (add-to-list 'auto-mode-alist '("Cask\\'" . emacs-lisp-mode))
  66. ;; ielm is an interactive Emacs Lisp shell
  67. (defun prelude-ielm-mode-defaults ()
  68. "Sensible defaults for `ielm'."
  69. (run-hooks 'prelude-interactive-lisp-coding-hook)
  70. (eldoc-mode +1))
  71. (setq prelude-ielm-mode-hook 'prelude-ielm-mode-defaults)
  72. (add-hook 'ielm-mode-hook (lambda ()
  73. (run-hooks 'prelude-ielm-mode-hook)))
  74. (eval-after-load "elisp-slime-nav"
  75. '(diminish 'elisp-slime-nav-mode))
  76. (eval-after-load "rainbow-mode"
  77. '(diminish 'rainbow-mode))
  78. (eval-after-load "eldoc"
  79. '(diminish 'eldoc-mode))
  80. (eval-after-load "ielm"
  81. '(progn
  82. (define-key ielm-map (kbd "M-(") (prelude-wrap-with "("))
  83. (define-key ielm-map (kbd "M-\"") (prelude-wrap-with "\""))))
  84. ;; enable elisp-slime-nav-mode
  85. (dolist (hook '(emacs-lisp-mode-hook ielm-mode-hook))
  86. (add-hook hook 'elisp-slime-nav-mode))
  87. (defun conditionally-enable-smartparens-mode ()
  88. "Enable `smartparens-mode' in the minibuffer, during `eval-expression'."
  89. (if (eq this-command 'eval-expression)
  90. (smartparens-mode 1)))
  91. (add-hook 'minibuffer-setup-hook 'conditionally-enable-smartparens-mode)
  92. (provide 'prelude-emacs-lisp)
  93. ;;; prelude-emacs-lisp.el ends here