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.

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