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.

999 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. (:map company-active-map
  366. ("RET" . nil)
  367. ([return] . nil)
  368. ("TAB" . company-complete-selection)
  369. ([tab] . company-complete-selection)
  370. ("<right>" . company-complete-common))
  371. :hook
  372. (after-init . global-company-mode)
  373. :config
  374. (setq company-idle-delay .2
  375. company-minimum-prefix-length 1
  376. company-require-match nil
  377. company-show-numbers t
  378. company-tooltip-align-annotations t))
  379. (use-package company-statistics
  380. :ensure t
  381. :after company
  382. :init
  383. (setq company-statistics-file (concat MY--PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el")
  384. :config
  385. (company-statistics-mode 1))
  386. (use-package company-dabbrev
  387. :ensure nil
  388. :after company
  389. :config
  390. (setq-default company-dabbrev-downcase nil))
  391. (use-package company-box
  392. :ensure t
  393. :init
  394. (add-hook 'company-mode-hook 'company-box-mode))
  395. #+END_SRC
  396. ** company backends
  397. :PROPERTIES:
  398. :ID: 4ce2e728-276d-41f9-9538-84e6e08afd8d
  399. :END:
  400. #+BEGIN_SRC emacs-lisp
  401. (defun company/org-mode-hook()
  402. (set (make-local-variable 'company-backends)
  403. '(company-capf company-files))
  404. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  405. (message "company/org-mode-hook"))
  406. (defun company/elisp-mode-hook()
  407. (set (make-local-variable 'company-backends)
  408. '((company-elisp company-dabbrev) company-capf company-files))
  409. (message "company/elisp-mode-hook"))
  410. (defun company/beancount-mode-hook()
  411. (set (make-local-variable 'company-backends)
  412. '(company-beancount)))
  413. #+END_SRC
  414. * orgmode
  415. ** org
  416. :PROPERTIES:
  417. :ID: b89d7639-080c-4168-8884-bd5d8965f466
  418. :END:
  419. #+BEGIN_SRC emacs-lisp
  420. (use-package org
  421. :ensure org-plus-contrib
  422. :mode (("\.org$" . org-mode))
  423. :init
  424. (add-hook 'org-mode-hook 'company/org-mode-hook)
  425. (add-hook 'org-src-mode-hook 'smartparens-mode)
  426. (add-hook 'org-mode-hook 'org-indent-mode)
  427. :config
  428. (setq org-modules (quote (org-id
  429. org-habit
  430. org-tempo ;; easy templates
  431. )))
  432. (setq org-default-notes-file (concat MY--PATH_ORG_FILES "notes.org")
  433. org-agenda-files (list (concat MY--PATH_ORG_FILES "notes.org")
  434. (concat MY--PATH_ORG_FILES "projects.org")
  435. (concat MY--PATH_ORG_FILES "todo.org")))
  436. (when *sys/linux*
  437. (setq org-agenda-files (list org-agenda-files
  438. MY--PATH_ORG_FILES_MOBILE)))
  439. (setq org-id-locations-file (concat MY--PATH_USER_LOCAL ".org-id-locations")
  440. org-log-into-drawer "LOGBOOK")
  441. ;; some display customizations
  442. (setq org-pretty-entities t
  443. org-startup-truncated t
  444. org-startup-align-all-tables t)
  445. ;; some source code blocks customizations
  446. (setq org-src-window-setup 'current-window ;; C-c ' opens in current window
  447. org-src-fontify-natively t ;; use syntax highlighting in code blocks
  448. org-src-preserve-indentation t ;; no extra indentation
  449. org-src-tab-acts-natively t))
  450. #+END_SRC
  451. ** languages
  452. :PROPERTIES:
  453. :ID: ad3af718-d0db-448c-9f75-eb9e250c2862
  454. :END:
  455. Set some languages and disable confirmation for evaluating code blocks C-c C-c
  456. #+BEGIN_SRC emacs-lisp
  457. (org-babel-do-load-languages
  458. 'org-babel-load-languages
  459. '((emacs-lisp . t)
  460. (gnuplot . t)
  461. (js . t)
  462. (latex . t)
  463. (lisp . t)
  464. (python . t)
  465. (shell . t)
  466. (sqlite . t)
  467. (org . t)
  468. (R . t)
  469. (scheme . t)))
  470. (setq org-confirm-babel-evaluate nil)
  471. #+END_SRC
  472. ** habits
  473. :PROPERTIES:
  474. :ID: fcc91d0a-d040-4910-b2cf-3221496a3842
  475. :END:
  476. #+BEGIN_SRC emacs-lisp
  477. (require 'org-habit) ;;TODO Lösung ohne require finden, scheint mir nicht ideal zu sein, nur um ein org-modul zu aktivieren
  478. ;; (add-to-list 'org-modules "org-habit")
  479. (setq org-habit-graph-column 80
  480. org-habit-preceding-days 30
  481. org-habit-following-days 7
  482. org-habit-show-habits-only-for-today nil)
  483. #+END_SRC
  484. ** org-id
  485. :PROPERTIES:
  486. :ID: c4017c45-d650-410c-8bd4-bc3cf42bbbb9
  487. :END:
  488. Currently it causes some debugger errors "not a standard org time string", so it's disabled
  489. #+BEGIN_SRC emacs-lisp
  490. ;; (use-package org-id
  491. ;; :config
  492. ;; (setq org-id-link-to-org-use-id t)
  493. ;; (org-id-update-id-locations)) ;; update id file .org-id-locations on startup
  494. #+END_SRC
  495. ** org-agenda
  496. :PROPERTIES:
  497. :ID: 03b67efb-4179-41e5-bc2e-c472b13f8be6
  498. :END:
  499. Custom keywords, depending on environment
  500. #+BEGIN_SRC emacs-lisp
  501. (when *work_remote*
  502. (setq org-todo-keywords
  503. '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE"))))
  504. #+END_SRC
  505. Add some key bindings
  506. #+BEGIN_SRC emacs-lisp
  507. (bind-key "C-c l" 'org-store-link)
  508. (bind-key "C-c c" 'org-capture)
  509. (bind-key "C-c a" 'org-agenda)
  510. #+END_SRC
  511. Sort agenda by deadline and priority
  512. #+BEGIN_SRC emacs-lisp
  513. (setq org-agenda-sorting-strategy
  514. (quote
  515. ((agenda deadline-up priority-down)
  516. (todo priority-down category-keep)
  517. (tags priority-down category-keep)
  518. (search category-keep))))
  519. #+END_SRC
  520. Customize the org agenda
  521. #+BEGIN_SRC emacs-lisp
  522. (defun me--org-skip-subtree-if-priority (priority)
  523. "Skip an agenda subtree if it has a priority of PRIORITY.
  524. PRIORITY may be one of the characters ?A, ?B, or ?C."
  525. (let ((subtree-end (save-excursion (org-end-of-subtree t)))
  526. (pri-value (* 1000 (- org-lowest-priority priority)))
  527. (pri-current (org-get-priority (thing-at-point 'line t))))
  528. (if (= pri-value pri-current)
  529. subtree-end
  530. nil)))
  531. (setq org-agenda-custom-commands
  532. '(("c" "Simple agenda view"
  533. ((tags "PRIORITY=\"A\""
  534. ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
  535. (org-agenda-overriding-header "Hohe Priorität:")))
  536. (agenda ""
  537. ((org-agenda-span 7)
  538. (org-agenda-start-on-weekday nil)
  539. (org-agenda-overriding-header "Nächste 7 Tage:")))
  540. (alltodo ""
  541. ((org-agenda-skip-function '(or (me--org-skip-subtree-if-priority ?A)
  542. (org-agenda-skip-if nil '(scheduled deadline))))
  543. (org-agenda-overriding-header "Sonstige Aufgaben:")))))))
  544. #+END_SRC
  545. ** *TODO*
  546. org-super-agenda
  547. ** org-caldav
  548. :PROPERTIES:
  549. :ID: 6bd24369-0d04-452f-85a0-99914dfb74ff
  550. :END:
  551. Vorerst deaktiviert, Nutzen evtl. nicht vorhanden
  552. #+BEGIN_SRC emacs-lisp
  553. ;;(use-package org-caldav
  554. ;; :ensure t
  555. ;; :config
  556. ;; (setq org-caldav-url "https://nextcloud.cloudsphere.duckdns.org/remote.php/dav/calendars/marc"
  557. ;; org-caldav-calendar-id "orgmode"
  558. ;; org-caldav-inbox (expand-file-name "~/Archiv/Organisieren/caldav-inbox")
  559. ;; org-caldav-files (concat MY--PATH_ORG_FILES "tasks")))
  560. #+END_SRC
  561. ** journal
  562. :PROPERTIES:
  563. :ID: a1951e18-d862-4198-9652-016e979053c8
  564. :END:
  565. [[https://github.com/bastibe/org-journal][Source]]
  566. #+BEGIN_SRC emacs-lisp
  567. (use-package org-journal
  568. :if *sys/linux*
  569. :ensure t
  570. :defer t
  571. :config
  572. ;; feels hacky, but this way compiler error "assignment to free variable" disappears
  573. (when (and (boundp 'org-journal-dir)
  574. (boundp 'org-journal-enable-agenda-integration))
  575. (setq org-journal-dir MY--PATH_ORG_JOURNAl
  576. org-journal-enable-agenda-integration t)))
  577. #+END_SRC
  578. * Programming
  579. ** Magit / Git
  580. :PROPERTIES:
  581. :ID: d3589460-317f-40f6-9056-053be9ba3217
  582. :END:
  583. Little crash course in magit:
  584. - magit-init to init a git project
  585. - magit-status (C-x g) to call the status window
  586. In status buffer:
  587. - s stage files
  588. - u unstage files
  589. - U unstage all files
  590. - a apply changes to staging
  591. - c c commit (type commit message, then C-c C-c to commit)
  592. - b b switch to another branch
  593. - P u git push
  594. - F u git pull
  595. #+BEGIN_SRC emacs-lisp
  596. (use-package magit
  597. :ensure t
  598. :defer t
  599. :init
  600. ; set git-path in work environment
  601. (if (string-equal user-login-name "POH")
  602. (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe")
  603. )
  604. :bind (("C-x g" . magit-status))
  605. )
  606. #+END_SRC
  607. ** LSP
  608. :PROPERTIES:
  609. :ID: 06ad00e0-44a6-4bfb-ba6f-b1672811e053
  610. :END:
  611. Configuration for the language server protocol
  612. *ACHTUNG* Dateipfad muss absolut sein, symlink im Pfad führt zumindest beim ersten Start zu Fehlern beim lsp
  613. Sobald der lsp einmal lief, kann zukünftig der symlink-Pfad genommen werden.
  614. Getestet wurde die funktionierende Datei selbst und neu erstellte Dateien im selben Pfad.
  615. TODO Unterverzeichnisse wurden noch nicht getestet
  616. #+BEGIN_SRC emacs-lisp
  617. (use-package lsp-mode
  618. :defer t
  619. :commands lsp
  620. :custom
  621. (lsp-auto-guess-root nil)
  622. (lsp-prefer-flymake nil) ; use flycheck instead
  623. (lsp-file-watch-threshold 2000)
  624. :bind (:map lsp-mode-map ("C-c C-f" . lsp-format-buffer))
  625. :hook ((python-mode
  626. js-mode
  627. js2-mode
  628. typescript-mode
  629. web-mode) . lsp))
  630. (use-package lsp-ui
  631. :after lsp-mode
  632. :ensure t
  633. :diminish
  634. :commands lsp-ui-mode
  635. :config
  636. (setq lsp-ui-doc-enable t
  637. lsp-ui-doc-header t
  638. lsp-ui-doc-include-signature t
  639. lsp-ui-doc-position 'top
  640. lsp-ui-doc-border (face-foreground 'default)
  641. lsp-ui-sideline-enable nil
  642. lsp-ui-sideline-ignore-duplicate t
  643. lsp-ui-sideline-show-code-actions nil)
  644. (when *sys/gui*
  645. (setq lsp-ui-doc-use-webkit t))
  646. ;; workaround hide mode-line of lsp-ui-imenu buffer
  647. (defadvice lsp-ui-imenu (after hide-lsp-ui-imenu-mode-line activate)
  648. (setq mode-line-format nil)))
  649. (use-package company-lsp
  650. :requires company
  651. :defer t
  652. :ensure t
  653. :config
  654. ;;disable client-side cache because lsp server does a better job
  655. (setq company-transformers nil
  656. company-lsp-async t
  657. company-lsp-cache-candidates nil))
  658. #+END_SRC
  659. ** yasnippet
  660. :PROPERTIES:
  661. :ID: 935d89ef-645e-4e92-966f-2fe3bebb2880
  662. :END:
  663. For useful snippet either install yasnippet-snippets or get them from here
  664. [[https://github.com/AndreaCrotti/yasnippet-snippets][Github]]
  665. #+begin_src emacs-lisp
  666. (use-package yasnippet
  667. :ensure t
  668. :diminish yas-minor-mode
  669. :config
  670. (setq yas-snippet-dirs (list (concat MY--PATH_USER_GLOBAL "snippets")))
  671. (yas-global-mode t)
  672. (yas-reload-all)
  673. (unbind-key "TAB" yas-minor-mode-map)
  674. (unbind-key "<tab>" yas-minor-mode-map))
  675. #+end_src
  676. ** hippie expand
  677. :PROPERTIES:
  678. :ID: c55245bc-813d-4816-a0ca-b4e2e793e28b
  679. :END:
  680. With hippie expand I am able to use yasnippet and emmet at the same time with the same key.
  681. #+begin_src emacs-lisp
  682. (use-package hippie-exp
  683. :defer t
  684. :bind
  685. ("C-<return>" . hippie-expand)
  686. :config
  687. (setq hippie-expand-try-functions-list
  688. '(yas-hippie-try-expand emmet-expand-line)))
  689. #+end_src
  690. ** flycheck
  691. :PROPERTIES:
  692. :ID: 3d8f2547-c5b3-46d0-91b0-9667f9ee5c47
  693. :END:
  694. #+BEGIN_SRC emacs-lisp
  695. (use-package flycheck
  696. :ensure t
  697. :hook
  698. ((css-mode . flycheck-mode)
  699. (emacs-lisp-mode . flycheck-mode)
  700. (python-mode . flycheck-mode))
  701. :init
  702. (setq flycheck-emacs-lisp-load-path 'inherit)
  703. :config
  704. (setq-default
  705. flycheck-check-synta-automatically '(save mode-enabled)
  706. flycheck-disable-checkers '(emacs-lisp-checkdoc)
  707. eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck
  708. flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages
  709. #+END_SRC
  710. ** Projectile
  711. :PROPERTIES:
  712. :ID: a90329fd-4d36-435f-8308-a2771ac4c320
  713. :END:
  714. Manage projects and jump quickly between its files
  715. #+BEGIN_SRC emacs-lisp
  716. (use-package projectile
  717. :ensure t
  718. :defer t
  719. :bind
  720. (("C-c p p" . projectile-switch-project)
  721. ("C-c p c" . projectile-command-map)
  722. ("C-c p s s" . projectile-ag))
  723. :init
  724. (setq-default projectile-cache-file (concat MY--PATH_USER_LOCAL ".projectile-cache")
  725. projectile-known-projects-file (concat MY--PATH_USER_LOCAL ".projectile-bookmarks"))
  726. :config
  727. (projectile-mode t)
  728. (setq-default projectile-completion-system 'ivy
  729. projectile-enable-caching t
  730. projectile-mode-line '(:eval (projectile-project-name))))
  731. #+END_SRC
  732. ** smartparens
  733. :PROPERTIES:
  734. :ID: 997ec416-33e6-41ed-8c7c-75a7bc47d285
  735. :END:
  736. #+BEGIN_SRC emacs-lisp
  737. (use-package smartparens
  738. :ensure t
  739. :diminish smartparens-mode
  740. :bind
  741. (:map smartparens-mode-map
  742. ("C-M-f" . sp-forward-sexp)
  743. ("C-M-b" . sp-backward-sexp)
  744. ("C-M-a" . sp-backward-down-sexp)
  745. ("C-M-e" . sp-up-sexp)
  746. ("C-M-w" . sp-copy-sexp)
  747. ("M-k" . sp-kill-sexp)
  748. ("C-M-<backspace>" . sp-slice-sexp-killing-backward)
  749. ("C-S-<backspace>" . sp-slice-sexp-killing-around)
  750. ("C-]" . sp-select-next-thing-exchange))
  751. :config
  752. (setq sp-show-pair-from-inside nil
  753. sp-escape-quotes-after-insert nil)
  754. (require 'smartparens-config))
  755. #+END_SRC
  756. ** lisp
  757. :PROPERTIES:
  758. :ID: a2bc3e08-b203-49d3-b337-fb186a14eecb
  759. :END:
  760. #+BEGIN_SRC emacs-lisp
  761. (add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook)
  762. #+END_SRC
  763. ** web
  764. :PROPERTIES:
  765. :ID: c0b0b4e4-2162-429f-b80d-6e5334b1290e
  766. :END:
  767. apt install npm
  768. sudo npm install -g vscode-html-languageserver-bin
  769. evtl alternativ typescript-language-server?
  770. Unter Windows:
  771. Hier runterladen: https://nodejs.org/dist/latest/
  772. und in ein Verzeichnis entpacken.
  773. Optional: PATH erweitern unter Windows (so kann exec-path-from-shell den Pfad ermitteln):
  774. PATH=P:\path\to\node;%path%
  775. #+BEGIN_SRC emacs-lisp
  776. (use-package web-mode
  777. :ensure t
  778. :defer t
  779. :mode
  780. ("\\.phtml\\'"
  781. "\\.tpl\\.php\\'"
  782. "\\.djhtml\\'"
  783. "\\.[t]?html?\\'")
  784. :init
  785. (if *work_remote*
  786. (setq exec-path (append exec-path '("P:/Tools/node"))))
  787. :config
  788. (setq web-mode-enable-auto-closing t
  789. web-mode-enable-auto-pairing t)
  790. (add-hook 'web-mode-hook 'smartparens-mode))
  791. #+END_SRC
  792. Emmet offers snippets, similar to yasnippet.
  793. Default completion is C-j
  794. [[https://github.com/smihica/emmet-mode#usage][Github]]
  795. #+begin_src emacs-lisp
  796. (use-package emmet-mode
  797. :ensure t
  798. :defer t
  799. :hook
  800. ((web-mode . emmet-mode)
  801. (css-mode . emmet-mode))
  802. :config
  803. (unbind-key "C-<return>" emmet-mode-keymap))
  804. #+end_src
  805. ** YAML
  806. :PROPERTIES:
  807. :ID: 95413247-04d5-4e02-8431-06c162ec8f3b
  808. :END:
  809. #+begin_src emacs-lisp
  810. (use-package yaml-mode
  811. :if *sys/linux*
  812. :ensure t
  813. :mode ("\\.yml$" . yaml-mode))
  814. #+end_src
  815. ** R
  816. #+BEGIN_SRC emacs-lisp
  817. (use-package ess
  818. :ensure t
  819. :init
  820. (if *work_remote*
  821. (setq exec-path (append exec-path '("P:/Tools/R/bin/x64"))
  822. org-babel-R-command "P:/Tools/R/bin/x64/R --slave --no-save")))
  823. #+END_SRC
  824. ** Python
  825. :PROPERTIES:
  826. :ID: 8c76fcd1-c57c-48ab-8af0-aa782de6337f
  827. :END:
  828. Systemseitig muss python-language-server installiert sein:
  829. pip3 install 'python-language-server[all]'
  830. für andere language servers
  831. https://github.com/emacs-lsp/lsp-mode#install-language-server
  832. #+BEGIN_SRC emacs-lisp
  833. (if *sys/linux*
  834. (defun my/postactivatehook ()
  835. (setq lsp-python-ms-extra-paths pyvenv-virtual-env))
  836. (use-package pyvenv
  837. :ensure t
  838. :config
  839. (setenv "WORKON_HOME" (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))
  840. (add-hook 'pyvenv-post-activate-hooks 'my/postactivatehook))
  841. (use-package virtualenvwrapper
  842. :ensure t
  843. :hook (venv-postmkvirtualenv . (lambda() (shell-command "pip3 install importmagic epc")))
  844. :config
  845. (setq venv-location (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
  846. (use-package lsp-python-ms
  847. :ensure t
  848. :after lsp-mode python))
  849. ; :custom (lsp-python-executable-cmd "python3"))
  850. #+END_SRC
  851. * beancount
  852. ** Installation
  853. :PROPERTIES:
  854. :ID: 2c329043-b7a9-437d-a5cf-f2ad6514be91
  855. :END:
  856. #+BEGIN_SRC shell
  857. sudo su
  858. cd /opt
  859. python3 -m venv beancount
  860. source ./beancount/bin/activate
  861. pip3 install wheel
  862. pip3 install beancount
  863. sleep 100
  864. echo "shell running!"
  865. deactivate
  866. #+END_SRC
  867. #+BEGIN_SRC emacs-lisp
  868. (use-package beancount
  869. :if *sys/linux*
  870. :load-path "user-global/elisp"
  871. ; :ensure t
  872. :defer t
  873. :mode
  874. ("\\.beancount$" . beancount-mode)
  875. :init
  876. (add-hook 'beancount-mode-hook 'company/beancount-mode-hook)
  877. ; (add-hook 'beancount-mode-hook (pyvenv-activate "/opt/beancount"))
  878. ; (setenv "PATH"
  879. ; (concat "/opt/beancount/bin:"
  880. ; (getenv "PATH")))
  881. :config
  882. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount"))
  883. #+END_SRC
  884. To support org-babel, check if it can find the symlink to ob-beancount.el
  885. #+BEGIN_SRC shell
  886. orgpath=`find /home/marc/.emacs.d/elpa/ -type d -name "org-plus*" -print`
  887. beansym="$orgpath/ob-beancount.el
  888. bean="/home/marc/Archiv/Programmierprojekte/Lisp/beancount-mode/ob-beancount.el"
  889. if [ -h "$beansym" ]
  890. then
  891. echo "$beansym found"
  892. elif [ -e "$bean" ]
  893. then
  894. echo "creating symlink"
  895. ln -s "$bean" "$beansym"
  896. else
  897. echo "$bean not found, symlink creation aborted"
  898. fi
  899. #+END_SRC
  900. Fava is strongly recommended.
  901. #+BEGIN_SRC shell
  902. cd /opt
  903. python3 -m venv fava
  904. source ./fava/bin/activate
  905. pip3 install wheel
  906. pip3 install fava
  907. deactivate
  908. #+END_SRC
  909. Start fava with fava my_file.beancount
  910. It is accessable on this URL: [[http://127.0.0.1:5000][Fava]]
  911. Beancount-mode can start fava and open the URL right away.