FG42/nix/modules/organize/lisp/fg42/organize.el

212 lines
7.2 KiB
EmacsLisp

;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; URL: https://devheroes.codes/FG42/FG42
;; Version: 4.0.0
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;
;;; Commentary:
;;; Code:
(eval-when-compile
(require 'fpkg)
(require 'fg42/utils)
(require 'fg42/config)
(require 'hydra))
;;=============================================================================
;; Vars that user meant to set
;;=============================================================================
(defvar org-home "~/.orgs"
"The location to the org file repository.")
(defvar fg42/org-main-file "main.org")
(defvar fg42/org-notes-file "notes.org")
(defvar fg42/org-agenda-files "main.org")
(defvar fg42/global-tags nil)
;;=============================================================================
;; Helper functions
;;=============================================================================
(defun fg42/org-home ()
"Return the directory path to store everthing org related."
(config-get-or "org-dir" org-home))
(defun fg42/create-org-home ()
"Create the org-files directory directory."
(make-directory (fg42/org-home) t))
(defun fg42/organize-setup ()
"Setup all the necessary files and directories to use `org' and `org-roam'."
(fg42/create-org-home))
;;=============================================================================
;; Package defs
;;=============================================================================
(use! org-ql
"This package provides a query language for Org files. It offers two
syntax styles: Lisp-like sexps and search engine-like keywords.
It includes three libraries: The `org-ql' library is flexible and may
be used as a backend for other tools. The libraries `org-ql-search' and
`helm-org-ql' (a separate package) provide interactive search commands
and saved views."
:after org)
(use! org-super-agenda
"This package lets you supercharge your Org daily/weekly agenda. The idea is
to group items into sections, rather than having them all in one big list.
Now you can sort-of do this already with custom agenda commands, but when you
do that, you lose the daily/weekly aspect of the agenda: items are no longer
shown based on deadline/scheduled timestamps, but are shown no-matter-what.
For more information checkout `https://github.com/alphapapa/org-super-agenda'"
:after org-agenda
:config
(setq org-agenda-skip-scheduled-if-done t
org-agenda-skip-deadline-if-done t
org-agenda-include-deadlines t
org-agenda-compact-blocks t
org-agenda-start-day nil ;; Today
org-agenda-span 1)
(org-super-agenda-mode))
(use! org-capture
"Quickly capture what is in your head."
:bind (("<f6>" . org-capture))
:init
(setq-default
org-capture-templates
(eval
`(list
'("t" "Todo" entry (file+headline ,(expand-file-name fg42/org-main-file (fg42/org-home)) "New Tasks")
(file ,(expand-file-name "templates/todo" (fg42/org-home)))
:prepend t)
'("l" "Link" entry (file+headline ,(expand-file-name "bookmarks.org" (fg42/org-home)) "Links")
(file ,(expand-file-name "templates/links" (fg42/org-home)))
:prepend t
:immediate-finish t
:empty-lines 1)
'("h" "Thoughts" entry (file+datetree ,(expand-file-name "journal.org" (fg42/org-home)))
(file ,(expand-file-name "templates/thoughts" (fg42/org-home))))))))
(use! org-protocol
"`org-protocol' intercepts calls from emacsclient to trigger custom actions without external
dependencies. Only one protocol has to be configured with your external applications or
the operating system, to trigger an arbitrary number of custom actions. Just register
your custom sub-protocol and handler with the variable `org-protocol-protocol-alist'."
:init
(require 'org-protocol))
(use! org
"A GNU Emacs major mode for keeping notes, authoring documents, computational notebooks,
literate programming, maintaining to-do lists, planning projects, and more — in a fast
and effective plain text system.
For more info on ~org-mode~ check out `https://orgmode.org/'"
:hook
(org-mod . flyspell-mode)
(org-mode . fg42/organize-setup)
:init
(setq
org-auto-align-tags nil
org-tags-column 0
org-catch-invisible-edits 'show-and-error
org-special-ctrl-a/e t
org-insert-heading-respect-content t)
org-tag-alist fg42/global-tags
;; Org styling, hide markup etc.
org-hide-emphasis-markers t
org-pretty-entities t
org-ellipsis ""
;; Agenda styling
org-agenda-tags-column 0
org-agenda-block-separator ?─
org-agenda-time-grid
'((daily today require-timed)
(800 1000 1200 1400 1600 1800 2000)
" ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄")
org-agenda-current-time-string
"<── now ─────────────────────────────────────────────────"
org-agenda-files (concat (file-name-as-directory (fg42/org-home))
fg42/org-agenda-files)
org-directory (fg42/org-home)
org-default-notes-file (concat (file-name-as-directory (fg42/org-home))
fg42/org-notes-file)
org-refile-targets '((org-agenda-files :maxlevel . 3))
(with-eval-after-load "ox-latex"
(setq org-latex-default-packages-alist
(append '(("hidelinks" "hyperref" nil))
org-latex-default-packages-alist))))
(use! org-modern
"A modern look for the old org."
:hook ((org-mode . org-modern-mode)
(org-agenda-finalize . org-modern-mode)))
(with-config "org-roam"
(use! org-roam
"Create a second brain for yourself with this great knowledge base tool."
:after org
:commands (org-roam-node-find org-roam-node-insert
org-roam-capture org-roam-ui-mode)
:config
(setq-default org-roam-directory (file-truename (path-join (fg42/org-home) "roam"))
org-roam-db-update-on-save t)
(make-directory org-roam-directory t)
(org-roam-db-autosync-mode))
(use! websocket
"Websocket support for Elisp."
:after org-roam)
(use! org-roam-ui
"A nice web UI for `org-roam'"
:after org-roam
:config
(setq org-roam-ui-sync-theme t
org-roam-ui-follow t
org-roam-ui-update-on-save t
org-roam-ui-open-on-start t))
(defhydra hydra-org-roam (:exit t)
"Org Roam"
("i" org-roam-node-insert "Insert")
("f" org-roam-node-find "Find")
("c" org-roam-capture "Capture")
("u" org-roam-ui-mode "Web UI"))
(global-set-key (kbd "C-c o") 'hydra-org-roam/body))
(provide 'fg42/organize)
;;; organize.el ends here