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.

1836 lines
56 KiB

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