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.

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