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, 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) 'plastic)
  289. (progn (disable-theme 'plastic)
  290. (load-theme 'leuven))
  291. (progn
  292. (disable-theme 'leuven)
  293. (load-theme 'plastic)))))
  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. Default preview key: M-.
  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. ("C-x r b" . consult-bookmark)) ;replace bookmark-jump
  724. :config
  725. ;; disable preview for some commands and buffers
  726. ;; and enable it by M-.
  727. ;; see https://github.com/minad/consult#use-package-example
  728. (consult-customize
  729. consult-theme :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 '(:debounce 0.2 any)))
  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