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.

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