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.

1897 lines
57 KiB

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