2017-06-08 11:47:56 +02:00
|
|
|
;;; lang/emacs-lisp/autoload.el -*- lexical-binding: t; -*-
|
2017-01-16 23:30:11 -05:00
|
|
|
|
2018-05-25 00:46:11 +02:00
|
|
|
;;;###autoload
|
|
|
|
(autoload 'overseer-test "overseer" nil t)
|
|
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
;; Library
|
|
|
|
;;
|
|
|
|
|
2017-01-16 23:30:11 -05:00
|
|
|
;;;###autoload
|
|
|
|
(defun +emacs-lisp/repl ()
|
2017-03-04 18:31:18 -05:00
|
|
|
"Open the Emacs Lisp REPL (`ielm')."
|
2017-01-16 23:30:11 -05:00
|
|
|
(interactive)
|
2017-03-04 18:31:18 -05:00
|
|
|
(pop-to-buffer
|
|
|
|
(or (get-buffer "*ielm*")
|
|
|
|
(progn (ielm)
|
|
|
|
(let ((buf (get-buffer "*ielm*")))
|
|
|
|
(bury-buffer buf)
|
|
|
|
buf)))))
|
2017-05-07 02:27:54 +02:00
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +emacs-lisp-eval (beg end)
|
|
|
|
"Evaluate a region and print it to the echo area (if one line long), otherwise
|
|
|
|
to a pop up buffer."
|
|
|
|
(require 'pp)
|
2017-12-29 13:37:26 -05:00
|
|
|
(let ((result (eval (read (concat "(progn " (buffer-substring-no-properties beg end) "\n)"))))
|
2017-05-15 15:11:32 +02:00
|
|
|
(buf (get-buffer-create "*doom eval*"))
|
2017-05-07 02:27:54 +02:00
|
|
|
(inhibit-read-only t)
|
|
|
|
lines)
|
2017-06-08 11:47:56 +02:00
|
|
|
(with-current-buffer buf
|
|
|
|
(read-only-mode +1)
|
|
|
|
(erase-buffer)
|
|
|
|
(setq-local scroll-margin 0)
|
2018-03-02 22:32:15 -05:00
|
|
|
(delay-mode-hooks (emacs-lisp-mode))
|
2017-06-08 11:47:56 +02:00
|
|
|
(prin1 result buf)
|
|
|
|
(pp-buffer)
|
|
|
|
(setq lines (count-lines (point-min) (point-max)))
|
2018-01-08 16:18:16 -05:00
|
|
|
(cond ((> lines 1)
|
|
|
|
(save-selected-window
|
|
|
|
(pop-to-buffer buf)
|
|
|
|
(with-current-buffer buf
|
|
|
|
(goto-char (point-min)))))
|
|
|
|
(t
|
|
|
|
(message "%s" (buffer-substring (point-min) (point-max)))
|
|
|
|
(kill-buffer buf))))))
|