Neue Capture-Templates

This commit is contained in:
hansi
2026-04-06 14:04:32 +02:00
parent ee451f78fd
commit b230f57ff0
10 changed files with 220 additions and 29 deletions

11
bookmarks Normal file
View File

@@ -0,0 +1,11 @@
;;;; Emacs Bookmark Format Version 1;;;; -*- coding: utf-8-emacs; mode: lisp-data -*-
;;; This format is meant to be slightly human-readable;
;;; nevertheless, you probably don't want to edit it.
;;; -*- End Of Bookmark File Format Version Stamp -*-
(("org-capture-last-stored"
(filename . "~/org/docs/umsatz.org")
(front-context-string . "#+title: umsatz\n")
(rear-context-string)
(position . 1)
(last-modified 27091 40363 706421 401000))
)

View File

@@ -5,11 +5,13 @@
(setq custom-file "~/.emacs.d/custom.el") (setq custom-file "~/.emacs.d/custom.el")
(load custom-file 'noerror 'nomessage) (load custom-file 'noerror 'nomessage)
(require 'init-keybindings)
(require 'init-packages) (require 'init-packages)
(require 'init-ui) (require 'init-ui)
(require 'init-org) (require 'init-org)
(require 'init-markdown) (require 'init-markdown)
(require 'init-search)
(require 'init-capture)

143
lisp/init-capture.el Normal file
View File

@@ -0,0 +1,143 @@
;; (provide 'init-capture)
;; (defvar my/org-capture-title nil)
;; (defun my/org-slugify (s)
;; (replace-regexp-in-string
;; "-+"
;; "-"
;; (replace-regexp-in-string
;; "[^[:alnum:]]+"
;; "-"
;; (downcase (string-trim s)))))
;; ;; Aufgabe (Task) erstellen
;; (defun my/org-capture-new-task ()
;; (interactive)
;; (let ((my/org-capture-title (read-string "Titel: ")))
;; (org-capture nil "n")))
;; (setq org-capture-templates
;; '(("n" "Neue Task-Datei" plain
;; (file
;; (lambda ()
;; (expand-file-name
;; (concat (my/org-slugify my/org-capture-title) ".org")
;; "~/org/todos/")))
;; "#+title: %(or my/org-capture-title \"\")\n\n* TODO %(or my/org-capture-title \"\")\n\n** Kontext\n%?\n\n** Nächste Schritte\n- [ ] \n\n** Notizen\n"
;; :if-new (file+head "%F" "")
;; :unnarrowed t
;; :jump-to-captured t)))
;; (setq org-agenda-files '("~/org/todos/"))
;;; init-capture.el --- Capture-Funktionen für Org -*- lexical-binding: t; -*-
;;; init-capture.el --- Capture-Funktionen -*- lexical-binding: t; -*-
(require 'org)
(require 'org-capture)
(require 'subr-x)
(defvar my/org-capture-title nil)
(defun my/org-slugify (s)
"Wandle S in einen sauberen Dateinamen um."
(let ((s (downcase (string-trim s))))
(setq s (replace-regexp-in-string "ä" "ae" s))
(setq s (replace-regexp-in-string "ö" "oe" s))
(setq s (replace-regexp-in-string "ü" "ue" s))
(setq s (replace-regexp-in-string "ß" "ss" s))
(setq s (replace-regexp-in-string "[^[:alnum:]]+" "-" s))
(setq s (replace-regexp-in-string "-+" "-" s))
(setq s (replace-regexp-in-string "\\`-\\|-\\'" "" s))
s))
(defun my/org-ensure-directory (dir)
(make-directory dir t)
dir)
(defun my/org-task-file-from-title (title)
(expand-file-name
(concat (my/org-slugify title) ".org")
(my/org-ensure-directory "~/org/todos/")))
(defun my/org-doc-file-from-title (title)
(expand-file-name
(concat (my/org-slugify title) ".org")
(my/org-ensure-directory "~/org/docs/")))
(defun my/org-today-file ()
(let* ((date (format-time-string "%Y-%m-%d"))
(year (format-time-string "%Y"))
(dir (expand-file-name year "~/org/notes/")))
(my/org-ensure-directory dir)
(expand-file-name (concat date ".org") dir)))
(defun my/org-open-or-capture (title key file-fn)
(let ((file (funcall file-fn title)))
(if (file-exists-p file)
(find-file file)
(let ((my/org-capture-title title))
(org-capture nil key)))))
;; ===== Commands =====
(defun my/org-capture-new-task ()
(interactive)
(let ((title (read-string "Task-Titel: ")))
(my/org-open-or-capture title "n" #'my/org-task-file-from-title)))
(defun my/org-capture-new-doc ()
(interactive)
(let ((title (read-string "Doku-Titel: ")))
(my/org-open-or-capture title "d" #'my/org-doc-file-from-title)))
(defun my/org-capture-new-kpi ()
(interactive)
(let ((title (read-string "KPI-Titel: ")))
(my/org-open-or-capture title "k" #'my/org-doc-file-from-title)))
(defun my/org-capture-new-note ()
(interactive)
(find-file (my/org-today-file))
(when (= (point-max) 1)
(insert
(format "#+title: Notizen %s\n#+category: Notes\n\n"
(format-time-string "%Y-%m-%d"))))
(goto-char (point-max)))
;; ===== Capture Templates =====
(setq org-capture-templates
'(("n" "Neue Task-Datei" plain
(file
(lambda ()
(my/org-task-file-from-title my/org-capture-title)))
"#+title: %(or my/org-capture-title \"\")\n\n* TODO %(or my/org-capture-title \"\")\n\n** Kontext\n%?\n\n** Nächste Schritte\n- [ ] \n\n** Notizen\n"
:unnarrowed t
:jump-to-captured t)
("d" "Neue Doku-Datei" plain
(file
(lambda ()
(my/org-doc-file-from-title my/org-capture-title)))
"#+title: %(or my/org-capture-title \"\")\n#+category: Docs\n\n:PROPERTIES:\n:ART: Analyse\n:END:\n\n* Überblick\n%?\n\n* Details\n\n* Referenzen\n"
:unnarrowed t
:jump-to-captured t)
;; 👉 HIER ist dein KPI-Template
("k" "KPI-Steckbrief" plain
(file
(lambda ()
(my/org-doc-file-from-title my/org-capture-title)))
"#+title: %(or my/org-capture-title \"\")\n#+category: Docs\n\n:PROPERTIES:\n:ART: KPI-Steckbrief\n:VERANTWORTLICH: %^{Verantwortlich}\n:BEREICH: %^{Bereich}\n:END:\n\n* Definition\n%?\n\n* Berechnung\n#+begin_src sql\n\n#+end_src\n\n* Datenquelle\n\n* Interpretation\n\n* Hinweise\n"
:unnarrowed t
:jump-to-captured t)))
;; ===== Agenda =====
(setq org-agenda-files '("~/org/todos/" "~/org/docs/"))
(provide 'init-capture)
;;; init-capture.el ends here

View File

@@ -0,0 +1,8 @@
(provide 'init-capture)
(setq org-capture-templates
'(("t" "Todo" entry
(file "~/org/todo.org")
"* TODO %?\n %U\n")))
(global-set-key (kbd "C-c t") #'org-capture)
(add-hook 'org-capture-mode-hook 'delete-other-windows)

10
lisp/init-keybindings.el Normal file
View File

@@ -0,0 +1,10 @@
;;; init-keybindings.el --- Keybindings -*- lexical-binding: t; -*-
(global-set-key (kbd "C-c t") #'my/org-capture-new-task)
(global-set-key (kbd "C-c d") #'my/org-capture-new-doc)
(global-set-key (kbd "C-c k") #'my/org-capture-new-kpi)
(global-set-key (kbd "C-c n") #'my/org-capture-new-note)
(provide 'init-keybindings)
;;; init-keybindings.el ends here

View File

View File

@@ -51,28 +51,7 @@
(provide 'init-markdown) (provide 'init-markdown)
;; (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)) (define-key markdown-mode-map (kbd "RET") #'markdown-follow-thing-at-point)
(custom-set-faces
;; (add-hook 'markdown-mode-hook #'my/text-indentation-setup) '(markdown-link-face ((t (:foreground "#88c0d0" :underline t))))
;; (add-hook 'markdown-mode-hook #'outline-minor-mode) '(markdown-url-face ((t (:foreground "#81a1c1" :underline t)))))
;; (with-eval-after-load 'markdown-mode
;; (setq markdown-fontify-code-blocks-natively t)
;; (setq markdown-enable-math t)
;; (setq markdown-hide-markup t)
;; ;; Ruhige, org-artige Überschriften für doom-badger
;; (set-face-attribute 'markdown-header-face-1 nil
;; :foreground "#e5e9f0" :weight 'bold :height 1.35)
;; (set-face-attribute 'markdown-header-face-2 nil
;; :foreground "#d8dee9" :weight 'bold :height 1.25)
;; (set-face-attribute 'markdown-header-face-3 nil
;; :foreground "#d8dee9" :weight 'bold :height 1.18)
;; (set-face-attribute 'markdown-header-face-4 nil
;; :foreground "#c0c5ce" :weight 'semi-bold :height 1.12)
;; (set-face-attribute 'markdown-header-face-5 nil
;; :foreground "#c0c5ce" :weight 'semi-bold :height 1.08)
;; (set-face-attribute 'markdown-header-face-6 nil
;; :foreground "#b0b6bf" :weight 'normal :height 1.05))
;; (provide 'init-markdown)

View File

@@ -5,3 +5,5 @@
(add-hook 'org-mode-hook #'org-indent-mode) (add-hook 'org-mode-hook #'org-indent-mode)
(provide 'init-org) (provide 'init-org)
(require 'ox-md)

View File

@@ -10,8 +10,13 @@
(unless package-archive-contents (unless package-archive-contents
(package-refresh-contents)) (package-refresh-contents))
(dolist (pkg '(doom-themes markdown-mode)) (dolist (package '(doom-themes
(unless (package-installed-p pkg) markdown-mode
(package-install pkg))) vertico
consult
orderless
marginalia))
(unless (package-installed-p package)
(package-install package)))
(provide 'init-packages) (provide 'init-packages)

31
lisp/init-search.el Normal file
View File

@@ -0,0 +1,31 @@
;;; init-search.el --- Search and completion setup -*- lexical-binding: t; -*-
;; Vertico: schlanke vertikale Completion UI
(vertico-mode 1)
;; Zusätzliche Infos in der Minibuffer-Auswahl
(marginalia-mode 1)
;; Flexiblere Suchsyntax
(setq completion-styles '(orderless basic)
completion-category-defaults nil
completion-category-overrides '((file (styles basic partial-completion))))
;; Consult-Vorschau etwas verzögert, damit es im Terminal angenehm bleibt
(setq consult-preview-key '(:debounce 0.2 any))
;; Optional: Vorschau ab bestimmter Taste statt immer
;; (setq consult-preview-key "M-.")
;; Ripgrep verwenden
(setq consult-ripgrep-args
"rg --null --line-buffered --color=never --max-columns=300 --path-separator / --smart-case --no-heading --line-number .")
;; Nützliche Keybindings
(global-set-key (kbd "C-c s") #'consult-ripgrep)
(global-set-key (kbd "C-c f") #'consult-line)
(global-set-key (kbd "C-c b") #'consult-buffer)
(global-set-key (kbd "C-c g") #'consult-git-grep)
(provide 'init-search)
;;; init-search.el ends here