forked from FG42/FG42
1
0
Fork 0

Extract organize into its own module and add org-roam

This commit is contained in:
Sameer Rahmani 2024-05-02 21:08:37 +01:00
parent 9453925e34
commit d0ee179dc9
Signed by: lxsameer
GPG Key ID: 8741FACBF412FFA5
5 changed files with 172 additions and 41 deletions

View File

@ -37,6 +37,7 @@ let
./verilog ./verilog
./workspace ./workspace
./rss ./rss
./organize
]; ];
in in
modules modules

View File

@ -26,9 +26,6 @@ let
deps = deps =
(with pkgs.emacsPackages; [ (with pkgs.emacsPackages; [
origami origami
#which-key
# projectile
#projectile-ripgrep
pkg-info pkg-info
expand-region expand-region
direnv direnv
@ -40,11 +37,7 @@ let
avy avy
ace-window ace-window
flycheck flycheck
org
org-super-agenda
rainbow-delimiters rainbow-delimiters
org-ql
org-modern
base16-theme base16-theme
tempel tempel
tempel-collection tempel-collection

View File

@ -25,12 +25,12 @@
(require 'fpkg) (require 'fpkg)
;; We build this file via the main FG42's Nix derivation. It ;; We build this file via the main FG42's Nix derivation. It
;; contains the final Nix configuration of FG42. ;; contains the final Nix configuration of FG42.
(require 'fg42/config) (require 'fg42/config))
(require 'fg42/organize))
(require 'server) (require 'server)
(require 'fg42/utils) (require 'fg42/utils)
(defun fg42/setup-font () (defun fg42/setup-font ()
"Set the default font of `FG42' to FONT-NAME and FONT-SIZE." "Set the default font of `FG42' to FONT-NAME and FONT-SIZE."
(let ((name (config-get font-name)) (let ((name (config-get font-name))
@ -289,8 +289,7 @@ short extension."
(when (not (server-running-p)) (when (not (server-running-p))
(when-wm (when-wm
(setq server-name "fg42-wm")) (setq server-name "fg42-wm"))
(server-start) (server-start))
(require 'org-protocol))
(when-wm (when-wm
;; Activating the WM mode ;; Activating the WM mode

View File

@ -0,0 +1,85 @@
# Fg42 - Emacs Editor for advance users
#
# Copyright (c) 2010-2024 Sameer Rahmani <lxsameer@gnu.org>
#
# 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, version 2.
#
# 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/>.
# This is the home manager module that exposes FG42. It differs
# from FG42 modules that are structurally the same but used in
# different context
# A list of default FG42 modules to build FG42 with.
{ lib, config, pkgs, makeFG42Drv, ... }:
with lib;
let
cfg = config.fg42.organize;
deps =
(with pkgs.emacsPackages; [
org
org-super-agenda
org-ql
org-modern
] ++ optionals (cfg.org-roam) [
org-roam
org-roam-ui
websocket
simple-httpd
f
]);
drv = makeFG42Drv {
pname = "organize";
version = config.fg42.version;
buildInputs = deps;
src = ./.;
};
in
{
imports = [
../editor
];
options.fg42.organize = {
enable = mkAndEnableOption "organize";
org-roam = mkAndEnableOption "organize";
org-dir = mkOption {
type = types.str;
default = "~/.orgs";
example = literalExpression ''"~/.orgs"'';
description = mdDoc ''
A non-nix `path` (string `path`) of the location your want org-mode
to store you org files.
'';
};
};
config = mkIf cfg.enable {
fg42.elispPackages = [ drv ] ++ deps;
fg42.requires = [ drv.pname ];
fg42.vars = [
(defVar "org-home" cfg.org-dir "Where to store org files.")
(defVar "org-roam" cfg.org-roam "Enable org-roam?")
];
meta = {
maintainers = [ maintainers.lxsameer ];
doc = ./README.md;
};
};
}

View File

@ -22,28 +22,43 @@
;;; Commentary: ;;; Commentary:
;;; Code: ;;; Code:
(eval-when-compile (eval-when-compile
(require 'fpkg)) (require 'fpkg)
(require 'fg42/utils)
(require 'fg42/config)
(require 'hydra))
;;=============================================================================
(defvar fg42/org-super-agenda-groups nil) ;; Vars that user meant to set
;;=============================================================================
(defvar fg42/org-home "~/.orgs" (defvar org-home "~/.orgs"
"The location to the org file repository.") "The location to the org file repository.")
(defvar fg42/default-org-journal-heder (defvar fg42/org-main-file "main.org")
" (defvar fg42/org-notes-file "notes.org")
#+TITLE: Yearly Journal (defvar fg42/org-agenda-files "main.org")
#+STARTUP: folded logdrawer logdone logreschedule indent content align constSI entitiespretty
"
"Org journal header.")
(defvar fg42/notes-file "notes.org")
(defvar fg42/global-tags nil) (defvar fg42/global-tags nil)
(defvar fg42/agenda-files "main.org") ;;=============================================================================
;; 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 (use! org-ql
"This package provides a query language for Org files. It offers two "This package provides a query language for Org files. It offers two
syntax styles: Lisp-like sexps and search engine-like keywords. syntax styles: Lisp-like sexps and search engine-like keywords.
@ -63,7 +78,6 @@ 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 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. shown based on deadline/scheduled timestamps, but are shown no-matter-what.
h
For more information checkout `https://github.com/alphapapa/org-super-agenda'" For more information checkout `https://github.com/alphapapa/org-super-agenda'"
:after org-agenda :after org-agenda
:config :config
@ -72,8 +86,7 @@ For more information checkout `https://github.com/alphapapa/org-super-agenda'"
org-agenda-include-deadlines t org-agenda-include-deadlines t
org-agenda-compact-blocks t org-agenda-compact-blocks t
org-agenda-start-day nil ;; Today org-agenda-start-day nil ;; Today
org-agenda-span 1 org-agenda-span 1)
org-super-agenda-groups fg42/org-super-agenda-groups)
(org-super-agenda-mode)) (org-super-agenda-mode))
@ -86,24 +99,27 @@ For more information checkout `https://github.com/alphapapa/org-super-agenda'"
org-capture-templates org-capture-templates
(eval (eval
`(list `(list
'("t" "Todo" entry (file+headline ,(expand-file-name "main.org" fg42/org-home) "New Tasks") '("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)) (file ,(expand-file-name "templates/todo" (fg42/org-home)))
:prepend t) :prepend t)
'("l" "Link" entry (file+headline ,(expand-file-name "bookmarks.org" fg42/org-home) "Links") '("l" "Link" entry (file+headline ,(expand-file-name "bookmarks.org" (fg42/org-home)) "Links")
(file ,(expand-file-name "templates/links" fg42/org-home)) (file ,(expand-file-name "templates/links" (fg42/org-home)))
:prepend t :prepend t
:immediate-finish t :immediate-finish t
:empty-lines 1) :empty-lines 1)
'("h" "Thoughts" entry (file+datetree ,(expand-file-name "journal.org" fg42/org-home)) '("h" "Thoughts" entry (file+datetree ,(expand-file-name "journal.org" (fg42/org-home)))
(file ,(expand-file-name "templates/thoughts" fg42/org-home))))))) (file ,(expand-file-name "templates/thoughts" (fg42/org-home))))))))
(use! org-protocol (use! org-protocol
"`org-protocol' intercepts calls from emacsclient to trigger custom actions without external "`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 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 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'.") your custom sub-protocol and handler with the variable `org-protocol-protocol-alist'."
:init
(require 'org-protocol))
(use! org (use! org
"A GNU Emacs major mode for keeping notes, authoring documents, computational notebooks, "A GNU Emacs major mode for keeping notes, authoring documents, computational notebooks,
@ -111,7 +127,9 @@ literate programming, maintaining to-do lists, planning projects, and more — i
and effective plain text system. and effective plain text system.
For more info on ~org-mode~ check out `https://orgmode.org/'" For more info on ~org-mode~ check out `https://orgmode.org/'"
:hook (org-mod . flyspell-mode) :hook
(org-mod . flyspell-mode)
(org-mode . fg42/organize-setup)
:init :init
(setq (setq
org-auto-align-tags nil org-auto-align-tags nil
@ -133,12 +151,12 @@ For more info on ~org-mode~ check out `https://orgmode.org/'"
" ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄") " ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄")
org-agenda-current-time-string org-agenda-current-time-string
"<── now ─────────────────────────────────────────────────" "<── now ─────────────────────────────────────────────────"
org-agenda-files (concat (file-name-as-directory fg42/org-home) org-agenda-files (concat (file-name-as-directory (fg42/org-home))
fg42/agenda-files) fg42/org-agenda-files)
org-directory fg42/org-home org-directory (fg42/org-home)
org-default-notes-file (concat (file-name-as-directory fg42/org-home) org-default-notes-file (concat (file-name-as-directory (fg42/org-home))
fg42/notes-file) fg42/org-notes-file)
org-refile-targets '((org-agenda-files :maxlevel . 3)) org-refile-targets '((org-agenda-files :maxlevel . 3))
@ -154,5 +172,40 @@ For more info on ~org-mode~ check out `https://orgmode.org/'"
(org-agenda-finalize . 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) (provide 'fg42/organize)
;;; organize.el ends here ;;; organize.el ends here