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.

1311 lines
36 KiB

5 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
3 years ago
3 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. #+TITLE: Emacs configuration file
  2. #+AUTHOR: Marc
  3. #+BABEL: :cache yes
  4. #+PROPERTY: header-args :tangle yes
  5. * TODOS
  6. - early-init.el? What to outsource here?
  7. - Paket exec-path-from-shell, um PATH aus Linux auch in emacs zu haben
  8. - Smart mode line?
  9. - Theme
  10. - evil-collection or custom in init file?
  11. - Hydra
  12. - General
  13. - (defalias 'list-buffers 'ibuffer) ;; change default to ibuffer
  14. - ido?
  15. - treemacs (for linux)
  16. - treemacs-evil?
  17. - treemacs-projectile
  18. windmove?
  19. - tramp (in linux)
  20. - visual-regexp
  21. - org configuration: paths
  22. - org custom agenda
  23. - org-ql (related to org agendas)
  24. - org configuration: everything else
  25. - beancount configuration from config.org
  26. - CONTINUE TODO from config.org at Programming
  27. - all-the-icons?
  28. * Header
  29. :PROPERTIES:
  30. :ID: a14d7c89-24ea-41ae-b185-944bab49aa02
  31. :END:
  32. Emacs variables are dynamically scoped. That's unusual for most languages, so disable it here, too
  33. #+begin_src emacs-lisp
  34. ;;; init.el --- -*- lexical-binding: t -*-
  35. #+end_src
  36. * First start
  37. :PROPERTIES:
  38. :ID: 1c24d48e-0124-4a0b-8e78-82e4c531e818
  39. :END:
  40. When pulling the repository the first time, an initial init.el needs to be setup. After start it will replace itself with the configuration from init.org
  41. #+BEGIN_SRC emacs-lisp :tangle no
  42. (require 'org')
  43. (find-file (concat user-emacs-directory "init.org"))
  44. (org-babel-tangle)
  45. (load-file (concat user-emacs-directory "init.el"))
  46. (byte-compile-file (concat user-emacs-directory "init.el"))
  47. #+END_SRC
  48. This function updates init.el whenever changes in init.org are made. The update will be active after saving.
  49. #+BEGIN_SRC emacs-lisp
  50. (defun me/tangle-init ()
  51. "If the current buffer is 'init.org', the code blocks are tangled, and the tangled file is compiled."
  52. (when (equal (buffer-file-name)
  53. (expand-file-name (concat user-emacs-directory "init.org")))
  54. ;; avoid running hooks
  55. (let ((prog-mode-hook nil))
  56. (org-babel-tangle)
  57. (byte-compile-file (concat user-emacs-directory "init.el"))
  58. (load-file user-init-file))))
  59. (add-hook 'after-save-hook 'me/tangle-init)
  60. #+END_SRC
  61. A small function to measure start up time.
  62. Compare that to
  63. emacs -q --eval='(message "%s" (emacs-init-time))'
  64. (roughly 0.27s)
  65. https://blog.d46.us/advanced-emacs-startup/
  66. #+begin_src emacs-lisp
  67. (add-hook 'emacs-startup-hook
  68. (lambda ()
  69. (message "Emacs ready in %s with %d garbage collections."
  70. (format "%.2f seconds"
  71. (float-time
  72. (time-subtract after-init-time before-init-time)))
  73. gcs-done)))
  74. (setq gc-cons-threshold (* 50 1000 1000))
  75. #+end_src
  76. #+BEGIN_SRC emacs-lisp
  77. (require 'package)
  78. (add-to-list 'package-archives '("elpa" . "https://elpa.gnu.org/packages/") t)
  79. (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
  80. (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
  81. (add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
  82. ; fix for bug 34341
  83. (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
  84. (when (< emacs-major-version 27)
  85. (package-initialize))
  86. #+END_SRC
  87. #+BEGIN_SRC emacs-lisp
  88. (unless (package-installed-p 'use-package)
  89. (package-refresh-contents)
  90. (package-install 'use-package))
  91. (eval-when-compile
  92. (require 'use-package))
  93. (require 'bind-key)
  94. (setq use-package-verbose nil)
  95. (use-package diminish
  96. :ensure t)
  97. #+END_SRC
  98. cl is deprecated in favor for cl-lib, some packages like emmet still depend on cl.
  99. Shut off the compiler warning about it.
  100. Maybe turn it on again at some point before the next major emacs upgrade
  101. #+begin_src emacs-lisp
  102. (setq byte-compile-warnings '(cl-functions))
  103. #+end_src
  104. * Default settings
  105. :PROPERTIES:
  106. :ID: 3512d679-d111-4ccd-8372-6fc2acbc0374
  107. :END:
  108. #+BEGIN_SRC emacs-lisp
  109. (defconst *sys/gui*
  110. (display-graphic-p)
  111. "Is emacs running in a gui?")
  112. (defconst *sys/linux*
  113. (string-equal system-type 'gnu/linux)
  114. "Is the system running Linux?")
  115. (defconst *sys/windows*
  116. (string-equal system-type 'windows-nt)
  117. "Is the system running Windows?")
  118. (defconst *home_desktop*
  119. (string-equal (system-name) "marc")
  120. "Is emacs running on my desktop?")
  121. (defconst *home_laptop*
  122. (string-equal (system-name) "laptop")
  123. "Is emacs running on my laptop?")
  124. (defconst *work_local*
  125. (string-equal (system-name) "PMPCNEU08")
  126. "Is emacs running at work on the local system?")
  127. (defconst *work_remote*
  128. (string-equal (system-name) "PMTS01")
  129. "Is emacs running at work on the remote system?")
  130. #+END_SRC
  131. #+BEGIN_SRC emacs-lisp
  132. (defvar MY--PATH_USER_LOCAL (concat user-emacs-directory "user-local/"))
  133. (defvar MY--PATH_USER_GLOBAL (concat user-emacs-directory "user-global/"))
  134. (add-to-list 'custom-theme-load-path (concat MY--PATH_USER_GLOBAL "themes"))
  135. (when *sys/linux*
  136. (defconst MY--PATH_ORG_FILES (expand-file-name "~/Archiv/Organisieren/"))
  137. (defconst MY--PATH_ORG_FILES_MOBILE (expand-file-name "~/Archiv/Organisieren/mobile/")))
  138. (defconst MY--PATH_ORG_JOURNAl (expand-file-name "~/Archiv/Organisieren/Journal/"))
  139. (when *work_remote*
  140. (defconst MY--PATH_ORG_FILES "p:/Eigene Dateien/Notizen/")
  141. (defconst MY--PATH_ORG_FILES_MOBILE nil) ;; hacky way to prevent "free variable" compiler error
  142. (defconst MY--PATH_ORG_JOURNAL nil) ;; hacky way to prevent "free variable" compiler error
  143. (defconst MY--PATH_START "p:/Eigene Dateien/Notizen/"))
  144. (setq recentf-save-file (concat MY--PATH_USER_LOCAL "recentf"))
  145. ;; exclude some dirs from spamming recentf
  146. (use-package recentf
  147. :config
  148. (recentf-mode)
  149. (setq recentf-exclude '(".*-autoloads\\.el\\"
  150. "[/\\]\\.elpa/")))
  151. (setq custom-file (concat MY--PATH_USER_LOCAL "custom.el")) ;; don't spam init.e with saved customization settings
  152. (setq abbrev-file-name (concat MY--PATH_USER_GLOBAL "abbrev_defs"))
  153. (setq backup-directory-alist `((".*" . ,temporary-file-directory)))
  154. (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory)))
  155. (setq save-abbrevs 'silently) ;; don't bother me with asking for abbrev saving
  156. (setq-default create-lockfiles nil) ;; disable lock files, can cause trouble in e.g. lsp-mode
  157. (defalias 'yes-or-no-p 'y-or-n-p) ;; answer with y and n
  158. (setq custom-safe-themes t) ;; don't ask me if I want to load a theme
  159. (setq sentence-end-double-space nil) ;; don't coun two spaces after a period as the end of a sentence.
  160. (delete-selection-mode t) ;; delete selected region when typing
  161. (save-place-mode 1) ;; saves position in file when it's closed
  162. (setq save-place-forget-unreadable-files nil) ;; checks if file is readable before saving position
  163. (set-charset-priority 'unicode)
  164. (setq locale-coding-system 'utf-8)
  165. (set-terminal-coding-system 'utf-8)
  166. (set-keyboard-coding-system 'utf-8)
  167. (set-selection-coding-system 'utf-8)
  168. (setq default-process-coding-system '(utf-8-unix . utf-8-unix))
  169. (if *sys/windows*
  170. (prefer-coding-system 'utf-8-dos)
  171. (prefer-coding-system 'utf-8))
  172. (blink-cursor-mode -1) ;; turn off blinking cursor
  173. (column-number-mode t)
  174. (setq uniquify-buffer-name-style 'forward)
  175. (setq-default indent-tabs-mode nil) ;; avoid tabs in place of multiple spaces (they look bad in tex)
  176. (setq-default indicate-empty-lines t) ;; show empty lines
  177. (setq scroll-margin 5 ;; smooth scrolling
  178. scroll-conservatively 10000
  179. scroll-preserve-screen-position 1
  180. scroll-step 1)
  181. (global-hl-line-mode t) ;; highlight current line
  182. (menu-bar-mode 0) ;; disable menu bar
  183. (tool-bar-mode 0) ;; disable tool bar
  184. (scroll-bar-mode 0) ;; disable scroll bar
  185. #+END_SRC
  186. Bookmarks
  187. Usage:
  188. - C-x r m (bookmark-set): add bookmark
  189. - C-x r l (list-bookmark): list bookmarks
  190. - C-x r b (bookmark-jump): open bookmark
  191. Edit bookmarks (while in bookmark file):
  192. - d: mark current item
  193. - x: delete marked items
  194. - r: rename current item
  195. - s: save changes
  196. #+begin_src emacs-lisp
  197. (use-package bookmark
  198. :custom
  199. (bookmark-default-file (concat MY--PATH_USER_LOCAL "bookmarks")))
  200. #+end_src
  201. Some windows specific stuff
  202. #+BEGIN_SRC emacs-lisp
  203. (when *sys/windows*
  204. (remove-hook 'find-file-hook 'vc-refresh-state)
  205. (progn
  206. (setq gc-cons-threshold (* 511 1024 1024)
  207. gc-cons-percentage 0.5
  208. garbage-collection-messages t)
  209. (run-with-idle-timer 5 t #'garbage-collect))
  210. (when (boundp 'w32-pipe-read-delay)
  211. (setq w32-pipe-read-delay 0))
  212. (when (boundp 'w32-get-true-file-attributes)
  213. (setq w32-get-true-file-attributes nil)))
  214. #+END_SRC
  215. * visuals
  216. ** Font
  217. :PROPERTIES:
  218. :ID: dc8eb670-e6bb-4bfb-98f0-aae1860234fb
  219. :END:
  220. #+BEGIN_SRC emacs-lisp
  221. (when *sys/linux*
  222. (set-face-font 'default "Hack-10"))
  223. (when *work_remote*
  224. (set-face-font 'default "Lucida Sans Typewriter-11"))
  225. #+END_SRC
  226. ** Themes
  227. :PROPERTIES:
  228. :ID: 9ccf37c0-6837-43cb-bed8-5a353799d8b1
  229. :END:
  230. #+BEGIN_SRC emacs-lisp
  231. (defun my/toggle-theme ()
  232. (interactive)
  233. (when (or *sys/windows* *sys/linux*)
  234. (if (eq (car custom-enabled-themes) 'tango-dark)
  235. (progn (disable-theme 'tango-dark)
  236. (load-theme 'tango))
  237. (progn
  238. (disable-theme 'tango)
  239. (load-theme 'tango-dark)))))
  240. (bind-key "C-c t" 'my/toggle-theme)
  241. #+END_SRC
  242. Windows Theme:
  243. #+BEGIN_SRC emacs-lisp
  244. (when *sys/windows*
  245. (load-theme 'tango))
  246. (when *sys/linux*
  247. (load-theme 'plastic))
  248. #+END_SRC
  249. ** line wrappings
  250. :PROPERTIES:
  251. :ID: 14ae933e-2941-4cc3-82de-38f90f91bfd3
  252. :END:
  253. #+BEGIN_SRC emacs-lisp
  254. (global-visual-line-mode)
  255. (diminish 'visual-line-mode)
  256. (use-package adaptive-wrap
  257. :ensure t
  258. :config
  259. (add-hook 'visual-line-mode-hook #'adaptive-wrap-prefix-mode))
  260. ; :init
  261. ; (when (fboundp 'adaptive-wrap-prefix-mode)
  262. ; (defun my/activate-adaptive-wrap-prefix-mode ()
  263. ; "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously."
  264. ; (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1)))
  265. ; (add-hook 'visual-line-mode-hook 'my/activate-adaptive-wrap-prefix-mode)))
  266. #+END_SRC
  267. ** line numbers
  268. :PROPERTIES:
  269. :ID: 7b969436-98c9-4b61-ba7a-9fb22c9781ad
  270. :END:
  271. #+BEGIN_SRC emacs-lisp
  272. (use-package display-line-numbers
  273. :init
  274. (add-hook 'prog-mode-hook 'display-line-numbers-mode)
  275. (add-hook 'org-src-mode-hook 'display-line-numbers-mode)
  276. :config
  277. (setq-default display-line-numbers-type 'visual
  278. display-line-numbers-current-absolute t
  279. display-line-numbers-with 4
  280. display-line-numbers-widen t))
  281. ; (add-hook 'emacs-lisp-mode-hook 'display-line-numbers-mode)
  282. #+END_SRC
  283. ** misc
  284. :PROPERTIES:
  285. :ID: a2873138-16ee-4990-89a2-26eab778ea74
  286. :END:
  287. #+BEGIN_SRC emacs-lisp
  288. (use-package rainbow-mode
  289. :ensure t
  290. :diminish
  291. :hook ((org-mode
  292. emacs-lisp-mode) . rainbow-mode))
  293. (use-package delight
  294. :ensure t)
  295. (show-paren-mode t) ;; show other part of brackets
  296. (use-package rainbow-delimiters
  297. :ensure t
  298. :hook ((prog-mode . rainbow-delimiters-mode)))
  299. #+END_SRC
  300. * undo
  301. :PROPERTIES:
  302. :ID: d57621b2-5472-4c89-a520-b4133db0b9af
  303. :END:
  304. #+BEGIN_SRC emacs-lisp
  305. (use-package undo-tree
  306. :ensure t
  307. :diminish undo-tree-mode
  308. :init
  309. (global-undo-tree-mode 1))
  310. #+END_SRC
  311. * ace-window
  312. #+begin_src emacs-lisp
  313. (use-package ace-window
  314. :ensure t
  315. :bind
  316. (:map global-map
  317. ("C-x o" . ace-window)))
  318. #+end_src
  319. * imenu-list
  320. :PROPERTIES:
  321. :ID: 0ae27ec9-5d77-43cf-ac76-5e12cc959046
  322. :END:
  323. A minor mode to show imenu in a sidebar.
  324. Call imenu-list-smart-toggle.
  325. [[https://github.com/bmag/imenu-list][Source]]
  326. #+BEGIN_SRC emacs-lisp
  327. (use-package imenu-list
  328. :ensure t
  329. :defer t
  330. :config
  331. (setq imenu-list-focus-after-activation t
  332. imenu-list-auto-resize t
  333. imenu-list-position 'right)
  334. :bind
  335. (:map global-map
  336. ([f9] . imenu-list-smart-toggle))
  337. :custom
  338. (org-imenu-depth 4)
  339. )
  340. #+END_SRC
  341. * which-key
  342. :PROPERTIES:
  343. :ID: a880f079-b3a3-4706-bf1e-5f6c680101f1
  344. :END:
  345. #+BEGIN_SRC emacs-lisp
  346. (use-package which-key
  347. :ensure t
  348. :diminish which-key-mode
  349. :defer t
  350. :config
  351. (which-key-mode)
  352. (which-key-setup-side-window-right-bottom)
  353. (which-key-setup-minibuffer)
  354. (setq which-key-idle-delay 0.5))
  355. #+END_SRC
  356. * Evil
  357. :PROPERTIES:
  358. :ID: 80ca70e2-a146-46db-b581-418d655dc1fc
  359. :END:
  360. #+BEGIN_SRC emacs-lisp
  361. (use-package evil
  362. :ensure t
  363. :defer .1 ;; don't block emacs when starting, load evil immediately after startup
  364. :config
  365. (evil-mode 1))
  366. #+END_SRC
  367. * General (key mapper)
  368. :PROPERTIES:
  369. :ID: a20f183f-d41a-4dff-bc37-3bc4e25c8036
  370. :END:
  371. #+BEGIN_SRC emacs-lisp
  372. (use-package general
  373. :ensure t)
  374. (general-define-key
  375. :states 'normal
  376. :keymaps 'imenu-list-major-mode-map
  377. "RET" '(imenu-list-goto-entry :which-key "goto")
  378. "TAB" '(hs-toggle-hiding :which-key "collapse")
  379. "d" '(imenu-list-display-entry :which-key "show")
  380. "q" '(imenu-list-quit-window :which-key "quit"))
  381. #+END_SRC
  382. * ivy / counsel / swiper
  383. :PROPERTIES:
  384. :ID: 55c74ba9-7761-4545-8ddd-087d6ee33e4b
  385. :END:
  386. #+BEGIN_SRC emacs-lisp
  387. ; (require 'ivy)
  388. (use-package ivy
  389. :ensure t
  390. :diminish
  391. (ivy-mode . "")
  392. :defer t
  393. :init
  394. (ivy-mode 1)
  395. :bind
  396. ("C-r" . ivy-resume) ;; overrides isearch-backwards binding
  397. :config
  398. (setq ivy-use-virtual-buffers t ;; recent files and bookmarks in ivy-switch-buffer
  399. ivy-height 20 ;; height of ivy window
  400. ivy-count-format "%d/%d" ;; current and total number
  401. ivy-re-builders-alist ;; regex replaces spaces with *
  402. '((t . ivy--regex-plus))))
  403. ; make counsel-M-x more descriptive
  404. (use-package ivy-rich
  405. :ensure t
  406. :defer t
  407. :init
  408. (ivy-rich-mode 1))
  409. (use-package counsel
  410. :ensure t
  411. :defer t
  412. :bind
  413. (("M-x" . counsel-M-x)
  414. ("C-x C-f" . counsel-find-file)
  415. ("C-x C-r" . counsel-recentf)
  416. ("C-x b" . counsel-switch-buffer)
  417. ("C-c C-f" . counsel-git)
  418. ("C-c h f" . counsel-describe-function)
  419. ("C-c h v" . counsel-describe-variable)
  420. ("M-i" . counsel-imenu)))
  421. ; :map minibuffer-local-map ;;currently mapped to evil-redo
  422. ; ("C-r" . 'counsel-minibuffer-history)))
  423. (use-package swiper
  424. :ensure t
  425. :bind
  426. ("C-s" . swiper))
  427. (use-package ivy-hydra
  428. :ensure t)
  429. #+END_SRC
  430. * misc
  431. #+begin_src emacs-lisp
  432. (use-package autorevert
  433. :diminish auto-revert-mode)
  434. #+end_src
  435. * company
  436. :PROPERTIES:
  437. :ID: 944563b6-b04a-44f2-9b21-a6a3e200867c
  438. :END:
  439. #+BEGIN_SRC emacs-lisp
  440. (use-package company
  441. :defer 1
  442. :diminish
  443. :defer t
  444. :bind
  445. (("C-<tab>" . company-complete)
  446. :map company-active-map
  447. ("RET" . nil)
  448. ([return] . nil)
  449. ("TAB" . company-complete-selection)
  450. ([tab] . company-complete-selection)
  451. ("<right>" . company-complete-common))
  452. :hook
  453. (after-init . global-company-mode)
  454. :config
  455. (setq company-idle-delay .2
  456. company-minimum-prefix-length 1
  457. company-require-match nil
  458. company-show-numbers t
  459. company-tooltip-align-annotations t))
  460. (use-package company-statistics
  461. :ensure t
  462. :after company
  463. :defer t
  464. :init
  465. (setq company-statistics-file (concat MY--PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el")
  466. :config
  467. (company-statistics-mode 1))
  468. (use-package company-dabbrev
  469. :ensure nil
  470. :after company
  471. :defer t
  472. :config
  473. (setq-default company-dabbrev-downcase nil))
  474. (use-package company-box
  475. :ensure t
  476. :diminish
  477. :defer t
  478. :init
  479. (add-hook 'company-mode-hook 'company-box-mode))
  480. #+END_SRC
  481. * orgmode
  482. ** org
  483. :PROPERTIES:
  484. :ID: b89d7639-080c-4168-8884-bd5d8965f466
  485. :END:
  486. #+BEGIN_SRC emacs-lisp
  487. (use-package org
  488. :ensure org-plus-contrib
  489. :mode (("\.org$" . org-mode))
  490. :diminish org-indent-mode
  491. :defer t
  492. :hook
  493. (org-mode . my/org-company)
  494. (org-mode . org-indent-mode)
  495. (org-source-mode . smartparens-mode)
  496. ; :init
  497. ; (add-hook 'org-mode-hook 'company/org-mode-hook)
  498. ; (add-hook 'org-src-mode-hook 'smartparens-mode)
  499. ; (add-hook 'org-mode-hook 'org-indent-mode)
  500. :config
  501. (defun my/org-company ()
  502. (set (make-local-variable 'company-backends)
  503. '(company-capf company-files))
  504. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  505. (message "company/org-mode-hook"))
  506. (setq org-modules (quote (org-id
  507. org-habit
  508. org-tempo ;; easy templates
  509. )))
  510. (setq org-default-notes-file (concat MY--PATH_ORG_FILES "notes.org")
  511. org-agenda-files (list (concat MY--PATH_ORG_FILES "notes.org")
  512. (concat MY--PATH_ORG_FILES "projects.org")
  513. (concat MY--PATH_ORG_FILES "tasks.org")))
  514. (when *sys/linux*
  515. (nconc org-agenda-files
  516. (directory-files-recursively MY--PATH_ORG_FILES_MOBILE "\\.org$")))
  517. (setq org-id-locations-file (concat MY--PATH_USER_LOCAL ".org-id-locations")
  518. org-log-into-drawer "LOGBOOK")
  519. ;; some display customizations
  520. (setq org-pretty-entities t
  521. org-startup-truncated t
  522. org-startup-align-all-tables t)
  523. ;; some source code blocks customizations
  524. (setq org-src-window-setup 'current-window ;; C-c ' opens in current window
  525. org-src-fontify-natively t ;; use syntax highlighting in code blocks
  526. org-src-preserve-indentation t ;; no extra indentation
  527. org-src-tab-acts-natively t)
  528. (setq org-log-done 'time)) ;; create timestamp when task is done
  529. #+END_SRC
  530. ** languages
  531. :PROPERTIES:
  532. :ID: ad3af718-d0db-448c-9f75-eb9e250c2862
  533. :END:
  534. Set some languages and disable confirmation for evaluating code blocks C-c C-c
  535. +BEGIN_SRC emacs-lisp
  536. (org-babel-do-load-languages
  537. 'org-babel-load-languages
  538. '((emacs-lisp . t)
  539. (gnuplot . t)
  540. (js . t)
  541. (latex . t)
  542. (lisp . t)
  543. (python . t)
  544. (shell . t)
  545. (sqlite . t)
  546. (org . t)
  547. (R . t)
  548. (scheme . t)))
  549. (setq org-confirm-babel-evaluate nil)
  550. +END_SRC
  551. Another setup, because org-babel-do-load-languages requires eager loading
  552. #+begin_src emacs-lisp
  553. (use-package ob-org
  554. :defer t
  555. :ensure org-plus-contrib
  556. :commands
  557. (org-babel-execute:org
  558. org-babel-expand-body:org))
  559. (use-package ob-python
  560. :defer t
  561. :ensure org-plus-contrib
  562. :commands (org-babel-execute:python))
  563. (use-package ob-js
  564. :defer t
  565. :ensure org-plus-contrib
  566. :commands (org-babel-execute:js))
  567. (use-package ob-shell
  568. :defer t
  569. :ensure org-plus-contrib
  570. :commands
  571. (org-babel-execute:sh
  572. org-babel-expand-body:sh
  573. org-babel-execute:bash
  574. org-babel-expand-body:bash))
  575. (use-package ob-emacs-lisp
  576. :defer t
  577. :ensure org-plus-contrib
  578. :commands
  579. (org-babel-execute:emacs-lisp
  580. org-babel-expand-body:emacs-lisp))
  581. (use-package ob-lisp
  582. :defer t
  583. :ensure org-plus-contrib
  584. :commands
  585. (org-babel-execute:lisp
  586. org-babel-expand-body:lisp))
  587. (use-package ob-gnuplot
  588. :defer t
  589. :ensure org-plus-contrib
  590. :commands
  591. (org-babel-execute:gnuplot
  592. org-babel-expand-body:gnuplot))
  593. (use-package ob-sqlite
  594. :defer t
  595. :ensure org-plus-contrib
  596. :commands
  597. (org-babel-execute:sqlite
  598. org-babel-expand-body:sqlite))
  599. (use-package ob-latex
  600. :defer t
  601. :ensure org-plus-contrib
  602. :commands
  603. (org-babel-execute:latex
  604. org-babel-expand-body:latex))
  605. (use-package ob-R
  606. :defer t
  607. :ensure org-plus-contrib
  608. :commands
  609. (org-babel-execute:R
  610. org-babel-expand-body:R))
  611. (use-package ob-scheme
  612. :defer t
  613. :ensure org-plus-contrib
  614. :commands
  615. (org-babel-execute:scheme
  616. org-babel-expand-body:scheme))
  617. #+end_src
  618. ** habits
  619. :PROPERTIES:
  620. :ID: fcc91d0a-d040-4910-b2cf-3221496a3842
  621. :END:
  622. #+BEGIN_SRC emacs-lisp
  623. (require 'org-habit) ;;TODO Lösung ohne require finden, scheint mir nicht ideal zu sein, nur um ein org-modul zu aktivieren
  624. ;; (add-to-list 'org-modules "org-habit")
  625. (setq org-habit-graph-column 80
  626. org-habit-preceding-days 30
  627. org-habit-following-days 7
  628. org-habit-show-habits-only-for-today nil)
  629. #+END_SRC
  630. ** org-id
  631. :PROPERTIES:
  632. :ID: c4017c45-d650-410c-8bd4-bc3cf42bbbb9
  633. :END:
  634. Currently it causes some debugger errors "not a standard org time string", so it's disabled
  635. #+BEGIN_SRC emacs-lisp
  636. ;; (use-package org-id
  637. ;; :config
  638. ;; (setq org-id-link-to-org-use-id t)
  639. ;; (org-id-update-id-locations)) ;; update id file .org-id-locations on startup
  640. #+END_SRC
  641. ** org-agenda
  642. :PROPERTIES:
  643. :ID: 03b67efb-4179-41e5-bc2e-c472b13f8be6
  644. :END:
  645. Custom keywords, depending on environment
  646. #+BEGIN_SRC emacs-lisp
  647. (when *work_remote*
  648. (setq org-todo-keywords
  649. '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE" "CANCELLED"))))
  650. #+END_SRC
  651. Add some key bindings
  652. #+BEGIN_SRC emacs-lisp
  653. (bind-key "C-c l" 'org-store-link)
  654. (bind-key "C-c c" 'org-capture)
  655. (bind-key "C-c a" 'org-agenda)
  656. #+END_SRC
  657. Sort agenda by deadline and priority
  658. #+BEGIN_SRC emacs-lisp
  659. (setq org-agenda-sorting-strategy
  660. (quote
  661. ((agenda deadline-up priority-down)
  662. (todo priority-down category-keep)
  663. (tags priority-down category-keep)
  664. (search category-keep))))
  665. #+END_SRC
  666. Customize the org agenda
  667. #+BEGIN_SRC emacs-lisp
  668. (defun me--org-skip-subtree-if-priority (priority)
  669. "Skip an agenda subtree if it has a priority of PRIORITY.
  670. PRIORITY may be one of the characters ?A, ?B, or ?C."
  671. (let ((subtree-end (save-excursion (org-end-of-subtree t)))
  672. (pri-value (* 1000 (- org-lowest-priority priority)))
  673. (pri-current (org-get-priority (thing-at-point 'line t))))
  674. (if (= pri-value pri-current)
  675. subtree-end
  676. nil)))
  677. (setq org-agenda-custom-commands
  678. '(("c" "Simple agenda view"
  679. ((tags "PRIORITY=\"A\""
  680. ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
  681. (org-agenda-overriding-header "Hohe Priorität:")))
  682. (agenda ""
  683. ((org-agenda-span 7)
  684. (org-agenda-start-on-weekday nil)
  685. (org-agenda-overriding-header "Nächste 7 Tage:")))
  686. (alltodo ""
  687. ((org-agenda-skip-function '(or (me--org-skip-subtree-if-priority ?A)
  688. (org-agenda-skip-if nil '(scheduled deadline))))
  689. (org-agenda-overriding-header "Sonstige Aufgaben:")))))))
  690. #+END_SRC
  691. ** *TODO*
  692. org-super-agenda
  693. ** org-caldav
  694. :PROPERTIES:
  695. :ID: 6bd24369-0d04-452f-85a0-99914dfb74ff
  696. :END:
  697. Vorerst deaktiviert, Nutzen evtl. nicht vorhanden
  698. #+BEGIN_SRC emacs-lisp
  699. ;;(use-package org-caldav
  700. ;; :ensure t
  701. ;; :config
  702. ;; (setq org-caldav-url "https://nextcloud.cloudsphere.duckdns.org/remote.php/dav/calendars/marc"
  703. ;; org-caldav-calendar-id "orgmode"
  704. ;; org-caldav-inbox (expand-file-name "~/Archiv/Organisieren/caldav-inbox")
  705. ;; org-caldav-files (concat MY--PATH_ORG_FILES "tasks")))
  706. #+END_SRC
  707. ** journal
  708. :PROPERTIES:
  709. :ID: a1951e18-d862-4198-9652-016e979053c8
  710. :END:
  711. [[https://github.com/bastibe/org-journal][Source]]
  712. #+BEGIN_SRC emacs-lisp
  713. (use-package org-journal
  714. :if *sys/linux*
  715. :ensure t
  716. :defer t
  717. :config
  718. ;; feels hacky, but this way compiler error "assignment to free variable" disappears
  719. (when (and (boundp 'org-journal-dir)
  720. (boundp 'org-journal-enable-agenda-integration))
  721. (setq org-journal-dir MY--PATH_ORG_JOURNAl
  722. org-journal-enable-agenda-integration t)))
  723. #+END_SRC
  724. * Programming
  725. ** misc
  726. #+begin_src emacs-lisp
  727. (use-package eldoc
  728. :diminish eldoc-mode
  729. :defer t)
  730. #+end_src
  731. ** Magit / Git
  732. :PROPERTIES:
  733. :ID: d3589460-317f-40f6-9056-053be9ba3217
  734. :END:
  735. Little crash course in magit:
  736. - magit-init to init a git project
  737. - magit-status (C-x g) to call the status window
  738. In status buffer:
  739. - s stage files
  740. - u unstage files
  741. - U unstage all files
  742. - a apply changes to staging
  743. - c c commit (type commit message, then C-c C-c to commit)
  744. - b b switch to another branch
  745. - P u git push
  746. - F u git pull
  747. #+BEGIN_SRC emacs-lisp
  748. (use-package magit
  749. :ensure t
  750. :defer t
  751. :init
  752. ; set git-path in work environment
  753. (if (string-equal user-login-name "POH")
  754. (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe")
  755. )
  756. :bind (("C-x g" . magit-status)))
  757. #+END_SRC
  758. ** LSP
  759. :PROPERTIES:
  760. :ID: 06ad00e0-44a6-4bfb-ba6f-b1672811e053
  761. :END:
  762. Configuration for the language server protocol
  763. *ACHTUNG* Dateipfad muss absolut sein, symlink im Pfad führt zumindest beim ersten Start zu Fehlern beim lsp
  764. Sobald der lsp einmal lief, kann zukünftig der symlink-Pfad genommen werden.
  765. Getestet wurde die funktionierende Datei selbst und neu erstellte Dateien im selben Pfad.
  766. TODO Unterverzeichnisse wurden noch nicht getestet
  767. #+BEGIN_SRC emacs-lisp
  768. (setq read-process-output-max (* 1024 1024)) ;; support reading large blobs of data for LSP's sake
  769. (use-package lsp-mode
  770. :defer t
  771. :commands (lsp lsp-execute-code-action)
  772. :custom
  773. (lsp-auto-guess-root nil)
  774. (lsp-prefer-flymake nil) ; use flycheck instead
  775. (lsp-file-watch-threshold 5000)
  776. (lsb-print-performance t)
  777. (lsp-log-io nil) ; enable log only for debug
  778. (lsp-enable-folding t) ; default, maybe evil-matchit instead for performance?
  779. (lsp-diagnostics-modeline-scope :project)
  780. (lsp-enable-file-watchers nil)
  781. :bind (:map lsp-mode-map ("C-c C-f" . lsp-format-buffer))
  782. :hook
  783. (((python-mode
  784. js-mode
  785. js2-mode
  786. typescript-mode
  787. web-mode
  788. ) . lsp)
  789. (lsp-mode . lsp-enable-which-key-integration)
  790. (lsp-mode . lsp-diagnostics-modeline-mode))
  791. :config
  792. (setq lsp-diagnostics-package :none) ; disable flycheck-lsp for most modes
  793. (add-hook 'web-mode-hook #'lsp-flycheck-enable)) ; enable flycheck-lsp for web-mode locally
  794. (use-package lsp-ui
  795. :after lsp-mode
  796. :ensure t
  797. :defer t
  798. :diminish
  799. :commands lsp-ui-mode
  800. :config
  801. (setq lsp-ui-doc-enable t
  802. lsp-ui-doc-header t
  803. lsp-ui-doc-include-signature t
  804. lsp-ui-doc-position 'top
  805. lsp-ui-doc-border (face-foreground 'default)
  806. lsp-ui-sideline-enable nil
  807. lsp-ui-sideline-ignore-duplicate t
  808. lsp-ui-sideline-show-code-actions nil)
  809. (when *sys/gui*
  810. (setq lsp-ui-doc-use-webkit t))
  811. ;; workaround hide mode-line of lsp-ui-imenu buffer
  812. (defadvice lsp-ui-imenu (after hide-lsp-ui-imenu-mode-line activate)
  813. (setq mode-line-format nil)))
  814. (use-package company-lsp
  815. :requires company
  816. :defer t
  817. :ensure t
  818. :config
  819. ;;disable client-side cache because lsp server does a better job
  820. (setq company-transformers nil
  821. company-lsp-async t
  822. company-lsp-cache-candidates nil))
  823. #+END_SRC
  824. ** yasnippet
  825. :PROPERTIES:
  826. :ID: 935d89ef-645e-4e92-966f-2fe3bebb2880
  827. :END:
  828. For useful snippet either install yasnippet-snippets or get them from here
  829. [[https://github.com/AndreaCrotti/yasnippet-snippets][Github]]
  830. #+begin_src emacs-lisp
  831. (use-package yasnippet
  832. :ensure t
  833. :defer t
  834. :diminish yas-minor-mode
  835. :config
  836. (setq yas-snippet-dirs (list (concat MY--PATH_USER_GLOBAL "snippets")))
  837. (yas-global-mode t)
  838. (yas-reload-all)
  839. (unbind-key "TAB" yas-minor-mode-map)
  840. (unbind-key "<tab>" yas-minor-mode-map))
  841. #+end_src
  842. ** hippie expand
  843. :PROPERTIES:
  844. :ID: c55245bc-813d-4816-a0ca-b4e2e793e28b
  845. :END:
  846. With hippie expand I am able to use yasnippet and emmet at the same time with the same key.
  847. #+begin_src emacs-lisp
  848. (use-package hippie-exp
  849. :defer t
  850. :bind
  851. ("C-<return>" . hippie-expand)
  852. :config
  853. (setq hippie-expand-try-functions-list
  854. '(yas-hippie-try-expand emmet-expand-line)))
  855. #+end_src
  856. ** flycheck
  857. :PROPERTIES:
  858. :ID: 3d8f2547-c5b3-46d0-91b0-9667f9ee5c47
  859. :END:
  860. #+BEGIN_SRC emacs-lisp
  861. (use-package flycheck
  862. :ensure t
  863. :hook
  864. ((css-mode . flycheck-mode)
  865. (emacs-lisp-mode . flycheck-mode)
  866. (python-mode . flycheck-mode))
  867. :defer 1.0
  868. :init
  869. (setq flycheck-emacs-lisp-load-path 'inherit)
  870. :config
  871. (setq-default
  872. flycheck-check-synta-automatically '(save mode-enabled)
  873. flycheck-disable-checkers '(emacs-lisp-checkdoc)
  874. eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck
  875. flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages
  876. #+END_SRC
  877. ** Projectile
  878. :PROPERTIES:
  879. :ID: a90329fd-4d36-435f-8308-a2771ac4c320
  880. :END:
  881. Manage projects and jump quickly between its files
  882. #+BEGIN_SRC emacs-lisp
  883. (defun set-workon_home()
  884. (setenv "WORKON_HOME" (projectile-project-root))
  885. (message "set workon_home"))
  886. (use-package projectile
  887. :ensure t
  888. ; :defer 1.0
  889. :diminish
  890. ; :hook (projectile-after-switch-project . (lambda ()
  891. ; (set-workon_home)
  892. ; (message "set workon_home"))) ;; for pyvenv to auto activate environment
  893. ; :hook (projectile-after-switch-project #'set-workon_home)
  894. :bind-keymap
  895. ("C-c p" . projectile-command-map)
  896. ;:preface
  897. :init
  898. (setq-default projectile-cache-file (concat MY--PATH_USER_LOCAL ".projectile-cache")
  899. projectile-known-projects-file (concat MY--PATH_USER_LOCAL ".projectile-bookmarks"))
  900. :config
  901. (projectile-mode t)
  902. ; (add-hook 'projectile-after-switch-project-hook #'set-workon_home)
  903. (setq-default projectile-completion-system 'ivy
  904. projectile-enable-caching t
  905. projectile-mode-line '(:eval (projectile-project-name))))
  906. ;; requires ripgrep on system for rg functions
  907. (use-package counsel-projectile
  908. :ensure t
  909. :config (counsel-projectile-mode))
  910. #+END_SRC
  911. ** smartparens
  912. :PROPERTIES:
  913. :ID: 997ec416-33e6-41ed-8c7c-75a7bc47d285
  914. :END:
  915. #+BEGIN_SRC emacs-lisp
  916. (use-package smartparens
  917. :ensure t
  918. :diminish smartparens-mode
  919. :bind
  920. (:map smartparens-mode-map
  921. ("C-M-f" . sp-forward-sexp)
  922. ("C-M-b" . sp-backward-sexp)
  923. ("C-M-a" . sp-backward-down-sexp)
  924. ("C-M-e" . sp-up-sexp)
  925. ("C-M-w" . sp-copy-sexp)
  926. ("M-k" . sp-kill-sexp)
  927. ("C-M-<backspace>" . sp-slice-sexp-killing-backward)
  928. ("C-S-<backspace>" . sp-slice-sexp-killing-around)
  929. ("C-]" . sp-select-next-thing-exchange))
  930. :config
  931. (setq sp-show-pair-from-inside nil
  932. sp-escape-quotes-after-insert nil)
  933. (require 'smartparens-config))
  934. #+END_SRC
  935. ** lisp
  936. :PROPERTIES:
  937. :ID: a2bc3e08-b203-49d3-b337-fb186a14eecb
  938. :END:
  939. #+BEGIN_SRC emacs-lisp
  940. (use-package elisp-mode
  941. :defer t
  942. :hook
  943. (elisp-mode . my/elisp-company)
  944. :config
  945. (defun my/elisp-company ()
  946. (set (make-local-variable 'company-backends)
  947. '(company-capf company-files))))
  948. #+END_SRC
  949. ** web
  950. :PROPERTIES:
  951. :ID: c0b0b4e4-2162-429f-b80d-6e5334b1290e
  952. :END:
  953. apt install npm
  954. sudo npm install -g vscode-html-languageserver-bin
  955. evtl alternativ typescript-language-server?
  956. Unter Windows:
  957. Hier runterladen: https://nodejs.org/dist/latest/
  958. und in ein Verzeichnis entpacken.
  959. Optional: PATH erweitern unter Windows (so kann exec-path-from-shell den Pfad ermitteln):
  960. PATH=P:\path\to\node;%path%
  961. #+BEGIN_SRC emacs-lisp
  962. (use-package web-mode
  963. :ensure t
  964. :defer t
  965. :mode
  966. ("\\.phtml\\'"
  967. "\\.tpl\\.php\\'"
  968. "\\.djhtml\\'"
  969. "\\.[t]?html?\\'")
  970. :init
  971. (if *work_remote*
  972. (setq exec-path (append exec-path '("P:/Tools/node"))))
  973. :config
  974. (setq web-mode-enable-auto-closing t
  975. web-mode-enable-auto-pairing t)
  976. (add-hook 'web-mode-hook 'smartparens-mode))
  977. #+END_SRC
  978. Emmet offers snippets, similar to yasnippet.
  979. Default completion is C-j
  980. [[https://github.com/smihica/emmet-mode#usage][Github]]
  981. #+begin_src emacs-lisp
  982. (use-package emmet-mode
  983. :ensure t
  984. :defer t
  985. :hook
  986. ((web-mode . emmet-mode)
  987. (css-mode . emmet-mode))
  988. :config
  989. (unbind-key "C-<return>" emmet-mode-keymap))
  990. #+end_src
  991. *** JavaScript
  992. npm install -g typescript-language-server typescript
  993. #+begin_src emacs-lisp
  994. (use-package rjsx-mode
  995. :ensure t
  996. :mode ("\\.js\\'"
  997. "\\.jsx'")
  998. :config
  999. (setq js2-mode-show-parse-errors nil
  1000. js2-mode-show-strict-warnings nil
  1001. js2-basic-offset 2
  1002. js-indent-level 2)
  1003. (setq-local flycheck-disabled-checkers (cl-union flycheck-disable-checkers
  1004. '(javascript-jshint)))) ; jshint doesn"t work for JSX
  1005. (use-package add-node-modules-path
  1006. :ensure t
  1007. :defer t
  1008. :hook (((js2-mode rsjx-mode) . add-node-modules-path)))
  1009. (use-package prettier-js
  1010. :ensure t
  1011. :defer t
  1012. :diminish prettier-js-mode
  1013. :hook (((js2-mode rsjx-mode) . prettier-js-mode)))
  1014. #+end_src
  1015. ** YAML
  1016. :PROPERTIES:
  1017. :ID: 95413247-04d5-4e02-8431-06c162ec8f3b
  1018. :END:
  1019. #+begin_src emacs-lisp
  1020. (use-package yaml-mode
  1021. :if *sys/linux*
  1022. :ensure t
  1023. :defer t
  1024. :mode ("\\.yml$" . yaml-mode))
  1025. #+end_src
  1026. ** R
  1027. #+BEGIN_SRC emacs-lisp
  1028. (use-package ess
  1029. :ensure t
  1030. :defer t
  1031. :init
  1032. (if *work_remote*
  1033. (setq exec-path (append exec-path '("P:/Tools/R/bin/x64"))
  1034. org-babel-R-command "P:/Tools/R/bin/x64/R --slave --no-save")))
  1035. #+END_SRC
  1036. ** Python
  1037. :PROPERTIES:
  1038. :ID: 8c76fcd1-c57c-48ab-8af0-aa782de6337f
  1039. :END:
  1040. Systemseitig muss python-language-server installiert sein:
  1041. apt install python3-pip python3-setuptools python3-wheel
  1042. apt install build-essential python3-dev
  1043. pip3 install 'python-language-server[all]'
  1044. für andere language servers
  1045. https://github.com/emacs-lsp/lsp-mode#install-language-server
  1046. #+BEGIN_SRC emacs-lisp
  1047. (use-package lsp-python-ms
  1048. :if *sys/linux*
  1049. :ensure t
  1050. :defer t
  1051. :custom (lsp-python-ms-auto-install-server t))
  1052. (use-package python
  1053. :if *sys/linux*
  1054. :delight "π "
  1055. :defer t
  1056. :bind (("M-[" . python-nav-backward-block)
  1057. ("M-]" . python-nav-forward-block)))
  1058. (use-package pyvenv
  1059. :if *sys/linux*
  1060. :ensure t
  1061. :defer t
  1062. :after python
  1063. :hook ((python-mode . pyvenv-mode)
  1064. (python-mode . (lambda ()
  1065. (if-let ((pyvenv-directory (find-pyvenv-directory (buffer-file-name))))
  1066. (pyvenv-activate pyvenv-directory))
  1067. (lsp))))
  1068. :custom
  1069. (pyvenv-default-virtual-env-name "env")
  1070. (pyvenv-mode-line-indicator '(pyvenv-virtual-env-name ("[venv:" pyvenv-virtual-env-name "]")))
  1071. :preface
  1072. (defun find-pyvenv-directory (path)
  1073. "Check if a pyvenv directory exists."
  1074. (cond
  1075. ((not path) nil)
  1076. ((file-regular-p path) (find-pyvenv-directory (file-name-directory path)))
  1077. ((file-directory-p path)
  1078. (or
  1079. (seq-find
  1080. (lambda (path) (file-regular-p (expand-file-name "pyvenv.cfg" path)))
  1081. (directory-files path t))
  1082. (let ((parent (file-name-directory (directory-file-name path))))
  1083. (unless (equal parent path) (find-pyvenv-directory parent))))))))
  1084. ;; manage multiple python version
  1085. ;; needs to be installed on system
  1086. ; (use-package pyenv-mode
  1087. ; :ensure t
  1088. ; :after python
  1089. ; :hook ((python-mode . pyenv-mode)
  1090. ; (projectile-switch-project . projectile-pyenv-mode-set))
  1091. ; :custom (pyenv-mode-set "3.8.5")
  1092. ; :preface
  1093. ; (defun projectile-pyenv-mode-set ()
  1094. ; "Set pyenv version matching project name."
  1095. ; (let ((project (projectile-project-name)))
  1096. ; (if (member project (pyenv-mode-versions))
  1097. ; (pyenv-mode-set project)
  1098. ; (pyenv-mode-unset)))))
  1099. ;)
  1100. #+END_SRC
  1101. * beancount
  1102. ** Installation
  1103. :PROPERTIES:
  1104. :ID: 2c329043-b7a9-437d-a5cf-f2ad6514be91
  1105. :END:
  1106. #+BEGIN_SRC shell
  1107. sudo su
  1108. cd /opt
  1109. python3 -m venv beancount
  1110. source ./beancount/bin/activate
  1111. pip3 install wheel
  1112. pip3 install beancount
  1113. sleep 100
  1114. echo "shell running!"
  1115. deactivate
  1116. #+END_SRC
  1117. #+BEGIN_SRC emacs-lisp
  1118. (use-package beancount
  1119. :if *sys/linux*
  1120. :load-path "user-global/elisp"
  1121. ; :ensure t
  1122. :defer t
  1123. :mode
  1124. ("\\.beancount$" . beancount-mode)
  1125. :hook
  1126. (beancount-mode . my/beancount-company)
  1127. :init
  1128. (add-hook 'beancount-mode-hook 'company/beancount-mode-hook)
  1129. :config
  1130. (defun my/beancount-company ()
  1131. (set (make-local-variable 'company-backends)
  1132. '(company-beancount)))
  1133. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount"))
  1134. #+END_SRC
  1135. To support org-babel, check if it can find the symlink to ob-beancount.el
  1136. #+BEGIN_SRC shell
  1137. orgpath=`find /home/marc/.emacs.d/elpa/ -type d -name "org-plus*" -print`
  1138. beansym="$orgpath/ob-beancount.el
  1139. bean="/home/marc/Archiv/Programmierprojekte/Lisp/beancount-mode/ob-beancount.el"
  1140. if [ -h "$beansym" ]
  1141. then
  1142. echo "$beansym found"
  1143. elif [ -e "$bean" ]
  1144. then
  1145. echo "creating symlink"
  1146. ln -s "$bean" "$beansym"
  1147. else
  1148. echo "$bean not found, symlink creation aborted"
  1149. fi
  1150. #+END_SRC
  1151. Fava is strongly recommended.
  1152. #+BEGIN_SRC shell
  1153. cd /opt
  1154. python3 -m venv fava
  1155. source ./fava/bin/activate
  1156. pip3 install wheel
  1157. pip3 install fava
  1158. deactivate
  1159. #+END_SRC
  1160. Start fava with fava my_file.beancount
  1161. It is accessable on this URL: [[http://127.0.0.1:5000][Fava]]
  1162. Beancount-mode can start fava and open the URL right away.
  1163. * Stuff after everything else
  1164. Set garbage collector to a smaller value to let it kick in faster.
  1165. Maybe a problem on Windows?
  1166. #+begin_src emacs-lisp
  1167. (setq gc-cons-threshold (* 2 1000 1000))
  1168. #+end_src