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.

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