Experimenting with org-krita

This commit is contained in:
Emmet 2024-04-02 23:13:28 -05:00
parent 9eccb97326
commit f4c52cc68e
3 changed files with 74 additions and 2 deletions

View file

@ -434,6 +434,30 @@ same directory as the org-buffer and insert a link to this file."
))
(openwith-mode 1)))
(add-load-path! "~/.emacs.d/org-krita")
(require 'org-krita)
(add-hook 'org-mode-hook 'org-krita-mode)
(defun org-krita-show-link (link)
(org-krita-hide-link link)
(let* ((start (org-element-property :begin link))
(end (org-element-property :end link))
(overlay (make-overlay (+ start 0) (+ end 0)))
(kra-path (org-element-property :path link)))
(overlay-put overlay 'display (create-image (org-krita-extract-png kra-path) 'png t :scale 0.5))
(push (cons kra-path overlay) org-krita-overlays)))
(defun org-krita-edit (path &optional full-mode)
"Edit given PATH in krita canvasonly mode.
If FULL-MODE is not null, run full krita."
(let ((kra-path (expand-file-name path)))
(when (f-exists-p kra-path)
(if full-mode
(call-process org-krita-executable nil 0 nil kra-path)
(call-process org-krita-executable nil 0 nil kra-path))
(org-krita-add-watcher kra-path))))
(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!
@ -956,6 +980,8 @@ same directory as the org-buffer and insert a link to this file."
'(org-agenda-date-weekend :ineherit outline-2 :height 1.15)
'(org-agenda-date-weekend-today :inherit outline-4 :height 1.15)
'(org-super-agenda-header :inherit custom-button :weight bold :height 1.05)
'(link :foreground unspecified :underline nil :background "#46354a")
'(org-link :foreground unspecified)
)
;; Toggle completed entries function

View file

@ -1,5 +1,5 @@
{ config, lib, pkgs-emacs, pkgs-stable, userSettings, systemSettings,
org-nursery, org-yaap, org-side-tree, org-timeblock, phscroll, mini-frame, ... }:
org-nursery, org-yaap, org-side-tree, org-timeblock, org-krita, phscroll, mini-frame, ... }:
let
themePolarity = lib.removeSuffix "\n" (builtins.readFile (./. + "../../../../themes"+("/"+userSettings.theme)+"/polarity.txt"));
dashboardLogo = ./. + "/nix-" + themePolarity + ".png";
@ -97,6 +97,10 @@ in
source = "${org-nursery}";
};
home.file.".emacs.d/org-krita" = {
source = "${org-krita}";
};
home.file.".emacs.d/dashboard-logo.png".source = dashboardLogo;
home.file.".emacs.d/scripts/copy-link-or-file/copy-link-or-file-to-clipboard.sh" = {
source = ./scripts/copy-link-or-file/copy-link-or-file-to-clipboard.sh;

View file

@ -511,6 +511,30 @@ same directory as the org-buffer and insert a link to this file."
))
(openwith-mode 1)))
(add-load-path! "~/.emacs.d/org-krita")
(require 'org-krita)
(add-hook 'org-mode-hook 'org-krita-mode)
(defun org-krita-show-link (link)
(org-krita-hide-link link)
(let* ((start (org-element-property :begin link))
(end (org-element-property :end link))
(overlay (make-overlay (+ start 0) (+ end 0)))
(kra-path (org-element-property :path link)))
(overlay-put overlay 'display (create-image (org-krita-extract-png kra-path) 'png t :scale 0.5))
(push (cons kra-path overlay) org-krita-overlays)))
(defun org-krita-edit (path &optional full-mode)
"Edit given PATH in krita canvasonly mode.
If FULL-MODE is not null, run full krita."
(let ((kra-path (expand-file-name path)))
(when (f-exists-p kra-path)
(if full-mode
(call-process org-krita-executable nil 0 nil kra-path)
(call-process org-krita-executable nil 0 nil kra-path))
(org-krita-add-watcher kra-path))))
#+END_SRC
*** Copy Links/Files into Clipboard
#+BEGIN_SRC emacs-lisp :tangle config.el
@ -1113,6 +1137,8 @@ On Wayland, EAF doesn't work.
'(org-agenda-date-weekend :ineherit outline-2 :height 1.15)
'(org-agenda-date-weekend-today :inherit outline-4 :height 1.15)
'(org-super-agenda-header :inherit custom-button :weight bold :height 1.05)
'(link :foreground unspecified :underline nil :background "#46354a")
'(org-link :foreground unspecified)
)
;; Toggle completed entries function
@ -1153,6 +1179,18 @@ On Wayland, EAF doesn't work.
))
#+END_SRC
#+RESULTS:
| Teaching.p | () | nil | nil | :ascent | center |
| Family.s | () | nil | nil | :ascent | center |
| Producer.p | () | nil | nil | :ascent | center |
| Bard.p | () | nil | nil | :ascent | center |
| Stories.s | () | nil | nil | :ascent | center |
| Author.p | () | nil | nil | :ascent | center |
| Gamedev.s | () | nil | nil | :ascent | center |
| Knowledge.p | () | nil | nil | :ascent | center |
| Personal.p | () | nil | nil | :ascent | center |
*** Org Agenda Convenience Functions
#+BEGIN_SRC emacs-lisp :tangle config.el
(defun org-categorize-by-roam-db-on-save ()
@ -1965,7 +2003,7 @@ Any git package can be configured for a particular commit or branch:
In order to have Nix load my Doom Emacs configuration [[./doom.nix][doom.nix]], which I source in the =imports= block of my [[../../../profiles/work/home.nix][home.nix]].
#+BEGIN_SRC nix :tangle doom.nix
{ config, lib, pkgs-emacs, pkgs-stable, userSettings, systemSettings,
org-nursery, org-yaap, org-side-tree, org-timeblock, phscroll, mini-frame, ... }:
org-nursery, org-yaap, org-side-tree, org-timeblock, org-krita, phscroll, mini-frame, ... }:
let
themePolarity = lib.removeSuffix "\n" (builtins.readFile (./. + "../../../../themes"+("/"+userSettings.theme)+"/polarity.txt"));
dashboardLogo = ./. + "/nix-" + themePolarity + ".png";
@ -2063,6 +2101,10 @@ in
source = "${org-nursery}";
};
home.file.".emacs.d/org-krita" = {
source = "${org-krita}";
};
home.file.".emacs.d/dashboard-logo.png".source = dashboardLogo;
home.file.".emacs.d/scripts/copy-link-or-file/copy-link-or-file-to-clipboard.sh" = {
source = ./scripts/copy-link-or-file/copy-link-or-file-to-clipboard.sh;