From 58d3d160f5472e1d23baaa413e67fa17d1091254 Mon Sep 17 00:00:00 2001 From: Emmet Date: Sat, 13 Apr 2024 19:07:10 -0500 Subject: [PATCH] Added org-xournalpp with some config tweaks --- flake.lock | 17 +++++++++++++++++ flake.nix | 4 ++++ user/app/doom-emacs/config.el | 31 ++++++++++++++++++++++++++++++ user/app/doom-emacs/doom.nix | 4 ++++ user/app/doom-emacs/doom.org | 36 +++++++++++++++++++++++++++++++++++ 5 files changed, 92 insertions(+) diff --git a/flake.lock b/flake.lock index 05bd2ae..108cebe 100644 --- a/flake.lock +++ b/flake.lock @@ -837,6 +837,22 @@ "type": "github" } }, + "org-xournalpp": { + "flake": false, + "locked": { + "lastModified": 1625233179, + "narHash": "sha256-c0AYWMkBb7wdl7SWTffjWSXwXbq1PGov2vT8A1pdqpQ=", + "owner": "vherrmann", + "repo": "org-xournalpp", + "rev": "c09bd8b99d36c355d632b85ecbffb3b275802381", + "type": "gitlab" + }, + "original": { + "owner": "vherrmann", + "repo": "org-xournalpp", + "type": "gitlab" + } + }, "org-yaap": { "flake": false, "locked": { @@ -936,6 +952,7 @@ "org-side-tree": "org-side-tree", "org-sliced-images": "org-sliced-images", "org-timeblock": "org-timeblock", + "org-xournalpp": "org-xournalpp", "org-yaap": "org-yaap", "phscroll": "phscroll", "rust-overlay": "rust-overlay", diff --git a/flake.nix b/flake.nix index 13250d4..4ffb4ba 100644 --- a/flake.nix +++ b/flake.nix @@ -218,6 +218,10 @@ url = "github:librephoenix/org-krita"; flake = false; }; + org-xournalpp = { + url = "gitlab:vherrmann/org-xournalpp"; + flake = false; + }; org-sliced-images = { url = "github:jcfk/org-sliced-images"; flake = false; diff --git a/user/app/doom-emacs/config.el b/user/app/doom-emacs/config.el index db780d9..89d0615 100644 --- a/user/app/doom-emacs/config.el +++ b/user/app/doom-emacs/config.el @@ -440,6 +440,37 @@ same directory as the org-buffer and insert a link to this file." (setq org-krita-extract-filename "preview.png") (setq org-krita-scale 1) +(add-load-path! "~/.emacs.d/org-xournalpp") +(require 'org-xournalpp) +(add-hook 'org-mode-hook 'org-xournalpp-mode) +(setq org-xournalpp-template-getter + '(closure + (t) + nil + (file-truename "~/Templates/template.xopp") ; use my own template + ) +) + +;; override width to static 250 for now +;; so I don't have massive images in org mode (scrolling not fun) +(defun org-xournalpp--create-image (link refresh) + "Extract svg/png from given LINK and return image. + +Regenerate the cached inline image, if REFRESH is true. + +If the path from LINK does not exist, nil is returned." + (let ((width 250) + (xopp-path (f-expand (org-element-property :path link)))) + (when (f-exists? xopp-path) + (if width + (create-image (org-xournalpp--get-image xopp-path refresh) + org-xournalpp-image-type + nil + :width width) + (create-image (org-xournalpp--get-image xopp-path refresh) + org-xournalpp-image-type + nil))))) + (defun org-copy-link-to-clipboard-at-point () "Copy current link at point into clipboard (useful for images and links)" ;; Remember to press C-g to kill this foreground process if it hangs! diff --git a/user/app/doom-emacs/doom.nix b/user/app/doom-emacs/doom.nix index 4add4e2..77120a2 100644 --- a/user/app/doom-emacs/doom.nix +++ b/user/app/doom-emacs/doom.nix @@ -101,6 +101,10 @@ in source = "${inputs.org-krita}"; }; + home.file.".emacs.d/org-xournalpp" = { + source = "${inputs.org-xournalpp}"; + }; + home.file.".emacs.d/org-sliced-images" = { source = "${inputs.org-sliced-images}"; }; diff --git a/user/app/doom-emacs/doom.org b/user/app/doom-emacs/doom.org index 9ccce13..2151480 100644 --- a/user/app/doom-emacs/doom.org +++ b/user/app/doom-emacs/doom.org @@ -517,6 +517,38 @@ same directory as the org-buffer and insert a link to this file." (setq org-krita-extract-filename "preview.png") (setq org-krita-scale 1) +(add-load-path! "~/.emacs.d/org-xournalpp") +(require 'org-xournalpp) +(add-hook 'org-mode-hook 'org-xournalpp-mode) +(setq org-xournalpp-template-getter + '(closure + (t) + nil + (file-truename "~/Templates/template.xopp") ; use my own template + ) +) + +;; override width to static 250 for now +;; so I don't have massive images in org mode (scrolling not fun) +(defun org-xournalpp--create-image (link refresh) + "Extract svg/png from given LINK and return image. + +Regenerate the cached inline image, if REFRESH is true. + +If the path from LINK does not exist, nil is returned." + (let ((width 250) + (xopp-path (f-expand (org-element-property :path link)))) + (when (f-exists? xopp-path) + (if width + (create-image (org-xournalpp--get-image xopp-path refresh) + org-xournalpp-image-type + nil + :width width) + (create-image (org-xournalpp--get-image xopp-path refresh) + org-xournalpp-image-type + nil))))) + + #+END_SRC *** Copy Links/Files into Clipboard #+BEGIN_SRC emacs-lisp :tangle config.el @@ -2089,6 +2121,10 @@ in source = "${inputs.org-krita}"; }; + home.file.".emacs.d/org-xournalpp" = { + source = "${inputs.org-xournalpp}"; + }; + home.file.".emacs.d/org-sliced-images" = { source = "${inputs.org-sliced-images}"; };