Add org module

This commit is contained in:
Wojciech Kozlowski 2022-08-13 22:38:19 +02:00
parent 1d2176fc01
commit 1f6f4d911e
3 changed files with 101 additions and 7 deletions

View File

@ -117,11 +117,86 @@
;; Remove background from `avy'. ;; Remove background from `avy'.
(after! avy (setq avy-background t)) (after! avy (setq avy-background t))
;; Remove org-agenda from dashboard. (after! org
(let ((org-agenda-section (defvar +x/org-capture-inbox-file "inbox.org")
(seq-find (lambda (item) (string= (nth 0 item) "Open org-agenda")) (defvar +x/org-capture-reading-list-file "reading.org")
+doom-dashboard-menu-sections))) (add-to-list 'org-capture-templates
(delete org-agenda-section +doom-dashboard-menu-sections)) `("r" "Reading list" entry
(file+headline ,+x/org-capture-reading-list-file "Inbox")
"* %?"))
(add-to-list 'org-capture-templates
`("i" "Inbox" entry
(file ,+x/org-capture-inbox-file)
"* HOLD [#C] %?" :prepend t))
(setq org-todo-keywords
'((sequence
"HOLD(h)" ; This task needs doing eventually, but not yet
"NEXT(n)" ; A task that needs doing and is ready to do
"WEEK(w)" ; A task that is scheduled to work on this week
"TODO(d)" ; A task that is currently getting done
"WAIT(t)" ; Something external is holding up this task
"|"
"DONE(x)")); Task successfully completed
org-todo-keyword-faces
'(("HOLD" . +org-todo-onhold)
("NEXT" . +org-todo-active)
("WEEK" . org-todo)
("WAIT" . +org-todo-cancel)))
(add-to-list 'org-after-todo-state-change-hook
(lambda ()
(when (equal org-state "DONE")
(org-archive-to-archive-sibling)))))
(after! org-agenda
(setq org-agenda-custom-commands
'(("d" "Agenda and tasklist for the day"
((agenda "")
(todo "TODO"))
((org-agenda-span 'day)
(org-agenda-start-day "")
(org-deadline-warning-days 0)))
("w" "Agenda and tasklist for the week"
((agenda "")
(todo "TODO")
(todo "WEEK"))
((org-agenda-start-on-weekday 1)
(org-agenda-span 'week)
(org-agenda-start-day "")
(org-deadline-warning-days 0)))
("p" . "Planning lists")
("pd" "Agenda and tasklist for daily planning"
((agenda "")
(todo "WEEK")
(todo "TODO"))
((org-agenda-start-on-weekday 1)
(org-agenda-span 'week)
(org-agenda-start-day "")
(org-deadline-warning-days 0)))
("pw" "Agenda and tasklist for weekly planning"
((agenda "")
(todo "NEXT")
(todo "HOLD")
(todo "WEEK")
(todo "TODO"))
((org-agenda-start-on-weekday 1)
(org-agenda-span 'fortnight)
(org-agenda-start-day "")
(org-deadline-warning-days 0)))
("r" . "Weekly review lists")
("rl" "Tasklist of leftover work"
((todo "TODO")
(todo "WEEK")))
("rn" "Agenda and tasklist of upcoming tasks"
((agenda "")
(todo "WAIT")
(todo "NEXT")
(todo "HOLD"))
((org-agenda-start-on-weekday 1)
(org-agenda-span 'month)
(org-agenda-start-day "")
(org-deadline-warning-days 0))))))
;; Remove the silly doom newline advice. ;; Remove the silly doom newline advice.
(advice-remove 'newline-and-indent (advice-remove 'newline-and-indent
@ -133,7 +208,9 @@
"Add some extra whitespace highlights to doom's opinion" "Add some extra whitespace highlights to doom's opinion"
:after #'doom-highlight-non-default-indentation-h :after #'doom-highlight-non-default-indentation-h
(when (bound-and-true-p whitespace-mode) (when (bound-and-true-p whitespace-mode)
(appendq! whitespace-style '(trailing lines-tail empty)) (appendq! whitespace-style '(trailing empty))
(when (not (eq major-mode 'org-mode))
(appendq! whitespace-style '(lines-tail)))
(whitespace-mode +1))) (whitespace-mode +1)))
;; I actually like it when Emacs recenters the screen while scrolling. This may ;; I actually like it when Emacs recenters the screen while scrolling. This may
@ -360,6 +437,8 @@
"C-<" #'+x/scroll-down-one "C-<" #'+x/scroll-down-one
"C->" #'+x/scroll-up-one "C->" #'+x/scroll-up-one
"M-Q" #'+x/unfill-paragraph "M-Q" #'+x/unfill-paragraph
(:map org-mode-map
"C-c C-;" #'+x/org-insert-link-with-title)
;; Faster navigation with avy. ;; Faster navigation with avy.
"M-g M-c" #'avy-goto-char "M-g M-c" #'avy-goto-char
"M-g M-v" #'avy-goto-char-2 "M-g M-v" #'avy-goto-char-2

View File

@ -151,7 +151,7 @@
;;nim ; python + lisp at the speed of c ;;nim ; python + lisp at the speed of c
;;nix ; I hereby declare "nix geht mehr!" ;;nix ; I hereby declare "nix geht mehr!"
;;ocaml ; an objective camel ;;ocaml ; an objective camel
;;org ; organize your plain life in plain text (org +dragndrop +pretty); organize your plain life in plain text
;;php ; perl's insecure younger brother ;;php ; perl's insecure younger brother
;;plantuml ; diagrams for confusing people more ;;plantuml ; diagrams for confusing people more
;;purescript ; javascript, but functional ;;purescript ; javascript, but functional

View File

@ -3,6 +3,8 @@
;; ;;
;;; Code: ;;; Code:
(require 'subr-x)
;;;###autoload ;;;###autoload
(defun +x/indent-region-or-buffer () (defun +x/indent-region-or-buffer ()
"Indent a region if selected, otherwise the whole buffer." "Indent a region if selected, otherwise the whole buffer."
@ -40,5 +42,18 @@
(emacs-lisp-docstring-fill-column t)) (emacs-lisp-docstring-fill-column t))
(fill-paragraph nil region))) (fill-paragraph nil region)))
;;;###autoload
(defun +x/org-insert-link-with-title (url)
"Insert a link to URL with the title provided by the site itself."
(interactive "sURL for which to insert link: ")
(let ((title
(string-trim
(shell-command-to-string
(concat "curl -sL " url
" | "
"xmllint --html --xpath '//head/title/text()' - "
"2>/dev/null")))))
(insert "[[" url "][" title "]]")))
(provide 'x-lib) (provide 'x-lib)
;;; x-lib.el ends here ;;; x-lib.el ends here