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.

1362 lines
38 KiB

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