From 201af79a424d4b5357fd15c97af06074191c8288 Mon Sep 17 00:00:00 2001 From: Peter Tillemans Date: Mon, 13 Jan 2025 07:24:33 +0100 Subject: [PATCH] refactor org-babel --- init.org | 236 ++++++++++++++++++++++++++----------------------------- 1 file changed, 111 insertions(+), 125 deletions(-) diff --git a/init.org b/init.org index a4fb1b4..f2d6833 100644 --- a/init.org +++ b/init.org @@ -258,7 +258,7 @@ metadata and get the version number from the JSON. #+END_SRC #+RESULTS: -: v1.2024.6 +: v1.2025.0 * Integration with Environment @@ -408,7 +408,6 @@ up, which a totally different can of worms). A function #+RESULTS: : [nil 26383 36877 803383 nil elpaca-process-queues nil nil 768000 nil] - * Editor Features #+BEGIN_SRC emacs-lisp @@ -987,51 +986,44 @@ whether to put it under writing, comms or programming as it is equally /useful(?)/ for either activity. So I promoted it to an Editor feature. #+BEGIN_SRC emacs-lisp - (use-package llm - :ensure t - :commands (llm-chat llm-ask-about llm-ask-line llm-ask-selection make-llm-openai make-llm-gemini) - :custom - (llm-vertex-gcloud-region "europe-west3") - :config - (require 'llm-openai) - (require 'llm-vertex) - ) + (use-package llm :ensure t) #+END_SRC #+RESULTS: -: [nil 26492 6451 233211 nil elpaca-process-queues nil nil 232000 nil] +: [nil 26497 15516 337719 nil elpaca-process-queues nil nil 495000 nil] #+RESULTS:g -#+BEGIN_SRC emacs-lisp - (use-package ellama - :ensure t - :requires (llm) - :commands (ellama-chat ellama-ask-about ellama-ask-line ellama-ask-selection) - :custom - (ellama-language "English") - (ellama-sessions-directory (expand-file-name "~/Nextcloud/ellama-sessions")) - :bind-keymap - ("C-c e" . ellama-command-map) - :init - (setopt ellama-providers - '(("openai" . (make-llm-openai - :key (auth-source-pass-get 'secret "snamellit/openai-api-key") - :chat-model "gpt-4o")) - ("unifylearn" . (make-llm-vertex - :project "com-melexis-prod-unifylearn"))))) +#+BEGIN_SRC emacs-lisp + (use-package ellama + :ensure t + :defer t + :requires (llm) + :config + (message "Ellama loaded") + (keymap-global-set "C-c e" 'ellama-transient-main-menu) + :custom + (ellama-language "English") + (ellama-sessions-directory (expand-file-name "~/Nextcloud/ellama-sessions")) + (ellama-providers + '(("openai" . (progn + (require 'llm-openai) + (make-llm-openai + :key (auth-source-pass-get 'secret "snamellit/openai-api-key") + :chat-model "gpt-4o")))) + )) #+END_SRC #+RESULTS: -: [nil 26492 1502 118737 nil elpaca-process-queues nil nil 57000 nil] +: [nil 26497 19957 511863 nil elpaca-process-queues nil nil 742000 nil] -It seems the *gpt-4o* model provides better responses. I should -investigate local models more. + +It seems the *gpt-4o* model provides better responses. + +I should investigate local models more. *** Use Gemini with ellama - - This is mostly for those who want to use Google Cloud specifically, most users should use Gemini instead, which is easier to set up. You can set up with make-llm-vertex, with the following parameters: @@ -1057,6 +1049,9 @@ gcloud beta services identity create --service=aiplatform.googleapis.com --proje #+END_SRC +However this is not for the Gemini Code Assistant. It is unclear how +to use that backend. Gemini Code Assistant is part of the Google Cloud +Tools. ** Dired Configuration Enables an alternative file navigation behavior in Dired, Emacs' directory editor: #+BEGIN_SRC emacs-lisp @@ -1977,7 +1972,7 @@ Map the keymap consistently to the eglot mappings. #+BEGIN_SRC emacs-lisp (use-package copilot - :ensure (:host github :repo "zerolfx/copilot.el" + :ensure (copilot :host github :repo "zerolfx/copilot.el" :branch "main" :files ("dist" "*.el")) :bind @@ -1996,12 +1991,13 @@ Map the keymap consistently to the eglot mappings. #+END_SRC #+RESULTS: -: [nil 26482 40231 262145 nil elpaca-process-queues nil nil 167000 nil] +: [nil 26500 6758 925534 nil elpaca-process-queues nil nil 360000 nil] *** TODO move scheme configuration to the scheme section or leave it here but move it to config, whatever makes most sense at the moment. + ** Gitlab Support #+BEGIN_SRC emacs-lisp @@ -2044,7 +2040,6 @@ templates to be generated. By default it uses #+END_SRC ** Org Mode - *** Mixed Pitch Support by Default in Org #+BEGIN_SRC emacs-lisp (defun pti-org-mode-config () @@ -2068,49 +2063,6 @@ templates to be generated. By default it uses #+RESULTS: : [nil 26279 36119 854408 nil elpaca-process-queues nil nil 376000 nil] -*** Org Configuration -#+BEGIN_SRC emacs-lisp - (use-package org - :ensure nil - :custom - (org-return-follows-link t) - (org-mouse-1-follows-link t) - (org-link-descriptive t) - (org-agenda-skip-scheduled-if-done t) - (org-agenda-skip-deadline-if-done t) - (org-hide-emphasis-markers t) - - (line-spacing 0.1) - (left-margin-width 2) - (right-margin-width 2) - - (org-todo-keywords '((sequence "TODO(t)" "NEXT(n)" "WAITING(w)" "SOMEDAY(s)" "PROJ(p)" - "|" "DONE(d)" "CANCELED(c)"))) - (org-todo-keywords-for-agenda '((sequence "NEXT(n)" "TODO(t)" "WAITING(w)" "SOMEDAY(s)" "PROJ(p)" "|" "DONE(d)" "CANCELED(c)"))) - (org-agenda-files (list "~/Nextcloud/org/" "~/org/snamellit/" "~/org/customer/" "~/org/personal/")) - (org-refile-targets '( - (org-agenda-files . (:level . 1)) - ("~/org/personal/bijen.org" . (:level . 1)) - ("~/org/personal/fitness.org" . (:level . 1)) - )) - :config - ;; set files for agenda views - (setq +org-capture-todo-file "~/Nextcloud/org/inbox.org" - +org-capture-notes-file "~/Nextcloud/org/inbox.org" - +org-capture-journal-file "~/Nextcloud/org/journal.org" - +org-capture-projects-file "~/Nextcloud/org/projects.org") - :hook ( - (org-mode . pti-org-mode-config) - (org-mode . org-indent-mode) - - ) - :bind ( - (" o a" . org-agenda) - (" o s" . org-store-link) - )) -#+END_SRC - -#+RESULTS: *** Org Appear Hide the org markers when point is not on the element being decorated. @@ -2132,30 +2084,23 @@ 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 REST calls in Babel Blocks - -#+BEGIN_SRC emacs-lisp - ;; enable verb package to do REST calls - (use-package verb - :ensure t - :defer 3 - :bind - (:map org-mode-map - ("C-c C-r" . verb-command-map))) - - (use-package ob-verb - :after verb - :defer 3) - #+END_SRC **** Support Mermaid Diagrams in Babel Blocks #+BEGIN_SRC emacs-lisp ;; enable mermaid for org-babel (use-package ob-mermaid :ensure t - :defer 3) + :demand t + :config + (message "configuring ob-mermaid") + (org-babel-do-load-languages + 'org-babel-load-languages + (add-to-list 'org-babel-load-languages '(mermaid . t)))) #+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 @@ -2205,29 +2150,28 @@ interactive to manually install the latest version if needed. #+END_SRC #+RESULTS: -: /home/pti/.config/emacs/plantuml.jar +: ~/.config/emacs/plantuml.jar -**** Configure Babel Languages -#+BEGIN_SRC emacs-lisp - ;; configure babel languages - (use-package org-babel - :no-require - :after '(ob-verb ob-mermaid) - :config - (org-babel-do-load-languages - 'org-babel-load-languages - '((emacs-lisp . t) - (shell . t) - (python . t) - (latex . t) - (verb . t) - (scheme . t) - (plantuml . t) - (mermaid . t) - (dot . t)))) +**** Configure Babel Languages +#+BEGIN_SRC emacs-lisp :tangle no + ;; configure babel languages + (use-package org-babel + :demand t + :custom + (org-babel-load-languages '((emacs-lisp . t) + (shell . t) + (python . t) + (latex . t) + (scheme . t) + (plantuml . t) + (dot . t))) + :config + (message "Configuring org-babel languages") + ) #+END_SRC #+RESULTS: +: [nil 26499 54180 830807 nil elpaca-process-queues nil nil 413000 nil] **** Temporary Patches for Org Babel @@ -2258,14 +2202,7 @@ interactive to manually install the latest version if needed. Alternatively I might add a sample after each configured block to keep it in the same context. Hmmm.... sounds even better. - *** Org Export -#+BEGIN_SRC emacs-lisp - (use-package ox - :ensure nil) - -#+END_SRC - **** Org Export to Markdown #+BEGIN_SRC emacs-lisp (use-package ox-md @@ -2391,7 +2328,7 @@ gicrisf has [[https://github.com/gicrisf/ox-zola][created a package]] to export :after ox) (use-package ox-zola :ensure (ox-zola :host github :repo "gicrisf/ox-zola" :files (:defaults "*.el" "backend" "stylesheets")) - :after ox-hugo + :after (ox-hugo) :config (require 'ox-hugo) :general @@ -2404,7 +2341,6 @@ It is a wrapper around ~ox-hugo~ to export org files to Zola. It supports most features of it and directs the user to the [[https://ox-hugo.scripter.co/][the hugo exporter manual.]] - *** Org Capture Customization #+BEGIN_SRC emacs-lisp (use-package org-capture @@ -2653,7 +2589,6 @@ projects: - update issues in background when opening the project. - run custom JQL defined in the project iso globally. - *** Daviwil's Productivity Tools @daviwil has a set of productivity tools which are very useful. I have @@ -2758,7 +2693,58 @@ We can add a list of queries #+RESULTS: | w | Weekly Review | ((agenda ((org-agenda-overriding-header Completed Tasks) (org-agenda-skip-function (org-agenda-skip-entry-if 'nottodo 'done)) (org-agenda-span 'week))) (agenda ((org-agenda-overriding-header Unfinished Scheduled Tasks) (org-agenda-skip-function (org-agenda-skip-entry-if 'todo 'done)) (org-agenda-span 'week)))) | +*** Org Configuration +#+BEGIN_SRC emacs-lisp + (use-package org + :ensure nil + :demand t + :custom + (org-return-follows-link t) + (org-mouse-1-follows-link t) + (org-link-descriptive t) + (org-agenda-skip-scheduled-if-done t) + (org-agenda-skip-deadline-if-done t) + (org-hide-emphasis-markers t) + + (line-spacing 0.1) + (left-margin-width 2) + (right-margin-width 2) + (org-todo-keywords '((sequence "TODO(t)" "NEXT(n)" "WAITING(w)" "SOMEDAY(s)" "PROJ(p)" + "|" "DONE(d)" "CANCELED(c)"))) + (org-todo-keywords-for-agenda '((sequence "NEXT(n)" "TODO(t)" "WAITING(w)" "SOMEDAY(s)" "PROJ(p)" "|" "DONE(d)" "CANCELED(c)"))) + (org-agenda-files (list "~/Nextcloud/org/" "~/org/snamellit/" "~/org/customer/" "~/org/personal/")) + (org-refile-targets '( + (org-agenda-files . (:level . 1)) + ("~/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))) + :config + (message "Configuring org mode") + ;; set files for agenda views + (setq +org-capture-todo-file "~/Nextcloud/org/inbox.org" + +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) + :hook ( + (org-mode . pti-org-mode-config) + (org-mode . org-indent-mode) + ) + :bind ( + (" o a" . org-agenda) + (" o s" . org-store-link) + )) +#+END_SRC + +#+RESULTS: ** Denote #+BEGIN_SRC emacs-lisp