:x -> doom:scratch-buffer; :org -> doom:org-capture

This commit is contained in:
Henrik Lissner 2016-06-18 00:53:01 -04:00
parent a49c89ceba
commit 09f1b21b5b
3 changed files with 31 additions and 21 deletions

View file

@ -259,27 +259,25 @@ buffers regardless of project."
(interactive "<!><a>")
(doom-kill-buffers (doom/get-matching-buffers pattern (doom/get-buffers (not bang)))))
;;;###autoload (autoload 'doom:scratch-or-org "defuns-buffers" nil t)
(evil-define-operator doom:scratch-or-org (&optional beg end bang)
"Send a selection to the scratch buffer. If BANG, use org-capture instead."
;;;###autoload (autoload 'doom:scratch-buffer "defuns-buffers" nil t)
(evil-define-operator doom:scratch-buffer (&optional beg end bang)
"Send a selection to the scratch buffer. If BANG, don't use a popup."
:move-point nil
:type inclusive
(interactive "<r><!>")
(let ((text (when (and (evil-visual-state-p) beg end)
(buffer-substring beg end))))
(if bang
(org-capture-string text)
;; or scratch buffer by default
(let ((mode major-mode)
(buffer-substring beg end)))
(mode major-mode)
(old-project (doom/project-root))
(new-buf (get-buffer-create "*doom:scratch*")))
(with-selected-window (doom/popup-buffer new-buf)
(with-current-buffer new-buf
(setq default-directory old-project)
(setq mode-line-format (doom-mode-line 'scratch))
(when (and (not (eq major-mode mode))
(functionp mode))
(funcall mode))
(if text (insert text)))))))
(if text (insert text)))
(if bang (switch-to-buffer new-buf) (doom/popup-buffer new-buf))))
;;;###autoload (autoload 'doom:cd "defuns-buffers" nil t)
(evil-define-command doom:cd (dir)

View file

@ -357,5 +357,16 @@ re-align the table if necessary. (Necessary because org-mode has a
(and (= (1+ (line-beginning-position)) me)
(eq 32 (char-after me)))))
;;;###autoload (autoload 'doom:org-capture "defuns-org" nil t)
(evil-define-operator doom:org-capture (&optional beg end bang)
"Send a selection to `org-capture'."
:move-point nil
:type inclusive
(interactive "<r><!>")
(org-capture-string
(if (and (evil-visual-state-p) beg end)
(buffer-substring beg end)
"")))
(provide 'defuns-org)
;;; defuns-org.el ends here

View file

@ -47,7 +47,7 @@
(ex! "sh[ell]" 'doom/eshell)
(ex! "t[mux]" 'doom:tmux) ; send to tmux
(ex! "tcd" 'doom:tmux-cd) ; cd to default-directory in tmux
(ex! "x" 'doom:scratch-or-org)
(ex! "x" 'doom:scratch-buffer)
;; GIT
(ex! "ga[dd]" 'doom/vcs-stage-hunk)
@ -99,10 +99,11 @@
(ex! "tabs" 'doom/tab-display)
;; Org-mode
(ex! "org" 'doom:org-capture)
(add-hook! org-mode
;;(ex! "org" 'doom:org-helm-search) ; search org notes
(ex! "att[ach]" 'doom:org-attach) ; attach file to org file
(ex! "link" 'doom:org-link)
(ex-local! "att[ach]" 'doom:org-attach) ; attach file to org file
(ex-local! "link" 'doom:org-link)
(ex-local! "vlc" 'doom-org-insert-vlc))
(provide 'my-commands)