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.

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