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.

1038 lines
30 KiB

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