2017-01-16 23:30:11 -05:00
|
|
|
;;; lang/emacs-lisp/autoload.el
|
|
|
|
|
|
|
|
;;;###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)
|
|
|
|
(let ((result (eval (read (buffer-substring-no-properties beg end))))
|
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-05-15 15:11:32 +02:00
|
|
|
(unwind-protect
|
|
|
|
(progn
|
|
|
|
(with-current-buffer buf
|
|
|
|
(read-only-mode +1)
|
|
|
|
(erase-buffer)
|
|
|
|
(setq-local scroll-margin 0)
|
|
|
|
(emacs-lisp-mode)
|
|
|
|
(prin1 result buf)
|
|
|
|
(pp-buffer)
|
|
|
|
(setq lines (count-lines (point-min) (point-max)))
|
|
|
|
(goto-char (point-min))
|
|
|
|
(if (> lines 1)
|
|
|
|
(doom-popup-buffer buf)
|
|
|
|
(message "%s" (buffer-substring (point-min) (point-max)))
|
|
|
|
(kill-buffer buf)))))))
|