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.

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