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.

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