fix tangle all org-files

Signed-off-by: Frieder Schlesier <frieder@fschl.de>
This commit is contained in:
Frieder Schlesier 2023-07-17 22:08:19 +02:00
parent c3b02f62fd
commit 6d84262718
6 changed files with 156 additions and 198 deletions

View File

@ -5,7 +5,7 @@ my Notes and LaTeX support.
** Handling emacs Configuration changes ** 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 currently every =fschl-module.org= file contains it's own
=org-babel-tangle-config()= block There must be a more generalized =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 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 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 *** 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 get used to clocking and export
# *** TODO graphviz setup *** TODO graphviz setup
# ** Communication Tools ** Communication Tools
# *** TODO IRC client + setup *** TODO IRC client + setup
# e.g. for system-crafter, gnu guix, rde e.g. for system-crafter, gnu guix, rde
*** TODO matrix client setup *** TODO matrix client setup
e.g. for Chemnitzer LinuxTage, system-crafter, rde,... e.g. for Chemnitzer LinuxTage, system-crafter, rde,...

View File

@ -10,6 +10,20 @@
(tool-bar-mode -1) (tool-bar-mode -1)
(scroll-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)) (defvar fschl-org-file (expand-file-name "fschl-org.el" user-emacs-directory))
(when (and fschl-org-file (when (and fschl-org-file
(file-exists-p fschl-org-file)) (file-exists-p fschl-org-file))

View File

@ -1,6 +1,6 @@
;;; fschl-org.el -- Fschl Crafted Emacs user customization file -*- lexical-binding: t; -*- ;;; 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 ;; This file is generated from the .org-file with the same name. If you want to edit the
;; configuration, DO NOT edit fschl-org.el, edit fsch-org.org, instead. ;; configuration, DO NOT edit this .el-file, edit .org, instead.
;;(add-to-list 'package-selected-packages 'org-roam) ;;(add-to-list 'package-selected-packages 'org-roam)
(add-to-list 'package-selected-packages 'ox-latex) (add-to-list 'package-selected-packages 'ox-latex)
@ -65,6 +65,29 @@
;; \\setkomavar{frombank}{(1234)\\,567\\,890} ;; \\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 (setq org-capture-templates
'(("t" "todo list item" entry '(("t" "todo list item" entry
@ -83,31 +106,10 @@
"* TODO %?\n SCHEDULED: %^T \n %^L \n" "* TODO %?\n SCHEDULED: %^T \n %^L \n"
:tree-type month :tree-type month
) )
; ("l" "letter to Documents/letters/<datetime.org>" ("l" "letter to Documents/letters/<datetime.org>"
; entry (file fschl/create-org-letter) entry (file fschl/create-org-letter)
; "* Preamble :noexport: letter-template
;# #+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 ("m" "Schedule a meeting" entry
(file+headline "~/Documents/Org/tasks.org") (file+headline "~/Documents/Org/tasks.org")
"* MEETING %?\n SCHEDULED: %^T\n %a" "* 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") (setq org-ref-default-bibliography '("~/Documents/references/references.bib")
org-ref-pdf-directory "~/Documents/references/" org-ref-pdf-directory "~/Documents/references/"
org-ref-bibliography-notes "~/Documents/references/notes.org") 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)))

View File

@ -2,19 +2,17 @@
#+PROPERTY: header-args:emacs-lisp :tangle ./fschl-org.el :mkdirp yes #+PROPERTY: header-args:emacs-lisp :tangle ./fschl-org.el :mkdirp yes
* Basic configuration * Basic configuration
** Additional Packages ** Additional Packages
#+begin_src emacs-lisp #+begin_src emacs-lisp
;;; fschl-org.el -- Fschl Crafted Emacs user customization file -*- lexical-binding: t; -*- ;;; 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 ;; This file is generated from the .org-file with the same name. If you want to edit the
;; configuration, DO NOT edit fschl-org.el, edit fsch-org.org, instead. ;; configuration, DO NOT edit this .el-file, edit .org, instead.
;;(add-to-list 'package-selected-packages 'org-roam) ;;(add-to-list 'package-selected-packages 'org-roam)
(add-to-list 'package-selected-packages 'ox-latex) (add-to-list 'package-selected-packages 'ox-latex)
(add-to-list 'package-selected-packages 'ox-koma-letter) (add-to-list 'package-selected-packages 'ox-koma-letter)
(add-to-list 'package-selected-packages 'ox-moderncv) (add-to-list 'package-selected-packages 'ox-moderncv)
(package-install-selected-packages :noconfirm) (package-install-selected-packages :noconfirm)
#+end_src #+end_src
** Configure Org-Roam ** Configure Org-Roam
@ -42,7 +40,7 @@
"~/Documents/Org/birthdays.org"))) "~/Documents/Org/birthdays.org")))
#+end_src #+end_src
Add Week to Calendar *** Add Week to Calendar
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq calendar-week-start-day 1) (setq calendar-week-start-day 1)
@ -59,6 +57,7 @@ Add Week to Calendar
'font-lock-face 'font-lock-keyword-face)) 'font-lock-face 'font-lock-keyword-face))
#+end_src #+end_src
*** Custom TODO keywords
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq org-todo-keywords (setq org-todo-keywords
(quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)") (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
@ -80,11 +79,10 @@ Add Week to Calendar
- https://orgmode.org/manual/Template-expansion.html - https://orgmode.org/manual/Template-expansion.html
*** Export Letter *** Export Letter
#+begin_src emacs-lisp #+begin_src emacs-lisp
(eval-after-load 'ox '(require 'ox-koma-letter)) (eval-after-load 'ox '(require 'ox-koma-letter))
(eval-after-load 'ox '(require 'ox-moderncv)) (eval-after-load 'ox '(require 'ox-moderncv))
(eval-after-load 'ox-koma-letter (eval-after-load 'ox-koma-letter
'(progn '(progn
(add-to-list 'org-latex-classes (add-to-list 'org-latex-classes
'("Brief-de-modern" '("Brief-de-modern"
@ -97,12 +95,34 @@ Add Week to Calendar
;; \\setkomavar{frombank}{(1234)\\,567\\,890} ;; \\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 #+end_src
*** Capture Templates *** Capture Templates
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq org-capture-templates (setq org-capture-templates
'(("t" "todo list item" entry '(("t" "todo list item" entry
(file+olp+datetree "~/Documents/Org/tasks.org") (file+olp+datetree "~/Documents/Org/tasks.org")
"* TODO %?\n SCHEDULED: %^T" "* TODO %?\n SCHEDULED: %^T"
@ -119,31 +139,10 @@ Add Week to Calendar
"* TODO %?\n SCHEDULED: %^T \n %^L \n" "* TODO %?\n SCHEDULED: %^T \n %^L \n"
:tree-type month :tree-type month
) )
; ("l" "letter to Documents/letters/<datetime.org>" ("l" "letter to Documents/letters/<datetime.org>"
; entry (file fschl/create-org-letter) entry (file fschl/create-org-letter)
; "* Preamble :noexport: letter-template
;# #+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 ("m" "Schedule a meeting" entry
(file+headline "~/Documents/Org/tasks.org") (file+headline "~/Documents/Org/tasks.org")
"* MEETING %?\n SCHEDULED: %^T\n %a" "* MEETING %?\n SCHEDULED: %^T\n %a"
@ -163,30 +162,15 @@ Add Week to Calendar
) )
#+end_src #+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 #+begin_src emacs-lisp
(setq org-ref-default-bibliography '("~/Documents/references/references.bib") (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-pdf-directory "~/Documents/references/"
org-ref-bibliography-notes "~/Documents/references/notes.org") org-ref-bibliography-notes "~/Documents/references/notes.org")
#+end_src #+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)))
#+end_src

16
init.el
View File

@ -1,6 +1,6 @@
;;; init.el -- Fschl Crafted Emacs user customization file -*- lexical-binding: t; -*- ;;; init.el -- Fschl Crafted Emacs user customization file -*- lexical-binding: t; -*-
;; This file is generated from init.org. If you want to edit the ;; This file is generated from the .org-file with the same name. If you want to edit the
;; configuration, DO NOT edit init.el, edit init.org, instead. ;; configuration, DO NOT edit this .el-file, edit .org, instead.
(setq user-emacs-directory "~/.config/crafted-emacs-configdir/") (setq user-emacs-directory "~/.config/crafted-emacs-configdir/")
(setq crafted-emacs-home "~/src/crafted-emacs/") (setq crafted-emacs-home "~/src/crafted-emacs/")
@ -29,15 +29,3 @@
(unless crafted-startup-inhibit-splash (unless crafted-startup-inhibit-splash
(setq initial-buffer-choice #'crafted-startup-screen)) (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)))

View File

@ -6,8 +6,8 @@
** Set import directories for =crafted-emacs= ** Set import directories for =crafted-emacs=
#+begin_src emacs-lisp #+begin_src emacs-lisp
;;; init.el -- Fschl Crafted Emacs user customization file -*- lexical-binding: t; -*- ;;; init.el -- Fschl Crafted Emacs user customization file -*- lexical-binding: t; -*-
;; This file is generated from init.org. If you want to edit the ;; This file is generated from the .org-file with the same name. If you want to edit the
;; configuration, DO NOT edit init.el, edit init.org, instead. ;; configuration, DO NOT edit this .el-file, edit .org, instead.
(setq user-emacs-directory "~/.config/crafted-emacs-configdir/") (setq user-emacs-directory "~/.config/crafted-emacs-configdir/")
(setq crafted-emacs-home "~/src/crafted-emacs/") (setq crafted-emacs-home "~/src/crafted-emacs/")
@ -43,24 +43,3 @@
(unless crafted-startup-inhibit-splash (unless crafted-startup-inhibit-splash
(setq initial-buffer-choice #'crafted-startup-screen)) (setq initial-buffer-choice #'crafted-startup-screen))
#+end_src #+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