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.

1023 lines
30 KiB

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