[Org] Quick capture setup
This commit is contained in:
parent
558a5a9f5e
commit
777c358e8a
2 changed files with 55 additions and 0 deletions
15
config.org
15
config.org
|
@ -1206,6 +1206,21 @@ Finally define the org-agenda display using [[https://github.com/alphapapa/org-s
|
|||
(:name "Someday" :todo "SOMEDAY" :scheduled future :order 101))))))))))
|
||||
#+end_src
|
||||
|
||||
** Quick Capture from everywhere
|
||||
|
||||
Given the fact that I run Emacs using Emacsclient all the time I though it would be quite helpful to have the ability to capture a to-do from everywhere, e.g. a sudden thought crossing my mind while developing photos or browsing the web. Thanks to the help of an [[https://www.reddit.com/r/emacs/comments/74gkeq/system_wide_org_capture][Reddit post]] by [[https://www.reddit.com/user/lebitso][u/lebitso]] I was able to achieve this goal and I put the code in an extra package that is loaded here.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package org-quick-capture
|
||||
:load-path "packages/")
|
||||
#+end_src
|
||||
|
||||
To use this, I wrote a small shell script that I'm assigning a keyboard shortcut in my window manager / desktop environment. The shell script essentially runs the following command:
|
||||
|
||||
#+begin_src sh
|
||||
emacsclient -c -F '(quote (name . "capture"))' -e '(activate-capture-frame)'
|
||||
#+end_src
|
||||
|
||||
** Automatic UUID creation
|
||||
|
||||
I am currently exploring the option in Org mode to export a file (or some entries) to an ics-file which I can then in turn import into my calendar. For reliably creating (and most importantly: updating) entries it is necessary that each one has an unique ID. To create a ID for the current entry I could just run =M-x org-id-get-create= and for an entire file execute the following Emacs Lisp ~(org-map-entries 'org-id-get-create)~. Of course this is not an ideal solution. But adding this s-expression to ~org-mode-hook~ would create IDs in all Org file I edit which I also don't like. Since the amount of files I do want the automatic creation is (currently) not that large it is OK for me to do some work on my own, at least if it is only a one time setup.
|
||||
|
|
40
packages/org-quick-capture.el
Normal file
40
packages/org-quick-capture.el
Normal file
|
@ -0,0 +1,40 @@
|
|||
;;; org-quick-capture.el --- Open a org capture frame and close it directly afterwards. -*- lexical-binding: t; -*-
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; The code is grabbed from Reddit
|
||||
;;; (https://www.reddit.com/r/emacs/comments/74gkeq/system_wide_org_capture/)
|
||||
;;; and was written by u/lebitso (https://www.reddit.com/user/lebitso)
|
||||
;;; with the help of an anoymous other user.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org)
|
||||
(require 'org-capture)
|
||||
|
||||
(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 Capture" (frame-parameter nil 'name))
|
||||
(delete-other-windows)))
|
||||
|
||||
(defadvice org-capture-finalize
|
||||
(after delete-capture-frame activate)
|
||||
"Advise capture-finalize to close the frame when finished."
|
||||
(when (and (equal "Org Capture" (frame-parameter nil 'name))
|
||||
(not (eq this-command 'org-capture-refile)))
|
||||
(delete-frame)))
|
||||
|
||||
(defadvice org-capture-refile
|
||||
(after delete-capture-frame activate)
|
||||
"Advise org-refile to close the frame when finished."
|
||||
(delete-frame))
|
||||
|
||||
(defun org-quick-capture ()
|
||||
"Run 'org-capture' in an own capture frame."
|
||||
(select-frame-by-name "Org Capture")
|
||||
(switch-to-buffer (get-buffer-create "*scratch*"))
|
||||
(org-capture))
|
||||
|
||||
(provide 'org-quick-capture)
|
||||
;;; org-quick-capture.el ends here
|
Loading…
Reference in a new issue