Refactor org related code

This commit is contained in:
Max Schlueter 2023-10-25 21:50:57 +02:00
parent 618e69fc3d
commit eb88540696
2 changed files with 32 additions and 24 deletions

View File

@ -42,10 +42,6 @@
;; change `org-directory'. It must be set before org loads!
(setq org-directory "~/Nextcloud/org/")
(after! org
;; Store org links to info pages
(add-to-list 'org-modules 'ol-info))
;; (defun max/org-gtd--incubate ()
;; "Process GTD inbox item by incubating it.
;; Allow the user apply user-defined tags from
@ -366,26 +362,6 @@
;; (setq ns-auto-hide-menu-bar t)
(defun max/org-clock-get-clock-string ()
"Form a clock string that will be shown in polybar.
Adapted from `org-clock-get-clock-string'."
(require 'org-clock)
(when (org-clocking-p)
(let* ((currently-clocked-time
(floor (org-time-convert-to-integer
(time-since org-clock-start-time))
60))
(clocked-time (org-clock-get-clocked-time))
(current-work-done-str (org-duration-from-minutes currently-clocked-time)))
(if org-clock-effort
(let* ((effort-in-minutes (org-duration-to-minutes org-clock-effort))
(work-done-str (org-duration-from-minutes clocked-time))
(effort-str (org-duration-from-minutes effort-in-minutes)))
(format "%s (%s/%s) %s"
current-work-done-str work-done-str effort-str org-clock-heading))
(format "%s %s"
current-work-done-str
org-clock-heading)))))
;; (defun my/toggle-org-agenda ()
;; "Toggle my custom org agenda view"
@ -503,3 +479,4 @@ Adapted from `org-clock-get-clock-string'."
;; load personal modules
(load! "email")
(load! "gtd")
(load! "org")

31
org.el Normal file
View File

@ -0,0 +1,31 @@
;;; org.el -*- lexical-binding: t; -*-
(defun max/org-clock-get-clock-string ()
"Form a clock string that will be shown in polybar.
Adapted from `org-clock-get-clock-string'."
(require 'org-clock)
(when (org-clocking-p)
(let* ((currently-clocked-time
(floor (org-time-convert-to-integer
(time-since org-clock-start-time))
60))
(clocked-time (org-clock-get-clocked-time))
(current-work-done-str (org-duration-from-minutes currently-clocked-time)))
(if org-clock-effort
(let* ((effort-in-minutes (org-duration-to-minutes org-clock-effort))
(work-done-str (org-duration-from-minutes clocked-time))
(effort-str (org-duration-from-minutes effort-in-minutes)))
(format "%s (%s/%s) %s"
current-work-done-str work-done-str effort-str org-clock-heading))
(format "%s %s"
current-work-done-str
org-clock-heading)))))
(after! org
;; Store org links to info pages
(add-to-list 'org-modules 'ol-info))
(map! :after org
:map org-mode-map
:localleader
"Y" #'ox-clip-image-to-clipboard)