feat: Progress towards comfortable Lisp editing
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
(require 'syd-handle-repl)
|
||||
(require 'syd-handle-lookup)
|
||||
(require 'syd-handle-eval)
|
||||
(require 'syd-lisp-lib)
|
||||
;; (require 'handle)
|
||||
|
||||
;; Don't `use-package' `ielm', since it's loaded by Emacs. You'll get weird
|
||||
@@ -12,6 +13,7 @@
|
||||
:custom ((ielm-history-file-name ; Stay out of my config dir!
|
||||
(file-name-concat syd-cache-dir "ielm-history.eld"))))
|
||||
|
||||
;;;###autoload
|
||||
(defun syd/open-emacs-lisp-repl ()
|
||||
(interactive)
|
||||
(pop-to-buffer
|
||||
@@ -23,21 +25,19 @@
|
||||
(bury-buffer b)
|
||||
b)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun syd-emacs-lisp-lookup-documentation (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 probably
|
||||
;; breaks if `syd-emacs-lisp-lookup-documentation' is called while
|
||||
;; the help buffer is already open.
|
||||
;; 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 probably 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)))
|
||||
|
||||
(set-repl-handler! 'emacs-lisp-mode
|
||||
#'syd/open-emacs-lisp-repl)
|
||||
|
||||
;;;###autoload
|
||||
(defun syd-emacs-lisp-eval (beg end)
|
||||
"Evaluate a region and print it to the echo area (if one line long), otherwise
|
||||
@@ -60,13 +60,35 @@ to a pop up buffer."
|
||||
:source-buffer (current-buffer)
|
||||
:force-popup current-prefix-arg))
|
||||
|
||||
(set-repl-handler! 'emacs-lisp-mode
|
||||
#'syd/open-emacs-lisp-repl)
|
||||
|
||||
(set-eval-handler! 'emacs-lisp-mode
|
||||
#'syd-emacs-lisp-eval)
|
||||
|
||||
(defun syd-emacs-set-handlers ()
|
||||
(add-hook 'emacs-lisp-mode-hook #'syd-lisp-mode)
|
||||
|
||||
(defun syd-emacs-set-handlers-h ()
|
||||
(setq-local syd-lookup-documentation-handlers
|
||||
(list #'syd-emacs-lisp-lookup-documentation)))
|
||||
|
||||
(add-hook 'emacs-lisp-mode-hook #'syd-emacs-set-handlers)
|
||||
(add-hook 'emacs-lisp-mode-hook #'syd-emacs-set-handlers-h)
|
||||
(add-hook 'help-mode-hook #'syd-emacs-set-handlers-h)
|
||||
|
||||
;; Semantic highlighting for Elisp.
|
||||
(use-package highlight-defined
|
||||
:hook (emacs-lisp-mode-hook . highlight-defined-mode))
|
||||
|
||||
;; Automatically and inteligently expand abbreviations. E.g. `wcb` will be
|
||||
;; expanded to `(with-current-buffer)`, but only where it makes sense for a
|
||||
;; function/macro call to be.
|
||||
(use-package sotlisp
|
||||
:straight (:host github
|
||||
:repo "Malabarba/speed-of-thought-lisp")
|
||||
:hook (emacs-lisp-mode . speed-of-thought-mode))
|
||||
|
||||
;; Give different pairs of delimiters different colours.
|
||||
(use-package rainbow-delimiters
|
||||
:hook (emacs-lisp-mode . rainbow-delimiters-mode))
|
||||
|
||||
(provide 'syd-lang-emacs-lisp)
|
||||
|
||||
Reference in New Issue
Block a user