From 09f1b21b5bf52f6501dd68d78491507e2c1f5cde Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 18 Jun 2016 00:53:01 -0400 Subject: [PATCH] :x -> doom:scratch-buffer; :org -> doom:org-capture --- core/defuns/defuns-buffers.el | 32 +++++++++++++++----------------- modules/defuns/defuns-org.el | 11 +++++++++++ private/my-commands.el | 9 +++++---- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/core/defuns/defuns-buffers.el b/core/defuns/defuns-buffers.el index ac611744b..9673e5ad5 100644 --- a/core/defuns/defuns-buffers.el +++ b/core/defuns/defuns-buffers.el @@ -259,27 +259,25 @@ buffers regardless of project." (interactive "") (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 "") (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) - (old-project (doom/project-root)) - (new-buf (get-buffer-create "*doom:scratch*"))) - (with-selected-window (doom/popup-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))))))) + (buffer-substring beg end))) + (mode major-mode) + (old-project (doom/project-root)) + (new-buf (get-buffer-create "*doom:scratch*"))) + (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 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) diff --git a/modules/defuns/defuns-org.el b/modules/defuns/defuns-org.el index efb5e65e7..5f43bfe4f 100644 --- a/modules/defuns/defuns-org.el +++ b/modules/defuns/defuns-org.el @@ -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 "") + (org-capture-string + (if (and (evil-visual-state-p) beg end) + (buffer-substring beg end) + ""))) + (provide 'defuns-org) ;;; defuns-org.el ends here diff --git a/private/my-commands.el b/private/my-commands.el index 69c3e2261..4d5d29f09 100644 --- a/private/my-commands.el +++ b/private/my-commands.el @@ -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,11 +99,12 @@ (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! "vlc" 'doom-org-insert-vlc)) + (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) ;;; my-commands.el ends here