From 1186d5d7cb04ca03ebfcf29f3cbc93edd8464097 Mon Sep 17 00:00:00 2001 From: petrucci4prez Date: Sat, 19 May 2018 17:39:36 -0400 Subject: [PATCH] fix capture window sizing --- conf.el | 17 +++++++++++++++++ conf.org | 26 +++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/conf.el b/conf.el index bea5e6f..1047aa5 100644 --- a/conf.el +++ b/conf.el @@ -320,6 +320,23 @@ event of an error or nonlocal exit." (advice-add #'org-fast-tag-selection :around #'nd/org-tag-window-advice) +(defun nd/org-capture-position (buffer alist) + (let ((new (split-window (get-buffer-window) -14 'below))) + (set-window-buffer new buffer) + new)) + +(defun nd/org-capture-window-advice (orig-fn table title &optional prompt specials) + "Advice to fix window placement in `org-capture-select-template'." + (let ((override '("\\*Org Select\\*" nd/org-capture-position))) + (add-to-list 'display-buffer-alist override) + (nd/with-advice + ((#'org-switch-to-buffer-other-window :override #'pop-to-buffer)) + (unwind-protect (funcall orig-fn table title prompt specials) + (setq display-buffer-alist + (delete override display-buffer-alist)))))) + +(advice-add #'org-mks :around #'nd/org-capture-window-advice) + (setq org-src-window-setup 'current-window) (setq org-src-fontify-natively t) (setq org-edit-src-content-indentation 0) diff --git a/conf.org b/conf.org index 8521bdd..e0107d1 100644 --- a/conf.org +++ b/conf.org @@ -430,6 +430,10 @@ The fonts in org headings bug me, make them smaller and less invasive #+END_SRC *** window splitting Org mode is great and all, but the windows never show up in the right place +The solutions here are simple, but have the downside that the window sizing +must be changed when tags/capture templates/todo items are changed. +This is because the buffer size is not known at window creation time +and I didn't feel like making a function to predict it **** todo selection I only need a teeny tiny window below my current window for todo selection #+BEGIN_SRC emacs-lisp @@ -471,6 +475,26 @@ By default, the tag selection window obliterates all but the current window...ho (advice-add #'org-fast-tag-selection :around #'nd/org-tag-window-advice) #+END_SRC +**** capture +Capture should show up in the bottom of any currently active buffer +#+BEGIN_SRC emacs-lisp +(defun nd/org-capture-position (buffer alist) + (let ((new (split-window (get-buffer-window) -14 'below))) + (set-window-buffer new buffer) + new)) + +(defun nd/org-capture-window-advice (orig-fn table title &optional prompt specials) + "Advice to fix window placement in `org-capture-select-template'." + (let ((override '("\\*Org Select\\*" nd/org-capture-position))) + (add-to-list 'display-buffer-alist override) + (nd/with-advice + ((#'org-switch-to-buffer-other-window :override #'pop-to-buffer)) + (unwind-protect (funcall orig-fn table title prompt specials) + (setq display-buffer-alist + (delete override display-buffer-alist)))))) + +(advice-add #'org-mks :around #'nd/org-capture-window-advice) +#+END_SRC ** src *** basic #+BEGIN_SRC emacs-lisp @@ -1335,7 +1359,7 @@ the agenda does not do this by default...it's annoying (set-face-attribute 'org-column nil :background "#1e2023") ;; org-columns-summary-types #+END_SRC -** interactive functions +** interactive commands #+BEGIN_SRC emacs-lisp (defun nd/mark-subtree-keyword (new-keyword &optional exclude) "marks all tasks in a subtree with keyword unless original keyword