From c487b09d6a1b054c3912397ec6cdbabd58d35eb0 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Fri, 8 Mar 2019 18:15:27 +0000 Subject: [PATCH] Support i3wm and org-capture integration Now this has been missing from my workflow for awhile. --- configs/linux/misc/.config/i3/config | 4 ++ .../emacs/.emacs.d/wpc/packages/wpc-org.el | 39 +++++++++++++------ configs/shared/zsh/dumping_grounds.zsh | 17 ++++++++ 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/configs/linux/misc/.config/i3/config b/configs/linux/misc/.config/i3/config index 1feb71dc8..d1bd2116b 100644 --- a/configs/linux/misc/.config/i3/config +++ b/configs/linux/misc/.config/i3/config @@ -62,6 +62,10 @@ bindsym F10 exec --no-startup-id pactl set-sink-mute @DEFAULT bindsym XF86MonBrightnessUp exec light -A 10 bindsym XF86MonBrightnessDown exec light -U 10 +# integrate with Emacs's org-mode +bindsym $mod+o exec zsh -i -c org_capture +for_window [class="GoogleEmacs" instance="org-protocol-capture"] floating enable + # ensure wallpaper exec --no-startup-id feh --bg-scale ~/Pictures/cartoon-outdoors.jpg diff --git a/configs/shared/emacs/.emacs.d/wpc/packages/wpc-org.el b/configs/shared/emacs/.emacs.d/wpc/packages/wpc-org.el index c2682be5c..dcbe06688 100644 --- a/configs/shared/emacs/.emacs.d/wpc/packages/wpc-org.el +++ b/configs/shared/emacs/.emacs.d/wpc/packages/wpc-org.el @@ -6,16 +6,23 @@ ;;; Code: +;; TODO: figure out how to nest this in (use-package org ...) +(setq org-capture-templates + (quote ( + +("w" "work" entry (file+headline "~/Documents/org/work.org" "Tasks") + "* TODO %?") + +("p" "personal" entry (file+headline "~/Documents/org/personal.org" "Tasks") + "* TODO %? ") + +))) +(evil-set-initial-state 'org-mode 'insert) + (use-package org :preface (defconst wpc-org-directory - "~/Dropbox/org") - (defconst ub-org-directory - "~/Dropbox/sprint-planning-staging") - (defun wpc/org-file (file) - (f-join wpc-org-directory (f-swap-ext file "org"))) - (defun ub/org-file (file) - (f-join ub-org-directory (f-swap-ext file "org"))) + "~/Documents/org") :config ; (general-add-hook org-mode-hook (disable linum-mode)) (general-define-key :prefix "C-c" @@ -25,15 +32,25 @@ (setq org-default-notes-file (wpc/org-file "notes")) (setq org-log-done 'time) (setq org-agenda-files (list (wpc/org-file "work") - (wpc/org-file "personal"))) - (setq org-capture-templates - `(("t" "Todo" entry (file+heading ,(ub/org-file "index") "Ideas") - "* TODO %?\n %i")))) + (wpc/org-file "personal")))) (use-package org-bullets :after (org) :config (general-add-hook 'org-mode-hook (enable org-bullets-mode))) +;; i3, `org-mode' integration +;; Heavily influenced by: https://somethingsomething.us/post/i3_and_orgmode/ +(defadvice org-switch-to-buffer-other-window + (after supress-window-splitting activate) + "Delete the extra window if we're in a capture frame." + (if (equal "org-protocol-capture" (wpc/frame-name)) + (delete-other-windows))) + +(add-hook 'org-capture-after-finalize-hook + (lambda () + (when (equal "org-protocol-capture" (wpc/frame-name)) + (delete-frame)))) + (provide 'wpc-org) ;;; wpc-org.el ends here diff --git a/configs/shared/zsh/dumping_grounds.zsh b/configs/shared/zsh/dumping_grounds.zsh index c2acc6456..ae16bb78b 100644 --- a/configs/shared/zsh/dumping_grounds.zsh +++ b/configs/shared/zsh/dumping_grounds.zsh @@ -9,6 +9,23 @@ dsh() { docker exec -it "${container}" "${cmd}" } +# Emacs +dired() { + # Opens either the `$(pwd)` or `$1` in Emacs's `dired`. + # Uses i3 to focus Emacs. + directory=${1:-$(pwd)} + echo $directory + emacsclient --eval "(dired \"$directory\")" && focus Emacs +} + +org_capture() { + # Spawns an Emacs frame running org-capture. + echo called + emacsclient --create-frame \ + --frame-parameters '(quote (name . "org-protocol-capture"))' \ + --eval '(org-capture)' +} + # Git conflicts() { # Edit git conflicts one-by-one in your favorite editor.