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.

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