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.

1860 lines
57 KiB

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