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.

859 lines
25 KiB

5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
4 years ago
4 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 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
4 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. - Paket exec-path-from-shell, um PATH aus Linux auch in emacs zu haben
  7. - Smart mode line?
  8. - Theme
  9. - evil-collection or custom in init file?
  10. - Hydra
  11. - General
  12. - (defalias 'list-buffers 'ibuffer) ;; change default to ibuffer
  13. - ido?
  14. - treemacs (for linux)
  15. - treemacs-evil?
  16. - treemacs-projectile
  17. - ace-window
  18. - windmove?
  19. - tramp (in linux)
  20. - visual-regexp
  21. - org configuration: paths
  22. - org custom agenda
  23. - org configuration: everything else
  24. - beancount configuration from config.org
  25. - CONTINUE TODO from config.org at Programming
  26. * First start
  27. :PROPERTIES:
  28. :ID: ec248005-527f-4fa1-bdef-9343f2fa28b0
  29. :END:
  30. 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
  31. #+BEGIN_SRC emacs-lisp :tangle no
  32. (require 'org')
  33. (find-file (concat user-emacs-directory "init.org"))
  34. (org-babel-tangle)
  35. (load-file (concat user-emacs-directory "init.el"))
  36. (byte-compile-file (concat user-emacs-directory "init.el"))
  37. #+END_SRC
  38. This function updates init.el whenever changes in init.org are made. The update will be active after saving.
  39. #+BEGIN_SRC emacs-lisp
  40. (defun me/tangle-init ()
  41. "If the current buffer is 'init.org',
  42. the code blocks are tangled, and the tangled file is compiled."
  43. (when (equal (buffer-file-name)
  44. (expand-file-name (concat user-emacs-directory "init.org")))
  45. ;; avoid running hooks
  46. (let ((prog-mode-hook nil))
  47. (org-babel-tangle)
  48. (byte-compile-file (concat user-emacs-directory "init.el"))
  49. (load-file user-init-file))))
  50. (add-hook 'after-save-hook 'me/tangle-init)
  51. #+END_SRC
  52. #+BEGIN_SRC emacs-lisp
  53. (require 'package)
  54. ;; bug before emacs 26.3
  55. (when (version< emacs-version "26.3")
  56. (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
  57. (add-to-list 'package-archives '("elpa" . "https://elpa.gnu.org/packages/") t)
  58. (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
  59. (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
  60. (add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
  61. (package-initialize)
  62. #+END_SRC
  63. #+BEGIN_SRC emacs-lisp
  64. (unless (package-installed-p 'use-package)
  65. (package-refresh-contents)
  66. (package-install 'use-package))
  67. (setq use-package-verbose nil)
  68. (eval-when-compile
  69. (require 'use-package))
  70. (require 'bind-key)
  71. (use-package diminish
  72. :ensure t)
  73. #+END_SRC
  74. * Default settings
  75. :PROPERTIES:
  76. :ID: 00b48602-2a95-492e-a90b-c1e3a94c1ecb
  77. :END:
  78. #+BEGIN_SRC emacs-lisp
  79. (setq *home_desktop* (string-equal (system-name) "marc")
  80. ,*home_laptop* (string-equal (system-name) "laptop")
  81. ,*work_local* (string-equal (system-name) "PMPCNEU08")
  82. ,*work_remote* (string-equal (system-name) "PMTS01")
  83. ,*linux* (string-equal system-type 'gnu/linux)
  84. ,*windows* (string-equal system-type 'windows-nt))
  85. #+END_SRC
  86. #+BEGIN_SRC emacs-lisp
  87. (defvar MY--PATH_USER_LOCAL (expand-file-name "~/.emacs.d/user-local/"))
  88. (defvar MY--PATH_USER_GLOBAL (expand-file-name "~/.emacs.d/user-global/"))
  89. (when *linux*
  90. (defvar MY--PATH_ORG_FILES (expand-file-name "~/Archiv/Organisieren/"))
  91. (defvar MY--PATH_ORG_FILES_MOBILE (expand-file-name "~/Archiv/Organisieren/mobile/"))
  92. (defvar MY--PATH_ORG_JOURNAl (expand-file-name "~/Archiv/Organisieren/Journal/")))
  93. (when *work_remote*
  94. (defvar MY--PATH_ORG_FILES "p:/Eigene Dateien/Notizen/")
  95. (defvar MY--PATH_ORG_FILES_MOBILE nil) ;; hacky way to prevent "free variable" compiler error
  96. (defvar MY--PATH_ORG_JOURNAL nil)
  97. (defvar MY--PATH_START "p:/Eigene Dateien/Notizen/"))
  98. (setq bookmark-default-file (concat MY--PATH_USER_LOCAL "bookmarks"))
  99. (setq recentf-save-file (concat MY--PATH_USER_LOCAL "recentf"))
  100. (setq custom-file (concat MY--PATH_USER_LOCAL "custom.el")) ;; don't spam init.e with saved customization settings
  101. (setq abbrev-file-name (concat MY--PATH_USER_GLOBAL "abbrev_defs"))
  102. (setq backup-directory-alist `((".*" . ,temporary-file-directory)))
  103. (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory)))
  104. (setq save-abbrevs 'silently) ;; don't bother me with asking for abbrev saving
  105. (setq-default create-lockfiles nil) ;; disable lock files, can cause trouble in e.g. lsp-mode
  106. (defalias 'yes-or-no-p 'y-or-n-p) ;; answer with y and n
  107. (setq custom-safe-themes t) ;; don't ask me if I want to load a theme
  108. (setq sentence-end-double-space nil) ;; don't coun two spaces after a period as the end of a sentence.
  109. (delete-selection-mode t) ;; delete selected region when typing
  110. (save-place-mode 1) ;; saves position in file when it's closed
  111. (setq save-place-forget-unreadable-files nil) ;; checks if file is readable before saving position
  112. (setq locale-coding-system 'utf-8)
  113. (set-terminal-coding-system 'utf-8)
  114. (set-keyboard-coding-system 'utf-8)
  115. (set-selection-coding-system 'utf-8)
  116. (if *windows*
  117. (prefer-coding-system 'utf-8-dos)
  118. (prefer-coding-system 'utf-8))
  119. (blink-cursor-mode -1) ;; turn off blinking cursor
  120. (show-paren-mode t) ;; show other part of brackets
  121. (column-number-mode t)
  122. (setq uniquify-buffer-name-style 'forward)
  123. (setq-default indent-tabs-mode nil) ;; avoid tabs in place of multiple spaces (they look bad in tex)
  124. (setq-default indicate-empty-lines t) ;; show empty lines
  125. (setq scroll-margin 5 ;; smooth scrolling
  126. scroll-conservatively 10000
  127. scroll-preserve-screen-position 1
  128. scroll-step 1)
  129. (global-hl-line-mode t) ;; highlight current line
  130. (menu-bar-mode 0) ;; disable menu bar
  131. (tool-bar-mode 0) ;; disable tool bar
  132. (scroll-bar-mode 0) ;; disable scroll bar
  133. #+END_SRC
  134. Some windows specific stuff
  135. #+BEGIN_SRC emacs-lisp
  136. (when (eq system-type 'windows-nt)
  137. (remove-hook 'find-file-hooks 'vc-refresh-state)
  138. (progn
  139. (setq gc-cons-threshold (* 511 1024 1024)
  140. gc-cons-percentage 0.5
  141. garbage-collection-messages t)
  142. (run-with-idle-timer 5 t #'garbage-collect))
  143. (when (boundp 'w32-pipe-read-delay)
  144. (setq w32-pipe-read-delay 0))
  145. (when (boundp 'w32-get-true-file-attributes)
  146. (setq )w32-get-true-file-attributes nil))
  147. #+END_SRC
  148. * visuals
  149. ** Font
  150. :PROPERTIES:
  151. :ID: cdfaaf73-b027-4b86-8d27-ebdce4b85009
  152. :END:
  153. #+BEGIN_SRC emacs-lisp
  154. (if (string-equal system-type "gnu/linux")
  155. (set-face-font 'default "Hack-10"))
  156. #+END_SRC
  157. ** line wrappings
  158. :PROPERTIES:
  159. :ID: 60b1f231-ab1e-4c47-ac6d-262dc208a520
  160. :END:
  161. #+BEGIN_SRC emacs-lisp
  162. (global-visual-line-mode)
  163. (diminish 'visual-line-mode)
  164. (use-package adaptive-wrap
  165. :ensure t
  166. :config
  167. (add-hook 'visual-line-mode-hook #'adaptive-wrap-prefix-mode))
  168. ; :init
  169. ; (when (fboundp 'adaptive-wrap-prefix-mode)
  170. ; (defun my/activate-adaptive-wrap-prefix-mode ()
  171. ; "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously."
  172. ; (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1)))
  173. ; (add-hook 'visual-line-mode-hook 'my/activate-adaptive-wrap-prefix-mode)))
  174. #+END_SRC
  175. ** line numbers
  176. :PROPERTIES:
  177. :ID: d3dfb79a-103a-4318-a5af-5a55e12674ce
  178. :END:
  179. #+BEGIN_SRC emacs-lisp
  180. (use-package display-line-numbers
  181. :init
  182. (add-hook 'prog-mode-hook 'display-line-numbers-mode)
  183. (add-hook 'org-src-mode-hook 'display-line-numbers-mode)
  184. :config
  185. (setq-default display-line-numbers-type 'visual
  186. display-line-numbers-current-absolute t
  187. display-line-numbers-with 4
  188. display-line-numbers-widen t))
  189. ; (add-hook 'emacs-lisp-mode-hook 'display-line-numbers-mode)
  190. #+END_SRC
  191. ** misc
  192. :PROPERTIES:
  193. :ID: f0f774d6-db13-4871-9192-d36e78120dde
  194. :END:
  195. #+BEGIN_SRC emacs-lisp
  196. (use-package rainbow-mode
  197. :ensure t
  198. :diminish
  199. :hook ((org-mode
  200. emacs-lisp-mode) . rainbow-mode))
  201. #+END_SRC
  202. * undo
  203. :PROPERTIES:
  204. :ID: fde526fa-b053-48dd-9ac1-c443d987f4d2
  205. :END:
  206. #+BEGIN_SRC emacs-lisp
  207. (use-package undo-tree
  208. :ensure t
  209. :diminish undo-tree-mode
  210. :init
  211. (global-undo-tree-mode 1))
  212. #+END_SRC
  213. * imenu-list
  214. :PROPERTIES:
  215. :ID: 796d00db-aadb-412b-a291-619b029977f3
  216. :END:
  217. A minor mode to show imenu in a sidebar.
  218. Call imenu-list-smart-toggle.
  219. [[https://github.com/bmag/imenu-list][Source]]
  220. #+BEGIN_SRC emacs-lisp
  221. (use-package imenu-list
  222. :ensure t
  223. :config
  224. (setq imenu-list-focus-after-activation t
  225. imenu-list-auto-resize t
  226. imenu-list-position 'right)
  227. :bind
  228. (:map global-map
  229. ([f9] . imenu-list-smart-toggle))
  230. )
  231. #+END_SRC
  232. * which-key
  233. :PROPERTIES:
  234. :ID: 0a67aeb4-4060-4f4d-a7ff-61c70fe7ec7b
  235. :END:
  236. #+BEGIN_SRC emacs-lisp
  237. (use-package which-key
  238. :ensure t
  239. :diminish which-key-mode
  240. :config
  241. (which-key-mode)
  242. (which-key-setup-side-window-right-bottom)
  243. (which-key-setup-minibuffer)
  244. (setq which-key-idle-delay 0.5))
  245. #+END_SRC
  246. * Evil
  247. :PROPERTIES:
  248. :ID: a3389b7d-3833-42b7-97e1-413b8c4d9833
  249. :END:
  250. #+BEGIN_SRC emacs-lisp
  251. (use-package evil
  252. :ensure t
  253. :defer .1 ;; don't block emacs when starting, load evil immediately after startup
  254. :config
  255. (evil-mode 1))
  256. #+END_SRC
  257. * General (key mapper)
  258. :PROPERTIES:
  259. :ID: 027bdcf8-95c9-4e9b-88ba-6e9d3e5116c0
  260. :END:
  261. #+BEGIN_SRC emacs-lisp
  262. (use-package general
  263. :ensure t)
  264. (general-define-key
  265. :states 'normal
  266. :keymaps 'imenu-list-major-mode-map
  267. (kbd "RET") '(imenu-list-goto-entry :which-key "goto")
  268. (kbd "TAB") '(hs-toggle-hiding :which-key "collapse")
  269. "d" '(imenu-list-display-entry :which-key "show")
  270. "q" '(imenu-list-quit-window :which-key "quit"))
  271. #+END_SRC
  272. * ivy / counsel / swiper
  273. :PROPERTIES:
  274. :ID: c2146a70-03f4-4f60-9bce-094eec28cefe
  275. :END:
  276. #+BEGIN_SRC emacs-lisp
  277. ; (require 'ivy)
  278. (use-package ivy
  279. :ensure t
  280. :diminish
  281. (ivy-mode . "")
  282. :init
  283. (ivy-mode 1)
  284. :bind
  285. ("C-r" . ivy-resume) ;; overrides isearch-backwards binding
  286. :config
  287. (setq ivy-use-virtual-buffers t ;; recent files and bookmarks in ivy-switch-buffer
  288. ivy-height 20 ;; height of ivy window
  289. ivy-count-format "%d/%d" ;; current and total number
  290. ivy-re-builders-alist ;; regex replaces spaces with *
  291. '((t . ivy--regex-plus))))
  292. (use-package counsel
  293. :ensure t
  294. :bind*
  295. (("M-x" . counsel-M-x)
  296. ("C-x C-f" . counsel-find-file)
  297. ("C-x C-r" . counsel-recentf)
  298. ("C-c C-f" . counsel-git)
  299. ("C-c h f" . counsel-describe-function)
  300. ("C-c h v" . counsel-describe-variable)
  301. ("M-i" . counsel-imenu)))
  302. (use-package swiper
  303. :ensure t
  304. :bind
  305. ("C-s" . swiper))
  306. (use-package ivy-hydra
  307. :ensure t)
  308. #+END_SRC
  309. * company
  310. :PROPERTIES:
  311. :ID: 1630ac5e-7467-458c-940c-4f724e283813
  312. :END:
  313. #+BEGIN_SRC emacs-lisp
  314. ; (require 'company)
  315. (use-package company
  316. :defer 1
  317. :bind
  318. (:map company-active-map
  319. ("RET" . nil)
  320. ([return] . nil)
  321. ("TAB" . company-complete-selection)
  322. ([tab] . company-complete-selection)
  323. ("<right>" . company-complete-common))
  324. :config
  325. (global-company-mode 1)
  326. (setq-default
  327. company-idle-delay .2
  328. company-minimum-prefix-length 1
  329. company-require-match nil
  330. company-show-numbers t
  331. company-tooltip-align-annotations t))
  332. ; (require 'company-statistics)
  333. (use-package company-statistics
  334. :ensure t
  335. :after company
  336. :init
  337. (setq company-statistics-file (concat MY--PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el")
  338. :config
  339. (company-statistics-mode 1))
  340. (use-package company-dabbrev
  341. :ensure nil
  342. :after company
  343. :config
  344. (setq-default company-dabbrev-downcase nil))
  345. (use-package company-box
  346. :ensure t
  347. :init
  348. (add-hook 'company-mode-hook 'company-box-mode))
  349. #+END_SRC
  350. ** company backends
  351. :PROPERTIES:
  352. :ID: 6ac59f9d-54e3-422d-883f-128fb172468d
  353. :END:
  354. #+BEGIN_SRC emacs-lisp
  355. (defun company/org-mode-hook()
  356. (set (make-local-variable 'company-backends)
  357. '(company-capf company-files))
  358. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  359. (message "company/org-mode-hook"))
  360. (defun company/elisp-mode-hook()
  361. (set (make-local-variable 'company-backends)
  362. '((company-elisp company-dabbrev) company-capf company-files))
  363. (message "company/elisp-mode-hook"))
  364. (defun company/beancount-mode-hook()
  365. (set (make-local-variable 'company-backends)
  366. '(company-beancount)))
  367. #+END_SRC
  368. * orgmode
  369. ** org
  370. :PROPERTIES:
  371. :ID: 3877251e-5ece-4006-baa6-1f1b4846a8f3
  372. :END:
  373. #+BEGIN_SRC emacs-lisp
  374. (use-package org
  375. :ensure org-plus-contrib
  376. :mode (("\.org$" . org-mode))
  377. :init
  378. (add-hook 'org-mode-hook 'company/org-mode-hook)
  379. (add-hook 'org-src-mode-hook 'smartparens-mode)
  380. :config
  381. (setq org-modules (quote (org-id
  382. org-habit
  383. org-tempo ;; easy templates
  384. )))
  385. (setq org-default-notes-file (concat MY--PATH_ORG_FILES "notes.org")
  386. org-agenda-files (list MY--PATH_ORG_FILES
  387. MY--PATH_ORG_FILES_MOBILE)
  388. org-id-locations-file (concat MY--PATH_USER_LOCAL ".org-id-locations")
  389. org-log-into-drawer "LOGBOOK")
  390. ;; some display customizations
  391. (setq org-pretty-entities t
  392. org-startup-truncated t
  393. org-startup-align-all-tables t)
  394. ;; some source code blocks customizations
  395. (setq org-src-window-setup 'current-window ;; C-c ' opens in current window
  396. org-src-fontify-natively t ;; use syntax highlighting in code blocks
  397. org-src-preserve-indentation t ;; no extra indentation
  398. org-src-tab-acts-natively t))
  399. #+END_SRC
  400. ** languages
  401. :PROPERTIES:
  402. :ID: 467efd58-e928-4ccf-9ac4-d144eaede8ed
  403. :END:
  404. #+BEGIN_SRC emacs-lisp
  405. (org-babel-do-load-languages
  406. 'org-babel-load-languages
  407. '((emacs-lisp . t)
  408. (gnuplot . t)
  409. (js . t)
  410. (latex . t)
  411. (lisp . t)
  412. (python . t)
  413. (shell . t)
  414. (sqlite . t)
  415. (org . t)
  416. (R . t)
  417. (scheme . t)
  418. ))
  419. (defun me--org-confirm-babel-evaluate (lang body)
  420. "Do not confirm evaluation for these languages."
  421. (not (or (string= lang "python")
  422. (string= lang "ipython")
  423. (string= lang "emacs-lisp")
  424. (string= lang "R")
  425. (string= lang "latex")
  426. (string= lang "sqlite"))))
  427. (setq org-confirm-babel-evaluate 'me--org-confirm-babel-evaluate)
  428. #+END_SRC
  429. ** habits
  430. :PROPERTIES:
  431. :ID: 61735b0c-5016-4697-80c6-beb7b3f27a1b
  432. :END:
  433. #+BEGIN_SRC emacs-lisp
  434. (require 'org-habit) ;;TODO Lösung ohne require finden, scheint mir nicht ideal zu sein, nur um ein org-modul zu aktivieren
  435. ;; (add-to-list 'org-modules "org-habit")
  436. (setq org-habit-graph-column 80
  437. org-habit-preceding-days 30
  438. org-habit-following-days 7
  439. org-habit-show-habits-only-for-today nil)
  440. #+END_SRC
  441. ** org-id
  442. :PROPERTIES:
  443. :ID: 017ef411-8239-4bfe-bbef-66b98a2971a9
  444. :END:
  445. Currently it causes some debugger errors "not a standard org time string", so it's disabled
  446. #+BEGIN_SRC emacs-lisp
  447. ;; (use-package org-id
  448. ;; :config
  449. ;; (setq org-id-link-to-org-use-id t)
  450. ;; (org-id-update-id-locations)) ;; update id file .org-id-locations on startup
  451. #+END_SRC
  452. ** org-agenda
  453. :PROPERTIES:
  454. :ID: 10e65f59-ba2c-47e4-a40c-3097c15544aa
  455. :END:
  456. Custom keywords, depending on environment
  457. #+BEGIN_SRC emacs-lisp
  458. (when *work_remote*
  459. (setq org-todo-keywords
  460. '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE"))))
  461. #+END_SRC
  462. Add some key bindings
  463. #+BEGIN_SRC emacs-lisp
  464. (bind-key "C-c l" 'org-store-link)
  465. (bind-key "C-c c" 'org-capture)
  466. (bind-key "C-c a" 'org-agenda)
  467. #+END_SRC
  468. Sort agenda by deadline and priority
  469. #+BEGIN_SRC emacs-lisp
  470. (setq org-agenda-sorting-strategy
  471. (quote
  472. ((agenda deadline-up priority-down)
  473. (todo priority-down category-keep)
  474. (tags priority-down category-keep)
  475. (search category-keep))))
  476. #+END_SRC
  477. Customize the org agenda
  478. #+BEGIN_SRC emacs-lisp
  479. (defun me--org-skip-subtree-if-priority (priority)
  480. "Skip an agenda subtree if it has a priority of PRIORITY.
  481. PRIORITY may be one of the characters ?A, ?B, or ?C."
  482. (let ((subtree-end (save-excursion (org-end-of-subtree t)))
  483. (pri-value (* 1000 (- org-lowest-priority priority)))
  484. (pri-current (org-get-priority (thing-at-point 'line t))))
  485. (if (= pri-value pri-current)
  486. subtree-end
  487. nil)))
  488. (setq org-agenda-custom-commands
  489. '(("c" "Simple agenda view"
  490. ((tags "PRIORITY=\"A\""
  491. ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
  492. (org-agenda-overriding-header "Hohe Priorität:")))
  493. (agenda ""
  494. ((org-agenda-span 7)
  495. (org-agenda-start-on-weekday nil)
  496. (org-agenda-overriding-header "Nächste 7 Tage:")))
  497. (alltodo ""
  498. ((org-agenda-skip-function '(or (me--org-skip-subtree-if-priority ?A)
  499. (org-agenda-skip-if nil '(scheduled deadline))))
  500. (org-agenda-overriding-header "Sonstige Aufgaben:")))))))
  501. #+END_SRC
  502. ** *TODO*
  503. org-super-agenda
  504. ** org-caldav
  505. :PROPERTIES:
  506. :ID: 58aa11ef-80f7-4629-a957-a9e00e070136
  507. :END:
  508. Vorerst deaktiviert, Nutzen evtl. nicht vorhanden
  509. #+BEGIN_SRC emacs-lisp
  510. ;;(use-package org-caldav
  511. ;; :ensure t
  512. ;; :config
  513. ;; (setq org-caldav-url "https://nextcloud.cloudsphere.duckdns.org/remote.php/dav/calendars/marc"
  514. ;; org-caldav-calendar-id "orgmode"
  515. ;; org-caldav-inbox (expand-file-name "~/Archiv/Organisieren/caldav-inbox")
  516. ;; org-caldav-files (concat MY--PATH_ORG_FILES "tasks")))
  517. #+END_SRC
  518. ** journal
  519. :PROPERTIES:
  520. :ID: 0b7243ac-049f-4b9c-a062-7a349c515133
  521. :END:
  522. [[https://github.com/bastibe/org-journal][Source]]
  523. #+BEGIN_SRC emacs-lisp
  524. (when *linux*
  525. (use-package org-journal
  526. :ensure t
  527. :defer t
  528. :config
  529. (setq org-journal-dir MY--PATH_ORG_JOURNAL
  530. org-journal-enable-agenda-integration t)))
  531. #+END_SRC
  532. * Programming
  533. ** Magit / Git
  534. :PROPERTIES:
  535. :ID: a947f806-181d-4d33-9734-435849385b0b
  536. :END:
  537. Little crash course in magit:
  538. - magit-init to init a git project
  539. - magit-status (C-x g) to call the status window
  540. In status buffer:
  541. - s stage files
  542. - u unstage files
  543. - U unstage all files
  544. - a apply changes to staging
  545. - c c commit (type commit message, then C-c C-c to commit)
  546. - b b switch to another branch
  547. - P u git push
  548. - F u git pull
  549. #+BEGIN_SRC emacs-lisp
  550. (use-package magit
  551. :ensure t
  552. :defer t
  553. :init
  554. ; set git-path in work environment
  555. (if (string-equal user-login-name "POH")
  556. (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe")
  557. )
  558. :bind (("C-x g" . magit-status))
  559. )
  560. #+END_SRC
  561. ** LSP
  562. :PROPERTIES:
  563. :ID: d529d096-ec38-42e6-91c9-099c1d8bdd06
  564. :END:
  565. Configuration for the language server protocol
  566. *ACHTUNG* Dateipfad muss absolut sein, symlink im Pfad führt zumindest beim ersten Start zu Fehlern beim lsp
  567. Sobald der lsp einmal lief, kann zukünftig der symlink-Pfad genommen werden.
  568. Getestet wurde die funktionierende Datei selbst und neu erstellte Dateien im selben Pfad.
  569. TODO Unterverzeichnisse wurden noch nicht getestet
  570. #+BEGIN_SRC emacs-lisp
  571. (use-package lsp-mode
  572. :defer t
  573. :commands lsp
  574. :custom
  575. (lsp-auto-guess-root nil)
  576. (lsp-prefer-flymake nil) ; use flycheck instead
  577. (lsp-file-watch-threshold 2000)
  578. :bind (:map lsp-mode-map ("C-c C-f" . lsp-format-buffer))
  579. :hook ((python-mode
  580. js-mode
  581. js2-mode
  582. typescript-mode
  583. web-mode) . lsp))
  584. (use-package lsp-ui
  585. :after lsp-mode
  586. :ensure t
  587. :diminish
  588. :commands lsp-ui-mode
  589. :config
  590. (setq lsp-ui-doc-enable t
  591. lsp-ui-doc-header t
  592. lsp-ui-doc-include-signature t
  593. lsp-ui-doc-position 'top
  594. lsp-ui-doc-border (face-foreground 'default)
  595. lsp-ui-sideline-enable nil
  596. lsp-ui-sideline-ignore-duplicate t
  597. lsp-ui-sideline-show-code-actions nil)
  598. (when (display-graphic-p)
  599. (setq lsp-ui-doc-use-webkit t))
  600. ;; workaround hide mode-line of lsp-ui-imenu buffer
  601. (defadvice lsp-ui-imenu (after hide-lsp-ui-imenu-mode-line activate)
  602. (setq mode-line-format nil)))
  603. (use-package company-lsp
  604. :requires company
  605. :defer t
  606. :ensure t
  607. :config
  608. ;;disable client-side cache because lsp server does a better job
  609. (setq company-transformers nil
  610. company-lsp-async t
  611. company-lsp-cache-candidates nil))
  612. #+END_SRC
  613. ** flycheck
  614. :PROPERTIES:
  615. :ID: c8090ddb-4f22-49ba-8ab1-1de132e1d772
  616. :END:
  617. #+BEGIN_SRC emacs-lisp
  618. (use-package flycheck
  619. :ensure t
  620. :hook
  621. ((css-mode . flycheck-mode)
  622. (emacs-lisp-mode . flycheck-mode)
  623. (python-mode . flycheck-mode))
  624. :init
  625. (setq flycheck-emacs-lisp-load-path 'inherit)
  626. :config
  627. (setq-default
  628. flycheck-check-synta-automatically '(save mode-enabled)
  629. flycheck-disable-checkers '(emacs-lisp-checkdoc)
  630. eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck
  631. flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages
  632. #+END_SRC
  633. ** Projectile
  634. :PROPERTIES:
  635. :ID: 3cc5c1d2-1a5d-4d1a-bfeb-48de8172dd63
  636. :END:
  637. Manage projects and jump quickly between its files
  638. #+BEGIN_SRC emacs-lisp
  639. (use-package projectile
  640. :ensure t
  641. :defer t
  642. :bind
  643. (("C-c p p" . projectile-switch-project)
  644. ("C-c p c" . projectile-command-map)
  645. ("C-c p s s" . projectile-ag))
  646. :init
  647. (setq-default projectile-cache-file (concat MY--PATH_USER_LOCAL ".projectile-cache")
  648. projectile-known-projects-file (concat MY--PATH_USER_LOCAL ".projectile-bookmarks"))
  649. :config
  650. (projectile-mode t)
  651. (setq-default projectile-completion-system 'ivy
  652. projectile-enable-caching t
  653. projectile-mode-line '(:eval (projectile-project-name))))
  654. #+END_SRC
  655. ** smartparens
  656. :PROPERTIES:
  657. :ID: 04be375f-d100-47e7-99f1-af47a3139a54
  658. :END:
  659. #+BEGIN_SRC emacs-lisp
  660. (use-package smartparens
  661. :ensure t
  662. :diminish smartparens-mode
  663. :config
  664. (setq sp-show-pair-from-inside nil)
  665. (require 'smartparens-config))
  666. #+END_SRC
  667. ** lisp
  668. :PROPERTIES:
  669. :ID: e5ce0263-3b21-460e-a037-3fe27d6e836a
  670. :END:
  671. #+BEGIN_SRC emacs-lisp
  672. (add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook)
  673. #+END_SRC
  674. ** web
  675. :PROPERTIES:
  676. :ID: 5649b885-839f-48db-8b4f-8d594df7ebd8
  677. :END:
  678. apt install npm
  679. sudo npm install -g vscode-html-languageserver-bin
  680. evtl alternativ typescript-language-server?
  681. #+BEGIN_SRC emacs-lisp
  682. (use-package web-mode
  683. :ensure t
  684. :defer t
  685. :mode
  686. ("\\.phtml\\'"
  687. "\\.tpl\\.php\\'"
  688. "\\.djhtml\\'"
  689. "\\.[t]?html?\\'")
  690. :config
  691. (setq web-mode-enable-auto-closing t
  692. web-mode-enable-auto-pairing t)
  693. (add-hook 'web-mode-hook 'smartparens-mode))
  694. #+END_SRC
  695. ** Python
  696. :PROPERTIES:
  697. :ID: cd4bbd1f-9980-42c9-a5af-aa808779d524
  698. :END:
  699. Systemseitig muss python-language-server installiert sein:
  700. pip3 install 'python-language-server[all]'
  701. für andere language servers
  702. https://github.com/emacs-lsp/lsp-mode#install-language-server
  703. #+BEGIN_SRC emacs-lisp
  704. (if (string-equal system-type "gnu/linux")
  705. (defun my/postactivatehook ()
  706. (setq lsp-python-ms-extra-paths pyvenv-virtual-env))
  707. (use-package pyvenv
  708. :ensure t
  709. :config
  710. (setenv "WORKON_HOME" (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))
  711. (add-hook 'pyvenv-post-activate-hooks 'my/postactivatehook))
  712. (use-package virtualenvwrapper
  713. :ensure t
  714. :hook (venv-postmkvirtualenv . (lambda() (shell-command "pip3 install importmagic epc")))
  715. :config
  716. (setq venv-location (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
  717. (use-package lsp-python-ms
  718. :ensure t
  719. :after lsp-mode python))
  720. ; :custom (lsp-python-executable-cmd "python3"))
  721. #+END_SRC
  722. * beancount
  723. ** Installation
  724. :PROPERTIES:
  725. :ID: 0c5f3396-4b08-4549-ac68-0c516cfd4435
  726. :END:
  727. #+BEGIN_SRC shell
  728. sudo su
  729. cd /opt
  730. python3 -m venv beancount
  731. source ./beancount/bin/activate
  732. pip3 install wheel
  733. pip3 install beancount
  734. sleep 100
  735. echo "shell running!"
  736. deactivate
  737. #+END_SRC
  738. #+BEGIN_SRC emacs-lisp
  739. (if (string-equal system-type "gnu/linux")
  740. (use-package beancount
  741. :load-path "user-global/elisp"
  742. ; :ensure t
  743. :defer t
  744. :mode
  745. ("\\.beancount$" . beancount-mode)
  746. :init
  747. (add-hook 'beancount-mode-hook 'company/beancount-mode-hook)
  748. ; (add-hook 'beancount-mode-hook (pyvenv-activate "/opt/beancount"))
  749. ; (setenv "PATH"
  750. ; (concat "/opt/beancount/bin:"
  751. ; (getenv "PATH")))
  752. :config
  753. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount")))
  754. #+END_SRC
  755. To support org-babel, check if it can find the symlink to ob-beancount.el
  756. #+BEGIN_SRC shell
  757. orgpath=`find /home/marc/.emacs.d/elpa/ -type d -name "org-plus*" -print`
  758. beansym="$orgpath/ob-beancount.el
  759. bean="/home/marc/Archiv/Programmierprojekte/Lisp/beancount-mode/ob-beancount.el"
  760. if [ -h "$beansym" ]
  761. then
  762. echo "$beansym found"
  763. elif [ -e "$bean" ]
  764. then
  765. echo "creating symlink"
  766. ln -s "$bean" "$beansym"
  767. else
  768. echo "$bean not found, symlink creation aborted"
  769. fi
  770. #+END_SRC
  771. Fava is strongly recommended.
  772. #+BEGIN_SRC shell
  773. cd /opt
  774. python3 -m venv fava
  775. source ./fava/bin/activate
  776. pip3 install wheel
  777. pip3 install fava
  778. deactivate
  779. #+END_SRC
  780. Start fava with fava my_file.beancount
  781. It is accessable on this URL: [[http://127.0.0.1:5000][Fava]]
  782. Beancount-mode can start fava and open the URL right away.