diff --git a/config.org b/config.org index 776953d..ac62f8b 100644 --- a/config.org +++ b/config.org @@ -74,7 +74,72 @@ https://blog.d46.us/advanced-emacs-startup/ ;(setq gc-cons-threshold (* 50 1000 1000)) #+end_src -* Package Management +* Default settings +** paths +#+BEGIN_SRC emacs-lisp +(defconst *sys/gui* + (display-graphic-p) + "Is emacs running in a gui?") + +(defconst *sys/linux* + (string-equal system-type 'gnu/linux) + "Is the system running Linux?") + +(defconst *sys/windows* + (string-equal system-type 'windows-nt) + "Is the system running Windows?") + +(defconst *home_desktop* + (string-equal (system-name) "marc") + "Is emacs running on my desktop?") + +(defconst *home_laptop* + (string-equal (system-name) "laptop") + "Is emacs running on my laptop?") + +(defconst *work_local* + (string-equal (system-name) "PMPCNEU08") + "Is emacs running at work on the local system?") + +(defconst *work_remote* + (or (string-equal (system-name) "PMTS01") + (string-equal (system-name) "PMTSNEU01")) + "Is emacs running at work on the remote system?") +#+END_SRC + +#+BEGIN_SRC emacs-lisp +(defvar MY--PATH_USER_LOCAL (concat user-emacs-directory "user-local/")) +(defvar MY--PATH_USER_GLOBAL (concat user-emacs-directory "user-global/")) + +(add-to-list 'custom-theme-load-path (concat MY--PATH_USER_GLOBAL "themes")) + +(when *sys/linux* + (defconst MY--PATH_ORG_FILES (expand-file-name "~/Archiv/Organisieren/")) + (defconst MY--PATH_ORG_FILES_MOBILE (expand-file-name "~/Archiv/Organisieren/mobile/")) + (defconst MY--PATH_ORG_JOURNAl (expand-file-name "~/Archiv/Organisieren/Journal/")) + (defconst MY--PATH_ORG_ROAM (file-truename "~/Archiv/Organisieren/"))) +(when *work_remote* + (defconst MY--PATH_ORG_FILES "p:/Eigene Dateien/Notizen/") + (defconst MY--PATH_ORG_FILES_MOBILE nil) ;; hacky way to prevent "free variable" compiler error + (defconst MY--PATH_ORG_JOURNAL nil) ;; hacky way to prevent "free variable" compiler error + (defconst MY--PATH_START "p:/Eigene Dateien/Notizen/") + (defconst MY--PATH_ORG_ROAM (expand-file-name "p:/Eigene Dateien/Notizen/"))) + +(setq custom-file (concat MY--PATH_USER_LOCAL "custom.el")) ;; don't spam init.e with saved customization settings +(setq backup-directory-alist `((".*" . ,temporary-file-directory))) +(setq auto-save-file-name-transforms `((".*" ,temporary-file-directory))) +(customize-set-variable 'auth-sources (list (concat MY--PATH_USER_LOCAL "authinfo") + (concat MY--PATH_USER_LOCAL "authinfo.gpg") + (concat MY--PATH_USER_LOCAL "netrc"))) +#+end_src + + +** Browser +#+begin_src emacs-lisp +(setq browse-url-function 'browse-url-generic + browse-url-generic-program "firefox") +#+end_src* Package Management + ** Elpaca Boilerplate for Elpaca #+begin_src emacs-lisp @@ -118,8 +183,10 @@ Boilerplate for Elpaca For Windows it might be necessary to disable symlink creations #+begin_src emacs-lisp -;;(elpaca-no-symlink-mode) +(when *work_remote* + (elpaca-no-symlink-mode)) #+end_src + use-package integration #+begin_src emacs-lisp (elpaca elpaca-use-package @@ -199,6 +266,27 @@ Needs to be loaded before any other package which uses the :general keyword (elpaca-wait) #+END_SRC +* sane defaults +#+begin_src emacs-lisp +(setq-default create-lockfiles nil) ;; disable lock files, can cause trouble in e.g. lsp-mode +(defalias 'yes-or-no-p 'y-or-n-p) ;; answer with y and n +(setq custom-safe-themes t) ;; don't ask me if I want to load a theme +(setq sentence-end-double-space nil) ;; don't coun two spaces after a period as the end of a sentence. +(delete-selection-mode t) ;; delete selected region when typing +(use-package saveplace + :elpaca nil + :config + (save-place-mode 1) ;; saves position in file when it's closed + :custom + (save-place-file (concat MY--PATH_USER_LOCAL "places"))) +(setq save-place-forget-unreadable-files nil) ;; checks if file is readable before saving position +(global-set-key (kbd "RET") 'newline-and-indent) ;; indent after newline +(setq save-interprogram-paste-before-kill t) ;; put replaced text into killring + +;; https://emacs.stackexchange.com/questions/3673/how-to-make-vc-and-magit-treat-a-symbolic-link-to-a-real-file-in-git-repo-just +(setq find-file-visit-truename t) ;; some programs like lsp have trouble following symlinks, maybe vc-follow-symlinks would be enough +#+END_SRC + * Performance Optimization ** Garbage Collection Make startup faster by reducing the frequency of garbage collection. @@ -246,91 +334,7 @@ Restore it to reasonable value after init. Also stop garbage collection during m ;; than the system default. (setq frame-inhibit-implied-resize t) #+end_src -* Default settings -** paths -#+BEGIN_SRC emacs-lisp -(defconst *sys/gui* - (display-graphic-p) - "Is emacs running in a gui?") - -(defconst *sys/linux* - (string-equal system-type 'gnu/linux) - "Is the system running Linux?") - -(defconst *sys/windows* - (string-equal system-type 'windows-nt) - "Is the system running Windows?") - -(defconst *home_desktop* - (string-equal (system-name) "marc") - "Is emacs running on my desktop?") - -(defconst *home_laptop* - (string-equal (system-name) "laptop") - "Is emacs running on my laptop?") - -(defconst *work_local* - (string-equal (system-name) "PMPCNEU08") - "Is emacs running at work on the local system?") - -(defconst *work_remote* - (or (string-equal (system-name) "PMTS01") - (string-equal (system-name) "PMTSNEU01")) - "Is emacs running at work on the remote system?") -#+END_SRC - -#+BEGIN_SRC emacs-lisp -(defvar MY--PATH_USER_LOCAL (concat user-emacs-directory "user-local/")) -(defvar MY--PATH_USER_GLOBAL (concat user-emacs-directory "user-global/")) - -(add-to-list 'custom-theme-load-path (concat MY--PATH_USER_GLOBAL "themes")) - -(when *sys/linux* - (defconst MY--PATH_ORG_FILES (expand-file-name "~/Archiv/Organisieren/")) - (defconst MY--PATH_ORG_FILES_MOBILE (expand-file-name "~/Archiv/Organisieren/mobile/")) - (defconst MY--PATH_ORG_JOURNAl (expand-file-name "~/Archiv/Organisieren/Journal/")) - (defconst MY--PATH_ORG_ROAM (file-truename "~/Archiv/Organisieren/"))) -(when *work_remote* - (defconst MY--PATH_ORG_FILES "p:/Eigene Dateien/Notizen/") - (defconst MY--PATH_ORG_FILES_MOBILE nil) ;; hacky way to prevent "free variable" compiler error - (defconst MY--PATH_ORG_JOURNAL nil) ;; hacky way to prevent "free variable" compiler error - (defconst MY--PATH_START "p:/Eigene Dateien/Notizen/") - (defconst MY--PATH_ORG_ROAM (expand-file-name "p:/Eigene Dateien/Notizen/"))) - -(setq custom-file (concat MY--PATH_USER_LOCAL "custom.el")) ;; don't spam init.e with saved customization settings -(setq backup-directory-alist `((".*" . ,temporary-file-directory))) -(setq auto-save-file-name-transforms `((".*" ,temporary-file-directory))) -(customize-set-variable 'auth-sources (list (concat MY--PATH_USER_LOCAL "authinfo") - (concat MY--PATH_USER_LOCAL "authinfo.gpg") - (concat MY--PATH_USER_LOCAL "netrc"))) -#+end_src -** sane defaults -#+begin_src emacs-lisp -(setq-default create-lockfiles nil) ;; disable lock files, can cause trouble in e.g. lsp-mode -(defalias 'yes-or-no-p 'y-or-n-p) ;; answer with y and n -(setq custom-safe-themes t) ;; don't ask me if I want to load a theme -(setq sentence-end-double-space nil) ;; don't coun two spaces after a period as the end of a sentence. -(delete-selection-mode t) ;; delete selected region when typing -(use-package saveplace - :elpaca nil - :config - (save-place-mode 1) ;; saves position in file when it's closed - :custom - (save-place-file (concat MY--PATH_USER_LOCAL "places"))) -(setq save-place-forget-unreadable-files nil) ;; checks if file is readable before saving position -(global-set-key (kbd "RET") 'newline-and-indent) ;; indent after newline -(setq save-interprogram-paste-before-kill t) ;; put replaced text into killring - -;; https://emacs.stackexchange.com/questions/3673/how-to-make-vc-and-magit-treat-a-symbolic-link-to-a-real-file-in-git-repo-just -(setq find-file-visit-truename t) ;; some programs like lsp have trouble following symlinks, maybe vc-follow-symlinks would be enough -#+END_SRC - -** Browser -#+begin_src emacs-lisp -(setq browse-url-function 'browse-url-generic - browse-url-generic-program "firefox") -#+end_src * Appearance ** Defaults #+begin_src emacs-lisp @@ -1310,7 +1314,11 @@ Bei Problemen wie unique constraint org-roam-db-clear-all org-roam-db-sync #+BEGIN_SRC emacs-lisp - (use-package org-roam +(use-package emacsql-sqlite-builtin + :ensure t) + +(use-package org-roam + :requires emacsql-sqlite-builtin :ensure t :defer 2 :after org @@ -1466,8 +1474,8 @@ If nil it defaults to `split-string-default-separators', normally (org-roam-db-autosync-mode) ;; build the agenda list the first ime for the session (my/org-roam-refresh-agenda-list) - :custom + (org-roam-database-connector 'sqlite-builtin) (org-roam-directory MY--PATH_ORG_ROAM) (org-roam-completion-everywhere t) (org-roam-capture-templates @@ -1480,6 +1488,26 @@ If nil it defaults to `split-string-default-separators', normally :if-new (file+head "ideas/%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n") :unnarrowed t) )) + (when *work_remote* + (org-roam-capture-templates + '(("ß""telephone call" plain + "*** [%<%Y-%m-%d %H:%M>] ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n" + :target (file+olp "p:/Eigene Dateien/Notizen/phone_calls.org" + ("2023" "11"))) + ("x" "telephone call" plain + "%?" + :target (file+head "telephone/%<%Y%m%d%H%M>-${slug}.org" "#+title: CALL %<%Y-%m-%d %H:%M> ${title}\n") + :unnarrowed t) + ("p" "project" plain + "%?" + :target (file+head "projects/${slug}.org" "#+title: ${title}\n#+filetags: :project:\n") + :unnarrowed t) + ("s" "Sicherheitenmeldung" plain + "*** TODO [#A] Sicherheitenmeldung ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n%u\n" + :target (file+olp "tasks.org" ("Todos" "Sicherheitenmeldungen"))) + ("m" "Monatsbericht" plain + "*** TODO [#A] Monatsbericht ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n%u\n" + :target (file+olp "tasks.org" ("Todos" "Monatsberichte")))))) :bind (("C-c n l" . org-roam-buffer-toggle) ("C-c n f" . org-roam-node-find) ("C-c n i" . org-roam-node-insert) @@ -1491,42 +1519,6 @@ If nil it defaults to `split-string-default-separators', normally :bind-keymap ("C-c n d" . org-roam-dailies-map)) -(when *sys/windows* - (use-package emacsql-sqlite3 - :ensure t - :init - (setq emacsql-sqlite3-binary "P:/Tools/sqlite/sqlite3.exe" - exec-path (append exec-path '("P:/Tools/sqlite")))) - - (use-package org-roam - :requires emacsql-sqlite3 - :init - :config - (add-to-list 'org-roam-capture-templates - '("ß""telephone call" plain - "*** [%<%Y-%m-%d %H:%M>] ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n" - :target (file+olp "p:/Eigene Dateien/Notizen/phone_calls.org" - ("2023" "11")))) - (add-to-list 'org-roam-capture-templates - '("x" "telephone call" plain - "%?" - :target (file+head "telephone/%<%Y%m%d%H%M>-${slug}.org" "#+title: CALL %<%Y-%m-%d %H:%M> ${title}\n") - :unnarrowed t) t) - (add-to-list 'org-roam-capture-templates - '("p" "project" plain - "%?" - :target (file+head "projects/${slug}.org" "#+title: ${title}\n#+filetags: :project:\n") - :unnarrowed t) t) - (add-to-list 'org-roam-capture-templates - '("s" "Sicherheitenmeldung" plain - "*** TODO [#A] Sicherheitenmeldung ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n%u\n" - :target (file+olp "tasks.org" ("Todos" "Sicherheitenmeldungen"))) t) - (add-to-list 'org-roam-capture-templates - '("m" "Monatsbericht" plain - "*** TODO [#A] Monatsbericht ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n%u\n" - :target (file+olp "tasks.org" ("Todos" "Monatsberichte"))) t) - :custom - (org-roam-database-connector 'sqlite3))) #+END_SRC *** TODO Verzeichnis außerhalb roam zum Archivieren (u.a. für erledigte Monatsmeldungen etc.)