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.

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