From 93f87f4f6384ad321b9fc74f34d13e5efdb5f76e Mon Sep 17 00:00:00 2001 From: Peter Tillemans Date: Mon, 4 Aug 2025 18:01:44 +0200 Subject: [PATCH] add org babel demos --- init.org | 549 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 453 insertions(+), 96 deletions(-) diff --git a/init.org b/init.org index 31c4341..b843982 100644 --- a/init.org +++ b/init.org @@ -1242,8 +1242,6 @@ I always get errors compiling support for *janet* so I pruned the ***** TODO figure out why Latex does not want to install -***** TODO decide whether to keep using treesitter-auto at all or just plain treesit with some support functions. - **** Recompiling all Treesitter Grammars To recompile all treesitter grammars, execute following block with *C-c C-c*. @@ -1340,8 +1338,6 @@ see also [[https://www.masteringemacs.org/article/how-to-get-started-tree-sitter #+BEGIN_SRC emacs-lisp :tangle no ;; configure go support (use-package go-ts-mode - :init - (add-to-list 'auto-mode-alist '("\\.go\\'" . go-ts-mode)) :hook (go-ts . eglot-ensure)) #+END_SRC @@ -1350,22 +1346,16 @@ see also [[https://www.masteringemacs.org/article/how-to-get-started-tree-sitter #+BEGIN_SRC emacs-lisp ;; configure typescript support (use-package typescript-ts-mode - :init - (add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-ts-mode)) :hook (typescript-ts-mode . eglot-ensure)) ;; configure javascript support (use-package javascript-ts-mode - :init - (add-to-list 'auto-mode-alist '("\\.js\\'" . js-ts-mode)) :hook (javascript-ts-mode . eglot-ensure)) ;; configure react support (use-package tsx-ts-mode - :init - (add-to-list 'auto-mode-alist '("\\.[jt]sx\\'" . tsx-ts-mode)) :hook (tsx-ts-mode . eglot-ensure)) #+END_SRC @@ -1767,6 +1757,87 @@ Map the keymap consistently to the eglot mappings. #+RESULTS: : [nil 26760 26150 568817 nil elpaca-process-queues nil nil 219000 nil] +*** Support Mermaid Diagrams + + +#+BEGIN_SRC emacs-lisp + ;; enable mermaid for org-babel + (use-package mermaid-mode + :ensure t + :demand t + :mode "\\.mmd\\'") + #+END_SRC + + #+RESULTS: + : [nil 26499 60213 709442 nil elpaca-process-queues nil nil 672000 nil] + + Mermaid needs support of the mermaid-cli which is a node package. It + can be installed with + +#+BEGIN_SRC shell :tangle no +npm install -g @mermaid-js/mermaid-cli +#+END_SRC + +#+RESULTS: +| | | | | | | | | | | | | +| added | 281 | packages, | removed | 60 | packages, | and | changed | 134 | packages | in | 18s | +| | | | | | | | | | | | | +| 52 | packages | are | looking | for | funding | | | | | | | +| run | `npm | fund` | for | details | | | | | | | | + + +*** Support PlantUML Diagrams + +Requires nothing special, other than *plantuml.jar* archive installed. + +The following code block depends on [[*Get latest version of a github released project][Get latest version of a github +released project]] utility function. This block will check if there is a +plantuml.jar in the emacs config directory and if not download the +latest version from github. The `snm-download-latest-plantuml` is made +interactive to manually install the latest version if needed. + +#+BEGIN_SRC emacs-lisp :lexical t + (setq plantuml-jar-path (concat user-emacs-directory "plantuml.jar")) + (setq plantuml-default-exec-mode 'jar) + + (defun snm-download-latest-plantuml () + "Download the latest version of PlantUML. + + This function is interactive to make it easy to upgrade to + the latest, current version with `M-x snm-download-latest-plantuml'." + (interactive) + (let* ((version (snm-latest-github-release "plantuml/plantuml")) + (url (format + "https://github.com/plantuml/plantuml/releases/download/%s/plantuml-%s.jar" + version (substring version 1)))) + (message "Downloading PlantUML version %s from %s" version url) + (url-copy-file + url + (concat user-emacs-directory "plantuml.jar") + t))) + + (if (not (file-exists-p plantuml-jar-path)) + (snm-download-latest-plantuml)) + + (setq org-plantuml-jar-path plantuml-jar-path) + + (use-package plantuml + :ensure nil + :mode "\\.puml\\'") +#+END_SRC + +#+RESULTS: +: ((\.ya?ml\' . yaml-ts-mode) (\.ts\' . typescript-ts-mode) (\.tsx\' . tsx-ts-mode) (\.toml\' . toml-ts-mode) (\.rs\' . rust-ts-mode) (\(?:\.\(?:rbw?\|ru\|rake\|thor\|jbuilder\|rabl\|gemspec\|podspec\)\|/\(?:Gem\|Rake\|Cap\|Thor\|Puppet\|Berks\|Brew\|Vagrant\|Guard\|Pod\)file\)\' . ruby-ts-mode) (\.py[iw]?\' . python-ts-mode) (\.md\' . markdown-ts-mode) (\.lua\' . lua-ts-mode) (\.json\' . json-ts-mode) (\.js\' . js-ts-mode) (\.java\' . java-ts-mode) (\.html\' . html-ts-mode) (go\.mod\' . go-mod-ts-mode) (\.go\' . go-ts-mode) (\.ex\' . elixir-ts-mode) ([/\]\(?:Containerfile\|Dockerfile\)\(?:\.[^/\]*\)?\' . dockerfile-ts-mode) (\.css\' . css-ts-mode) (\.cpp\' . c++-ts-mode) (\.cmake\' . cmake-ts-mode) (\.cs\' . csharp-ts-mode) (\.c\' . c-ts-mode) (\.sh\' . bash-ts-mode) (\.envrc\' . direnv-envrc-mode) (/git-rebase-todo\' . git-rebase-mode) (\.gitlab-ci\.yml\' . gitlab-ci-mode) (\.mmd\' . mermaid-mode) (\.gitlab-ci.yml\' . gitlab-ci-mode) (\.\(e?ya?\|ra\)ml\' . yaml-mode) (\.dockerfile\' . dockerfile-mode) ([/\]\(?:Containerfile\|Dockerfile\)\(?:\.[^/\]*\)?\' . dockerfile-mode) (\.puml\' . plantuml) (\.edn\' . clojure-mode) (\.clj\' . clojure-mode) (/home/pti/.password-store/.*\.gpg\' . pass-view-mode) (\.\(zig\|zon\)\' . zig-mode) (\.t\(f\(vars\)?\|ofu\)\' . terraform-mode) (\.nomad\' . hcl-mode) (\.hcl\' . hcl-mode) (\(?:build\|profile\)\.boot\' . clojure-mode) (\.joke\' . joker-mode) (\.jank\' . jank-mode) (\.cljd\' . clojuredart-mode) (\.cljs\' . clojurescript-mode) (\.cljc\' . clojurec-mode) (\.\(clj\|cljd\|dtm\|edn\|lpy\)\' . clojure-mode) (/guix/drvs/[[:alnum:]]\{2\}/[[:alnum:]]\{30\}-\(?:[+._[:alnum:]-]+\)\.drv\' . guix-build-log-mode) (/gnu/store/\(?:[+._[:alnum:]-]+\)\.drv\' . guix-derivation-mode) (/etc/profile\' . guix-env-var-mode) (/tmp/guix-build-\(?:[+._[:alnum:]-]+\)\.drv-[[:digit:]]+/environment-variables\' . guix-env-var-mode) (/guix/profiles/system\(?:[+._[:alnum:]-]+\)*/\(?:boot\|parameters\)\' . guix-scheme-mode) (/gnu/store/\(?:[0-9a-df-np-sv-z]\{32\}\)-\(?:activate\|activate-service\|boot\|parameters\|shepherd\.conf\|shepherd\(?:[+._[:alnum:]-]+\)\.scm\|\(?:[+._[:alnum:]-]+\)-builder\)\' . guix-scheme-mode) ([./]opam_?\' . tuareg-opam-mode) (\.mly\' . tuareg-menhir-mode) (\.eliomi?\' . tuareg-mode) (\.ml[ip]?\' . tuareg-mode) (\.rs\' . rustic-mode) (\.rs\' . rust-mode) (\.\(?:md\|markdown\|mkd\|mdown\|mkdn\|mdwn\)\' . markdown-mode) (\.gpg\(~\|\.~[0-9]+~\)?\' nil epa-file) (\.elc\' . elisp-byte-code-mode) (\.\(?:3fr\|a\(?:rw\|vs\)\|bmp[23]?\|c\(?:als?\|myka?\|r[2w]\|u[rt]\)\|d\(?:c[mrx]\|ds\|jvu\|ng\|px\)\|exr\|f\(?:ax\|its\)\|gif\(?:87\)?\|hrz\|ic\(?:on\|[bo]\)\|j\(?:2c\|ng\|p\(?:eg\|[2cg]\)\)\|k\(?:25\|dc\)\|m\(?:iff\|ng\|rw\|s\(?:l\|vg\)\|tv\)\|nef\|o\(?:rf\|tb\)\|p\(?:bm\|c\(?:ds\|[dltx]\)\|db\|ef\|gm\|i\(?:ct\|x\)\|jpeg\|n\(?:g\(?:24\|32\|8\)\|[gm]\)\|pm\|sd\|tif\|wp\)\|r\(?:a[fs]\|gb[ao]?\|l[ae]\)\|s\(?:c[rt]\|fw\|gi\|ix\|r[2f]\|un\|vgz?\)\|t\(?:ga\|i\(?:ff\(?:64\)?\|le\|m\)\|tf\)\|uyvy\|v\(?:da\|i\(?:car\|d\|ff\)\|st\)\|w\(?:bmp\|pg\)\|x\(?:3f\|bm\|cf\|pm\|wd\|[cv]\)\|yuv\)\' . image-mode) (\.zst\' nil jka-compr) (\.dz\' nil jka-compr) (\.xz\' nil jka-compr) (\.lzma\' nil jka-compr) (\.lz\' nil jka-compr) (\.g?z\' nil jka-compr) (\.bz2\' nil jka-compr) (\.Z\' nil jka-compr) (\.vr[hi]?\' . vera-mode) (\(?:\.\(?:rbw?\|ru\|rake\|thor\|axlsx\|jbuilder\|rabl\|gemspec\|podspec\)\|/\(?:Gem\|Rake\|Cap\|Thor\|Puppet\|Berks\|Brew\|Fast\|Vagrant\|Guard\|Pod\)file\)\' . ruby-mode) (\.re?st\' . rst-mode) (/\(?:Pipfile\|\.?flake8\)\' . conf-mode) (\(?:\.\(?:p\(?:th\|y[iw]?\)\)\|/\(?:SCons\(?:\(?:crip\|truc\)t\)\)\)\' . python-mode) (\.m\' . octave-maybe-mode) (\.less\' . less-css-mode) (/go\.work\' . go-work-ts-mode) (\.editorconfig\' . editorconfig-conf-mode) (\.scss\' . scss-mode) (\.cs\' . csharp-mode) (\.awk\' . awk-mode) (\.\(u?lpc\|pike\|pmod\(\.in\)?\)\' . pike-mode) (\.idl\' . idl-mode) (\.java\' . java-mode) (\.m\' . objc-mode) (\.ii\' . c++-mode) (\.i\' . c-mode) (\.lex\' . c-mode) (\.y\(acc\)?\' . c-mode) (\.h\' . c-or-c++-mode) (\.c\' . c-mode) (\.\(CC?\|HH?\)\' . c++-mode) (\.[ch]\(pp\|xx\|\+\+\)\' . c++-mode) (\.\(cc\|hh\)\' . c++-mode) (\.\(bat\|cmd\)\' . bat-mode) (\.[sx]?html?\(\.[a-zA-Z_]+\)?\' . mhtml-mode) (\.svgz?\' . image-mode) (\.svgz?\' . xml-mode) (\.x[bp]m\' . image-mode) (\.x[bp]m\' . c-mode) (\.p[bpgn]m\' . image-mode) (\.tiff?\' . image-mode) (\.gif\' . image-mode) (\.png\' . image-mode) (\.jpe?g\' . image-mode) (\.webp\' . image-mode) (\.te?xt\' . text-mode) (\.[tT]e[xX]\' . tex-mode) (\.ins\' . tex-mode) (\.ltx\' . latex-mode) (\.dtx\' . doctex-mode) (\.org\' . org-mode) (\.dir-locals\(?:-2\)?\.el\' . lisp-data-mode) (\.eld\' . lisp-data-mode) (eww-bookmarks\' . lisp-data-mode) (tramp\' . lisp-data-mode) (/archive-contents\' . lisp-data-mode) (places\' . lisp-data-mode) (\.emacs-places\' . lisp-data-mode) (\.el\' . emacs-lisp-mode) (Project\.ede\' . emacs-lisp-mode) (\(?:\.\(?:scm\|sls\|sld\|stk\|ss\|sch\)\|/\.guile\)\' . scheme-mode) (\.l\' . lisp-mode) (\.li?sp\' . lisp-mode) (\.[fF]\' . fortran-mode) (\.for\' . fortran-mode) (\.p\' . pascal-mode) (\.pas\' . pascal-mode) (\.\(dpr\|DPR\)\' . opascal-mode) (\.\([pP]\([Llm]\|erl\|od\)\|al\)\' . perl-mode) (Imakefile\' . makefile-imake-mode) (Makeppfile\(?:\.mk\)?\' . makefile-makepp-mode) (\.makepp\' . makefile-makepp-mode) (\.mk\' . makefile-gmake-mode) (\.make\' . makefile-gmake-mode) ([Mm]akefile\' . makefile-gmake-mode) (\.am\' . makefile-automake-mode) (\.texinfo\' . texinfo-mode) (\.te?xi\' . texinfo-mode) (\.[sS]\' . asm-mode) (\.asm\' . asm-mode) (\.css\' . css-mode) (\.mixal\' . mixal-mode) (\.gcov\' . compilation-mode) (/[._]?[A-Za-z0-9-]*\(?:gdbinit\(?:\.\(?:ini?\|loader\)\)?\|gdb\.ini\)\' . gdb-script-mode) (-gdb\.gdb . gdb-script-mode) ([cC]hange\.?[lL]og?\' . change-log-mode) ([cC]hange[lL]og[-.][0-9]+\' . change-log-mode) (\$CHANGE_LOG\$\.TXT . change-log-mode) (\.scm\.[0-9]*\' . scheme-mode) (\.[ckz]?sh\'\|\.shar\'\|/\.z?profile\' . sh-mode) (\.bash\' . sh-mode) (/bash-fc\.[0-9A-Za-z]\{6\}\' . sh-mode) (/PKGBUILD\' . sh-mode) (\(/\|\`\)\.\(bash_\(profile\|history\|log\(in\|out\)\)\|z?log\(in\|out\)\)\' . sh-mode) (\(/\|\`\)\.\(shrc\|zshrc\|m?kshrc\|bashrc\|t?cshrc\|esrc\)\' . sh-mode) (\(/\|\`\)\.\([kz]shenv\|xinitrc\|startxrc\|xsession\)\' . sh-mode) (\.m?spec\' . sh-mode) (\.m[mes]\' . nroff-mode) (\.man\' . nroff-mode) (\.sty\' . latex-mode) (\.cl[so]\' . latex-mode) (\.bbl\' . latex-mode) (\.bib\' . bibtex-mode) (\.bst\' . bibtex-style-mode) (\.sql\' . sql-mode) (\(acinclude\|aclocal\|acsite\)\.m4\' . autoconf-mode) (\.m[4c]\' . m4-mode) (\.mf\' . metafont-mode) (\.mp\' . metapost-mode) (\.vhdl?\' . vhdl-mode) (\.article\' . text-mode) (\.letter\' . text-mode) (\.i?tcl\' . tcl-mode) (\.exp\' . tcl-mode) (\.itk\' . tcl-mode) (\.icn\' . icon-mode) (\.sim\' . simula-mode) (\.mss\' . scribe-mode) (\.f9[05]\' . f90-mode) (\.f0[38]\' . f90-mode) (\.srt\' . srecode-template-mode) (\.prolog\' . prolog-mode) (\.tar\' . tar-mode) (\.\(arc\|zip\|lzh\|lha\|zoo\|[jew]ar\|xpi\|rar\|cbr\|7z\|squashfs\|ARC\|ZIP\|LZH\|LHA\|ZOO\|[JEW]AR\|XPI\|RAR\|CBR\|7Z\|SQUASHFS\)\' . archive-mode) (\.oxt\' . archive-mode) (\.\(deb\|[oi]pk\)\' . archive-mode) (\`/tmp/Re . text-mode) (/Message[0-9]*\' . text-mode) (\`/tmp/fol/ . text-mode) (\.oak\' . scheme-mode) (\.sgml?\' . sgml-mode) (\.x[ms]l\' . xml-mode) (\.dbk\' . xml-mode) (\.dtd\' . sgml-mode) (\.ds\(ss\)?l\' . dsssl-mode) (\.js[mx]?\' . javascript-mode) (\.har\' . javascript-mode) (\.json\' . js-json-mode) (\.[ds]?va?h?\' . verilog-mode) (\.by\' . bovine-grammar-mode) (\.wy\' . wisent-grammar-mode) (\.erts\' . erts-mode) ([:/\]\..*\(emacs\|gnus\|viper\)\' . emacs-lisp-mode) (\`\..*emacs\' . emacs-lisp-mode) ([:/]_emacs\' . emacs-lisp-mode) (/crontab\.X*[0-9]+\' . shell-script-mode) (\.ml\' . lisp-mode) (\.ld[si]?\' . ld-script-mode) (ld\.?script\' . ld-script-mode) (\.xs\' . c-mode) (\.x[abdsru]?[cnw]?\' . ld-script-mode) (\.zone\' . dns-mode) (\.soa\' . dns-mode) (\.asd\' . lisp-mode) (\.\(asn\|mib\|smi\)\' . snmp-mode) (\.\(as\|mi\|sm\)2\' . snmpv2-mode) (\.\(diffs?\|patch\|rej\)\' . diff-mode) (\.\(dif\|pat\)\' . diff-mode) (\.[eE]?[pP][sS]\' . ps-mode) (\.\(?:PDF\|EPUB\|CBZ\|FB2\|O?XPS\|DVI\|OD[FGPST]\|DOCX\|XLSX?\|PPTX?\|pdf\|epub\|cbz\|fb2\|o?xps\|djvu\|dvi\|od[fgpst]\|docx\|xlsx?\|pptx?\)\' . doc-view-mode-maybe) (configure\.\(ac\|in\)\' . autoconf-mode) (\.s\(v\|iv\|ieve\)\' . sieve-mode) (BROWSE\' . ebrowse-tree-mode) (\.ebrowse\' . ebrowse-tree-mode) (#\*mail\* . mail-mode) (\.g\' . antlr-mode) (\.mod\' . m2-mode) (\.ses\' . ses-mode) (\.docbook\' . sgml-mode) (\.com\' . dcl-mode) (/config\.\(?:bat\|log\)\' . fundamental-mode) (/\.?\(authinfo\|netrc\)\' . authinfo-mode) (\.\(?:[iI][nN][iI]\|[lL][sS][tT]\|[rR][eE][gG]\|[sS][yY][sS]\)\' . conf-mode) (\.la\' . conf-unix-mode) (\.ppd\' . conf-ppd-mode) (java.+\.conf\' . conf-javaprop-mode) (\.properties\(?:\.[a-zA-Z0-9._-]+\)?\' . conf-javaprop-mode) (\.toml\' . conf-toml-mode) (\.desktop\' . conf-desktop-mode) (/\.redshift\.conf\' . conf-windows-mode) (\`/etc/\(?:DIR_COLORS\|ethers\|.?fstab\|.*hosts\|lesskey\|login\.?de\(?:fs\|vperm\)\|magic\|mtab\|pam\.d/.*\|permissions\(?:\.d/.+\)?\|protocols\|rpc\|services\)\' . conf-space-mode) (\`/etc/\(?:acpid?/.+\|aliases\(?:\.d/.+\)?\|default/.+\|group-?\|hosts\..+\|inittab\|ksysguarddrc\|opera6rc\|passwd-?\|shadow-?\|sysconfig/.+\)\' . conf-mode) ([cC]hange[lL]og[-.][-0-9a-z]+\' . change-log-mode) (/\.?\(?:gitconfig\|gnokiirc\|hgrc\|kde.*rc\|mime\.types\|wgetrc\)\' . conf-mode) (/\.mailmap\' . conf-unix-mode) (/\.\(?:asound\|enigma\|fetchmail\|gltron\|gtk\|hxplayer\|mairix\|mbsync\|msmtp\|net\|neverball\|nvidia-settings-\|offlineimap\|qt/.+\|realplayer\|reportbug\|rtorrent\.\|screen\|scummvm\|sversion\|sylpheed/.+\|xmp\)rc\' . conf-mode) (/\.\(?:gdbtkinit\|grip\|mpdconf\|notmuch-config\|orbital/.+txt\|rhosts\|tuxracer/options\)\' . conf-mode) (/\.?X\(?:default\|resource\|re\)s\> . conf-xdefaults-mode) (/X11.+app-defaults/\|\.ad\' . conf-xdefaults-mode) (/X11.+locale/.+/Compose\' . conf-colon-mode) (/X11.+locale/compose\.dir\' . conf-javaprop-mode) (\.~?[0-9]+\.[0-9][-.0-9]*~?\' nil t) (\.\(?:orig\|in\|[bB][aA][kK]\)\' nil t) ([/.]c\(?:on\)?f\(?:i?g\)?\(?:\.[a-zA-Z0-9._-]+\)?\' . conf-mode-maybe) (\.[1-9]\' . nroff-mode) (\.art\' . image-mode) (\.avs\' . image-mode) (\.bmp\' . image-mode) (\.cmyk\' . image-mode) (\.cmyka\' . image-mode) (\.crw\' . image-mode) (\.dcm\' . image-mode) (\.dcr\' . image-mode) (\.dcx\' . image-mode) (\.dng\' . image-mode) (\.dpx\' . image-mode) (\.fax\' . image-mode) (\.heic\' . image-mode) (\.hrz\' . image-mode) (\.icb\' . image-mode) (\.icc\' . image-mode) (\.icm\' . image-mode) (\.ico\' . image-mode) (\.icon\' . image-mode) (\.jbg\' . image-mode) (\.jbig\' . image-mode) (\.jng\' . image-mode) (\.jnx\' . image-mode) (\.miff\' . image-mode) (\.mng\' . image-mode) (\.mvg\' . image-mode) (\.otb\' . image-mode) (\.p7\' . image-mode) (\.pcx\' . image-mode) (\.pdb\' . image-mode) (\.pfa\' . image-mode) (\.pfb\' . image-mode) (\.picon\' . image-mode) (\.pict\' . image-mode) (\.rgb\' . image-mode) (\.rgba\' . image-mode) (\.six\' . image-mode) (\.tga\' . image-mode) (\.wbmp\' . image-mode) (\.webp\' . image-mode) (\.wmf\' . image-mode) (\.wpg\' . image-mode) (\.xcf\' . image-mode) (\.xmp\' . image-mode) (\.xwd\' . image-mode) (\.yuv\' . image-mode) (\.tgz\' . tar-mode) (\.tbz2?\' . tar-mode) (\.txz\' . tar-mode) (\.tzst\' . tar-mode)) + + +#+BEGIN_SRC emacs-lisp + + +#+END_SRC + +#+RESULTS: +: ~/.config/emacs/plantuml.jar + ** Debugger Support #+BEGIN_SRC emacs-lisp @@ -1891,23 +1962,6 @@ Map the keymap consistently to the eglot mappings. or leave it here but move it to config, whatever makes most sense at the moment. -** BoilerPlate Generator - -The way I do advent of code requires me to create a main file and a -test file every day with some boilerplate content. - -The *org-generate* package uses an org file to structure boilerplate -templates to be generated. By default it uses - -#+BEGIN_SRC emacs-lisp - (use-package org-generate - :ensure t - ) -#+END_SRC - -#+RESULTS: -: [nil 26455 5250 886750 nil elpaca-process-queues nil nil 641000 nil] - * Writing and Planning #+BEGIN_SRC emacs-lisp @@ -1919,8 +1973,8 @@ templates to be generated. By default it uses *** Org Configuration #+BEGIN_SRC emacs-lisp (use-package org - :mode "\\.org$" - :ensure nil + :mode (("\\.org\\'" . org-mode)) + :ensure org-plus-contrib :custom (org-return-follows-link t) (org-mouse-1-follows-link t) @@ -1949,13 +2003,7 @@ templates to be generated. By default it uses ("~/org/personal/bijen.org" . (:level . 1)) ("~/org/personal/fitness.org" . (:level . 1)) )) - (org-babel-load-languages '((emacs-lisp . t) - (shell . t) - (python . t) - (latex . t) - (scheme . t) - (plantuml . t) - (dot . t))) + (org-babel-load-languages ') :config (message "Configuring org mode") @@ -1964,7 +2012,6 @@ templates to be generated. By default it uses +org-capture-notes-file "~/Nextcloud/org/inbox.org" +org-capture-journal-file "~/Nextcloud/org/journal.org" +org-capture-projects-file "~/Nextcloud/org/projects.org") - (org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages) (setq org-log-done 'time) (setq org-confirm-babel-evaluate nil) (setq org-export-babel-evaluate nil) @@ -1991,6 +2038,9 @@ confluence :ensure t) #+END_SRC +#+RESULTS: +: [nil 26768 38477 62891 nil elpaca-process-queues nil nil 29000 nil] + *** Mixed Pitch Support by Default in Org #+BEGIN_SRC emacs-lisp @@ -2037,72 +2087,18 @@ Hide the org markers when point is not on the element being decorated. I have a test file which has samples of babel features for easy testing in my [[file:~/org/snamellit/testfile.org::*User Journey Graph][org babel test file.]] -**** Support Mermaid Diagrams in Babel Blocks - +**** Configure Babel Languages #+BEGIN_SRC emacs-lisp - ;; enable mermaid for org-babel - (use-package mermaid-mode - :ensure t - :demand t - :mode "\\.mmd\\'") - #+END_SRC +(use-package ob-mermaid + :ensure t + :demand t) - #+RESULTS: - : [nil 26499 60213 709442 nil elpaca-process-queues nil nil 672000 nil] - - Mermaid needs support of the mermaid-cli which is a node package. It - can be installed with - -#+BEGIN_SRC shell :tangle no -npm install -g @mermaid-js/mermaid-cli #+END_SRC #+RESULTS: -| | | | | | | | | | | | | -| added | 281 | packages, | removed | 60 | packages, | and | changed | 134 | packages | in | 18s | -| | | | | | | | | | | | | -| 52 | packages | are | looking | for | funding | | | | | | | -| run | `npm | fund` | for | details | | | | | | | | +: [nil 26768 38911 12050 nil elpaca-process-queues nil nil 97000 nil] -**** Support PlantUML Diagrams in Babel Blocks - -Requires nothing special, other than *plantuml.jar* archive installed. - -The following code block depends on [[*Get latest version of a github released project][Get latest version of a github -released project]] utility function. This block will check if there is a -plantuml.jar in the emacs config directory and if not download the -latest version from github. The `snm-download-latest-plantuml` is made -interactive to manually install the latest version if needed. - -#+BEGIN_SRC emacs-lisp :lexical t - (defun snm-download-latest-plantuml () - "Download the latest version of PlantUML. - - This function is interactive to make it easy to upgrade to - the latest, current version with `M-x snm-download-latest-plantuml'." - (interactive) - (let* ((version (snm-latest-github-release "plantuml/plantuml")) - (url (format - "https://github.com/plantuml/plantuml/releases/download/%s/plantuml-%s.jar" - version (substring version 1)))) - (message "Downloading PlantUML version %s from %s" version url) - (url-copy-file - url - (concat user-emacs-directory "plantuml.jar") - t))) - - (let ((plantuml-jar (concat user-emacs-directory "plantuml.jar"))) - (if (not (file-exists-p plantuml-jar)) - (snm-download-latest-plantuml)) - - (setq org-plantuml-jar-path plantuml-jar)) -#+END_SRC - -#+RESULTS: -: ~/.config/emacs/plantuml.jar - -**** Configure Babel Languages #+BEGIN_SRC emacs-lisp :tangle yes ;; configure babel languages (use-package ob @@ -2116,12 +2112,356 @@ interactive to manually install the latest version if needed. (plantuml . t) (mermaid . t) (sql . t) + (sqlite . t) (dot . t))) ) #+END_SRC #+RESULTS: +***** Example Emacs Lisp + +#+BEGIN_SRC emacs-lisp +(+ 2 3) +#+END_SRC + +#+RESULTS: +: 5 + + +***** Example shell + +#+BEGIN_SRC shell +echo "Foo bar" +#+END_SRC + +#+RESULTS: +: Foo bar + + +***** Example python + +#+BEGIN_SRC python +bar="bar" +return f"Foo {bar}" +#+END_SRC + +#+RESULTS: +: Foo bar + +***** TODO Example Latex + + + + +#+name: hello-latex +#+BEGIN_SRC latex :results file raw :exports results :file latex.png +\LaTeX + +Dit is ne pot en tis ne grote! + +#+END_SRC + +#+RESULTS: hello-latex +[[file:latex.png]] + +***** Example Scheme + +#+BEGIN_SRC scheme +(+ 3 4) +#+END_SRC + +#+RESULTS: +: 7 + +***** Example PlantUML + +****** Archimate example : Capability Metamodel + +#+begin_src plantuml :file cap-meta-model.png +!include +title Capability Metamodel + +Strategy_ValueStream(vs, "ValueStream") +Business_Service(svc, "Service") +Strategy_Capability(cap, "Capability") +Strategy_Resource(fun, "Function") +Strategy_Resource(ppl, "People") +Strategy_Resource(process, "Processes") +Strategy_Resource(tools, "Tools") + + +Rel_Serving_Right(svc, vs, "supports") +Rel_Serving_Right(cap, svc, "provides") +Rel_Assignment_Up(fun,cap,"implements") +Rel_Composition_Up(ppl,fun,"") +Rel_Composition_Up(tools,fun,"") +Rel_Composition_Up(process,fun,"") +#+end_src + +#+RESULTS: +[[file:cap-meta-model.png]] + + + +***** Example Mermaid +:PROPERTIES: +:header-args: :tangle no +:END: + +****** Directed Graph + +#+begin_src mermaid :file test2.png +graph TD +A[Christmas] -->|Get money| B(Go shopping) +B --> C{Let me think} +C -->|One| D[Laptop] +C -->|Two| E[iPhone] +C -->|Three| F[Car] +#+end_src + +****** Gantt Chart + +#+begin_src mermaid :file gantt.png +gantt + section Section + Completed :done, des1, 2014-01-06,2014-01-08 + Active :active, des2, 2014-01-07, 3d + Parallel 1 : des3, after des1, 1d + Parallel 2 : des4, after des1, 1d + Parallel 3 : des5, after des3, 1d + Parallel 4 : des6, after des4, 1d +#+end_src + +#+RESULTS: +[[file:gantt.png]] + +****** Class Diagram + +#+begin_src mermaid :file class.png +classDiagram +Class01 <|-- AveryLongClass : Cool +<> Class01 +Class09 --> C2 : Where am i? +Class09 --* C3 +Class09 --|> Class07 +Class07 : equals() +Class07 : Object[] elementData +Class01 : size() +Class01 : int chimp +Class01 : int gorilla +class Class10 { + <> + int id + size() +} + +#+end_src + +#+RESULTS: +[[file:class.png]] + + +****** State Diagram + + +#+begin_src mermaid :file state.png +stateDiagram-v2 +[*] --> Still +Still --> [*] +Still --> Moving +Moving --> Still +Moving --> Crash +Crash --> [*] + +#+end_src + +#+RESULTS: +[[file:state.png]] + +****** Pie Chart + +#+begin_src mermaid :file pie.png +pie +"Dogs" : 386 +"Cats" : 85 +"Rats" : 15 +#+end_src + +#+RESULTS: +[[file:pie.png]] + + +***** Example sql +:PROPERTIES: +:header-args: :engine postgresql :dbuser emacs :dbpassword (auth-source-pass-get 'secret "snamellit/emacs/test-psql") :database emacs +:END: + +In the assumption that postgres is running and the current user has +admin privileges on the local dev database +#+BEGIN_SRC shell :result output +pass snamellit/emacs/test-psql | sed '/./{p}' | createuser emacs -P 2>&1 +createdb -Oemacs -EUNICODE emacs 2>&1 +#+END_SRC + +#+RESULTS: +| Enter | password | for | new | role: | +| Enter | it | again: | | | + +#+BEGIN_SRC sql :var rel="tname" n=300 :colnames yes +drop table if exists $rel; +create table $rel(id int, val int); +insert into $rel(id, val) values (1,210), (3,800); +select * from $rel where val > $n; +#+END_SRC + +#+RESULTS: +| DROP TABLE | | +|--------------+-----| +| CREATE TABLE | | +| INSERT 0 2 | | +| id | val | +| 3 | 800 | + + +#+BEGIN_SRC sql +SELECT * FROM DUAL; +#+END_SRC + +#+RESULTS: +|---| + +***** Example sqlite + +#+BEGIN_SRC sqlite :db /tmp/rip.db :var rel="tname" n=300 :colnames yes +drop table if exists $rel; +create table $rel(n int, id int); +insert into $rel(n,id) values (1,210), (3,800); +select * from $rel where id > $n; +#+END_SRC + +#+RESULTS: +| n | id | +|---+-----| +| 3 | 800 | + +***** Example dot aka Graphviz + +#+BEGIN_SRC dot :file metrics.png +digraph MetricsHierarchy { + node [shape=box, style=rounded]; + + // Fundamental Metrics + subgraph cluster_fundamental_metrics { + label="Fundamental Metrics"; + Performance_Rating [label="Performance Rating"]; + Latency_Rating [label="Latency Rating"]; + Quality_Rating [label="Quality Rating"]; + Security_Rating [label="Security Rating"]; + } + + // Derived Metrics + subgraph cluster_derived_metrics { + label="Derived Metrics"; + Application_Health_Score [label="Application Health Score"]; + User_Experience_Index [label="User Experience Index"]; + // Add more derived metrics as needed + } + + // Top-Level Metrics + subgraph cluster_toplevel_metrics { + label="Top-Level Metrics"; + Overall_Application_Performance [label="Overall Application Performance"]; + // Add more top-level metrics as needed + } + + // Connections + Performance_Rating -> Application_Health_Score; + Latency_Rating -> Application_Health_Score; + Quality_Rating -> User_Experience_Index; + Security_Rating -> User_Experience_Index; + + Application_Health_Score -> Overall_Application_Performance; +} +#+END_SRC + +#+RESULTS: +[[file:metrics.png]] + + + + +****** Git Graph + +#+begin_src mermaid :file git.png +gitGraph: +options +{ + "nodeSpacing": 150, + "nodeRadius": 10 +} +end +commit +branch newbranch +checkout newbranch +commit +commit +checkout master +commit +commit +merge newbranch + +#+end_src + +#+RESULTS: +[[file:git.png]] + +****** User Journey Graph + +#+begin_src mermaid :file user_journey.png +journey + title My working day + section Go to work + Make tea: 5: Me + Go upstairs: 3: Me + Do work: 1: Me, Cat + section Go home + Go downstairs: 5: Me + Sit down: 3: Me +#+end_src + +#+RESULTS: +[[file:user_journey.png]] + + + +****** ER Diagram + +#+begin_src mermaid :file er.png +erDiagram + CUSTOMER ||--o{ ORDER : places + ORDER ||--|{ LINE-ITEM : contains + CUSTOMER }|..|{ DELIVERY-ADDRESS : uses +#+end_src + +#+RESULTS: +[[file:er.png]] + + +***** TODO Example Rust + +#+begin_src rust +fn main() { + print!("hello world"); +} +#+end_src + +#+RESULTS: + : hello world + + + + **** Temporary Patches for Org Babel ***** Fix Scheme Babel Bug @@ -2608,6 +2948,23 @@ Create agenda views for specific contexts **** TODO explain what denote-dired-mode-in-directories does. +** BoilerPlate Generator + +The way I do advent of code requires me to create a main file and a +test file every day with some boilerplate content. + +The *org-generate* package uses an org file to structure boilerplate +templates to be generated. By default it uses + +#+BEGIN_SRC emacs-lisp + (use-package org-generate + :ensure t + ) +#+END_SRC + +#+RESULTS: +: [nil 26455 5250 886750 nil elpaca-process-queues nil nil 641000 nil] + * AI Support ** AI Provider API keys