2019-02-14 07:36:41 +01:00
|
|
|
|
;;; oni-elisp.el --- Emacs Lisp configuration -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
|
|
;; Copyright (C) 2019 Tom Willemse
|
|
|
|
|
|
|
|
|
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
|
|
|
|
;; Keywords: local
|
2024-11-01 15:20:50 +01:00
|
|
|
|
;; Version: 2024.1101.071725
|
|
|
|
|
;; Package-Requires: (oni-company oni-flycheck oni-paredit oni-yasnippet oni-hydra rainbow-delimiters nameless erefactor flycheck-relint elisp-format)
|
2019-02-14 07:36:41 +01:00
|
|
|
|
|
|
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; My configuration for working in Emacs Lisp.
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2021-02-28 00:37:36 +01:00
|
|
|
|
(require 'checkdoc)
|
2020-02-29 22:13:56 +01:00
|
|
|
|
(require 'flycheck-relint)
|
2020-09-09 17:51:26 +02:00
|
|
|
|
(require 'hydra)
|
|
|
|
|
(require 'yasnippet)
|
2019-08-25 22:37:25 +02:00
|
|
|
|
|
2019-04-12 09:55:40 +02:00
|
|
|
|
(let ((byte-compile-not-obsolete-funcs '(preceding-sexp)))
|
|
|
|
|
(require 'erefactor))
|
|
|
|
|
|
2019-03-05 08:39:03 +01:00
|
|
|
|
(require 'ielm)
|
2019-02-19 08:49:10 +01:00
|
|
|
|
|
2019-08-25 22:37:25 +02:00
|
|
|
|
(defconst oni-elisp-root
|
|
|
|
|
(file-name-directory
|
|
|
|
|
(or load-file-name
|
|
|
|
|
(buffer-file-name)))
|
|
|
|
|
"The directory where ‘oni-elisp’ was loaded from.")
|
|
|
|
|
|
|
|
|
|
(defconst oni-elisp-snippets-dir
|
|
|
|
|
(expand-file-name "snippets" oni-elisp-root)
|
|
|
|
|
"The directory where ‘oni-elisp’ stores its snippets.")
|
|
|
|
|
|
2020-06-17 07:20:16 +02:00
|
|
|
|
(font-lock-add-keywords
|
|
|
|
|
'emacs-lisp-mode
|
|
|
|
|
`((,(rx symbol-start
|
|
|
|
|
(group (or "t"
|
|
|
|
|
"nil"
|
2021-05-25 04:47:53 +02:00
|
|
|
|
(and (optional "-")
|
|
|
|
|
digit
|
2020-06-17 07:20:16 +02:00
|
|
|
|
(minimal-match (zero-or-more (any digit ?.))))))
|
|
|
|
|
symbol-end)
|
|
|
|
|
1 font-lock-constant-face)))
|
|
|
|
|
|
2019-08-25 22:37:25 +02:00
|
|
|
|
(defun oni-elisp-snippets-initialize ()
|
|
|
|
|
"Initialize the snippets for ‘oni-elisp’."
|
|
|
|
|
(when (boundp 'yas-snippet-dirs)
|
|
|
|
|
(add-to-list 'yas-snippet-dirs oni-elisp-snippets-dir t))
|
|
|
|
|
(yas-load-directory oni-elisp-snippets-dir))
|
|
|
|
|
|
2020-06-17 06:55:34 +02:00
|
|
|
|
(defun oni-elisp-auto-fill-mode ()
|
|
|
|
|
"Enable ‘auto-fill-mode’ only for comments and inhibit for Package-Requires."
|
2019-12-11 08:16:15 +01:00
|
|
|
|
(setq-local comment-auto-fill-only-comments t)
|
2020-06-17 06:55:34 +02:00
|
|
|
|
(setq-local auto-fill-inhibit-regexp (rx line-start ";; Package-Requires: "))
|
2019-12-11 08:16:15 +01:00
|
|
|
|
(auto-fill-mode))
|
|
|
|
|
|
2020-09-16 07:50:45 +02:00
|
|
|
|
(defun oni-elisp-setup-ielm-mode-line ()
|
|
|
|
|
"Clean up the mode-line for ielm buffers."
|
|
|
|
|
(setq mode-line-buffer-identification
|
|
|
|
|
(list (propertize "Interactive Emacs Lisp Mode" 'face 'mode-line-buffer-id))
|
|
|
|
|
mode-line-format
|
|
|
|
|
'("%e"
|
|
|
|
|
mode-line-front-space
|
|
|
|
|
mode-line-remote
|
|
|
|
|
mode-line-frame-identification
|
|
|
|
|
mode-line-buffer-identification
|
|
|
|
|
" on "
|
|
|
|
|
(:eval (buffer-name ielm-working-buffer))
|
|
|
|
|
mode-line-end-spaces)))
|
|
|
|
|
|
2023-04-12 05:20:57 +02:00
|
|
|
|
(defun oni-elisp-ielm-remove-paredit-newline-keys ()
|
|
|
|
|
"Disable ‘C-j’ and ‘RET’ keybindings from ‘paredit-mode’."
|
|
|
|
|
(let ((oldmap (map-elt minor-mode-map-alist 'paredit-mode))
|
|
|
|
|
(newmap (make-sparse-keymap)))
|
|
|
|
|
(set-keymap-parent newmap oldmap)
|
|
|
|
|
(define-key newmap (kbd "RET") nil)
|
|
|
|
|
(define-key newmap (kbd "C-j") nil)
|
|
|
|
|
(make-local-variable 'minor-mode-overriding-map-alist)
|
|
|
|
|
(push `(paredit-mode . ,newmap) minor-mode-overriding-map-alist)))
|
|
|
|
|
|
2020-03-07 08:14:50 +01:00
|
|
|
|
(defhydra oni-elisp-hydra (:color teal :hint nil)
|
|
|
|
|
"
|
|
|
|
|
^Eval^
|
|
|
|
|
^^----------
|
|
|
|
|
_eb_: Buffer
|
|
|
|
|
"
|
|
|
|
|
("eb" eval-buffer))
|
|
|
|
|
|
2020-06-17 06:55:34 +02:00
|
|
|
|
(add-hook 'emacs-lisp-mode-hook #'oni-elisp-auto-fill-mode)
|
2019-02-14 07:36:41 +01:00
|
|
|
|
(add-hook 'emacs-lisp-mode-hook 'company-mode)
|
2021-06-23 07:19:53 +02:00
|
|
|
|
(add-hook 'emacs-lisp-mode-hook 'display-fill-column-indicator-mode)
|
2019-06-13 17:20:59 +02:00
|
|
|
|
(add-hook 'emacs-lisp-mode-hook 'electric-quote-local-mode)
|
2019-02-19 08:49:10 +01:00
|
|
|
|
(add-hook 'emacs-lisp-mode-hook 'erefactor-lazy-highlight-turn-on)
|
2019-02-14 07:36:41 +01:00
|
|
|
|
(add-hook 'emacs-lisp-mode-hook 'flycheck-mode)
|
|
|
|
|
(add-hook 'emacs-lisp-mode-hook 'nameless-mode)
|
2019-02-19 08:49:10 +01:00
|
|
|
|
(add-hook 'emacs-lisp-mode-hook 'paredit-mode)
|
|
|
|
|
(add-hook 'emacs-lisp-mode-hook 'rainbow-delimiters-mode)
|
|
|
|
|
|
2023-04-12 05:20:57 +02:00
|
|
|
|
(add-hook 'ielm-mode-hook #'oni-elisp-ielm-remove-paredit-newline-keys)
|
2020-09-16 07:50:45 +02:00
|
|
|
|
(add-hook 'ielm-mode-hook #'oni-elisp-setup-ielm-mode-line)
|
2019-05-31 16:41:56 +02:00
|
|
|
|
(add-hook 'ielm-mode-hook 'company-mode)
|
2019-03-05 08:39:03 +01:00
|
|
|
|
(add-hook 'ielm-mode-hook 'paredit-mode)
|
|
|
|
|
|
|
|
|
|
(setq ielm-prompt "λ> ")
|
|
|
|
|
|
2019-07-10 16:59:03 +02:00
|
|
|
|
(define-key emacs-lisp-mode-map (kbd "C-c r") erefactor-map)
|
2020-03-07 08:14:50 +01:00
|
|
|
|
(define-key emacs-lisp-mode-map (kbd "C-c SPC") 'oni-elisp-hydra/body)
|
2019-02-14 07:36:41 +01:00
|
|
|
|
|
2019-06-13 17:20:40 +02:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(add-to-list 'auto-mode-alist '("/Cask\\'" . emacs-lisp-mode))
|
|
|
|
|
|
2019-09-09 01:55:34 +02:00
|
|
|
|
(add-to-list 'display-buffer-alist
|
|
|
|
|
'("\\`\\*ielm\\*\\'" display-buffer-in-side-window
|
|
|
|
|
(side . bottom)
|
|
|
|
|
(slot . 0)
|
|
|
|
|
(window-height . 0.33)))
|
|
|
|
|
|
2019-08-25 22:37:25 +02:00
|
|
|
|
(with-eval-after-load 'elisp-mode
|
|
|
|
|
(with-eval-after-load 'yasnippet
|
|
|
|
|
(oni-elisp-snippets-initialize)))
|
|
|
|
|
|
2020-02-29 22:13:56 +01:00
|
|
|
|
(flycheck-relint-setup)
|
|
|
|
|
|
2021-02-28 00:37:36 +01:00
|
|
|
|
(add-hook 'emacs-lisp-mode-hook 'checkdoc-minor-mode)
|
|
|
|
|
|
|
|
|
|
(setq checkdoc-spellcheck-documentation-flag t)
|
|
|
|
|
|
2019-02-14 07:36:41 +01:00
|
|
|
|
(provide 'oni-elisp)
|
|
|
|
|
;;; oni-elisp.el ends here
|