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.

1109 lines
32 KiB

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