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.

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