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.

1829 lines
56 KiB

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