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.

1349 lines
37 KiB

5 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
3 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
4 years ago
4 years ago
4 years ago
3 years ago
3 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. #+TITLE: Emacs configuration file
  2. #+AUTHOR: Marc
  3. #+BABEL: :cache yes
  4. #+PROPERTY: header-args :tangle yes
  5. * TODOS
  6. - early-init.el? What to outsource here?
  7. - Paket exec-path-from-shell, um PATH aus Linux auch in emacs zu haben
  8. - Smart mode line?
  9. - Theme
  10. - evil-collection or custom in init file?
  11. - Hydra
  12. - General
  13. - (defalias 'list-buffers 'ibuffer) ;; change default to ibuffer
  14. - ido?
  15. - treemacs (for linux)
  16. - treemacs-evil?
  17. - treemacs-projectile
  18. windmove?
  19. - tramp (in linux)
  20. - visual-regexp
  21. - org configuration: paths
  22. - org custom agenda
  23. - org-ql (related to org agendas)
  24. - org configuration: everything else
  25. - beancount configuration from config.org
  26. - CONTINUE TODO from config.org at Programming
  27. - all-the-icons?
  28. * Header
  29. :PROPERTIES:
  30. :ID: a14d7c89-24ea-41ae-b185-944bab49aa02
  31. :END:
  32. Emacs variables are dynamically scoped. That's unusual for most languages, so disable it here, too
  33. #+begin_src emacs-lisp
  34. ;;; init.el --- -*- lexical-binding: t -*-
  35. #+end_src
  36. * First start
  37. :PROPERTIES:
  38. :ID: 1c24d48e-0124-4a0b-8e78-82e4c531e818
  39. :END:
  40. When pulling the repository the first time, an initial init.el needs to be setup. After start it will replace itself with the configuration from init.org
  41. #+BEGIN_SRC emacs-lisp :tangle no
  42. (require 'org')
  43. (find-file (concat user-emacs-directory "init.org"))
  44. (org-babel-tangle)
  45. (load-file (concat user-emacs-directory "init.el"))
  46. (byte-compile-file (concat user-emacs-directory "init.el"))
  47. #+END_SRC
  48. This function updates init.el whenever changes in init.org are made. The update will be active after saving.
  49. #+BEGIN_SRC emacs-lisp
  50. (defun me/tangle-init ()
  51. "If the current buffer is 'init.org', the code blocks are tangled, and the tangled file is compiled."
  52. (when (equal (buffer-file-name)
  53. (expand-file-name (concat user-emacs-directory "init.org")))
  54. ;; avoid running hooks
  55. (let ((prog-mode-hook nil))
  56. (org-babel-tangle)
  57. (byte-compile-file (concat user-emacs-directory "init.el"))
  58. (load-file user-init-file))))
  59. (add-hook 'after-save-hook 'me/tangle-init)
  60. #+END_SRC
  61. A small function to measure start up time.
  62. Compare that to
  63. emacs -q --eval='(message "%s" (emacs-init-time))'
  64. (roughly 0.27s)
  65. https://blog.d46.us/advanced-emacs-startup/
  66. #+begin_src emacs-lisp
  67. (add-hook 'emacs-startup-hook
  68. (lambda ()
  69. (message "Emacs ready in %s with %d garbage collections."
  70. (format "%.2f seconds"
  71. (float-time
  72. (time-subtract after-init-time before-init-time)))
  73. gcs-done)))
  74. (setq gc-cons-threshold (* 50 1000 1000))
  75. #+end_src
  76. #+BEGIN_SRC emacs-lisp
  77. (require 'package)
  78. (add-to-list 'package-archives '("elpa" . "https://elpa.gnu.org/packages/") t)
  79. (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
  80. (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
  81. (add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
  82. ; fix for bug 34341
  83. (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
  84. (when (< emacs-major-version 27)
  85. (package-initialize))
  86. #+END_SRC
  87. #+BEGIN_SRC emacs-lisp
  88. (unless (package-installed-p 'use-package)
  89. (package-refresh-contents)
  90. (package-install 'use-package))
  91. (eval-when-compile
  92. (require 'use-package))
  93. (require 'bind-key)
  94. (setq use-package-verbose nil)
  95. (use-package diminish
  96. :ensure t)
  97. #+END_SRC
  98. cl is deprecated in favor for cl-lib, some packages like emmet still depend on cl.
  99. Shut off the compiler warning about it.
  100. Maybe turn it on again at some point before the next major emacs upgrade
  101. #+begin_src emacs-lisp
  102. (setq byte-compile-warnings '(cl-functions))
  103. #+end_src
  104. * Default settings
  105. :PROPERTIES:
  106. :ID: 3512d679-d111-4ccd-8372-6fc2acbc0374
  107. :END:
  108. #+BEGIN_SRC emacs-lisp
  109. (defconst *sys/gui*
  110. (display-graphic-p)
  111. "Is emacs running in a gui?")
  112. (defconst *sys/linux*
  113. (string-equal system-type 'gnu/linux)
  114. "Is the system running Linux?")
  115. (defconst *sys/windows*
  116. (string-equal system-type 'windows-nt)
  117. "Is the system running Windows?")
  118. (defconst *home_desktop*
  119. (string-equal (system-name) "marc")
  120. "Is emacs running on my desktop?")
  121. (defconst *home_laptop*
  122. (string-equal (system-name) "laptop")
  123. "Is emacs running on my laptop?")
  124. (defconst *work_local*
  125. (string-equal (system-name) "PMPCNEU08")
  126. "Is emacs running at work on the local system?")
  127. (defconst *work_remote*
  128. (string-equal (system-name) "PMTS01")
  129. "Is emacs running at work on the remote system?")
  130. #+END_SRC
  131. #+BEGIN_SRC emacs-lisp
  132. (defvar MY--PATH_USER_LOCAL (concat user-emacs-directory "user-local/"))
  133. (defvar MY--PATH_USER_GLOBAL (concat user-emacs-directory "user-global/"))
  134. (add-to-list 'custom-theme-load-path (concat MY--PATH_USER_GLOBAL "themes"))
  135. (when *sys/linux*
  136. (defconst MY--PATH_ORG_FILES (expand-file-name "~/Archiv/Organisieren/"))
  137. (defconst MY--PATH_ORG_FILES_MOBILE (expand-file-name "~/Archiv/Organisieren/mobile/")))
  138. (defconst MY--PATH_ORG_JOURNAl (expand-file-name "~/Archiv/Organisieren/Journal/"))
  139. (when *work_remote*
  140. (defconst MY--PATH_ORG_FILES "p:/Eigene Dateien/Notizen/")
  141. (defconst MY--PATH_ORG_FILES_MOBILE nil) ;; hacky way to prevent "free variable" compiler error
  142. (defconst MY--PATH_ORG_JOURNAL nil) ;; hacky way to prevent "free variable" compiler error
  143. (defconst MY--PATH_START "p:/Eigene Dateien/Notizen/"))
  144. (setq recentf-save-file (concat MY--PATH_USER_LOCAL "recentf"))
  145. ;; exclude some dirs from spamming recentf
  146. (use-package recentf
  147. :config
  148. (recentf-mode)
  149. (setq recentf-exclude '(".*-autoloads\\.el\\"
  150. "[/\\]\\.elpa/")))
  151. (setq custom-file (concat MY--PATH_USER_LOCAL "custom.el")) ;; don't spam init.e with saved customization settings
  152. (setq backup-directory-alist `((".*" . ,temporary-file-directory)))
  153. (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory)))
  154. (setq-default create-lockfiles nil) ;; disable lock files, can cause trouble in e.g. lsp-mode
  155. (defalias 'yes-or-no-p 'y-or-n-p) ;; answer with y and n
  156. (setq custom-safe-themes t) ;; don't ask me if I want to load a theme
  157. (setq sentence-end-double-space nil) ;; don't coun two spaces after a period as the end of a sentence.
  158. (delete-selection-mode t) ;; delete selected region when typing
  159. (save-place-mode 1) ;; saves position in file when it's closed
  160. (setq save-place-forget-unreadable-files nil) ;; checks if file is readable before saving position
  161. (set-charset-priority 'unicode)
  162. (setq locale-coding-system 'utf-8)
  163. (set-terminal-coding-system 'utf-8)
  164. (set-keyboard-coding-system 'utf-8)
  165. (set-selection-coding-system 'utf-8)
  166. (setq default-process-coding-system '(utf-8-unix . utf-8-unix))
  167. (if *sys/windows*
  168. (prefer-coding-system 'utf-8-dos)
  169. (prefer-coding-system 'utf-8))
  170. (blink-cursor-mode -1) ;; turn off blinking cursor
  171. (column-number-mode t)
  172. (setq uniquify-buffer-name-style 'forward)
  173. (setq-default indent-tabs-mode nil) ;; avoid tabs in place of multiple spaces (they look bad in tex)
  174. (setq-default indicate-empty-lines t) ;; show empty lines
  175. (setq scroll-margin 5 ;; smooth scrolling
  176. scroll-conservatively 10000
  177. scroll-preserve-screen-position 1
  178. scroll-step 1)
  179. (global-hl-line-mode t) ;; highlight current line
  180. (menu-bar-mode 0) ;; disable menu bar
  181. (tool-bar-mode 0) ;; disable tool bar
  182. (scroll-bar-mode 0) ;; disable scroll bar
  183. (setq ring-bell-function 'ignore ;; disable pc speaker bell
  184. visible-bell t)
  185. #+END_SRC
  186. Bookmarks
  187. Usage:
  188. - C-x r m (bookmark-set): add bookmark
  189. - C-x r l (list-bookmark): list bookmarks
  190. - C-x r b (bookmark-jump): open bookmark
  191. Edit bookmarks (while in bookmark file):
  192. - d: mark current item
  193. - x: delete marked items
  194. - r: rename current item
  195. - s: save changes
  196. #+begin_src emacs-lisp
  197. (use-package bookmark
  198. :custom
  199. (bookmark-default-file (concat MY--PATH_USER_LOCAL "bookmarks")))
  200. #+end_src
  201. Some windows specific stuff
  202. #+BEGIN_SRC emacs-lisp
  203. (when *sys/windows*
  204. (remove-hook 'find-file-hook 'vc-refresh-state)
  205. (progn
  206. (setq gc-cons-threshold (* 511 1024 1024)
  207. gc-cons-percentage 0.5
  208. garbage-collection-messages t)
  209. (run-with-idle-timer 5 t #'garbage-collect))
  210. (when (boundp 'w32-pipe-read-delay)
  211. (setq w32-pipe-read-delay 0))
  212. (when (boundp 'w32-get-true-file-attributes)
  213. (setq w32-get-true-file-attributes nil)))
  214. #+END_SRC
  215. * visuals
  216. ** Font
  217. :PROPERTIES:
  218. :ID: dc8eb670-e6bb-4bfb-98f0-aae1860234fb
  219. :END:
  220. #+BEGIN_SRC emacs-lisp
  221. (when *sys/linux*
  222. (set-face-font 'default "Hack-10"))
  223. (when *work_remote*
  224. (set-face-font 'default "Lucida Sans Typewriter-11"))
  225. #+END_SRC
  226. ** Themes
  227. :PROPERTIES:
  228. :ID: 9ccf37c0-6837-43cb-bed8-5a353799d8b1
  229. :END:
  230. #+BEGIN_SRC emacs-lisp
  231. (defun my/toggle-theme ()
  232. (interactive)
  233. (when (or *sys/windows* *sys/linux*)
  234. (if (eq (car custom-enabled-themes) 'tango-dark)
  235. (progn (disable-theme 'tango-dark)
  236. (load-theme 'tango))
  237. (progn
  238. (disable-theme 'tango)
  239. (load-theme 'tango-dark)))))
  240. (bind-key "C-c t" 'my/toggle-theme)
  241. #+END_SRC
  242. Windows Theme:
  243. #+BEGIN_SRC emacs-lisp
  244. (when *sys/windows*
  245. (load-theme 'tango))
  246. (when *sys/linux*
  247. (load-theme 'plastic))
  248. #+END_SRC
  249. ** line wrappings
  250. :PROPERTIES:
  251. :ID: 14ae933e-2941-4cc3-82de-38f90f91bfd3
  252. :END:
  253. #+BEGIN_SRC emacs-lisp
  254. (global-visual-line-mode)
  255. (diminish 'visual-line-mode)
  256. (use-package adaptive-wrap
  257. :ensure t
  258. :config
  259. (add-hook 'visual-line-mode-hook #'adaptive-wrap-prefix-mode))
  260. ; :init
  261. ; (when (fboundp 'adaptive-wrap-prefix-mode)
  262. ; (defun my/activate-adaptive-wrap-prefix-mode ()
  263. ; "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously."
  264. ; (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1)))
  265. ; (add-hook 'visual-line-mode-hook 'my/activate-adaptive-wrap-prefix-mode)))
  266. #+END_SRC
  267. ** line numbers
  268. :PROPERTIES:
  269. :ID: 7b969436-98c9-4b61-ba7a-9fb22c9781ad
  270. :END:
  271. #+BEGIN_SRC emacs-lisp
  272. (use-package display-line-numbers
  273. :init
  274. (add-hook 'prog-mode-hook 'display-line-numbers-mode)
  275. (add-hook 'org-src-mode-hook 'display-line-numbers-mode)
  276. :config
  277. (setq-default display-line-numbers-type 'visual
  278. display-line-numbers-current-absolute t
  279. display-line-numbers-with 4
  280. display-line-numbers-widen t))
  281. ; (add-hook 'emacs-lisp-mode-hook 'display-line-numbers-mode)
  282. #+END_SRC
  283. ** misc
  284. :PROPERTIES:
  285. :ID: a2873138-16ee-4990-89a2-26eab778ea74
  286. :END:
  287. #+BEGIN_SRC emacs-lisp
  288. (use-package rainbow-mode
  289. :ensure t
  290. :diminish
  291. :hook
  292. ((org-mode
  293. emacs-lisp-mode) . rainbow-mode))
  294. (use-package delight
  295. :ensure t)
  296. (show-paren-mode t) ;; show other part of brackets
  297. (use-package rainbow-delimiters
  298. :ensure t
  299. :hook
  300. (prog-mode . rainbow-delimiters-mode))
  301. #+END_SRC
  302. * undo
  303. :PROPERTIES:
  304. :ID: d57621b2-5472-4c89-a520-b4133db0b9af
  305. :END:
  306. #+BEGIN_SRC emacs-lisp
  307. (use-package undo-tree
  308. :ensure t
  309. :diminish undo-tree-mode
  310. :init
  311. (global-undo-tree-mode 1))
  312. #+END_SRC
  313. * ace-window
  314. #+begin_src emacs-lisp
  315. (use-package ace-window
  316. :ensure t
  317. :bind
  318. (:map global-map
  319. ("C-x o" . ace-window)))
  320. #+end_src
  321. * imenu-list
  322. :PROPERTIES:
  323. :ID: 0ae27ec9-5d77-43cf-ac76-5e12cc959046
  324. :END:
  325. A minor mode to show imenu in a sidebar.
  326. Call imenu-list-smart-toggle.
  327. [[https://github.com/bmag/imenu-list][Source]]
  328. #+BEGIN_SRC emacs-lisp
  329. (use-package imenu-list
  330. :ensure t
  331. :defer t
  332. :config
  333. (setq imenu-list-focus-after-activation t
  334. imenu-list-auto-resize t
  335. imenu-list-position 'right)
  336. :bind
  337. (:map global-map
  338. ([f9] . imenu-list-smart-toggle))
  339. :custom
  340. (org-imenu-depth 4)
  341. )
  342. #+END_SRC
  343. * which-key
  344. :PROPERTIES:
  345. :ID: a880f079-b3a3-4706-bf1e-5f6c680101f1
  346. :END:
  347. #+BEGIN_SRC emacs-lisp
  348. (use-package which-key
  349. :ensure t
  350. :diminish which-key-mode
  351. :defer t
  352. :config
  353. (which-key-mode)
  354. (which-key-setup-side-window-right-bottom)
  355. (which-key-setup-minibuffer)
  356. (setq which-key-idle-delay 0.5))
  357. #+END_SRC
  358. * abbrev
  359. #+begin_src emacs-lisp
  360. (use-package abbrev
  361. :diminish abbrev-mode
  362. :hook
  363. ((text-mode org-mode) . abbrev-mode)
  364. :init
  365. (setq abbrev-file-name (concat MY--PATH_USER_GLOBAL "abbrev_tables.el"))
  366. :config
  367. (if (file-exists-p abbrev-file-name)
  368. (quietly-read-abbrev-file))
  369. (setq save-abbrevs 'silently)) ;; don't bother me with asking for abbrev saving
  370. #+end_src
  371. * Evil
  372. :PROPERTIES:
  373. :ID: 80ca70e2-a146-46db-b581-418d655dc1fc
  374. :END:
  375. #+BEGIN_SRC emacs-lisp
  376. (use-package evil
  377. :ensure t
  378. :defer .1 ;; don't block emacs when starting, load evil immediately after startup
  379. :config
  380. (evil-mode 1))
  381. #+END_SRC
  382. * General (key mapper)
  383. :PROPERTIES:
  384. :ID: a20f183f-d41a-4dff-bc37-3bc4e25c8036
  385. :END:
  386. #+BEGIN_SRC emacs-lisp
  387. (use-package general
  388. :ensure t)
  389. (general-define-key
  390. :states 'normal
  391. :keymaps 'imenu-list-major-mode-map
  392. "RET" '(imenu-list-goto-entry :which-key "goto")
  393. "TAB" '(hs-toggle-hiding :which-key "collapse")
  394. "d" '(imenu-list-display-entry :which-key "show")
  395. "q" '(imenu-list-quit-window :which-key "quit"))
  396. #+END_SRC
  397. * ivy / counsel / swiper
  398. :PROPERTIES:
  399. :ID: 55c74ba9-7761-4545-8ddd-087d6ee33e4b
  400. :END:
  401. #+BEGIN_SRC emacs-lisp
  402. ; (require 'ivy)
  403. (use-package ivy
  404. :ensure t
  405. :diminish
  406. (ivy-mode . "")
  407. :defer t
  408. :init
  409. (ivy-mode 1)
  410. :bind
  411. ("C-r" . ivy-resume) ;; overrides isearch-backwards binding
  412. :config
  413. (setq ivy-use-virtual-buffers t ;; recent files and bookmarks in ivy-switch-buffer
  414. ivy-height 20 ;; height of ivy window
  415. ivy-count-format "%d/%d" ;; current and total number
  416. ivy-re-builders-alist ;; regex replaces spaces with *
  417. '((t . ivy--regex-plus))))
  418. ; make counsel-M-x more descriptive
  419. (use-package ivy-rich
  420. :ensure t
  421. :defer t
  422. :init
  423. (ivy-rich-mode 1))
  424. (use-package counsel
  425. :ensure t
  426. :defer t
  427. :bind
  428. (("M-x" . counsel-M-x)
  429. ("C-x C-f" . counsel-find-file)
  430. ("C-x C-r" . counsel-recentf)
  431. ("C-x b" . counsel-switch-buffer)
  432. ("C-c C-f" . counsel-git)
  433. ("C-c h f" . counsel-describe-function)
  434. ("C-c h v" . counsel-describe-variable)
  435. ("M-i" . counsel-imenu)))
  436. ; :map minibuffer-local-map ;;currently mapped to evil-redo
  437. ; ("C-r" . 'counsel-minibuffer-history)))
  438. (use-package swiper
  439. :ensure t
  440. :bind
  441. ("C-s" . swiper))
  442. (use-package ivy-hydra
  443. :ensure t)
  444. #+END_SRC
  445. * misc
  446. #+begin_src emacs-lisp
  447. (use-package autorevert
  448. :diminish auto-revert-mode)
  449. #+end_src
  450. * company
  451. :PROPERTIES:
  452. :ID: 944563b6-b04a-44f2-9b21-a6a3e200867c
  453. :END:
  454. #+BEGIN_SRC emacs-lisp
  455. (use-package company
  456. :defer 1
  457. :diminish
  458. :defer t
  459. :bind
  460. (("C-<tab>" . company-complete)
  461. :map company-active-map
  462. ("RET" . nil)
  463. ([return] . nil)
  464. ("TAB" . company-complete-selection)
  465. ([tab] . company-complete-selection)
  466. ("<right>" . company-complete-common))
  467. :hook
  468. (after-init . global-company-mode)
  469. (emacs-lisp-mode . my/company-elisp)
  470. (org-mode . my/company-org)
  471. :config
  472. (defun my/company-elisp ()
  473. (message "set up company for elisp")
  474. (set (make-local-variable 'company-backends)
  475. '(company-yasnippet
  476. company-capf
  477. company-dabbrev-code
  478. company-files)))
  479. (defun my/company-org ()
  480. (set (make-local-variable 'company-backends)
  481. '(company-capf company-files))
  482. ;; (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  483. (message "setup company for org"))
  484. (setq company-idle-delay .2
  485. company-minimum-prefix-length 1
  486. company-require-match nil
  487. company-show-numbers t
  488. company-tooltip-align-annotations t))
  489. (use-package company-statistics
  490. :ensure t
  491. :after company
  492. :defer t
  493. :init
  494. (setq company-statistics-file (concat MY--PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el")
  495. :config
  496. (company-statistics-mode 1))
  497. (use-package company-dabbrev
  498. :ensure nil
  499. :after company
  500. :defer t
  501. :config
  502. (setq-default company-dabbrev-downcase nil))
  503. ;; adds a info box right of the cursor with doc of the function
  504. (use-package company-box
  505. :ensure t
  506. :diminish
  507. :defer t
  508. :hook
  509. (company-mode . company-box-mode))
  510. ; :init
  511. ; (add-hook 'company-mode-hook 'company-box-mode))
  512. #+END_SRC
  513. * orgmode
  514. ** org
  515. :PROPERTIES:
  516. :ID: b89d7639-080c-4168-8884-bd5d8965f466
  517. :END:
  518. #+BEGIN_SRC emacs-lisp
  519. (use-package org
  520. :ensure org-plus-contrib
  521. :mode (("\.org$" . org-mode))
  522. :diminish org-indent-mode
  523. :defer t
  524. :hook
  525. (org-mode . org-indent-mode)
  526. (org-source-mode . smartparens-mode)
  527. ; :init
  528. ; (add-hook 'org-mode-hook 'company/org-mode-hook)
  529. ; (add-hook 'org-src-mode-hook 'smartparens-mode)
  530. ; (add-hook 'org-mode-hook 'org-indent-mode)
  531. :config
  532. (defun my/org-company ()
  533. (set (make-local-variable 'company-backends)
  534. '(company-capf company-files))
  535. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  536. (message "company/org-mode-hook"))
  537. (setq org-modules (quote (org-id
  538. org-habit
  539. org-tempo ;; easy templates
  540. )))
  541. (setq org-default-notes-file (concat MY--PATH_ORG_FILES "notes.org")
  542. org-agenda-files (list (concat MY--PATH_ORG_FILES "notes.org")
  543. (concat MY--PATH_ORG_FILES "projects.org")
  544. (concat MY--PATH_ORG_FILES "tasks.org")))
  545. (when *sys/linux*
  546. (nconc org-agenda-files
  547. (directory-files-recursively MY--PATH_ORG_FILES_MOBILE "\\.org$")))
  548. (setq org-id-locations-file (concat MY--PATH_USER_LOCAL ".org-id-locations")
  549. org-log-into-drawer "LOGBOOK")
  550. ;; some display customizations
  551. (setq org-pretty-entities t
  552. org-startup-truncated t
  553. org-startup-align-all-tables t)
  554. ;; some source code blocks customizations
  555. (setq org-src-window-setup 'current-window ;; C-c ' opens in current window
  556. org-src-fontify-natively t ;; use syntax highlighting in code blocks
  557. org-src-preserve-indentation t ;; no extra indentation
  558. org-src-tab-acts-natively t)
  559. (setq org-log-done 'time)) ;; create timestamp when task is done
  560. #+END_SRC
  561. ** languages
  562. :PROPERTIES:
  563. :ID: ad3af718-d0db-448c-9f75-eb9e250c2862
  564. :END:
  565. Set some languages and disable confirmation for evaluating code blocks C-c C-c
  566. +BEGIN_SRC emacs-lisp
  567. (org-babel-do-load-languages
  568. 'org-babel-load-languages
  569. '((emacs-lisp . t)
  570. (gnuplot . t)
  571. (js . t)
  572. (latex . t)
  573. (lisp . t)
  574. (python . t)
  575. (shell . t)
  576. (sqlite . t)
  577. (org . t)
  578. (R . t)
  579. (scheme . t)))
  580. (setq org-confirm-babel-evaluate nil)
  581. +END_SRC
  582. Another setup, because org-babel-do-load-languages requires eager loading
  583. #+begin_src emacs-lisp
  584. (use-package ob-org
  585. :defer t
  586. :ensure org-plus-contrib
  587. :commands
  588. (org-babel-execute:org
  589. org-babel-expand-body:org))
  590. (use-package ob-python
  591. :defer t
  592. :ensure org-plus-contrib
  593. :commands (org-babel-execute:python))
  594. (use-package ob-js
  595. :defer t
  596. :ensure org-plus-contrib
  597. :commands (org-babel-execute:js))
  598. (use-package ob-shell
  599. :defer t
  600. :ensure org-plus-contrib
  601. :commands
  602. (org-babel-execute:sh
  603. org-babel-expand-body:sh
  604. org-babel-execute:bash
  605. org-babel-expand-body:bash))
  606. (use-package ob-emacs-lisp
  607. :defer t
  608. :ensure org-plus-contrib
  609. :commands
  610. (org-babel-execute:emacs-lisp
  611. org-babel-expand-body:emacs-lisp))
  612. (use-package ob-lisp
  613. :defer t
  614. :ensure org-plus-contrib
  615. :commands
  616. (org-babel-execute:lisp
  617. org-babel-expand-body:lisp))
  618. (use-package ob-gnuplot
  619. :defer t
  620. :ensure org-plus-contrib
  621. :commands
  622. (org-babel-execute:gnuplot
  623. org-babel-expand-body:gnuplot))
  624. (use-package ob-sqlite
  625. :defer t
  626. :ensure org-plus-contrib
  627. :commands
  628. (org-babel-execute:sqlite
  629. org-babel-expand-body:sqlite))
  630. (use-package ob-latex
  631. :defer t
  632. :ensure org-plus-contrib
  633. :commands
  634. (org-babel-execute:latex
  635. org-babel-expand-body:latex))
  636. (use-package ob-R
  637. :defer t
  638. :ensure org-plus-contrib
  639. :commands
  640. (org-babel-execute:R
  641. org-babel-expand-body:R))
  642. (use-package ob-scheme
  643. :defer t
  644. :ensure org-plus-contrib
  645. :commands
  646. (org-babel-execute:scheme
  647. org-babel-expand-body:scheme))
  648. #+end_src
  649. ** habits
  650. :PROPERTIES:
  651. :ID: fcc91d0a-d040-4910-b2cf-3221496a3842
  652. :END:
  653. #+BEGIN_SRC emacs-lisp
  654. (require 'org-habit) ;;TODO Lösung ohne require finden, scheint mir nicht ideal zu sein, nur um ein org-modul zu aktivieren
  655. ;; (add-to-list 'org-modules "org-habit")
  656. (setq org-habit-graph-column 80
  657. org-habit-preceding-days 30
  658. org-habit-following-days 7
  659. org-habit-show-habits-only-for-today nil)
  660. #+END_SRC
  661. ** org-id
  662. :PROPERTIES:
  663. :ID: c4017c45-d650-410c-8bd4-bc3cf42bbbb9
  664. :END:
  665. Currently it causes some debugger errors "not a standard org time string", so it's disabled
  666. #+BEGIN_SRC emacs-lisp
  667. ;; (use-package org-id
  668. ;; :config
  669. ;; (setq org-id-link-to-org-use-id t)
  670. ;; (org-id-update-id-locations)) ;; update id file .org-id-locations on startup
  671. #+END_SRC
  672. ** org-agenda
  673. :PROPERTIES:
  674. :ID: 03b67efb-4179-41e5-bc2e-c472b13f8be6
  675. :END:
  676. Custom keywords, depending on environment
  677. #+BEGIN_SRC emacs-lisp
  678. (when *work_remote*
  679. (setq org-todo-keywords
  680. '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE" "CANCELLED"))))
  681. #+END_SRC
  682. Add some key bindings
  683. #+BEGIN_SRC emacs-lisp
  684. (bind-key "C-c l" 'org-store-link)
  685. (bind-key "C-c c" 'org-capture)
  686. (bind-key "C-c a" 'org-agenda)
  687. #+END_SRC
  688. Sort agenda by deadline and priority
  689. #+BEGIN_SRC emacs-lisp
  690. (setq org-agenda-sorting-strategy
  691. (quote
  692. ((agenda deadline-up priority-down)
  693. (todo priority-down category-keep)
  694. (tags priority-down category-keep)
  695. (search category-keep))))
  696. #+END_SRC
  697. Customize the org agenda
  698. #+BEGIN_SRC emacs-lisp
  699. (defun me--org-skip-subtree-if-priority (priority)
  700. "Skip an agenda subtree if it has a priority of PRIORITY.
  701. PRIORITY may be one of the characters ?A, ?B, or ?C."
  702. (let ((subtree-end (save-excursion (org-end-of-subtree t)))
  703. (pri-value (* 1000 (- org-lowest-priority priority)))
  704. (pri-current (org-get-priority (thing-at-point 'line t))))
  705. (if (= pri-value pri-current)
  706. subtree-end
  707. nil)))
  708. (setq org-agenda-custom-commands
  709. '(("c" "Simple agenda view"
  710. ((tags "PRIORITY=\"A\""
  711. ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
  712. (org-agenda-overriding-header "Hohe Priorität:")))
  713. (agenda ""
  714. ((org-agenda-span 7)
  715. (org-agenda-start-on-weekday nil)
  716. (org-agenda-overriding-header "Nächste 7 Tage:")))
  717. (alltodo ""
  718. ((org-agenda-skip-function '(or (me--org-skip-subtree-if-priority ?A)
  719. (org-agenda-skip-if nil '(scheduled deadline))))
  720. (org-agenda-overriding-header "Sonstige Aufgaben:")))))))
  721. #+END_SRC
  722. ** *TODO*
  723. org-super-agenda
  724. ** org-caldav
  725. :PROPERTIES:
  726. :ID: 6bd24369-0d04-452f-85a0-99914dfb74ff
  727. :END:
  728. Vorerst deaktiviert, Nutzen evtl. nicht vorhanden
  729. #+BEGIN_SRC emacs-lisp
  730. ;;(use-package org-caldav
  731. ;; :ensure t
  732. ;; :config
  733. ;; (setq org-caldav-url "https://nextcloud.cloudsphere.duckdns.org/remote.php/dav/calendars/marc"
  734. ;; org-caldav-calendar-id "orgmode"
  735. ;; org-caldav-inbox (expand-file-name "~/Archiv/Organisieren/caldav-inbox")
  736. ;; org-caldav-files (concat MY--PATH_ORG_FILES "tasks")))
  737. #+END_SRC
  738. ** journal
  739. :PROPERTIES:
  740. :ID: a1951e18-d862-4198-9652-016e979053c8
  741. :END:
  742. [[https://github.com/bastibe/org-journal][Source]]
  743. #+BEGIN_SRC emacs-lisp
  744. (use-package org-journal
  745. :if *sys/linux*
  746. :ensure t
  747. :defer t
  748. :config
  749. ;; feels hacky, but this way compiler error "assignment to free variable" disappears
  750. (when (and (boundp 'org-journal-dir)
  751. (boundp 'org-journal-enable-agenda-integration))
  752. (setq org-journal-dir MY--PATH_ORG_JOURNAl
  753. org-journal-enable-agenda-integration t)))
  754. #+END_SRC
  755. * Programming
  756. ** misc
  757. #+begin_src emacs-lisp
  758. (use-package eldoc
  759. :diminish eldoc-mode
  760. :defer t)
  761. #+end_src
  762. ** Magit / Git
  763. :PROPERTIES:
  764. :ID: d3589460-317f-40f6-9056-053be9ba3217
  765. :END:
  766. Little crash course in magit:
  767. - magit-init to init a git project
  768. - magit-status (C-x g) to call the status window
  769. In status buffer:
  770. - s stage files
  771. - u unstage files
  772. - U unstage all files
  773. - a apply changes to staging
  774. - c c commit (type commit message, then C-c C-c to commit)
  775. - b b switch to another branch
  776. - P u git push
  777. - F u git pull
  778. #+BEGIN_SRC emacs-lisp
  779. (use-package magit
  780. :ensure t
  781. :defer t
  782. :init
  783. ; set git-path in work environment
  784. (if (string-equal user-login-name "POH")
  785. (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe")
  786. )
  787. :bind (("C-x g" . magit-status)))
  788. #+END_SRC
  789. ** LSP
  790. :PROPERTIES:
  791. :ID: 06ad00e0-44a6-4bfb-ba6f-b1672811e053
  792. :END:
  793. Configuration for the language server protocol
  794. *ACHTUNG* Dateipfad muss absolut sein, symlink im Pfad führt zumindest beim ersten Start zu Fehlern beim lsp
  795. Sobald der lsp einmal lief, kann zukünftig der symlink-Pfad genommen werden.
  796. Getestet wurde die funktionierende Datei selbst und neu erstellte Dateien im selben Pfad.
  797. TODO Unterverzeichnisse wurden noch nicht getestet
  798. #+BEGIN_SRC emacs-lisp
  799. (setq read-process-output-max (* 1024 1024)) ;; support reading large blobs of data for LSP's sake
  800. (use-package lsp-mode
  801. :defer t
  802. :commands (lsp lsp-execute-code-action)
  803. :custom
  804. (lsp-auto-guess-root nil)
  805. (lsp-prefer-flymake nil) ; use flycheck instead
  806. (lsp-file-watch-threshold 5000)
  807. (lsb-print-performance t)
  808. (lsp-log-io nil) ; enable log only for debug
  809. (lsp-enable-folding t) ; default, maybe evil-matchit instead for performance?
  810. (lsp-diagnostics-modeline-scope :project)
  811. (lsp-enable-file-watchers nil)
  812. :bind (:map lsp-mode-map ("C-c C-f" . lsp-format-buffer))
  813. :hook
  814. (((python-mode
  815. js-mode
  816. js2-mode
  817. typescript-mode
  818. web-mode
  819. ) . lsp)
  820. (lsp-mode . lsp-enable-which-key-integration)
  821. (lsp-mode . lsp-diagnostics-modeline-mode))
  822. :config
  823. (setq lsp-diagnostics-package :none) ; disable flycheck-lsp for most modes
  824. (add-hook 'web-mode-hook #'lsp-flycheck-enable)) ; enable flycheck-lsp for web-mode locally
  825. (use-package lsp-ui
  826. :after lsp-mode
  827. :ensure t
  828. :defer t
  829. :diminish
  830. :commands lsp-ui-mode
  831. :config
  832. (setq lsp-ui-doc-enable t
  833. lsp-ui-doc-header t
  834. lsp-ui-doc-include-signature t
  835. lsp-ui-doc-position 'top
  836. lsp-ui-doc-border (face-foreground 'default)
  837. lsp-ui-sideline-enable nil
  838. lsp-ui-sideline-ignore-duplicate t
  839. lsp-ui-sideline-show-code-actions nil)
  840. (when *sys/gui*
  841. (setq lsp-ui-doc-use-webkit t))
  842. ;; workaround hide mode-line of lsp-ui-imenu buffer
  843. (defadvice lsp-ui-imenu (after hide-lsp-ui-imenu-mode-line activate)
  844. (setq mode-line-format nil)))
  845. ;;NO LONGER SUPPORTED, USE company-capf / completion-at-point
  846. (use-package company-lsp
  847. :requires company
  848. :defer t
  849. :ensure t
  850. :config
  851. ;;disable client-side cache because lsp server does a better job
  852. (setq company-transformers nil
  853. company-lsp-async t
  854. company-lsp-cache-candidates nil))
  855. #+END_SRC
  856. ** yasnippet
  857. :PROPERTIES:
  858. :ID: 935d89ef-645e-4e92-966f-2fe3bebb2880
  859. :END:
  860. For useful snippet either install yasnippet-snippets or get them from here
  861. [[https://github.com/AndreaCrotti/yasnippet-snippets][Github]]
  862. #+begin_src emacs-lisp
  863. (use-package yasnippet
  864. :ensure t
  865. :defer t
  866. :diminish yas-minor-mode
  867. :config
  868. (setq yas-snippet-dirs (list (concat MY--PATH_USER_GLOBAL "snippets")))
  869. (yas-global-mode t)
  870. (yas-reload-all)
  871. (unbind-key "TAB" yas-minor-mode-map)
  872. (unbind-key "<tab>" yas-minor-mode-map))
  873. #+end_src
  874. ** hippie expand
  875. :PROPERTIES:
  876. :ID: c55245bc-813d-4816-a0ca-b4e2e793e28b
  877. :END:
  878. With hippie expand I am able to use yasnippet and emmet at the same time with the same key.
  879. #+begin_src emacs-lisp
  880. (use-package hippie-exp
  881. :defer t
  882. :bind
  883. ("C-<return>" . hippie-expand)
  884. :config
  885. (setq hippie-expand-try-functions-list
  886. '(yas-hippie-try-expand emmet-expand-line)))
  887. #+end_src
  888. ** flycheck
  889. :PROPERTIES:
  890. :ID: 3d8f2547-c5b3-46d0-91b0-9667f9ee5c47
  891. :END:
  892. #+BEGIN_SRC emacs-lisp
  893. (use-package flycheck
  894. :ensure t
  895. :hook
  896. ((css-mode . flycheck-mode)
  897. (emacs-lisp-mode . flycheck-mode)
  898. (python-mode . flycheck-mode))
  899. :defer 1.0
  900. :init
  901. (setq flycheck-emacs-lisp-load-path 'inherit)
  902. :config
  903. (setq-default
  904. flycheck-check-synta-automatically '(save mode-enabled)
  905. flycheck-disable-checkers '(emacs-lisp-checkdoc)
  906. eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck
  907. flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages
  908. #+END_SRC
  909. ** Projectile
  910. :PROPERTIES:
  911. :ID: a90329fd-4d36-435f-8308-a2771ac4c320
  912. :END:
  913. Manage projects and jump quickly between its files
  914. #+BEGIN_SRC emacs-lisp
  915. (defun set-workon_home()
  916. (setenv "WORKON_HOME" (projectile-project-root))
  917. (message "set workon_home"))
  918. (use-package projectile
  919. :ensure t
  920. ; :defer 1.0
  921. :diminish
  922. ; :hook (projectile-after-switch-project . (lambda ()
  923. ; (set-workon_home)
  924. ; (message "set workon_home"))) ;; for pyvenv to auto activate environment
  925. ; :hook (projectile-after-switch-project #'set-workon_home)
  926. :bind-keymap
  927. ("C-c p" . projectile-command-map)
  928. ;:preface
  929. :init
  930. (setq-default projectile-cache-file (concat MY--PATH_USER_LOCAL ".projectile-cache")
  931. projectile-known-projects-file (concat MY--PATH_USER_LOCAL ".projectile-bookmarks"))
  932. :config
  933. (projectile-mode t)
  934. ; (add-hook 'projectile-after-switch-project-hook #'set-workon_home)
  935. (setq-default projectile-completion-system 'ivy
  936. projectile-enable-caching t
  937. projectile-mode-line '(:eval (projectile-project-name))))
  938. ;; requires ripgrep on system for rg functions
  939. (use-package counsel-projectile
  940. :ensure t
  941. :config (counsel-projectile-mode))
  942. #+END_SRC
  943. ** smartparens
  944. :PROPERTIES:
  945. :ID: 997ec416-33e6-41ed-8c7c-75a7bc47d285
  946. :END:
  947. #+BEGIN_SRC emacs-lisp
  948. (use-package smartparens
  949. :ensure t
  950. :diminish smartparens-mode
  951. :bind
  952. (:map smartparens-mode-map
  953. ("C-M-f" . sp-forward-sexp)
  954. ("C-M-b" . sp-backward-sexp)
  955. ("C-M-a" . sp-backward-down-sexp)
  956. ("C-M-e" . sp-up-sexp)
  957. ("C-M-w" . sp-copy-sexp)
  958. ("M-k" . sp-kill-sexp)
  959. ("C-M-<backspace>" . sp-slice-sexp-killing-backward)
  960. ("C-S-<backspace>" . sp-slice-sexp-killing-around)
  961. ("C-]" . sp-select-next-thing-exchange))
  962. :config
  963. (setq sp-show-pair-from-inside nil
  964. sp-escape-quotes-after-insert nil)
  965. (require 'smartparens-config))
  966. #+END_SRC
  967. ** lisp
  968. :PROPERTIES:
  969. :ID: a2bc3e08-b203-49d3-b337-fb186a14eecb
  970. :END:
  971. #+BEGIN_SRC emacs-lisp
  972. (use-package elisp-mode
  973. :defer t)
  974. #+END_SRC
  975. ** web
  976. :PROPERTIES:
  977. :ID: c0b0b4e4-2162-429f-b80d-6e5334b1290e
  978. :END:
  979. apt install npm
  980. sudo npm install -g vscode-html-languageserver-bin
  981. evtl alternativ typescript-language-server?
  982. Unter Windows:
  983. Hier runterladen: https://nodejs.org/dist/latest/
  984. und in ein Verzeichnis entpacken.
  985. Optional: PATH erweitern unter Windows (so kann exec-path-from-shell den Pfad ermitteln):
  986. PATH=P:\path\to\node;%path%
  987. #+BEGIN_SRC emacs-lisp
  988. (use-package web-mode
  989. :ensure t
  990. :defer t
  991. :mode
  992. ("\\.phtml\\'"
  993. "\\.tpl\\.php\\'"
  994. "\\.djhtml\\'"
  995. "\\.[t]?html?\\'")
  996. :init
  997. (if *work_remote*
  998. (setq exec-path (append exec-path '("P:/Tools/node"))))
  999. :config
  1000. (setq web-mode-enable-auto-closing t
  1001. web-mode-enable-auto-pairing t)
  1002. (add-hook 'web-mode-hook 'smartparens-mode))
  1003. #+END_SRC
  1004. Emmet offers snippets, similar to yasnippet.
  1005. Default completion is C-j
  1006. [[https://github.com/smihica/emmet-mode#usage][Github]]
  1007. #+begin_src emacs-lisp
  1008. (use-package emmet-mode
  1009. :ensure t
  1010. :defer t
  1011. :hook
  1012. ((web-mode . emmet-mode)
  1013. (css-mode . emmet-mode))
  1014. :config
  1015. (unbind-key "C-<return>" emmet-mode-keymap))
  1016. #+end_src
  1017. *** JavaScript
  1018. npm install -g typescript-language-server typescript
  1019. maybe only typescript?
  1020. npm install -g prettier
  1021. #+begin_src emacs-lisp
  1022. (use-package rjsx-mode
  1023. :ensure t
  1024. :mode ("\\.js\\'"
  1025. "\\.jsx'"))
  1026. ; :config
  1027. ; (setq js2-mode-show-parse-errors nil
  1028. ; js2-mode-show-strict-warnings nil
  1029. ; js2-basic-offset 2
  1030. ; js-indent-level 2)
  1031. ; (setq-local flycheck-disabled-checkers (cl-union flycheck-disable-checkers
  1032. ; '(javascript-jshint)))) ; jshint doesn"t work for JSX
  1033. (use-package tide
  1034. :ensure t
  1035. :after (rjsx-mode company flycheck)
  1036. ; :hook (rjsx-mode . setup-tide-mode)
  1037. :config
  1038. (defun setup-tide-mode ()
  1039. "Setup function for tide."
  1040. (interactive)
  1041. (tide-setup)
  1042. (flycheck-mode t)
  1043. (setq flycheck-check-synta-automatically '(save mode-enabled))
  1044. (tide-hl-identifier-mode t)))
  1045. ;; needs npm install -g prettier
  1046. (use-package prettier-js
  1047. :ensure t
  1048. :after (rjsx-mode)
  1049. :defer t
  1050. :diminish prettier-js-mode
  1051. :hook ((js2-mode rsjx-mode) . prettier-js-mode))
  1052. #+end_src
  1053. ** YAML
  1054. :PROPERTIES:
  1055. :ID: 95413247-04d5-4e02-8431-06c162ec8f3b
  1056. :END:
  1057. #+begin_src emacs-lisp
  1058. (use-package yaml-mode
  1059. :if *sys/linux*
  1060. :ensure t
  1061. :defer t
  1062. :mode ("\\.yml$" . yaml-mode))
  1063. #+end_src
  1064. ** R
  1065. #+BEGIN_SRC emacs-lisp
  1066. (use-package ess
  1067. :ensure t
  1068. :defer t
  1069. :init
  1070. (if *work_remote*
  1071. (setq exec-path (append exec-path '("P:/Tools/R/bin/x64"))
  1072. org-babel-R-command "P:/Tools/R/bin/x64/R --slave --no-save")))
  1073. #+END_SRC
  1074. ** Python
  1075. :PROPERTIES:
  1076. :ID: 8c76fcd1-c57c-48ab-8af0-aa782de6337f
  1077. :END:
  1078. Systemseitig muss python-language-server installiert sein:
  1079. apt install python3-pip python3-setuptools python3-wheel
  1080. apt install build-essential python3-dev
  1081. pip3 install 'python-language-server[all]'
  1082. für andere language servers
  1083. https://github.com/emacs-lsp/lsp-mode#install-language-server
  1084. #+BEGIN_SRC emacs-lisp
  1085. (use-package lsp-python-ms
  1086. :if *sys/linux*
  1087. :ensure t
  1088. :defer t
  1089. :custom (lsp-python-ms-auto-install-server t))
  1090. (use-package python
  1091. :if *sys/linux*
  1092. :delight "π "
  1093. :defer t
  1094. :bind (("M-[" . python-nav-backward-block)
  1095. ("M-]" . python-nav-forward-block)))
  1096. (use-package pyvenv
  1097. :if *sys/linux*
  1098. :ensure t
  1099. :defer t
  1100. :after python
  1101. :hook ((python-mode . pyvenv-mode)
  1102. (python-mode . (lambda ()
  1103. (if-let ((pyvenv-directory (find-pyvenv-directory (buffer-file-name))))
  1104. (pyvenv-activate pyvenv-directory))
  1105. (lsp))))
  1106. :custom
  1107. (pyvenv-default-virtual-env-name "env")
  1108. (pyvenv-mode-line-indicator '(pyvenv-virtual-env-name ("[venv:" pyvenv-virtual-env-name "]")))
  1109. :preface
  1110. (defun find-pyvenv-directory (path)
  1111. "Check if a pyvenv directory exists."
  1112. (cond
  1113. ((not path) nil)
  1114. ((file-regular-p path) (find-pyvenv-directory (file-name-directory path)))
  1115. ((file-directory-p path)
  1116. (or
  1117. (seq-find
  1118. (lambda (path) (file-regular-p (expand-file-name "pyvenv.cfg" path)))
  1119. (directory-files path t))
  1120. (let ((parent (file-name-directory (directory-file-name path))))
  1121. (unless (equal parent path) (find-pyvenv-directory parent))))))))
  1122. ;; manage multiple python version
  1123. ;; needs to be installed on system
  1124. ; (use-package pyenv-mode
  1125. ; :ensure t
  1126. ; :after python
  1127. ; :hook ((python-mode . pyenv-mode)
  1128. ; (projectile-switch-project . projectile-pyenv-mode-set))
  1129. ; :custom (pyenv-mode-set "3.8.5")
  1130. ; :preface
  1131. ; (defun projectile-pyenv-mode-set ()
  1132. ; "Set pyenv version matching project name."
  1133. ; (let ((project (projectile-project-name)))
  1134. ; (if (member project (pyenv-mode-versions))
  1135. ; (pyenv-mode-set project)
  1136. ; (pyenv-mode-unset)))))
  1137. ;)
  1138. #+END_SRC
  1139. * beancount
  1140. ** Installation
  1141. :PROPERTIES:
  1142. :ID: 2c329043-b7a9-437d-a5cf-f2ad6514be91
  1143. :END:
  1144. #+BEGIN_SRC shell
  1145. sudo su
  1146. cd /opt
  1147. python3 -m venv beancount
  1148. source ./beancount/bin/activate
  1149. pip3 install wheel
  1150. pip3 install beancount
  1151. sleep 100
  1152. echo "shell running!"
  1153. deactivate
  1154. #+END_SRC
  1155. #+BEGIN_SRC emacs-lisp
  1156. (use-package beancount
  1157. :if *sys/linux*
  1158. :load-path "user-global/elisp"
  1159. ; :ensure t
  1160. :defer t
  1161. :mode
  1162. ("\\.beancount$" . beancount-mode)
  1163. :hook
  1164. (beancount-mode . my/beancount-company)
  1165. :init
  1166. (add-hook 'beancount-mode-hook 'company/beancount-mode-hook)
  1167. :config
  1168. (defun my/beancount-company ()
  1169. (set (make-local-variable 'company-backends)
  1170. '(company-beancount)))
  1171. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount"))
  1172. #+END_SRC
  1173. To support org-babel, check if it can find the symlink to ob-beancount.el
  1174. #+BEGIN_SRC shell
  1175. orgpath=`find /home/marc/.emacs.d/elpa/ -type d -name "org-plus*" -print`
  1176. beansym="$orgpath/ob-beancount.el
  1177. bean="/home/marc/Archiv/Programmierprojekte/Lisp/beancount-mode/ob-beancount.el"
  1178. if [ -h "$beansym" ]
  1179. then
  1180. echo "$beansym found"
  1181. elif [ -e "$bean" ]
  1182. then
  1183. echo "creating symlink"
  1184. ln -s "$bean" "$beansym"
  1185. else
  1186. echo "$bean not found, symlink creation aborted"
  1187. fi
  1188. #+END_SRC
  1189. Fava is strongly recommended.
  1190. #+BEGIN_SRC shell
  1191. cd /opt
  1192. python3 -m venv fava
  1193. source ./fava/bin/activate
  1194. pip3 install wheel
  1195. pip3 install fava
  1196. deactivate
  1197. #+END_SRC
  1198. Start fava with fava my_file.beancount
  1199. It is accessable on this URL: [[http://127.0.0.1:5000][Fava]]
  1200. Beancount-mode can start fava and open the URL right away.
  1201. * Stuff after everything else
  1202. Set garbage collector to a smaller value to let it kick in faster.
  1203. Maybe a problem on Windows?
  1204. #+begin_src emacs-lisp
  1205. (setq gc-cons-threshold (* 2 1000 1000))
  1206. #+end_src