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.

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