From 6d84262718b94dc8afd890a0d18ffefbd1dfdded Mon Sep 17 00:00:00 2001 From: Frieder Schlesier Date: Mon, 17 Jul 2023 22:08:19 +0200 Subject: [PATCH] fix tangle all org-files Signed-off-by: Frieder Schlesier --- TODO.org | 12 +-- custom.el | 14 ++++ fschl-org.el | 87 ++++++++++------------ fschl-org.org | 200 +++++++++++++++++++++++--------------------------- init.el | 16 +--- init.org | 25 +------ 6 files changed, 156 insertions(+), 198 deletions(-) diff --git a/TODO.org b/TODO.org index 86d5ace..d821289 100644 --- a/TODO.org +++ b/TODO.org @@ -5,7 +5,7 @@ my Notes and LaTeX support. ** Handling emacs Configuration changes -*** TODO auto-tangle all .org files in this project +*** DONE auto-tangle all .org files in this project currently every =fschl-module.org= file contains it's own =org-babel-tangle-config()= block There must be a more generalized solution, e.g. set it up to auto-tangle all .org files within/below @@ -27,7 +27,7 @@ solution, e.g. set it up to auto-tangle all .org files within/below *** TODO syncable org-files, agenda files, calendar setup -*** TODO extend TODO-keyword: NEXT, MAYBE, MEETING, CALL, CANCELED, HOLD +*** DONE extend TODO-keyword: NEXT, MAYBE, MEETING, CALL, CANCELED, HOLD *** TODO make org-roam work with simple key chords @@ -37,12 +37,12 @@ solution, e.g. set it up to auto-tangle all .org files within/below *** TODO get used to clocking and export -# *** TODO graphviz setup +*** TODO graphviz setup -# ** Communication Tools +** Communication Tools -# *** TODO IRC client + setup -# e.g. for system-crafter, gnu guix, rde +*** TODO IRC client + setup +e.g. for system-crafter, gnu guix, rde *** TODO matrix client setup e.g. for Chemnitzer LinuxTage, system-crafter, rde,... diff --git a/custom.el b/custom.el index e020180..de00c2a 100644 --- a/custom.el +++ b/custom.el @@ -10,6 +10,20 @@ (tool-bar-mode -1) (scroll-bar-mode -1) +(defun org-babel-tangle-config () + "Tangle all Org-mode files in `user-emacs-directory` after save." + (let ((user-emacs-dir (expand-file-name user-emacs-directory)) + (buffer-file (expand-file-name (buffer-file-name)))) + (when (and (string-equal (file-name-extension (buffer-file-name)) "org") + (string-equal (file-name-directory (buffer-file-name)) user-emacs-dir)) + (let ((default-directory user-emacs-dir) + (org-confirm-babel-evaluate nil)) + (org-babel-tangle-file (buffer-file-name)))))) + +(add-hook 'org-mode-hook + (lambda () + (add-hook 'after-save-hook #'org-babel-tangle-config))) + (defvar fschl-org-file (expand-file-name "fschl-org.el" user-emacs-directory)) (when (and fschl-org-file (file-exists-p fschl-org-file)) diff --git a/fschl-org.el b/fschl-org.el index 1bae61f..5ce45d2 100644 --- a/fschl-org.el +++ b/fschl-org.el @@ -1,6 +1,6 @@ ;;; fschl-org.el -- Fschl Crafted Emacs user customization file -*- lexical-binding: t; -*- -;; This file is generated from fschl-org.org. If you want to edit the -;; configuration, DO NOT edit fschl-org.el, edit fsch-org.org, instead. +;; This file is generated from the .org-file with the same name. If you want to edit the +;; configuration, DO NOT edit this .el-file, edit .org, instead. ;;(add-to-list 'package-selected-packages 'org-roam) (add-to-list 'package-selected-packages 'ox-latex) @@ -55,16 +55,39 @@ (eval-after-load 'ox-koma-letter '(progn (add-to-list 'org-latex-classes - '("Brief-de-modern" - "\\documentclass\[Brief-de-modern\]\{scrlttr2\} - \[DEFAULT-PACKAGES] - \[PACKAGES] - \[EXTRA]")) + '("Brief-de-modern" + "\\documentclass\[Brief-de-modern\]\{scrlttr2\} + \[DEFAULT-PACKAGES] + \[PACKAGES] + \[EXTRA]")) - ;; \\usepackage[english]{babel} - ;; \\setkomavar{frombank}{(1234)\\,567\\,890} + ;; \\usepackage[english]{babel} + ;; \\setkomavar{frombank}{(1234)\\,567\\,890} - (setq org-koma-letter-default-class "Brief-de-modern"))) + (setq org-koma-letter-default-class "Brief-de-modern"))) +(defvar letter-template + "* Preamble :noexport: +\# #+TITLE: ? +\# #+DATE: +\ +\#+SUBJECT: Betreff des Briefs +\ +\#+LCO: Absender-Frieder +\# #+LCO: Absender-Marcelle +\# #+LCO: Absender-FamilieSchlesier +\#+LCO: Brief-de-modern +\#+STARTUP: showall +\ +\* To-address :to: +\ +\# * From :from: +\ +\* Sehr geehrte Damen und Herren, +\? +\ +\* Mit freundlichen Grüßen, :closing: +\ +Frieder Schlesier") (setq org-capture-templates '(("t" "todo list item" entry @@ -83,31 +106,10 @@ "* TODO %?\n SCHEDULED: %^T \n %^L \n" :tree-type month ) -; ("l" "letter to Documents/letters/" -; entry (file fschl/create-org-letter) -; "* Preamble :noexport: -;# #+TITLE: ? -;# #+DATE: -; -;#+SUBJECT: Betreff des Briefs -; -;#+LCO: Absender-Frieder -;# #+LCO: Absender-Marcelle -;# #+LCO: Absender-FamilieSchlesier -;#+LCO: Brief-de-modern -;#+STARTUP: showall -; -;* To-address :to: -; -;# * From :from: -; -;* Sehr geehrte Damen und Herren, -;? -; -;* Mit freundlichen Grüßen, :closing: -; -;Frieder Schlesier" -; ) + ("l" "letter to Documents/letters/" + entry (file fschl/create-org-letter) + letter-template + ) ("m" "Schedule a meeting" entry (file+headline "~/Documents/Org/tasks.org") "* MEETING %?\n SCHEDULED: %^T\n %a" @@ -126,18 +128,9 @@ ) ) +(use-package ox-moderncv + :load-path "~/src/org-cv/" + :init (require 'ox-moderncv)) (setq org-ref-default-bibliography '("~/Documents/references/references.bib") org-ref-pdf-directory "~/Documents/references/" org-ref-bibliography-notes "~/Documents/references/notes.org") - -;; Tangle the code blocks to fschl-org.el on save. -(defun org-babel-tangle-config () - (when (string-equal (buffer-file-name) - (expand-file-name "fschl-org.org" user-emacs-directory)) - ;; Dynamic scoping to the rescue - (let ((org-confirm-babel-evaluate nil)) - (org-babel-tangle)))) - -(add-hook 'org-mode-hook - (lambda () - (add-hook 'after-save-hook #'org-babel-tangle-config))) diff --git a/fschl-org.org b/fschl-org.org index c6b01f1..1088f58 100644 --- a/fschl-org.org +++ b/fschl-org.org @@ -2,19 +2,17 @@ #+PROPERTY: header-args:emacs-lisp :tangle ./fschl-org.el :mkdirp yes * Basic configuration - ** Additional Packages - #+begin_src emacs-lisp -;;; fschl-org.el -- Fschl Crafted Emacs user customization file -*- lexical-binding: t; -*- -;; This file is generated from fschl-org.org. If you want to edit the -;; configuration, DO NOT edit fschl-org.el, edit fsch-org.org, instead. + ;;; fschl-org.el -- Fschl Crafted Emacs user customization file -*- lexical-binding: t; -*- + ;; This file is generated from the .org-file with the same name. If you want to edit the + ;; configuration, DO NOT edit this .el-file, edit .org, instead. -;;(add-to-list 'package-selected-packages 'org-roam) -(add-to-list 'package-selected-packages 'ox-latex) -(add-to-list 'package-selected-packages 'ox-koma-letter) -(add-to-list 'package-selected-packages 'ox-moderncv) -(package-install-selected-packages :noconfirm) + ;;(add-to-list 'package-selected-packages 'org-roam) + (add-to-list 'package-selected-packages 'ox-latex) + (add-to-list 'package-selected-packages 'ox-koma-letter) + (add-to-list 'package-selected-packages 'ox-moderncv) + (package-install-selected-packages :noconfirm) #+end_src ** Configure Org-Roam @@ -42,7 +40,7 @@ "~/Documents/Org/birthdays.org"))) #+end_src -Add Week to Calendar +*** Add Week to Calendar #+begin_src emacs-lisp (setq calendar-week-start-day 1) @@ -59,6 +57,7 @@ Add Week to Calendar 'font-lock-face 'font-lock-keyword-face)) #+end_src +*** Custom TODO keywords #+begin_src emacs-lisp (setq org-todo-keywords (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)") @@ -80,113 +79,98 @@ Add Week to Calendar - https://orgmode.org/manual/Template-expansion.html *** Export Letter - #+begin_src emacs-lisp -(eval-after-load 'ox '(require 'ox-koma-letter)) -(eval-after-load 'ox '(require 'ox-moderncv)) -(eval-after-load 'ox-koma-letter - '(progn - (add-to-list 'org-latex-classes - '("Brief-de-modern" - "\\documentclass\[Brief-de-modern\]\{scrlttr2\} - \[DEFAULT-PACKAGES] - \[PACKAGES] - \[EXTRA]")) + (eval-after-load 'ox '(require 'ox-koma-letter)) + (eval-after-load 'ox '(require 'ox-moderncv)) + (eval-after-load 'ox-koma-letter + '(progn + (add-to-list 'org-latex-classes + '("Brief-de-modern" + "\\documentclass\[Brief-de-modern\]\{scrlttr2\} + \[DEFAULT-PACKAGES] + \[PACKAGES] + \[EXTRA]")) - ;; \\usepackage[english]{babel} - ;; \\setkomavar{frombank}{(1234)\\,567\\,890} + ;; \\usepackage[english]{babel} + ;; \\setkomavar{frombank}{(1234)\\,567\\,890} - (setq org-koma-letter-default-class "Brief-de-modern"))) + (setq org-koma-letter-default-class "Brief-de-modern"))) + (defvar letter-template + "* Preamble :noexport: + \# #+TITLE: ? + \# #+DATE: + \ + \#+SUBJECT: Betreff des Briefs + \ + \#+LCO: Absender-Frieder + \# #+LCO: Absender-Marcelle + \# #+LCO: Absender-FamilieSchlesier + \#+LCO: Brief-de-modern + \#+STARTUP: showall + \ + \* To-address :to: + \ + \# * From :from: + \ + \* Sehr geehrte Damen und Herren, + \? + \ + \* Mit freundlichen Grüßen, :closing: + \ + Frieder Schlesier") #+end_src *** Capture Templates - #+begin_src emacs-lisp -(setq org-capture-templates - '(("t" "todo list item" entry - (file+olp+datetree "~/Documents/Org/tasks.org") - "* TODO %?\n SCHEDULED: %^T" - :tree-type month - ) - ("T" "todo list item with source" entry - (file+olp+datetree "~/Documents/Org/tasks.org") - "* TODO %?\n %a \n SCHEDULED: %^T \n %^G \n" - :tree-type month - ) + (setq org-capture-templates + '(("t" "todo list item" entry + (file+olp+datetree "~/Documents/Org/tasks.org") + "* TODO %?\n SCHEDULED: %^T" + :tree-type month + ) + ("T" "todo list item with source" entry + (file+olp+datetree "~/Documents/Org/tasks.org") + "* TODO %?\n %a \n SCHEDULED: %^T \n %^G \n" + :tree-type month + ) - ("r" "Todo research some website/software" entry - (file+olp+datetree "~/Documents/Org/tasks.org") - "* TODO %?\n SCHEDULED: %^T \n %^L \n" - :tree-type month - ) -; ("l" "letter to Documents/letters/" -; entry (file fschl/create-org-letter) -; "* Preamble :noexport: -;# #+TITLE: ? -;# #+DATE: -; -;#+SUBJECT: Betreff des Briefs -; -;#+LCO: Absender-Frieder -;# #+LCO: Absender-Marcelle -;# #+LCO: Absender-FamilieSchlesier -;#+LCO: Brief-de-modern -;#+STARTUP: showall -; -;* To-address :to: -; -;# * From :from: -; -;* Sehr geehrte Damen und Herren, -;? -; -;* Mit freundlichen Grüßen, :closing: -; -;Frieder Schlesier" -; ) - ("m" "Schedule a meeting" entry - (file+headline "~/Documents/Org/tasks.org") - "* MEETING %?\n SCHEDULED: %^T\n %a" - ) - ("p" "Schedule a phone call" entry - (file+headline "~/Documents/Org/tasks.org") - "* PHONE %?\n SCHEDULED: %^T\\n %a" - ) - ("a" "Articles: keep notes of online articles" - entry - (file+datetree "~/Documents/Org/journal.org") - "* %? \n%x \n %u\n- $?" - :tree-type month - :kill-buffer t - :empty-lines-before 1) + ("r" "Todo research some website/software" entry + (file+olp+datetree "~/Documents/Org/tasks.org") + "* TODO %?\n SCHEDULED: %^T \n %^L \n" + :tree-type month + ) + ("l" "letter to Documents/letters/" + entry (file fschl/create-org-letter) + letter-template + ) + ("m" "Schedule a meeting" entry + (file+headline "~/Documents/Org/tasks.org") + "* MEETING %?\n SCHEDULED: %^T\n %a" + ) + ("p" "Schedule a phone call" entry + (file+headline "~/Documents/Org/tasks.org") + "* PHONE %?\n SCHEDULED: %^T\\n %a" + ) + ("a" "Articles: keep notes of online articles" + entry + (file+datetree "~/Documents/Org/journal.org") + "* %? \n%x \n %u\n- $?" + :tree-type month + :kill-buffer t + :empty-lines-before 1) + ) ) - ) #+end_src -** TODO not sure if we actually need this +** TeX and research + +- Write a CV in org-mode: https://titan-c.gitlab.io/org-cv/ +- requires: ~texlive-latex-extra texlive-xetex~ #+begin_src emacs-lisp -(setq org-ref-default-bibliography '("~/Documents/references/references.bib") - org-ref-pdf-directory "~/Documents/references/" - org-ref-bibliography-notes "~/Documents/references/notes.org") -#+end_src - -** Auto-tangle on save - -Whenever you edit =init.org= in Emacs and save it, it updates =init.el= in -the same directory. - -See the [[https://orgmode.org/manual/Extracting-Source-Code.html][Org Manual]] for details and alternatives. - -#+begin_src emacs-lisp - ;; Tangle the code blocks to fschl-org.el on save. - (defun org-babel-tangle-config () - (when (string-equal (buffer-file-name) - (expand-file-name "fschl-org.org" user-emacs-directory)) - ;; Dynamic scoping to the rescue - (let ((org-confirm-babel-evaluate nil)) - (org-babel-tangle)))) - - (add-hook 'org-mode-hook - (lambda () - (add-hook 'after-save-hook #'org-babel-tangle-config))) + (use-package ox-moderncv + :load-path "~/src/org-cv/" + :init (require 'ox-moderncv)) + (setq org-ref-default-bibliography '("~/Documents/references/references.bib") + org-ref-pdf-directory "~/Documents/references/" + org-ref-bibliography-notes "~/Documents/references/notes.org") #+end_src diff --git a/init.el b/init.el index 0b83a81..5aedf55 100644 --- a/init.el +++ b/init.el @@ -1,6 +1,6 @@ ;;; init.el -- Fschl Crafted Emacs user customization file -*- lexical-binding: t; -*- -;; This file is generated from init.org. If you want to edit the -;; configuration, DO NOT edit init.el, edit init.org, instead. +;; This file is generated from the .org-file with the same name. If you want to edit the +;; configuration, DO NOT edit this .el-file, edit .org, instead. (setq user-emacs-directory "~/.config/crafted-emacs-configdir/") (setq crafted-emacs-home "~/src/crafted-emacs/") @@ -29,15 +29,3 @@ (unless crafted-startup-inhibit-splash (setq initial-buffer-choice #'crafted-startup-screen)) - -;; Tangle the code blocks to config.el on save. -(defun org-babel-tangle-config () - (when (string-equal (buffer-file-name) - (expand-file-name "init.org" user-emacs-directory)) - ;; Dynamic scoping to the rescue - (let ((org-confirm-babel-evaluate nil)) - (org-babel-tangle)))) - -(add-hook 'org-mode-hook - (lambda () - (add-hook 'after-save-hook #'org-babel-tangle-config))) diff --git a/init.org b/init.org index f714720..46fd696 100644 --- a/init.org +++ b/init.org @@ -6,8 +6,8 @@ ** Set import directories for =crafted-emacs= #+begin_src emacs-lisp ;;; init.el -- Fschl Crafted Emacs user customization file -*- lexical-binding: t; -*- - ;; This file is generated from init.org. If you want to edit the - ;; configuration, DO NOT edit init.el, edit init.org, instead. + ;; This file is generated from the .org-file with the same name. If you want to edit the + ;; configuration, DO NOT edit this .el-file, edit .org, instead. (setq user-emacs-directory "~/.config/crafted-emacs-configdir/") (setq crafted-emacs-home "~/src/crafted-emacs/") @@ -43,24 +43,3 @@ (unless crafted-startup-inhibit-splash (setq initial-buffer-choice #'crafted-startup-screen)) #+end_src - -** Auto-tangle on save - -Whenever you edit =init.org= in Emacs and save it, it updates =init.el= in -the same directory. - -See the [[https://orgmode.org/manual/Extracting-Source-Code.html][Org Manual]] for details and alternatives. - -#+begin_src emacs-lisp - ;; Tangle the code blocks to config.el on save. - (defun org-babel-tangle-config () - (when (string-equal (buffer-file-name) - (expand-file-name "init.org" user-emacs-directory)) - ;; Dynamic scoping to the rescue - (let ((org-confirm-babel-evaluate nil)) - (org-babel-tangle)))) - - (add-hook 'org-mode-hook - (lambda () - (add-hook 'after-save-hook #'org-babel-tangle-config))) -#+end_src