Files
sydnix/modules/home/users/msyds/emacs/lisp/syd/emacs-lisp.el
2025-11-23 04:06:39 -07:00

57 lines
1.5 KiB
EmacsLisp
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
;;; -*- lexical-binding: t -*-
(require 'syd/base)
(require 'syd/handle)
(require 'syd/lisp)
;;; Pairs
(with-eval-after-load 'evil-surround
;; In Elisp, `' is a much more common pair than ``.
(syd-add-hook 'emacs-lisp-mode-hook
(defun syd-elisp-evil-surround-pairs-h ()
(push '(?` . ("`" . "'")) evil-surround-pairs-alist))))
;;; Ielm
;; Keep junk out of `user-emacs-directory'.
(setq ielm-history-file-name
(file-name-concat syd-data-dir "ielm-history.eld"))
;;; Define handlers
(defun syd-elisp-open-repl ()
(interactive)
(pop-to-buffer
(or (get-buffer "*ielm*")
(progn (ielm) ; Creates the *ielm* buffer.
(let ((b (get-buffer "*ielm*")))
;; We leave it to the enclosing `pop-to-buffer' to display the
;; buffer.
(bury-buffer b)
b)))))
(defun syd-elisp-handle-docs (identifier)
"Lookup IDENTIFIER with `describe-symbol'"
;; HACK: Much to my frustration, `describe-symbol' has no defined return
;; value. To test if the call was successful or not, we check if any window
;; is displaying the help buffer. This breaks if
;; `syd-emacs-lisp-lookup-documentation' is called while the help buffer is
;; already open.
(describe-symbol (intern identifier))
(let ((buffer (get-buffer (help-buffer))))
(and (get-buffer-window-list buffer)
buffer)))
(syd-handle '(emacs-lisp-mode lisp-interaction-mode)
:docs #'syd-elisp-handle-docs)
(add-hook 'lisp-interaction-mode-hook #'syd-lisp-mode)
(provide 'syd/emacs-lisp)