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.

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