You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1831 lines
56 KiB

5 years ago
2 years ago
3 years ago
3 years ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
6 years ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
1 year ago
9 months ago
9 months ago
9 months ago
6 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
1 year ago
9 months ago
9 months ago
2 years ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
6 years ago
9 months ago
9 months ago
9 months ago
6 years ago
9 months ago
6 years ago
6 years ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
1 year ago
1 year ago
  1. #+TITLE: Emacs configuration file
  2. #+AUTHOR: Marc
  3. #+BABEL: :cache yes
  4. #+PROPERTY: header-args :tangle init.el
  5. #+OPTIONS: ^:nil
  6. * TODOS
  7. - early-init.el? What to outsource here?
  8. - Paket exec-path-from-shell, um PATH aus Linux auch in emacs zu haben
  9. - Smart mode line?
  10. - Theme
  11. - flymake instead of flycheck?
  12. - Hydra
  13. - General
  14. - (defalias 'list-buffers 'ibuffer) ;; change default to ibuffer
  15. - ido?
  16. - treemacs (for linux)
  17. windmove?
  18. - tramp (in linux)
  19. - visual-regexp
  20. - org configuration: paths
  21. - org custom agenda
  22. - org-ql (related to org agendas)
  23. - org configuration: everything else
  24. - beancount configuration from config.org
  25. - CONTINUE TODO from config.org at Programming
  26. - all-the-icons?
  27. - lispy? [[https://github.com/abo-abo/lispy]]
  28. * Header
  29. Emacs variables are dynamically scoped. That's unusual for most languages, so disable it here, too
  30. #+begin_src emacs-lisp
  31. ;;; init.el --- -*- lexical-binding: t -*-
  32. #+end_src
  33. * First start
  34. These functions updates config.el whenever changes in config.org are made. The update will be active after saving.
  35. #+BEGIN_SRC emacs-lisp
  36. (defun my/tangle-config ()
  37. "Export code blocks from the literate config file."
  38. (interactive)
  39. ;; prevent emacs from killing until tangle-process has finished
  40. (add-to-list 'kill-emacs-query-functions
  41. (lambda ()
  42. (or (not (process-live-p (get-process "tangle-process")))
  43. (y-or-n-p "\"my/tangle-config\" is running; kill it? "))))
  44. (org-babel-tangle-file config-org init-el)
  45. (message "reloading user-init-file")
  46. (load-file init-el))
  47. (add-hook 'org-mode-hook
  48. (lambda ()
  49. (if (equal (buffer-file-name) config-org)
  50. (my--add-local-hook 'after-save-hook 'my/tangle-config))))
  51. (defun my--add-local-hook (hook function)
  52. "Add buffer-local hook."
  53. (add-hook hook function :local t))
  54. #+END_SRC
  55. A small function to measure start up time.
  56. Compare that to
  57. emacs -q --eval='(message "%s" (emacs-init-time))'
  58. (roughly 0.27s)
  59. https://blog.d46.us/advanced-emacs-startup/
  60. #+begin_src emacs-lisp
  61. (add-hook 'emacs-startup-hook
  62. (lambda ()
  63. (message "Emacs ready in %s with %d garbage collections."
  64. (format "%.2f seconds"
  65. (float-time
  66. (time-subtract after-init-time before-init-time)))
  67. gcs-done)))
  68. ;(setq gc-cons-threshold (* 50 1000 1000))
  69. #+end_src
  70. * Default settings
  71. ** paths
  72. #+BEGIN_SRC emacs-lisp
  73. (defconst *sys/gui*
  74. (display-graphic-p)
  75. "Is emacs running in a gui?")
  76. (defconst *sys/linux*
  77. (string-equal system-type 'gnu/linux)
  78. "Is the system running Linux?")
  79. (defconst *sys/windows*
  80. (string-equal system-type 'windows-nt)
  81. "Is the system running Windows?")
  82. (defconst *home_desktop*
  83. (string-equal (system-name) "marc")
  84. "Is emacs running on my desktop?")
  85. (defconst *home_laptop*
  86. (string-equal (system-name) "laptop")
  87. "Is emacs running on my laptop?")
  88. (defconst *work_local*
  89. (string-equal (system-name) "PMPCNEU08")
  90. "Is emacs running at work on the local system?")
  91. (defconst *work_remote*
  92. (or (string-equal (system-name) "PMTS01")
  93. (string-equal (system-name) "PMTSNEU01"))
  94. "Is emacs running at work on the remote system?")
  95. #+END_SRC
  96. #+BEGIN_SRC emacs-lisp
  97. (defvar MY--PATH_USER_LOCAL (concat user-emacs-directory "user-local/"))
  98. (defvar MY--PATH_USER_GLOBAL (concat user-emacs-directory "user-global/"))
  99. (add-to-list 'custom-theme-load-path (concat MY--PATH_USER_GLOBAL "themes"))
  100. (when *sys/linux*
  101. (defconst MY--PATH_ORG_FILES (expand-file-name "~/Archiv/Organisieren/"))
  102. (defconst MY--PATH_ORG_FILES_MOBILE (expand-file-name "~/Archiv/Organisieren/mobile/"))
  103. (defconst MY--PATH_ORG_JOURNAl (expand-file-name "~/Archiv/Organisieren/Journal/"))
  104. (defconst MY--PATH_ORG_ROAM (file-truename "~/Archiv/Organisieren/")))
  105. (when *work_remote*
  106. (defconst MY--PATH_ORG_FILES "p:/Eigene Dateien/Notizen/")
  107. (defconst MY--PATH_ORG_FILES_MOBILE nil) ;; hacky way to prevent "free variable" compiler error
  108. (defconst MY--PATH_ORG_JOURNAL nil) ;; hacky way to prevent "free variable" compiler error
  109. (defconst MY--PATH_START "p:/Eigene Dateien/Notizen/")
  110. (defconst MY--PATH_ORG_ROAM (expand-file-name "p:/Eigene Dateien/Notizen/")))
  111. (setq custom-file (concat MY--PATH_USER_LOCAL "custom.el")) ;; don't spam init.e with saved customization settings
  112. (setq backup-directory-alist `((".*" . ,temporary-file-directory)))
  113. (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory)))
  114. (customize-set-variable 'auth-sources (list (concat MY--PATH_USER_LOCAL "authinfo")
  115. (concat MY--PATH_USER_LOCAL "authinfo.gpg")
  116. (concat MY--PATH_USER_LOCAL "netrc")))
  117. #+end_src
  118. ** Browser
  119. #+begin_src emacs-lisp
  120. (setq browse-url-function 'browse-url-generic
  121. browse-url-generic-program "firefox")
  122. #+end_src* Package Management
  123. ** Elpaca
  124. Boilerplate for Elpaca
  125. #+begin_src emacs-lisp
  126. (defvar elpaca-installer-version 0.7)
  127. (defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
  128. (defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
  129. (defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory))
  130. (defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
  131. :ref nil :depth 1
  132. :files (:defaults "elpaca-test.el" (:exclude "extensions"))
  133. :build (:not elpaca--activate-package)))
  134. (let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory))
  135. (build (expand-file-name "elpaca/" elpaca-builds-directory))
  136. (order (cdr elpaca-order))
  137. (default-directory repo))
  138. (add-to-list 'load-path (if (file-exists-p build) build repo))
  139. (unless (file-exists-p repo)
  140. (make-directory repo t)
  141. (when (< emacs-major-version 28) (require 'subr-x))
  142. (condition-case-unless-debug err
  143. (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
  144. ((zerop (apply #'call-process `("git" nil ,buffer t "clone"
  145. ,@(when-let ((depth (plist-get order :depth)))
  146. (list (format "--depth=%d" depth) "--no-single-branch"))
  147. ,(plist-get order :repo) ,repo))))
  148. ((zerop (call-process "git" nil buffer t "checkout"
  149. (or (plist-get order :ref) "--"))))
  150. (emacs (concat invocation-directory invocation-name))
  151. ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
  152. "--eval" "(byte-recompile-directory \".\" 0 'force)")))
  153. ((require 'elpaca))
  154. ((elpaca-generate-autoloads "elpaca" repo)))
  155. (progn (message "%s" (buffer-string)) (kill-buffer buffer))
  156. (error "%s" (with-current-buffer buffer (buffer-string))))
  157. ((error) (warn "%s" err) (delete-directory repo 'recursive))))
  158. (unless (require 'elpaca-autoloads nil t)
  159. (require 'elpaca)
  160. (elpaca-generate-autoloads "elpaca" repo)
  161. (load "./elpaca-autoloads")))
  162. (add-hook 'after-init-hook #'elpaca-process-queues)
  163. (elpaca `(,@elpaca-order))
  164. ;(setq use-package-always-ensure t)
  165. (elpaca elpaca-use-package
  166. ;; enable use-package :ensure support for elpaca
  167. (elpaca-use-package-mode))
  168. (elpaca-wait)
  169. #+end_src
  170. For Windows it might be necessary to disable symlink creations
  171. #+begin_src emacs-lisp
  172. (when *work_remote*
  173. (elpaca-no-symlink-mode))
  174. #+end_src
  175. * use-package keywords general / diminish
  176. Needs to be loaded before any other package which uses the :general keyword
  177. #+BEGIN_SRC emacs-lisp
  178. (use-package general
  179. :ensure t
  180. :demand t)
  181. (use-package diminish
  182. :ensure t
  183. :demand t)
  184. ;;wait for elpaca any time a use-package keyword is added
  185. (elpaca-wait)
  186. #+END_SRC
  187. * sane defaults
  188. #+begin_src emacs-lisp
  189. (setq-default create-lockfiles nil) ;; disable lock files, can cause trouble in e.g. lsp-mode
  190. (defalias 'yes-or-no-p 'y-or-n-p) ;; answer with y and n
  191. (setq custom-safe-themes t) ;; don't ask me if I want to load a theme
  192. (setq sentence-end-double-space nil) ;; don't coun two spaces after a period as the end of a sentence.
  193. (delete-selection-mode t) ;; delete selected region when typing
  194. (use-package saveplace
  195. :ensure nil
  196. :config
  197. (save-place-mode 1) ;; saves position in file when it's closed
  198. :custom
  199. (save-place-file (concat MY--PATH_USER_LOCAL "places")))
  200. (setq save-place-forget-unreadable-files nil) ;; checks if file is readable before saving position
  201. (global-set-key (kbd "RET") 'newline-and-indent) ;; indent after newline
  202. (setq save-interprogram-paste-before-kill t) ;; put replaced text into killring
  203. ;; https://emacs.stackexchange.com/questions/3673/how-to-make-vc-and-magit-treat-a-symbolic-link-to-a-real-file-in-git-repo-just
  204. (setq find-file-visit-truename t) ;; some programs like lsp have trouble following symlinks, maybe vc-follow-symlinks would be enough
  205. #+END_SRC
  206. * Performance Optimization
  207. ** Garbage Collection
  208. Make startup faster by reducing the frequency of garbage collection.
  209. Set gc-cons-threshold (default is 800kb) to maximum value available, to prevent any garbage collection from happening during load time.
  210. #+BEGIN_SRC emacs-lisp :tangle early-init.el
  211. (setq gc-cons-threshold most-positive-fixnum)
  212. #+END_SRC
  213. Restore it to reasonable value after init. Also stop garbage collection during minibuffer interaction (helm etc.)
  214. #+begin_src emacs-lisp
  215. (defconst 1mb 1048576)
  216. (defconst 20mb 20971520)
  217. (defconst 30mb 31457280)
  218. (defconst 50mb 52428800)
  219. (defun my--defer-garbage-collection ()
  220. (setq gc-cons-threshold most-positive-fixnum))
  221. (defun my--restore-garbage-collection ()
  222. (run-at-time 1 nil (lambda () (setq gc-cons-threshold 30mb))))
  223. (add-hook 'emacs-startup-hook 'my--restore-garbage-collection 100)
  224. (add-hook 'minibuffer-setup-hook 'my--defer-garbage-collection)
  225. (add-hook 'minibuffer-exit-hook 'my--restore-garbage-collection)
  226. (setq read-process-output-max 1mb) ;; lsp-mode's performance suggest
  227. #+end_src
  228. ** File Handler
  229. #+begin_src emacs-lisp :tangle early-init.el
  230. (defvar default-file-name-handler-alist file-name-handler-alist)
  231. (setq file-name-handler-alist nil)
  232. (add-hook 'emacs-startup-hook
  233. (lambda ()
  234. (setq file-name-handler-alist default-file-name-handler-alist)) 100)
  235. #+end_src
  236. ** Others
  237. #+begin_src emacs-lisp :tangle early-init.el
  238. ;; Resizing the emacs frame can be a terriblu expensive part of changing the font.
  239. ;; By inhibiting this, we easily hale startup times with fonts that are larger
  240. ;; than the system default.
  241. (setq package-enable-at-startup nil)
  242. (setq frame-inhibit-implied-resize t)
  243. #+end_src
  244. * Appearance
  245. ** Defaults
  246. #+begin_src emacs-lisp
  247. (set-charset-priority 'unicode)
  248. (setq-default locale-coding-system 'utf-8
  249. default-process-coding-system '(utf-8-unix . utf-8-unix))
  250. (set-terminal-coding-system 'utf-8)
  251. (set-keyboard-coding-system 'utf-8)
  252. (set-selection-coding-system 'utf-8)
  253. (if *sys/windows*
  254. (prefer-coding-system 'utf-8-dos)
  255. (prefer-coding-system 'utf-8))
  256. (setq-default bidi-paragraph-direction 'left-to-right
  257. bidi-inhibit-bpa t ;; both settings reduce line rescans
  258. uniquify-buffer-name-style 'forward
  259. indent-tabs-mode nil ;; avoid tabs in place of multiple spaces (they look bad in tex)
  260. indicate-empty-lines t ;; show empty lines
  261. scroll-margin 5 ;; smooth scrolling
  262. scroll-conservatively 10000
  263. scroll-preserve-screen-position 1
  264. scroll-step 1
  265. ring-bell-function 'ignore ;; disable pc speaker bell
  266. visible-bell t)
  267. (global-hl-line-mode t) ;; highlight current line
  268. (blink-cursor-mode -1) ;; turn off blinking cursor
  269. (column-number-mode t)
  270. #+end_src
  271. ** Remove redundant UI
  272. #+begin_src emacs-lisp :tangle early-init.el
  273. (menu-bar-mode -1) ;; disable menu bar
  274. (tool-bar-mode -1) ;; disable tool bar
  275. (scroll-bar-mode -1) ;; disable scroll bar
  276. #+end_src
  277. ** Font
  278. #+BEGIN_SRC emacs-lisp
  279. (when *sys/linux*
  280. (set-face-font 'default "Hack-10"))
  281. (when *work_remote*
  282. (set-face-font 'default "Lucida Sans Typewriter-11"))
  283. #+END_SRC
  284. ** Themes
  285. #+BEGIN_SRC emacs-lisp
  286. (defun my/toggle-theme ()
  287. (interactive)
  288. (when (or *sys/windows* *sys/linux*)
  289. (if (eq (car custom-enabled-themes) 'tango-dark)
  290. (progn (disable-theme 'tango-dark)
  291. (load-theme 'tango))
  292. (progn
  293. (disable-theme 'tango)
  294. (load-theme 'tango-dark)))))
  295. (bind-key "C-c t" 'my/toggle-theme)
  296. #+END_SRC
  297. Windows Theme:
  298. #+BEGIN_SRC emacs-lisp
  299. (when *sys/windows*
  300. (load-theme 'tango))
  301. (when *sys/linux*
  302. (load-theme 'plastic))
  303. #+END_SRC
  304. ** line wrappings
  305. #+BEGIN_SRC emacs-lisp
  306. (global-visual-line-mode)
  307. ;(diminish 'visual-line-mode)
  308. (use-package adaptive-wrap
  309. :ensure t
  310. :hook
  311. (visual-line-mode . adaptive-wrap-prefix-mode))
  312. ; :init
  313. ; (when (fboundp 'adaptive-wrap-prefix-mode)
  314. ; (defun me/activate-adaptive-wrap-prefix-mode ()
  315. ; "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously."
  316. ; (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1)))
  317. ; (add-hook 'visual-line-mode-hook 'me/activate-adaptive-wrap-prefix-mode)))
  318. #+END_SRC
  319. ** line numbers
  320. #+BEGIN_SRC emacs-lisp
  321. (use-package display-line-numbers
  322. :ensure nil
  323. :init
  324. :hook
  325. ((prog-mode
  326. org-src-mode) . display-line-numbers-mode)
  327. :config
  328. (setq-default display-line-numbers-type 'visual
  329. display-line-numbers-current-absolute t
  330. display-line-numbers-with 4
  331. display-line-numbers-widen t))
  332. #+END_SRC
  333. ** misc
  334. Delight can replace mode names with custom names ,
  335. e.g. python-mode with just "π ".
  336. #+BEGIN_SRC emacs-lisp
  337. (use-package rainbow-mode
  338. :ensure t
  339. :diminish
  340. :hook
  341. ((org-mode
  342. emacs-lisp-mode) . rainbow-mode))
  343. (use-package delight
  344. :if *sys/linux*
  345. :ensure t)
  346. (show-paren-mode t) ;; show other part of brackets
  347. (setq blink-matching-paren nil) ;; not necessary with show-paren-mode, bugs out on C-s counsel-line
  348. (use-package rainbow-delimiters
  349. :ensure t
  350. :hook
  351. (prog-mode . rainbow-delimiters-mode))
  352. #+END_SRC
  353. * Bookmarks
  354. Usage:
  355. - C-x r m (bookmark-set): add bookmark
  356. - C-x r l (list-bookmark): list bookmarks
  357. - C-x r b (bookmark-jump): open bookmark
  358. Edit bookmarks (while in bookmark file):
  359. - d: mark current item
  360. - x: delete marked items
  361. - r: rename current item
  362. - s: save changes
  363. #+begin_src emacs-lisp
  364. (use-package bookmark
  365. :ensure nil
  366. :custom
  367. (bookmark-default-file (concat MY--PATH_USER_LOCAL "bookmarks")))
  368. #+end_src
  369. Some windows specific stuff
  370. #+BEGIN_SRC emacs-lisp
  371. (when *sys/windows*
  372. (remove-hook 'find-file-hook 'vc-refresh-state)
  373. ; (progn
  374. ; (setq gc-cons-threshold (* 511 1024 1024)
  375. ; gc-cons-percentage 0.5
  376. ; garbage-collection-messages t
  377. ; (run-with-idle-timer 5 t #'garbage-collect))
  378. (when (boundp 'w32-pipe-read-delay)
  379. (setq w32-pipe-read-delay 0))
  380. (when (boundp 'w32-get-true-file-attributes)
  381. (setq w32-get-true-file-attributes nil)))
  382. #+END_SRC
  383. * recentf
  384. Exclude some dirs from spamming recentf
  385. #+begin_src emacs-lisp
  386. (use-package recentf
  387. :ensure nil
  388. ; :defer 1
  389. :config
  390. (recentf-mode)
  391. :custom
  392. (recentf-exclude '(".*-autoloads\\.el\\'"
  393. "[/\\]\\elpa/"
  394. "COMMIT_EDITMSG\\'"))
  395. (recentf-save-file (concat MY--PATH_USER_LOCAL "recentf"))
  396. (recentf-max-menu-items 600)
  397. (recentf-max-saved-items 600))
  398. #+end_src
  399. * savehist
  400. #+begin_src emacs-lisp
  401. (use-package savehist
  402. :ensure nil
  403. :config
  404. (savehist-mode)
  405. :custom
  406. (savehist-file (concat MY--PATH_USER_LOCAL "history")))
  407. #+end_src
  408. * undo
  409. #+BEGIN_SRC emacs-lisp
  410. (use-package undo-tree
  411. :ensure t
  412. :diminish undo-tree-mode
  413. :init
  414. (global-undo-tree-mode 1)
  415. :custom
  416. (undo-tree-auto-save-history nil))
  417. #+END_SRC
  418. * COMMENT ace-window (now avy)
  419. #+begin_src emacs-lisp
  420. (use-package ace-window
  421. :ensure t
  422. :bind
  423. (:map global-map
  424. ("C-x o" . ace-window)))
  425. #+end_src
  426. * which-key
  427. #+BEGIN_SRC emacs-lisp
  428. (use-package which-key
  429. :ensure t
  430. :diminish which-key-mode
  431. :defer t
  432. :hook
  433. (after-init . which-key-mode)
  434. :custom
  435. (which-key-idle-delay 0.5)
  436. (which-key-sort-order 'which-key-description-order)
  437. :config
  438. (which-key-setup-side-window-bottom))
  439. #+END_SRC
  440. * abbrev
  441. #+begin_src emacs-lisp
  442. (use-package abbrev
  443. :ensure nil
  444. :diminish abbrev-mode
  445. :hook
  446. ((text-mode org-mode) . abbrev-mode)
  447. :init
  448. (setq abbrev-file-name (concat MY--PATH_USER_GLOBAL "abbrev_tables.el"))
  449. :config
  450. (if (file-exists-p abbrev-file-name)
  451. (quietly-read-abbrev-file))
  452. (setq save-abbrevs 'silently)) ;; don't bother me with asking for abbrev saving
  453. #+end_src
  454. * imenu-list
  455. A minor mode to show imenu in a sidebar.
  456. Call imenu-list-smart-toggle.
  457. [[https://github.com/bmag/imenu-list][Source]]
  458. #+BEGIN_SRC emacs-lisp
  459. (use-package imenu-list
  460. :ensure t
  461. :demand t ; otherwise mode loads too late and won't work on first file it's being activated on
  462. :config
  463. (setq imenu-list-focus-after-activation t
  464. imenu-list-auto-resize t
  465. imenu-list-position 'right)
  466. :general
  467. ([f9] 'imenu-list-smart-toggle)
  468. (:states '(normal insert)
  469. :keymaps 'imenu-list-major-mode-map
  470. "RET" '(imenu-list-goto-entry :which-key "goto")
  471. "TAB" '(hs-toggle-hiding :which-key "collapse")
  472. "v" '(imenu-list-display-entry :which-key "show") ; also prevents visual mode
  473. "q" '(imenu-list-quit-window :which-key "quit"))
  474. :custom
  475. (org-imenu-depth 4))
  476. #+END_SRC
  477. * COMMENT Evil
  478. See also
  479. https://github.com/noctuid/evil-guide
  480. Use C-z (evil-toggle-key) to switch between evil and emacs keybindings,
  481. in case evil is messing something up.
  482. #+BEGIN_SRC emacs-lisp
  483. (use-package evil
  484. :ensure t
  485. :defer .1
  486. :custom
  487. (evil-want-C-i-jump nil) ;; prevent evil from blocking TAB in org tree expanding
  488. (evil-want-integration t)
  489. (evil-want-keybinding nil)
  490. :config
  491. ;; example for using emacs default key map in a certain mode
  492. ;; (evil-set-initial-state 'dired-mode 'emacs)
  493. (evil-mode 1))
  494. #+END_SRC
  495. * Eldoc
  496. use builtin version
  497. #+begin_src emacs-lisp
  498. (use-package eldoc
  499. :ensure nil
  500. :diminish eldoc-mode
  501. :defer t)
  502. #+end_src
  503. * COMMENT Eldoc Box
  504. Currently corfu-popupinfo displays eldoc in highlighted completion candidate. Maybe that's good enough.
  505. #+begin_src emacs-lisp
  506. (use-package eldoc-box
  507. :ensure t)
  508. #+end_src
  509. * Meow
  510. #+begin_src emacs-lisp
  511. (use-package meow
  512. :ensure t
  513. :config
  514. (setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty)
  515. (meow-motion-overwrite-define-key
  516. '("j" . meow-next)
  517. '("k" . meow-prev)
  518. '("<escape>" . ignore))
  519. (meow-leader-define-key
  520. ;; SPC j/k will run the original command in MOTION state.
  521. '("j" . "H-j")
  522. '("k" . "H-k")
  523. ;; Use SPC (0-9) for digit arguments.
  524. '("1" . meow-digit-argument)
  525. '("2" . meow-digit-argument)
  526. '("3" . meow-digit-argument)
  527. '("4" . meow-digit-argument)
  528. '("5" . meow-digit-argument)
  529. '("6" . meow-digit-argument)
  530. '("7" . meow-digit-argument)
  531. '("8" . meow-digit-argument)
  532. '("9" . meow-digit-argument)
  533. '("0" . meow-digit-argument)
  534. '("/" . meow-keypad-describe-key)
  535. '("?" . meow-cheatsheet))
  536. (meow-normal-define-key
  537. '("0" . meow-expand-0)
  538. '("9" . meow-expand-9)
  539. '("8" . meow-expand-8)
  540. '("7" . meow-expand-7)
  541. '("6" . meow-expand-6)
  542. '("5" . meow-expand-5)
  543. '("4" . meow-expand-4)
  544. '("3" . meow-expand-3)
  545. '("2" . meow-expand-2)
  546. '("1" . meow-expand-1)
  547. '("-" . negative-argument)
  548. '(";" . meow-reverse)
  549. '("," . meow-inner-of-thing)
  550. '("." . meow-bounds-of-thing)
  551. '("[" . meow-beginning-of-thing)
  552. '("]" . meow-end-of-thing)
  553. '("a" . meow-append)
  554. '("A" . meow-open-below)
  555. '("b" . meow-back-word)
  556. '("B" . meow-back-symbol)
  557. '("c" . meow-change)
  558. '("d" . meow-delete)
  559. '("D" . meow-backward-delete)
  560. '("e" . meow-next-word)
  561. '("E" . meow-next-symbol)
  562. '("f" . meow-find)
  563. '("g" . meow-cancel-selection)
  564. '("G" . meow-grab)
  565. '("h" . meow-left)
  566. '("H" . meow-left-expand)
  567. '("i" . meow-insert)
  568. '("I" . meow-open-above)
  569. '("j" . meow-next)
  570. '("J" . meow-next-expand)
  571. '("k" . meow-prev)
  572. '("K" . meow-prev-expand)
  573. '("l" . meow-right)
  574. '("L" . meow-right-expand)
  575. '("m" . meow-join)
  576. '("n" . meow-search)
  577. '("o" . meow-block)
  578. '("O" . meow-to-block)
  579. '("p" . meow-yank)
  580. '("q" . meow-quit)
  581. '("Q" . meow-goto-line)
  582. '("r" . meow-replace)
  583. '("R" . meow-swap-grab)
  584. '("s" . meow-kill)
  585. '("t" . meow-till)
  586. '("u" . meow-undo)
  587. '("U" . meow-undo-in-selection)
  588. '("v" . meow-visit)
  589. '("w" . meow-mark-word)
  590. '("W" . meow-mark-symbol)
  591. '("x" . meow-line)
  592. '("X" . meow-goto-line)
  593. '("y" . meow-save)
  594. '("Y" . meow-sync-grab)
  595. '("z" . meow-pop-selection)
  596. '("'" . repeat)
  597. '("<escape>" . ignore))
  598. ; :config
  599. (meow-global-mode t))
  600. #+end_src
  601. * avy
  602. Search, move, copy, delete text within all visible buffers.
  603. Also replaces ace-window for buffer switching.
  604. [[https://github.com/abo-abo/avy]]
  605. #+BEGIN_SRC emacs-lisp
  606. (use-package avy
  607. :ensure t
  608. :general
  609. (:prefix "M-s"
  610. "" '(:ignore t :which-key "avy")
  611. "w" '(avy-goto-char-2 :which-key "avy-jump")
  612. "c" '(:ignore t :which-key "avy copy")
  613. "c l" '(avy-copy-line :which-key "avy copy line")
  614. "c r" '(avy-copy-region :which-key "avy copy region")
  615. "m" '(:ignore t :which-key "avy move")
  616. "m l" '(avy-move-line :which-key "avy move line")
  617. "m r" '(avy-move-region :which-key "avy move region")))
  618. #+END_SRC
  619. * Vertico
  620. Vertico is a completion ui for the minibuffer and replaced selectrum.
  621. [[https://github.com/minad/vertico][Vertico Github]]
  622. #+begin_src emacs-lisp
  623. ;; completion ui
  624. (use-package vertico
  625. :ensure t
  626. :init
  627. (vertico-mode))
  628. #+end_src
  629. * Corfu
  630. Completion ui, replaces company.
  631. [[https://github.com/minad/corfu][Corfu Github]]
  632. #+begin_src emacs-lisp
  633. (use-package corfu
  634. :ensure t
  635. :after savehist
  636. :custom
  637. (corfu-popupinfo-delay t)
  638. (corfu-auto t)
  639. (corfu-cycle t)
  640. (corfu-auto-delay 0.3)
  641. (corfu-preselect-first nil)
  642. (corfu-popupinfo-delay '(1.0 . 0.0)) ;1s for first popup, instant for subsequent popups
  643. (corfu-popupinfo-max-width 70)
  644. (corfu-popupinfo-max-height 20)
  645. :init
  646. (global-corfu-mode)
  647. ; (corfu-popupinfo-mode) ; causes corfu window to stay
  648. (corfu-history-mode)
  649. ;; belongs to emacs
  650. (add-to-list 'savehist-additional-variables 'corfu-history)
  651. :hook
  652. (corfu-mode . corfu-popupinfo-mode))
  653. ; :bind
  654. ; (:map corfu-map
  655. ; ("TAB" . corfu-next)
  656. ; ("<C-return>" . corfu-insert)
  657. ; ("C-TAB" . corfu-popupinfo-toggle)))
  658. ;; (general-define-key
  659. ;; :states 'insert
  660. ;; :definer 'minor-mode
  661. ;; :keymaps 'completion-in-region-mode
  662. ;; :predicate 'corfu-mode
  663. ;; "C-d" 'corfu-info-documentation)
  664. (use-package emacs
  665. :ensure nil
  666. :init
  667. ;; hide commands in M-x which do not apply to current mode
  668. (setq read-extended-command-predicate #'command-completion-default-include-p)
  669. ;; enable indentation + completion using TAB
  670. (setq tab-always-indent 'complete))
  671. #+end_src
  672. * Cape
  673. Adds completions for corfu
  674. [[https://github.com/minad/cape][Cape Github]]
  675. Available functions:
  676. dabbrev, file, history, keyword, tex, sgml, rfc1345, abbrev, ispell, dict, symbol, line
  677. #+begin_src emacs-lisp
  678. (use-package cape
  679. :ensure t
  680. :bind
  681. (("C-c p p" . completion-at-point) ;; capf
  682. ("C-c p t" . complete-tag) ;; etags
  683. ("C-c p d" . cape-dabbrev)
  684. ("C-c p h" . cape-history)
  685. ("C-c p f" . cape-file))
  686. :init
  687. (advice-add #'lsp-completion-at-point :around #'cape-wrap-noninterruptible) ;; for performance issues with lsp
  688. (add-to-list 'completion-at-point-functions #'cape-dabbrev)
  689. (add-to-list 'completion-at-point-functions #'cape-file)
  690. (add-to-list 'completion-at-point-functions #'cape-history))
  691. #+end_src
  692. * kind-icon
  693. Make corfu pretty
  694. [[https://github.com/jdtsmith/kind-icon][kind-icon Github]]
  695. #+begin_src emacs-lisp
  696. (use-package kind-icon
  697. :ensure t
  698. :after corfu
  699. :custom
  700. (kind-icon-default-face 'corfu-default) ;; to compute blended backgrounds correctly
  701. :config
  702. (add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))
  703. #+end_src
  704. * Orderless
  705. [[https://github.com/oantolin/orderless][Orderless Github]]
  706. Orderless orders the suggestions by recency. The package prescient orders by frequency.
  707. #+begin_src emacs-lisp
  708. (use-package orderless
  709. :ensure t
  710. :init
  711. (setq completion-styles '(orderless partial-completion basic)
  712. completion-category-defaults nil
  713. completion-category-overrides nil))
  714. ; completion-category-overrides '((file (styles partial-completion)))))
  715. #+end_src
  716. * Consult
  717. [[https://github.com/minad/consult][Github]]
  718. #+begin_src emacs-lisp
  719. (use-package consult
  720. :ensure t
  721. :bind
  722. (("C-x C-r" . consult-recent-file)
  723. ("C-x b" . consult-buffer)
  724. ("C-s" . consult-line))
  725. :config
  726. ;; disable preview for some commands and buffers
  727. ;; and enable it by M-.
  728. ;; see https://github.com/minad/consult#use-package-example
  729. (consult-customize
  730. consult-theme
  731. :preview-key '(debounce 0.2 any)
  732. consult-ripgrep consult-git-grep consult-grep
  733. consult-bookmark consult-recent-file consult-xref
  734. consult--source-bookmark consult--source-file-register
  735. consult--source-recent-file consult--source-project-recent-file
  736. :preview-key "M-."))
  737. #+end_src
  738. * Marginalia
  739. [[https://github.com/minad/marginalia/][Github]]
  740. Adds additional information to the minibuffer
  741. #+begin_src emacs-lisp
  742. (use-package marginalia
  743. :ensure t
  744. :init
  745. (marginalia-mode)
  746. :bind
  747. (:map minibuffer-local-map
  748. ("M-A" . marginalia-cycle))
  749. :custom
  750. ;; switch by 'marginalia-cycle
  751. (marginalia-annotators '(marginalia-annotators-heavy
  752. marginalia-annotators-light
  753. nil)))
  754. #+end_src
  755. * Embark
  756. Does stuff in the minibuffer results
  757. #+begin_src emacs-lisp
  758. (use-package embark
  759. :ensure t
  760. :bind
  761. (("C-S-a" . embark-act)
  762. ("C-h B" . embark-bindings))
  763. :init
  764. (setq prefix-help-command #'embark-prefix-help-command)
  765. :config
  766. ;; hide modeline of the embark live/completions buffers
  767. (add-to-list 'display-buffer-alist
  768. '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
  769. nil
  770. (window-parameters (mode-line-format . none)))))
  771. (use-package embark-consult
  772. :ensure t
  773. :after (embark consult)
  774. :demand t
  775. :hook
  776. (embark-collect-mode . embark-consult-preview-minor-mode))
  777. #+end_src
  778. * Tree-sitter
  779. #+begin_src emacs-lisp
  780. (when *sys/linux*
  781. (use-package tree-sitter
  782. :ensure t
  783. :init
  784. (global-tree-sitter-mode t)
  785. :hook
  786. (tree-sitter-after-on . tree-sitter-hl-mode))
  787. (use-package tree-sitter-langs
  788. :ensure t
  789. :after tree-sitter)
  790. )
  791. #+end_src
  792. * Org-ql
  793. [[https://github.com/alphapapa/org-ql][org-ql]]
  794. Run queries on org files
  795. #+begin_src emacs-lisp
  796. (use-package org-ql
  797. :ensure t
  798. )
  799. #+end_src
  800. * COMMENT Xeft (needs xapian, not really windows compatible)
  801. Fast full text search for stuff org-ql cannot cover
  802. #+begin_src emacs-lisp
  803. (use-package xeft
  804. :ensure t
  805. :custom
  806. (xeft-recursive 'follow-symlinks))
  807. #+end_src
  808. * COMMENT Helm
  809. As an alternative if I'm not happy with selectrum & co
  810. #+begin_src emacs-lisp
  811. (use-package helm
  812. :ensure t
  813. :hook
  814. (helm-mode . helm-autoresize-mode)
  815. ;; :bind
  816. ;; (("M-x" . helm-M-x)
  817. ;; ("C-s" . helm-occur)
  818. ;; ("C-x C-f" . helm-find-files)
  819. ;; ("C-x C-b" . helm-buffers-list)
  820. ;; ("C-x b" . helm-buffers-list)
  821. ;; ("C-x C-r" . helm-recentf)
  822. ;; ("C-x C-i" . helm-imenu))
  823. :config
  824. (helm-mode)
  825. :custom
  826. (helm-split-window-inside-p t) ;; open helm buffer inside current window
  827. (helm-move-to-line-cycle-in-source t)
  828. (helm-echo-input-in-header-line t)
  829. (helm-autoresize-max-height 20)
  830. (helm-autoresize-min-height 5)
  831. )
  832. #+end_src
  833. * outlook
  834. In outlook a macro is necessary, also a reference to FM20.DLL
  835. (Microsoft Forms 2.0 Object Library, in c:\windows\syswow64\fm20.dll)
  836. The macro copies the GUID of the email to the clipboard
  837. Attention: the GUID changes when the email is moved to another folder!
  838. The macro:
  839. #+BEGIN_SRC
  840. Sub AddLinkToMessageInClipboard()
  841. 'Adds a link to the currently selected message to the clipboard
  842. Dim objMail As Outlook.MailItem
  843. Dim doClipboard As New DataObject
  844. 'One and ONLY one message muse be selected
  845. If Application.ActiveExplorer.Selection.Count <> 1 Then
  846. MsgBox ("Select one and ONLY one message.")
  847. Exit Sub
  848. End If
  849. Set objMail = Application.ActiveExplorer.Selection.Item(1)
  850. doClipboard.SetText "[[outlook:" + objMail.EntryID + "][MESSAGE: " + objMail.Subject + " (" + objMail.SenderName + ")]]"
  851. doClipboard.PutInClipboard
  852. End Sub
  853. #+END_SRC
  854. #+BEGIN_SRC emacs-lisp
  855. ;(org-add-link-type "outlook" 'my--org-outlook-open)
  856. (defun my--org-outlook-open (id)
  857. (w32-shell-execute "open" "outlook" (concat " /select outlook:" id)))
  858. (defun my/org-outlook-open-test ()
  859. (interactive)
  860. (w32-shell-execute "open" "outlook" " /select outlook:000000008A209C397CEF2C4FBA9E54AEB5B1F97F0700846D043B407C5B43A0C05AFC46DC5C630587BE5E020900006E48FF8F6027694BA6593777F542C19E0002A6434D000000"))'
  861. #+END_SRC
  862. * misc
  863. #+begin_src emacs-lisp
  864. (use-package autorevert
  865. :diminish auto-revert-mode)
  866. #+end_src
  867. * orgmode
  868. ** some notes
  869. *** copy file path within emacs
  870. Enter dired-other-window
  871. place cursor on the file
  872. M-0 w (copy absolute path)
  873. C-u w (copy relative path)
  874. *** Archiving
  875. C-c C-x C-a
  876. To keep the subheading structure when archiving, set the properties of the superheading.
  877. #+begin_src org :tangle no
  878. ,* FOO
  879. :PROPERTIES:
  880. :ARCHIVE: %s_archive::* FOO
  881. ,** DONE BAR
  882. ,** TODO BAZ
  883. #+end_src
  884. When moving BAR to archive, it will go to FILENAME.org_archive below the heading FOO.
  885. [[http://doc.endlessparentheses.com/Var/org-archive-location.html][Other examples]]
  886. ** org
  887. This seems necessary to prevent 'org is already installed' error
  888. https://github.com/jwiegley/use-package/issues/319
  889. #+begin_src emacs-lisp
  890. ;(assq-delete-all 'org package--builtins)'
  891. ;(assq-delete-all 'org package--builtin-versions)
  892. #+end_src
  893. #+BEGIN_SRC emacs-lisp
  894. (defun my--buffer-prop-set (name value)
  895. "Set a file property called NAME to VALUE in buffer file.
  896. If the property is already set, replace its value."
  897. (setq name (downcase name))
  898. (org-with-point-at 1
  899. (let ((case-fold-search t))
  900. (if (re-search-forward (concat "^#\\+" name ":\\(.*\\)")
  901. (point-max) t)
  902. (replace-match (concat "#+" name ": " value) 'fixedcase)
  903. (while (and (not (eobp))
  904. (looking-at "^[#:]"))
  905. (if (save-excursion (end-of-line) (eobp))
  906. (progn
  907. (end-of-line)
  908. (insert "\n"))
  909. (forward-line)
  910. (beginning-of-line)))
  911. (insert "#+" name ": " value "\n")))))
  912. (defun my--buffer-prop-remove (name)
  913. "Remove a buffer property called NAME."
  914. (org-with-point-at 1
  915. (when (re-search-forward (concat "\\(^#\\+" name ":.*\n?\\)")
  916. (point-max) t)
  917. (replace-match ""))))
  918. (use-package org
  919. :ensure t
  920. ; :pin gnu
  921. :mode (("\.org$" . org-mode))
  922. :diminish org-indent-mode
  923. :defer 1
  924. :hook
  925. (org-mode . org-indent-mode)
  926. (org-source-mode . smartparens-mode)
  927. :bind (("C-c l" . org-store-link)
  928. ("C-c c" . org-capture)
  929. ("C-c a" . org-agenda)
  930. :map org-mode-map ("S-<right>" . org-shiftright)
  931. ("S-<left>" . org-shiftleft))
  932. :init
  933. (defun my--org-agenda-files-set ()
  934. "Sets default agenda files.
  935. Necessary when updating roam agenda todos."
  936. (setq org-agenda-files (list (concat MY--PATH_ORG_FILES "notes.org")
  937. (concat MY--PATH_ORG_FILES "projects.org")
  938. (concat MY--PATH_ORG_FILES "tasks.org")))
  939. (when *sys/linux*
  940. (nconc org-agenda-files
  941. (directory-files-recursively MY--PATH_ORG_FILES_MOBILE "\\.org$"))))
  942. (my--org-agenda-files-set)
  943. (defun my--org-skip-subtree-if-priority (priority)
  944. "Skip an agenda subtree if it has a priority of PRIORITY.
  945. PRIORITY may be one of the characters ?A, ?B, or ?C."
  946. (let ((subtree-end (save-excursion (org-end-of-subtree t)))
  947. (pri-value (* 1000 (- org-lowest-priority priority)))
  948. (pri-current (org-get-priority (thing-at-point 'line t))))
  949. (if (= pri-value pri-current)
  950. subtree-end
  951. nil)))
  952. :config
  953. (when *work_remote*
  954. (org-add-link-type "outlook" 'my--org-outlook-open)
  955. (setq org-todo-keywords
  956. '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE" "CANCELLED")))
  957. (setq org-capture-templates
  958. '(("t" "telephone call" entry
  959. ; (file+olp+datetree (concat MY--PATH_ORG_FILES "phone_calls.org"))
  960. (file+datetree "p:/Eigene Dateien/Notizen/phone_calls.org")
  961. "* [%<%Y-%m-%d %H:%M>] %?"
  962. :empty-lines 0 :jump-to-captured t))))
  963. (when *sys/linux*
  964. (setq org-pretty-entities t))
  965. :custom
  966. (org-startup-truncated t)
  967. (org-startup-align-all-tables t)
  968. (org-src-fontify-natively t) ;; use syntax highlighting in code blocks
  969. (org-src-preserve-indentation t) ;; no extra indentation
  970. (org-src-window-setup 'current-window) ;; C-c ' opens in current window
  971. (org-modules (quote (org-id
  972. org-habit
  973. org-tempo))) ;; easy templates
  974. (org-default-notes-file (concat MY--PATH_ORG_FILES "notes.org"))
  975. (org-id-locations-file (concat MY--PATH_USER_LOCAL ".org-id-locations"))
  976. (org-log-into-drawer "LOGBOOK")
  977. (org-log-done 'time) ;; create timestamp when task is done
  978. (org-blank-before-new-entry '((heading) (plain-list-item))) ;; prevent new line before new item
  979. (org-src-tab-acts-natively t)
  980. ;;Sort agenda by deadline and priority
  981. (org-agenda-sorting-strategy
  982. (quote
  983. ((agenda deadline-up priority-down)
  984. (todo priority-down category-keep)
  985. (tags priority-down category-keep)
  986. (search category-keep))))
  987. (org-agenda-custom-commands
  988. '(("c" "Simple agenda view"
  989. ((tags "PRIORITY=\"A\""
  990. ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
  991. (org-agenda-overriding-header "Hohe Priorität:")))
  992. (agenda ""
  993. ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
  994. (org-agenda-span 7)
  995. (org-agenda-start-on-weekday nil)
  996. (org-agenda-overriding-header "Nächste 7 Tage:")))
  997. (alltodo ""
  998. ((org-agenda-skip-function '(or (my--org-skip-subtree-if-priority ?A)
  999. (org-agenda-skip-if nil '(scheduled deadline))))
  1000. (org-agenda-overriding-header "Sonstige Aufgaben:"))))))))
  1001. #+END_SRC
  1002. ** COMMENT languages
  1003. Set some languages and disable confirmation for evaluating code blocks C-c C-c
  1004. Elpaca cant find it, though it's built in org
  1005. #+begin_src emacs-lisp
  1006. (use-package ob-python
  1007. ; :ensure nil
  1008. :defer t
  1009. :after org
  1010. ; :ensure org-contrib
  1011. :commands
  1012. (org-babel-execute:python))
  1013. #+end_src
  1014. ** COMMENT habits
  1015. #+BEGIN_SRC emacs-lisp
  1016. (require 'org-habit) ;;TODO Lösung ohne require finden, scheint mir nicht ideal zu sein, nur um ein org-modul zu aktivieren
  1017. ;; (add-to-list 'org-modules "org-habit")
  1018. (setq org-habit-graph-column 80
  1019. org-habit-preceding-days 30
  1020. org-habit-following-days 7
  1021. org-habit-show-habits-only-for-today nil)
  1022. #+END_SRC
  1023. ** *TODO*
  1024. [[https://github.com/nobiot/org-transclusion][org-transclusion]]?
  1025. ** COMMENT journal
  1026. [[https://github.com/bastibe/org-journal][Source]]
  1027. Ggf. durch org-roam-journal ersetzen
  1028. #+BEGIN_SRC emacs-lisp
  1029. (use-package org-journal
  1030. :if *sys/linux*
  1031. :ensure t
  1032. :defer t
  1033. :config
  1034. ;; feels hacky, but this way compiler error "assignment to free variable" disappears
  1035. (when (and (boundp 'org-journal-dir)
  1036. (boundp 'org-journal-enable-agenda-integration))
  1037. (setq org-journal-dir MY--PATH_ORG_JOURNAl
  1038. org-journal-enable-agenda-integration t)))
  1039. #+END_SRC
  1040. ** org-roam
  1041. [[https://github.com/org-roam/org-roam][Github]]
  1042. Um Headings innerhalb einer Datei zu verlinken:
  1043. - org-id-get-create im Heading,
  1044. - org-roam-node-insert in der verweisenden Datei
  1045. Bei Problemen wie unique constraint
  1046. org-roam-db-clear-all
  1047. org-roam-db-sync
  1048. #+BEGIN_SRC emacs-lisp
  1049. (use-package emacsql-sqlite-builtin
  1050. :ensure t)
  1051. (use-package org-roam
  1052. :requires emacsql-sqlite-builtin
  1053. :ensure t
  1054. :defer 2
  1055. :after org
  1056. :init
  1057. (setq org-roam-v2-ack t)
  1058. (defun my--roamtodo-p ()
  1059. "Return non-nil if current buffer has any todo entry.
  1060. TODO entries marked as done are ignored, meaning this function
  1061. returns nil if current buffer contains only completed tasks."
  1062. (seq-find
  1063. (lambda (type)
  1064. (eq type 'todo))
  1065. (org-element-map
  1066. (org-element-parse-buffer 'headline)
  1067. 'headline
  1068. (lambda (h)
  1069. (org-element-property :todo-type h)))))
  1070. (defun my--roamtodo-update-tag ()
  1071. "Update ROAMTODO tag in the current buffer."
  1072. (when (and (not (active-minibuffer-window))
  1073. (my--buffer-roam-note-p))
  1074. (save-excursion
  1075. (goto-char (point-min))
  1076. (let* ((tags (my--buffer-tags-get))
  1077. (original-tags tags))
  1078. (if (my--roamtodo-p)
  1079. (setq tags (cons "roamtodo" tags))
  1080. (setq tags (remove "roamtodo" tags)))
  1081. ;;cleanup duplicates
  1082. (when (or (seq-difference tags original-tags)
  1083. (seq-difference original-tags tags))
  1084. (apply #'my--buffer-tags-set tags))))))
  1085. (defun my--buffer-tags-get ()
  1086. "Return filetags value in current buffer."
  1087. (my--buffer-prop-get-list "filetags" "[ :]"))
  1088. (defun my--buffer-tags-set (&rest tags)
  1089. "Set TAGS in current buffer.
  1090. If filetags value is already set, replace it."
  1091. (if tags
  1092. (my--buffer-prop-set
  1093. "filetags" (concat ":" (string-join tags ":") ":"))
  1094. (my--buffer-prop-remove "filetags")))
  1095. (defun my--buffer-tags-add (tag)
  1096. "Add a TAG to filetags in current buffer."
  1097. (let* ((tags (my--buffer-tags-get))
  1098. (tags (append tags (list tag))))
  1099. (apply #'my--buffer-tags-set tags)))
  1100. (defun my--buffer-tags-remove (tag)
  1101. "Remove a TAG from filetags in current buffer."
  1102. (let* ((tags (my--buffer-tags-get))
  1103. (tags (delete tag tags)))
  1104. (apply #'my--buffer-tags-set tags)))
  1105. (defun my--buffer-prop-set (name value)
  1106. "Set a file property called NAME to VALUE in buffer file.
  1107. If the property is already set, replace its value."
  1108. (setq name (downcase name))
  1109. (org-with-point-at 1
  1110. (let ((case-fold-search t))
  1111. (if (re-search-forward (concat "^#\\+" name ":\\(.*\\)")
  1112. (point-max) t)
  1113. (replace-match (concat "#+" name ": " value) 'fixedcase)
  1114. (while (and (not (eobp))
  1115. (looking-at "^[#:]"))
  1116. (if (save-excursion (end-of-line) (eobp))
  1117. (progn
  1118. (end-of-line)
  1119. (insert "\n"))
  1120. (forward-line)
  1121. (beginning-of-line)))
  1122. (insert "#+" name ": " value "\n")))))
  1123. (defun my--buffer-prop-set-list (name values &optional separators)
  1124. "Set a file property called NAME to VALUES in current buffer.
  1125. VALUES are quoted and combined into single string using
  1126. `combine-and-quote-strings'.
  1127. If SEPARATORS is non-nil, it should be a regular expression
  1128. matching text that separates, but is not part of, the substrings.
  1129. If nil it defaults to `split-string-and-unquote', normally
  1130. \"[ \f\t\n\r\v]+\", and OMIT-NULLS is forced to t.
  1131. If the property is already set, replace its value."
  1132. (my--buffer-prop-set
  1133. name (combine-and-quote-strings values separators)))
  1134. (defun my--buffer-prop-get (name)
  1135. "Get a buffer property called NAME as a string."
  1136. (org-with-point-at 1
  1137. (when (re-search-forward (concat "^#\\+" name ": \\(.*\\)")
  1138. (point-max) t)
  1139. (buffer-substring-no-properties
  1140. (match-beginning 1)
  1141. (match-end 1)))))
  1142. (defun my--buffer-prop-get-list (name &optional separators)
  1143. "Get a buffer property NAME as a list using SEPARATORS.
  1144. If SEPARATORS is non-nil, it should be a regular expression
  1145. matching text that separates, but is not part of, the substrings.
  1146. If nil it defaults to `split-string-default-separators', normally
  1147. \"[ \f\t\n\r\v]+\", and OMIT-NULLS is forced to t."
  1148. (let ((value (my--buffer-prop-get name)))
  1149. (when (and value (not (string-empty-p value)))
  1150. (split-string-and-unquote value separators))))
  1151. (defun my--buffer-prop-remove (name)
  1152. "Remove a buffer property called NAME."
  1153. (org-with-point-at 1
  1154. (when (re-search-forward (concat "\\(^#\\+" name ":.*\n?\\)")
  1155. (point-max) t)
  1156. (replace-match ""))))
  1157. (defun my--buffer-roam-note-p ()
  1158. "Return non-nil if the currently visited buffer is a note."
  1159. (and buffer-file-name
  1160. (string-prefix-p
  1161. (expand-file-name (file-name-as-directory MY--PATH_ORG_ROAM))
  1162. (file-name-directory buffer-file-name))))
  1163. (defun my--org-roam-filter-by-tag (tag-name)
  1164. (lambda (node)
  1165. (member tag-name (org-roam-node-tags node))))
  1166. (defun my--org-roam-list-notes-by-tag (tag-name)
  1167. (mapcar #'org-roam-node-file
  1168. (seq-filter
  1169. (my--org-roam-filter-by-tag tag-name)
  1170. (org-roam-node-list))))
  1171. (defun my/org-roam-refresh-agenda-list ()
  1172. "Add all org roam files with #+filetags: roamtodo"
  1173. (interactive)
  1174. (my--org-agenda-files-set)
  1175. (nconc org-agenda-files
  1176. (my--org-roam-list-notes-by-tag "roamtodo"))
  1177. (setq org-agenda-files (delete-dups org-agenda-files)))
  1178. (add-hook 'find-file-hook #'my--roamtodo-update-tag)
  1179. (add-hook 'before-save-hook #'my--roamtodo-update-tag)
  1180. (advice-add 'org-agenda :before #'my/org-roam-refresh-agenda-list)
  1181. (advice-add 'org-todo-list :before #'my/org-roam-refresh-agenda-list)
  1182. (add-to-list 'org-tags-exclude-from-inheritance "roamtodo")
  1183. :config
  1184. (require 'org-roam-dailies) ;; ensure the keymap is available
  1185. (org-roam-db-autosync-mode)
  1186. ;; build the agenda list the first ime for the session
  1187. (my/org-roam-refresh-agenda-list)
  1188. (when *work_remote*
  1189. (setq org-roam-capture-templates
  1190. '(("n" "note" plain
  1191. "%?"
  1192. :if-new (file+head "notes/%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
  1193. :unnarrowed t)
  1194. ("i" "idea" plain
  1195. "%?"
  1196. :if-new (file+head "ideas/%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
  1197. :unnarrowed t)
  1198. ("p" "project" plain
  1199. "%?"
  1200. :target (file+head "projects/${slug}.org" "#+title: ${title}\n#+filetags: :project:\n")
  1201. :unnarrowed t)
  1202. ("s" "Sicherheitenmeldung" plain
  1203. "*** TODO [#A] Sicherheitenmeldung ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n%u\n"
  1204. :target (file+olp "tasks.org" ("Todos" "Sicherheitenmeldungen")))
  1205. ("m" "Monatsbericht" plain
  1206. "*** TODO [#A] Monatsbericht ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n%u\n"
  1207. :target (file+olp "tasks.org" ("Todos" "Monatsberichte"))))))
  1208. :custom
  1209. (org-roam-database-connector 'sqlite-builtin)
  1210. (org-roam-directory MY--PATH_ORG_ROAM)
  1211. (org-roam-completion-everywhere t)
  1212. (org-roam-capture-templates
  1213. '(("n" "note" plain
  1214. "%?"
  1215. :if-new (file+head "notes/%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
  1216. :unnarrowed t)
  1217. ("i" "idea" plain
  1218. "%?"
  1219. :if-new (file+head "ideas/%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
  1220. :unnarrowed t)
  1221. ))
  1222. :bind (("C-c n l" . org-roam-buffer-toggle)
  1223. ("C-c n f" . org-roam-node-find)
  1224. ("C-c n i" . org-roam-node-insert)
  1225. :map org-mode-map
  1226. ("C-M-i" . completion-at-point)
  1227. :map org-roam-dailies-map
  1228. ("Y" . org-roam-dailies-capture-yesterday)
  1229. ("T" . org-roam-dailies-capture-tomorrow))
  1230. :bind-keymap
  1231. ("C-c n d" . org-roam-dailies-map))
  1232. #+END_SRC
  1233. *** TODO Verzeichnis außerhalb roam zum Archivieren (u.a. für erledigte Monatsmeldungen etc.)
  1234. * Programming
  1235. ** Magit / Git
  1236. Little crash course in magit:
  1237. - magit-init to init a git project
  1238. - magit-status (C-x g) to call the status window
  1239. In status buffer:
  1240. - s stage files
  1241. - u unstage files
  1242. - U unstage all files
  1243. - a apply changes to staging
  1244. - c c commit (type commit message, then C-c C-c to commit)
  1245. - b b switch to another branch
  1246. - P u git push
  1247. - F u git pull
  1248. #+BEGIN_SRC emacs-lisp
  1249. (use-package magit
  1250. :ensure t
  1251. ; :pin melpa-stable
  1252. :defer t
  1253. :init
  1254. ; set git-path in work environment
  1255. (if (string-equal user-login-name "POH")
  1256. (setq magit-git-executable "P:/Tools/Git/bin/git.exe")
  1257. )
  1258. :bind (("C-x g" . magit-status)))
  1259. #+END_SRC
  1260. ** COMMENT Eglot (can't do dap-mode, maybe dape?)
  1261. for python pyls (in env: pip install python-language-server) seems to work better than pyright (npm install -g pyright),
  1262. at least pandas couldnt be resolved in pyright
  1263. #+begin_src emacs-lisp
  1264. (use-package eglot
  1265. :ensure t
  1266. :init
  1267. (setq completion-category-overrides '((eglot (styles orderless))))
  1268. :config
  1269. (add-to-list 'eglot-server-programs '(python-mode . ("pyright-langserver" "--stdio")))
  1270. (with-eval-after-load 'eglot
  1271. (load-library "project"))
  1272. :hook
  1273. (python-mode . eglot-ensure)
  1274. :custom
  1275. (eglot-ignored-server-capabilities '(:documentHighlightProvider))
  1276. (eglot-autoshutdown t)
  1277. (eglot-events-buffer-size 0)
  1278. )
  1279. ;; performance stuff if necessary
  1280. ;(fset #'jsonrpc--log-event #'ignore)
  1281. #+end_src
  1282. ** LSP-Mode
  1283. #+begin_src emacs-lisp
  1284. (defun corfu-lsp-setup ()
  1285. (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
  1286. '(orderless)))
  1287. (use-package lsp-mode
  1288. :ensure t
  1289. ; :hook
  1290. ; ((python-mode . lsp))
  1291. :custom
  1292. (lsp-completion-provider :none)
  1293. (lsp-enable-suggest-server-download nil)
  1294. :hook
  1295. (lsp-completion-mode #'corfu-lsp-setup))
  1296. ;(use-package lsp-ui
  1297. ; :ensure t
  1298. ; :commands lsp-ui-mode)
  1299. (use-package lsp-pyright
  1300. :ensure t
  1301. :after (python lsp-mode)
  1302. :custom
  1303. (lsp-pyright-multi-root nil)
  1304. :hook
  1305. (python-mode-hook . (lambda ()
  1306. (require 'lsp-pyright) (lsp))))
  1307. #+end_src
  1308. ** flymake
  1309. python in venv: pip install pyflake (or ruff?)
  1310. TODO: if ruff active, sideline stops working
  1311. #+begin_src emacs-lisp
  1312. (setq python-flymake-command '("ruff" "--quiet" "--stdin-filename=stdin" "-"))
  1313. #+end_src
  1314. ** sideline
  1315. show flymake errors on the right of code window
  1316. #+begin_src emacs-lisp
  1317. (use-package sideline
  1318. :ensure t)
  1319. (use-package sideline-flymake
  1320. :ensure t
  1321. :requires sideline
  1322. :hook
  1323. (flymake-mode . sideline-mode)
  1324. :init
  1325. (setq sideline-flymake-display-mode 'line ; 'point or 'line
  1326. ; sideline-backends-left '(sideline-lsp)
  1327. sideline-backends-right '(sideline-flymake)))
  1328. #+end_src
  1329. ** yasnippet
  1330. For useful snippet either install yasnippet-snippets or get them from here
  1331. [[https://github.com/AndreaCrotti/yasnippet-snippets][Github]]
  1332. #+begin_src emacs-lisp
  1333. (use-package yasnippet
  1334. :ensure t
  1335. :defer t
  1336. :diminish yas-minor-mode
  1337. :config
  1338. (setq yas-snippet-dirs (list (concat MY--PATH_USER_GLOBAL "snippets")))
  1339. (yas-global-mode t)
  1340. (yas-reload-all)
  1341. (unbind-key "TAB" yas-minor-mode-map)
  1342. (unbind-key "<tab>" yas-minor-mode-map))
  1343. #+end_src
  1344. ** hippie expand
  1345. With hippie expand I am able to use yasnippet and emmet at the same time with the same key.
  1346. #+begin_src emacs-lisp
  1347. (use-package hippie-exp
  1348. :ensure nil
  1349. :defer t
  1350. :bind
  1351. ("C-<return>" . hippie-expand)
  1352. :config
  1353. (setq hippie-expand-try-functions-list
  1354. '(yas-hippie-try-expand emmet-expand-line)))
  1355. #+end_src
  1356. ** COMMENT flycheck (now flymake)
  1357. #+BEGIN_SRC emacs-lisp
  1358. (use-package flycheck
  1359. :ensure t
  1360. :hook
  1361. ((css-mode . flycheck-mode)
  1362. (emacs-lisp-mode . flycheck-mode)
  1363. (python-mode . flycheck-mode))
  1364. :defer 1.0
  1365. :init
  1366. (setq flycheck-emacs-lisp-load-path 'inherit)
  1367. :config
  1368. (setq-default
  1369. flycheck-check-synta-automatically '(save mode-enabled)
  1370. flycheck-disable-checkers '(emacs-lisp-checkdoc)
  1371. eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck
  1372. flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages
  1373. #+END_SRC
  1374. ** smartparens
  1375. #+BEGIN_SRC emacs-lisp
  1376. (use-package smartparens
  1377. :ensure t
  1378. :diminish smartparens-mode
  1379. :bind
  1380. (:map smartparens-mode-map
  1381. ("C-M-f" . sp-forward-sexp)
  1382. ("C-M-b" . sp-backward-sexp)
  1383. ("C-M-a" . sp-backward-down-sexp)
  1384. ("C-M-e" . sp-up-sexp)
  1385. ("C-M-w" . sp-copy-sexp)
  1386. ("M-k" . sp-kill-sexp)
  1387. ("C-M-<backspace>" . sp-slice-sexp-killing-backward)
  1388. ("C-S-<backspace>" . sp-slice-sexp-killing-around)
  1389. ("C-]" . sp-select-next-thing-exchange))
  1390. :config
  1391. (setq sp-show-pair-from-inside nil
  1392. sp-escape-quotes-after-insert nil)
  1393. (require 'smartparens-config))
  1394. #+END_SRC
  1395. ** lisp
  1396. #+BEGIN_SRC emacs-lisp
  1397. (use-package elisp-mode
  1398. :ensure nil
  1399. :defer t)
  1400. #+END_SRC
  1401. ** web
  1402. apt install npm
  1403. sudo npm install -g vscode-html-languageserver-bin
  1404. evtl alternativ typescript-language-server?
  1405. Unter Windows:
  1406. Hier runterladen: https://nodejs.org/dist/latest/
  1407. und in ein Verzeichnis entpacken.
  1408. Optional: PATH erweitern unter Windows (so kann exec-path-from-shell den Pfad ermitteln):
  1409. PATH=P:\path\to\node;%path%
  1410. *** web-mode
  1411. #+BEGIN_SRC emacs-lisp
  1412. (use-package web-mode
  1413. :ensure t
  1414. :defer t
  1415. :mode
  1416. ("\\.phtml\\'"
  1417. "\\.tpl\\.php\\'"
  1418. "\\.djhtml\\'"
  1419. "\\.[t]?html?\\'")
  1420. :hook
  1421. (web-mode . smartparens-mode)
  1422. :init
  1423. (if *work_remote*
  1424. (setq exec-path (append exec-path '("P:/Tools/node"))))
  1425. :config
  1426. (setq web-mode-enable-auto-closing t
  1427. web-mode-enable-auto-pairing t))
  1428. #+END_SRC
  1429. Emmet offers snippets, similar to yasnippet.
  1430. Default completion is C-j
  1431. [[https://github.com/smihica/emmet-mode#usage][Github]]
  1432. #+begin_src emacs-lisp
  1433. (use-package emmet-mode
  1434. :ensure t
  1435. :defer t
  1436. :hook
  1437. ((web-mode . emmet-mode)
  1438. (css-mode . emmet-mode))
  1439. :config
  1440. (unbind-key "C-<return>" emmet-mode-keymap))
  1441. #+end_src
  1442. *** JavaScript
  1443. npm install -g typescript-language-server typescript
  1444. maybe only typescript?
  1445. npm install -g prettier
  1446. #+begin_src emacs-lisp
  1447. (use-package rjsx-mode
  1448. :ensure t
  1449. :mode ("\\.js\\'"
  1450. "\\.jsx'"))
  1451. ; :config
  1452. ; (setq js2-mode-show-parse-errors nil
  1453. ; js2-mode-show-strict-warnings nil
  1454. ; js2-basic-offset 2
  1455. ; js-indent-level 2)
  1456. ; (setq-local flycheck-disabled-checkers (cl-union flycheck-disable-checkers
  1457. ; '(javascript-jshint)))) ; jshint doesn"t work for JSX
  1458. (use-package tide
  1459. :ensure t
  1460. :after (rjsx-mode company flycheck)
  1461. ; :hook (rjsx-mode . setup-tide-mode)
  1462. :config
  1463. (defun setup-tide-mode ()
  1464. "Setup function for tide."
  1465. (interactive)
  1466. (tide-setup)
  1467. (flycheck-mode t)
  1468. (setq flycheck-check-synta-automatically '(save mode-enabled))
  1469. (tide-hl-identifier-mode t)))
  1470. ;; needs npm install -g prettier
  1471. (use-package prettier-js
  1472. :ensure t
  1473. :after (rjsx-mode)
  1474. :defer t
  1475. :diminish prettier-js-mode
  1476. :hook ((js2-mode rsjx-mode) . prettier-js-mode))
  1477. #+end_src
  1478. ** YAML
  1479. #+begin_src emacs-lisp
  1480. (use-package yaml-mode
  1481. :if *sys/linux*
  1482. :ensure t
  1483. :defer t
  1484. :mode ("\\.yml$" . yaml-mode))
  1485. #+end_src
  1486. ** R
  1487. #+BEGIN_SRC emacs-lisp
  1488. (use-package ess
  1489. :ensure t
  1490. :defer t
  1491. :init
  1492. (if *work_remote*
  1493. (setq exec-path (append exec-path '("P:/Tools/R/bin/x64"))
  1494. org-babel-R-command "P:/Tools/R/bin/x64/R --slave --no-save")))
  1495. #+END_SRC
  1496. ** project.el
  1497. #+begin_src emacs-lisp
  1498. (use-package project
  1499. :custom
  1500. (project-vc-extra-root-markers '(".project.el" ".project" )))
  1501. #+end_src
  1502. ** Python
  1503. Preparations:
  1504. - Install language server in *each* projects venv
  1505. source ./bin/activate
  1506. pip install pyright
  1507. - in project root:
  1508. touch .project.el
  1509. echo "((nil . (pyvenv-activate . "/path/to/project/.env")))" >> .dir-locals.el
  1510. für andere language servers
  1511. https://github.com/emacs-lsp/lsp-mode#install-language-server
  1512. TODO if in a project, set venv automatically
  1513. (when-let ((project (project-current))) (project-root project))
  1514. returns project path from project.el
  1515. to recognize a project, either have git or
  1516. place a .project.el file in project root and
  1517. (setq project-vc-extra-root-markers '(".project.el" "..." ))
  1518. #+begin_src emacs-lisp
  1519. (use-package python
  1520. :if *sys/linux*
  1521. :delight "π "
  1522. :defer t
  1523. :bind (("M-[" . python-nav-backward-block)
  1524. ("M-]" . python-nav-forward-block))
  1525. :mode
  1526. (("\\.py\\'" . python-mode)))
  1527. (use-package pyvenv
  1528. ; :if *sys/linux*
  1529. :ensure t
  1530. :defer t
  1531. :after python
  1532. :hook
  1533. (python-mode . pyvenv-mode)
  1534. :custom
  1535. (pyvenv-default-virtual-env-name ".env")
  1536. (pyvenv-mode-line-indicator '(pyvenv-virtual-env-name ("[venv:" pyvenv-virtual-env-name "]"))))
  1537. ;; formatting to pep8
  1538. ;; requires pip install black
  1539. ;(use-package blacken
  1540. ; :ensure t)
  1541. #+end_src
  1542. TODO python mode hook:
  1543. - activate venv
  1544. - activate eglot with proper ls
  1545. - activate tree-sitter?
  1546. - have some fallback if activations fail
  1547. * beancount
  1548. ** Installation
  1549. #+BEGIN_SRC shell :tangle no
  1550. sudo su
  1551. cd /opt
  1552. python3 -m venv beancount
  1553. source ./beancount/bin/activate
  1554. pip3 install wheel
  1555. pip3 install beancount
  1556. sleep 100
  1557. echo "shell running!"
  1558. deactivate
  1559. #+END_SRC
  1560. #+begin_src emacs-lisp
  1561. (use-package beancount
  1562. :ensure nil
  1563. :if *sys/linux*
  1564. :load-path "user-global/elisp/"
  1565. ; :ensure t
  1566. :defer t
  1567. :mode
  1568. ("\\.beancount$" . beancount-mode)
  1569. :hook
  1570. (beancount-mode . my/beancount-company)
  1571. :config
  1572. (defun my/beancount-company ()
  1573. (setq-local completion-at-point-functions #'beancount-completion-at-point))
  1574. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount"))
  1575. #+end_src
  1576. +BEGIN_SRC emacs-lisp
  1577. (use-package beancount
  1578. :if *sys/linux*
  1579. :load-path "user-global/elisp"
  1580. ; :ensure t
  1581. :defer t
  1582. :mode
  1583. ("\\.beancount$" . beancount-mode)
  1584. ; :hook
  1585. ; (beancount-mode . my/beancount-company)
  1586. ; :init
  1587. ; (add-hook 'beancount-mode-hook 'company/beancount-mode-hook)
  1588. :config
  1589. (defun my/beancount-company ()
  1590. (setq-local completion-at-point-functions #'beancount-complete-at-point nil t))
  1591. ; (mapcar #'cape-company-to-capf
  1592. ; (list #'company-beancount #'company-dabbrev))))
  1593. (defun my--beancount-companyALT ()
  1594. (set (make-local-variable 'company-backends)
  1595. '(company-beancount)))
  1596. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount"))
  1597. +END_SRC
  1598. To support org-babel, check if it can find the symlink to ob-beancount.el
  1599. #+BEGIN_SRC shell :tangle no
  1600. orgpath=`find /home/marc/.emacs.d/elpa/ -type d -name "org-plus*" -print`
  1601. beansym="$orgpath/ob-beancount.el
  1602. bean="/home/marc/Archiv/Programmierprojekte/Lisp/beancount-mode/ob-beancount.el"
  1603. if [ -h "$beansym" ]
  1604. then
  1605. echo "$beansym found"
  1606. elif [ -e "$bean" ]
  1607. then
  1608. echo "creating symlink"
  1609. ln -s "$bean" "$beansym"
  1610. else
  1611. echo "$bean not found, symlink creation aborted"
  1612. fi
  1613. #+END_SRC
  1614. Fava is strongly recommended.
  1615. #+BEGIN_SRC shell :tangle no
  1616. cd /opt
  1617. python3 -m venv fava
  1618. source ./fava/bin/activate
  1619. pip3 install wheel
  1620. pip3 install fava
  1621. deactivate
  1622. #+END_SRC
  1623. Start fava with fava my_file.beancount
  1624. It is accessable on this URL: [[http://127.0.0.1:5000][Fava]]
  1625. Beancount-mode can start fava and open the URL right away.
  1626. * Stuff after everything else
  1627. Set garbage collector to a smaller value to let it kick in faster.
  1628. Maybe a problem on Windows?
  1629. #+begin_src emacs-lisp
  1630. ;(setq gc-cons-threshold (* 2 1000 1000))
  1631. #+end_src
  1632. Rest of early-init.el
  1633. #+begin_src emacs-lisp :tangle early-init.el
  1634. (defconst config-org (expand-file-name "config.org" user-emacs-directory))
  1635. (defconst init-el (expand-file-name "init.el" user-emacs-directory))
  1636. (unless (file-exists-p init-el)
  1637. (require 'org)
  1638. (org-babel-tangle-file config-org init-el))
  1639. #+end_src