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.

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