diff options
author | Franck Cuny <franck.cuny@gmail.com> | 2020-06-18 19:50:44 -0700 |
---|---|---|
committer | Franck Cuny <franck.cuny@gmail.com> | 2020-06-18 19:50:44 -0700 |
commit | 51f49431a1da7219380c1c66f5769268951212b2 (patch) | |
tree | ad09bf749dd69cfad48aff6de36843fc2b4a3e30 | |
parent | emacs: once again, larger font (diff) | |
download | emacs.d-51f49431a1da7219380c1c66f5769268951212b2.tar.gz |
emacs: clean up org
too much configuration, too complex, which means I stop using it. Get back to the minimum.
-rw-r--r-- | emacs.d/custom/fcuny-org.el | 184 |
1 files changed, 43 insertions, 141 deletions
diff --git a/emacs.d/custom/fcuny-org.el b/emacs.d/custom/fcuny-org.el index 7ae92ca..d331a52 100644 --- a/emacs.d/custom/fcuny-org.el +++ b/emacs.d/custom/fcuny-org.el @@ -1,91 +1,75 @@ (require 'fcuny-vars) -(use-package dash +(use-package htmlize :ensure t) (use-package org :ensure t - :after (dash) - :hook ((org-mode . org-indent-mode) - (org-mode . visual-line-mode) - (org-mode . org-hide-block-all)) + :mode (("\\.txt\\'" . org-mode)) + :hook ((org-mode . org-indent-mode) + (org-mode . org-hide-block-all) + (org-mode . visual-line-mode) + (org-capture-after-finalize . org-save-all-org-buffers) + (org-capture-prepare-finalize . org-save-all-org-buffers)) :bind (("C-c c" . org-capture) - ("C-c a" . org-agenda) - ("C-c o" . hydra-org-menu/body)) + ("C-c a" . org-agenda)) + :config - (progn () - (org-babel-do-load-languages - 'org-babel-load-languages - '((shell . t) - (python . t) - (emacs-lisp . t)))) - - (defhydra hydra-org-menu (:hint nil) - " -^go to ^ ^action ^ -^-------------------^ ^---------------^ -_g i_: go to inbox _s_: save files -_g p_: go to personal -_g w_: go to work -_g n_: go to notes -" - ("g i" (find-file-other-window org-default-inbox-file)) - ("g p" (find-file-other-window org-default-tasks-file)) - ("g w" (find-file-other-window org-default-work-tasks-file)) - ("g n" (find-file-other-window org-default-work-notes-file)) - ("s" (org-save-all-org-buffers))) + (defvar load-language-list '((emacs-lisp . t) + (python . t) + (shell . t))) + (use-package org-id :ensure t) + (use-package ob-go + :ensure t + :init (cl-pushnew '(go . t) load-language-list)) + + (org-babel-do-load-languages 'org-babel-load-languages + load-language-list) :custom (org-id-locations-file (concat fcuny/path-emacs-var "/org-id-locations")) - (org-directory (expand-file-name "~/Documents/notebooks")) - (org-default-tasks-file (concat org-directory "/tasks.org")) - (org-default-journal-file (concat org-directory "/journal.org")) + (org-directory (expand-file-name "~/Documents/Notebooks")) + (org-default-inbox-file (concat org-directory "/inbox.org")) (org-default-notes-file (concat org-directory "/notes.org")) + (org-default-habit-file (concat org-directory "/habits.org")) + (org-default-tasks-file (concat org-directory "/personal-tasks.org")) (org-default-work-tasks-file (concat org-directory "/work-tasks.org")) + (org-default-journal-file (concat org-directory "/personal-journal.org")) (org-default-work-journal-file (concat org-directory "/work-journal.org")) - (org-default-work-notes-file (concat org-directory "/work-notes.org")) - (org-default-inbox-file (concat org-directory "/inbox.org")) + (org-default-interview-file (concat org-directory "/interviews.org")) - ;; cosmetic + ;; when archiving, inherit the tags from the parent + (org-archive-subtree-add-inherited-tags t) + + ;; display unicode characters (org-pretty-entities t) - (org-startup-indented nil) - (org-blank-before-new-entry nil) - ;; + ;; log the time of completion (org-log-done 'time) - ;; look - (org-agenda-window-setup 'current-window) - ;; priorities (org-priority-start-cycle-with-default nil) ;; Start one over/under default value. (org-lowest-priority ?F) (org-default-priority ?D) ;; Ensures unset tasks have low priority. - ;; how to manage tasks - (org-todo-keywords '((sequence "TODO(t)" "STARTED(s)" "DELEGATED(D)" "|" "DONE(d)") - (sequence "SOMEDAY" "|" "CANCELED(c)"))) - ;; agenda related (calendar-week-start-day 1) ;; org-mode uses calendar for the date picker, and I want this to start on Monday (org-agenda-start-on-weekday 1) ;; this is specific to org-agenda - (org-agenda-span 10) - (org-agenda-start-day "-7d") (org-agenda-files `(,org-default-tasks-file - ,org-default-work-tasks-file)) + ,org-default-work-tasks-file + ,org-default-habit-file)) ;; org babel related ;; prevent the conversion of spaces into tabs (necessary for Python code exports) (org-src-fontify-natively t) - (org-fontify-done-headline t) (org-src-preserve-indentation t) (org-edit-src-content-indentation t) - ;; behavior ;; I want to follow links on RET (org-return-follows-link t) - (org-enforce-todo-dependencies t) + + ;; some configurations for exporting document (org-export-with-toc nil) (org-export-with-section-numbers nil) @@ -97,116 +81,34 @@ _g n_: go to notes ("go" . "http://go/%s"))) ;; entries + (org-blank-before-new-entry nil) (org-blank-before-new-entry (quote ((heading . nil) (plain-list-item . nil)))) ;; see https://github.com/abo-abo/swiper/issues/986 (org-goto-interface 'outline-path-completion) - ;; refile and capture - (org-refile-use-outline-path 'file) - (org-outline-path-complete-in-steps nil) - (org-refile-allow-creating-parent-nodes 'confirm) - (org-refile-targets (quote ((org-default-tasks-file :level . 0) - (org-default-work-tasks-file :level . 0) - (org-default-notes-file :level . 0) - (org-default-work-notes-file :level . 0)))) - (org-reverse-note-order t) (org-capture-templates - `(("t" "Add task" entry - (file ,org-default-inbox-file) - "* TODO [#C] %?\n:PROPERTIES:\n:ID: %(shell-command-to-string \"uuidgen\"):CREATED: %U\n:END:\n") + `(("t" "Todo [inbox]" entry + (file+headline ,org-default-inbox-file "Tasks") + "* TODO [#D] %?\n:PROPERTIES:\n:ID: %(shell-command-to-string \"uuidgen\"):CREATED: %U\n:END:\n") ("n" "Note" entry - (file ,org-default-inbox-file) - "* %?\n:PROPERTIES:\n:ID: %(shell-command-to-string \"uuidgen\"):CREATED: %U\n:END:\n") + (file ,org-default-notes-file) + "* NOTE %?\n:PROPERTIES:\n:ID: %(shell-command-to-string \"uuidgen\"):CREATED: %U\n:END:\n") ("j" "Journal" entry (file+olp+datetree ,org-default-journal-file) - "* %?\n:PROPERTIES:\n:ID: %(shell-command-to-string \"uuidgen\"):CREATED: %U\n:END:\n" :tree-type month :unnarrowed t) - - ("m" "Meeting notes" entry - (file ,org-default-inbox-file) - "* %? %^g:meeting:\n:PROPERTIES:\n:ID: %(shell-command-to-string \"uuidgen\"):CREATED: %U\n:END:\n") + "* %?\n:PROPERTIES:\n:ID: %(shell-command-to-string \"uuidgen\"):CREATED: %U\n:END:\n" :tree-type month) ("i" "Interview notes" entry - (file ,org-default-inbox-file) + (file+olp+datetree ,org-default-interview-file) (file ,(concat fcuny/path-emacs-etc "/interview.org"))) ("J" "Work Journal" entry (file+olp+datetree ,org-default-work-journal-file) - "* %?\n:PROPERTIES:\n:ID: %(shell-command-to-string \"uuidgen\"):CREATED: %U\n:END:\n" :tree-type month :unnarrowed t)))) - -(use-package htmlize - :ensure t) - -;; can't use it for now, my version of org is too old -;(use-package orgit -; :ensure t) - -(defun fcuny/org-todo-age-time (&optional pos) - (let ((stamp (org-entry-get (or pos (point)) "CREATED" t))) - (when stamp - (time-subtract (current-time) - (org-time-string-to-time - (org-entry-get (or pos (point)) "CREATED" t)))))) - -(defun fcuny/org-todo-age (&optional pos) - (let ((days (time-to-number-of-days (fcuny/org-todo-age-time pos)))) - (cond - ((< days 1) "today") - ((< days 7) (format "%dd" days)) - ((< days 30) (format "%.1fw" (/ days 7.0))) - ((< days 358) (format "%.1fM" (/ days 30.0))) - (t (format "%.1fY" (/ days 365.0)))))) - -(defun fcuny/org-refile-to-datetree (&optional file) -"Refile current subtree to a datetree in FILE corresponding to it's timestamp. -The current time is used if the entry has no timestamp. If FILE -is nil, refile in the current file." - (interactive) - (require 'org-datetree) - (let* ((file (cond - (file (find-file-noselect file)) - (t (current-buffer)))) - (datetree-date (or (org-entry-get nil "CREATED" t) - (org-read-date t nil "now"))) - (date (org-date-to-gregorian datetree-date))) - (org-refile nil nil (list nil (buffer-file-name file) nil - (with-current-buffer file - (save-excursion - (org-datetree-find-date-create date) - (point))))))) - -(defun fcuny/org-refile-to-work-journal () -"Refile current subtree to a datetree in work journal corresponding to it's timestamp. -The current time is used if the entry has no timestamp." - (interactive) - (fcuny/org-refile-to-datetree org-default-work-journal-file)) - -(defun fcuny/org-subtree-region () - "Return a list of the start and end of a subtree." - (save-excursion - (list (progn (org-back-to-heading) (point)) - (progn (org-end-of-subtree) (point))))) - -(defun fcuny/org-refile-directly (file-dest) - "Move the current subtree to the end of FILE-DEST. -If SHOW-AFTER is non-nil, show the destination window, -otherwise, this destination buffer is not shown." - (interactive "fDestination: ") - - (defun dump-it (file contents) - (find-file-other-window file-dest) - (goto-char (point-max)) - (insert "\n" contents)) - - (save-excursion - (let* ((region (fcuny/org-subtree-region)) - (contents (buffer-substring (first region) (second region)))) - (apply 'kill-region region) - (save-window-excursion (dump-it file-dest contents))))) + "* %?\n:PROPERTIES:\n:ID: %(shell-command-to-string \"uuidgen\"):CREATED: %U\n:END:\n" :tree-type month)))) (provide 'fcuny-org) |