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.

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