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.

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