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.

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