emacs: Add plantuml wrapper so org-mode can work with plantuml-server

This commit is contained in:
Erwin Boskma 2024-12-16 16:16:53 +01:00
parent 59cee7f975
commit 1524994bab
Signed by: erwin
SSH key fingerprint: SHA256:9LmFDe1C6jSrEyqxxvX8NtJBmcbB105XoqyUZF092bg
2 changed files with 54 additions and 20 deletions

View file

@ -1778,26 +1778,28 @@ Configuration
#+name: org-config #+name: org-config
#+begin_src emacs-lisp :tangle no #+begin_src emacs-lisp :tangle no
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode)) (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(add-to-list (add-to-list
'org-src-lang-modes '("plantuml" . plantuml)) 'org-src-lang-modes '("plantuml" . plantuml))
(dolist (face '((org-level-1 . 1.2) (dolist (face '((org-level-1 . 1.2)
(org-level-2 . 1.1) (org-level-2 . 1.1)
(org-level-3 . 1.05) (org-level-3 . 1.05)
(org-level-4 . 1.0) (org-level-4 . 1.0)
(org-level-5 . 1.0) (org-level-5 . 1.0)
(org-level-6 . 1.0) (org-level-6 . 1.0)
(org-level-7 . 1.0) (org-level-7 . 1.0)
(org-level-8 . 1.0))) (org-level-8 . 1.0)))
(set-face-attribute (car face) nil :family my/variable-width-font :weight 'medium :height (cdr face))) (set-face-attribute (car face) nil :family my/variable-width-font :weight 'medium :height (cdr face)))
(set-face-attribute 'org-document-title nil :family my/variable-width-font :weight 'bold :height 1.3) (set-face-attribute 'org-document-title nil :family my/variable-width-font :weight 'bold :height 1.3)
(set-face-attribute 'org-block nil :foreground nil :inherit 'fixed-pitch) (set-face-attribute 'org-block nil :foreground nil :inherit 'fixed-pitch)
(set-face-attribute 'org-table nil :inherit 'fixed-pitch) (set-face-attribute 'org-table nil :inherit 'fixed-pitch)
(set-face-attribute 'org-formula nil :inherit 'fixed-pitch) (set-face-attribute 'org-formula nil :inherit 'fixed-pitch)
(set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch)) (set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch)) (set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch)) (set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch) (set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch)
(setq org-plantuml-exec-mode 'plantuml
org-plantuml-executable-path "plantuml-client")
#+end_src #+end_src
=org-capture= allows creating and saving quick notes, links and TODOs =org-capture= allows creating and saving quick notes, links and TODOs

View file

@ -8,6 +8,37 @@ with lib;
let let
cfg = config.eboskma.programs.emacs; cfg = config.eboskma.programs.emacs;
plantuml-client = pkgs.writeShellApplication {
name = "plantuml-client";
runtimeInputs = with pkgs; [
coreutils
xh
];
text = ''
type=
while getopts ":t:" option; do
case "''${option}" in
t)
type="''${OPTARG}";;
\?)
;;
esac
done
tempfile=$(mktemp --suffix plantuml)
while IFS= read -r line; do
echo "''${line}" >> "''${tempfile}"
done
encoded=$(xh --print=b post http://localhost:5080/plantuml/coder Content-Type:text/plain < "''${tempfile}")
rm "''${tempfile}"
xh get "http://localhost:5080/plantuml/''${type}/''${encoded}"
'';
};
tangleEmacsConfig = tangleEmacsConfig =
initFile: initFile:
pkgs.runCommand "tangled-emacs-${initFile}" { } '' pkgs.runCommand "tangled-emacs-${initFile}" { } ''
@ -173,6 +204,7 @@ in
})) }))
nixfmt-rfc-style nixfmt-rfc-style
python3 python3
plantuml-client
] ]
++ (with aspellDicts; [ ++ (with aspellDicts; [
en en