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.

1854 lines
56 KiB

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