2017-02-19 18:52:26 -05:00
|
|
|
;;; ui/doom/autoload/evil.el
|
2017-01-31 05:09:20 -05:00
|
|
|
|
2017-02-19 18:52:26 -05:00
|
|
|
;;;###autoload (autoload '+doom:scratch-buffer "ui/doom/autoload/evil" nil t)
|
2017-01-31 05:09:20 -05:00
|
|
|
(evil-define-operator +doom:scratch-buffer (&optional beg end bang)
|
|
|
|
"Send a region to and pop up the scratch buffer. If BANG, don't use a popup,
|
|
|
|
use the current window."
|
2017-02-19 18:52:26 -05:00
|
|
|
:move-point nil :type inclusive
|
|
|
|
;; TODO Test me
|
2017-01-31 05:09:20 -05:00
|
|
|
(interactive "<r><!>")
|
|
|
|
(let ((text (when (and (evil-visual-state-p) beg end)
|
|
|
|
(buffer-substring beg end)))
|
|
|
|
(mode major-mode)
|
|
|
|
(old-project (doom-project-root))
|
2017-04-25 22:56:49 -04:00
|
|
|
(new-buf (get-buffer-create "*doom:scratch*")))
|
|
|
|
(if bang
|
|
|
|
(switch-to-buffer new-buf)
|
|
|
|
(doom-popup-buffer new-buf))
|
2017-01-31 05:09:20 -05:00
|
|
|
(with-current-buffer new-buf
|
2017-04-25 22:56:49 -04:00
|
|
|
(setq default-directory old-project)
|
2017-01-31 05:09:20 -05:00
|
|
|
(when (and (not (eq major-mode mode))
|
|
|
|
(functionp mode))
|
|
|
|
(funcall mode))
|
2017-04-25 22:56:49 -04:00
|
|
|
(if text (insert text)))))
|
2017-01-31 05:09:20 -05:00
|
|
|
|