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