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.

1882 lines
57 KiB

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