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.

1900 lines
57 KiB

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