diff --git a/bookmarks b/bookmarks new file mode 100644 index 0000000..d43ff19 --- /dev/null +++ b/bookmarks @@ -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)) +) diff --git a/init.el b/init.el index c55cf26..79dc782 100644 --- a/init.el +++ b/init.el @@ -5,11 +5,13 @@ (setq custom-file "~/.emacs.d/custom.el") (load custom-file 'noerror 'nomessage) +(require 'init-keybindings) (require 'init-packages) (require 'init-ui) (require 'init-org) (require 'init-markdown) - +(require 'init-search) +(require 'init-capture) diff --git a/lisp/init-capture.el b/lisp/init-capture.el new file mode 100644 index 0000000..09a8d26 --- /dev/null +++ b/lisp/init-capture.el @@ -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 diff --git a/lisp/init-capture.el.test b/lisp/init-capture.el.test new file mode 100644 index 0000000..214d1f2 --- /dev/null +++ b/lisp/init-capture.el.test @@ -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) diff --git a/lisp/init-keybindings.el b/lisp/init-keybindings.el new file mode 100644 index 0000000..f819ccc --- /dev/null +++ b/lisp/init-keybindings.el @@ -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 diff --git a/lisp/init-keybindings.el~ b/lisp/init-keybindings.el~ new file mode 100644 index 0000000..e69de29 diff --git a/lisp/init-markdown.el b/lisp/init-markdown.el index 6dc39b4..d0fedda 100644 --- a/lisp/init-markdown.el +++ b/lisp/init-markdown.el @@ -51,28 +51,7 @@ (provide 'init-markdown) -;; (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)) - -;; (add-hook 'markdown-mode-hook #'my/text-indentation-setup) -;; (add-hook 'markdown-mode-hook #'outline-minor-mode) - -;; (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) +(define-key markdown-mode-map (kbd "RET") #'markdown-follow-thing-at-point) +(custom-set-faces + '(markdown-link-face ((t (:foreground "#88c0d0" :underline t)))) + '(markdown-url-face ((t (:foreground "#81a1c1" :underline t))))) diff --git a/lisp/init-org.el b/lisp/init-org.el index 5b06901..f274576 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -5,3 +5,5 @@ (add-hook 'org-mode-hook #'org-indent-mode) (provide 'init-org) + +(require 'ox-md) diff --git a/lisp/init-packages.el b/lisp/init-packages.el index 987156f..9310146 100644 --- a/lisp/init-packages.el +++ b/lisp/init-packages.el @@ -10,8 +10,13 @@ (unless package-archive-contents (package-refresh-contents)) -(dolist (pkg '(doom-themes markdown-mode)) - (unless (package-installed-p pkg) - (package-install pkg))) +(dolist (package '(doom-themes + markdown-mode + vertico + consult + orderless + marginalia)) + (unless (package-installed-p package) + (package-install package))) (provide 'init-packages) diff --git a/lisp/init-search.el b/lisp/init-search.el new file mode 100644 index 0000000..288d297 --- /dev/null +++ b/lisp/init-search.el @@ -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