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.

1946 lines
59 KiB

5 years ago
1 year ago
3 years ago
3 years ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 years ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
1 year ago
7 months ago
7 months ago
7 months ago
6 years ago
6 years ago
6 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
1 year ago
7 months ago
7 months ago
1 year ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 years ago
7 months ago
7 months ago
7 months ago
6 years ago
7 months ago
6 years ago
6 years ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
1 year ago
1 year ago
  1. #+TITLE: Emacs configuration file
  2. #+AUTHOR: Marc
  3. #+BABEL: :cache yes
  4. #+PROPERTY: header-args :tangle init.el
  5. #+OPTIONS: ^:nil
  6. * TODOS
  7. - early-init.el? What to outsource here?
  8. - Paket exec-path-from-shell, um PATH aus Linux auch in emacs zu haben
  9. - Smart mode line?
  10. - Theme
  11. - flymake instead of flycheck?
  12. - Hydra
  13. - General
  14. - (defalias 'list-buffers 'ibuffer) ;; change default to ibuffer
  15. - ido?
  16. - treemacs (for linux)
  17. windmove?
  18. - tramp (in linux)
  19. - visual-regexp
  20. - org configuration: paths
  21. - org custom agenda
  22. - org-ql (related to org agendas)
  23. - org configuration: everything else
  24. - beancount configuration from config.org
  25. - CONTINUE TODO from config.org at Programming
  26. - all-the-icons?
  27. - lispy? [[https://github.com/abo-abo/lispy]]
  28. * Header
  29. Emacs variables are dynamically scoped. That's unusual for most languages, so disable it here, too
  30. #+begin_src emacs-lisp
  31. ;;; init.el --- -*- lexical-binding: t -*-
  32. #+end_src
  33. * First start
  34. These functions updates config.el whenever changes in config.org are made. The update will be active after saving.
  35. #+BEGIN_SRC emacs-lisp
  36. (defun my/tangle-config ()
  37. "Export code blocks from the literate config file."
  38. (interactive)
  39. ;; prevent emacs from killing until tangle-process has finished
  40. (add-to-list 'kill-emacs-query-functions
  41. (lambda ()
  42. (or (not (process-live-p (get-process "tangle-process")))
  43. (y-or-n-p "\"my/tangle-config\" is running; kill it? "))))
  44. (org-babel-tangle-file config-org init-el)
  45. (message "reloading user-init-file")
  46. (load-file init-el))
  47. (add-hook 'org-mode-hook
  48. (lambda ()
  49. (if (equal (buffer-file-name) config-org)
  50. (my--add-local-hook 'after-save-hook 'my/tangle-config))))
  51. (defun my--add-local-hook (hook function)
  52. "Add buffer-local hook."
  53. (add-hook hook function :local t))
  54. #+END_SRC
  55. A small function to measure start up time.
  56. Compare that to
  57. emacs -q --eval='(message "%s" (emacs-init-time))'
  58. (roughly 0.27s)
  59. https://blog.d46.us/advanced-emacs-startup/
  60. #+begin_src emacs-lisp
  61. (add-hook 'emacs-startup-hook
  62. (lambda ()
  63. (message "Emacs ready in %s with %d garbage collections."
  64. (format "%.2f seconds"
  65. (float-time
  66. (time-subtract after-init-time before-init-time)))
  67. gcs-done)))
  68. ;(setq gc-cons-threshold (* 50 1000 1000))
  69. #+end_src
  70. * Default settings
  71. ** paths
  72. #+BEGIN_SRC emacs-lisp
  73. (defconst *sys/gui*
  74. (display-graphic-p)
  75. "Is emacs running in a gui?")
  76. (defconst *sys/linux*
  77. (string-equal system-type 'gnu/linux)
  78. "Is the system running Linux?")
  79. (defconst *sys/windows*
  80. (string-equal system-type 'windows-nt)
  81. "Is the system running Windows?")
  82. (defconst *home_desktop*
  83. (string-equal (system-name) "marc")
  84. "Is emacs running on my desktop?")
  85. (defconst *home_laptop*
  86. (string-equal (system-name) "laptop")
  87. "Is emacs running on my laptop?")
  88. (defconst *work_local*
  89. (string-equal (system-name) "PMPCNEU08")
  90. "Is emacs running at work on the local system?")
  91. (defconst *work_remote*
  92. (or (string-equal (system-name) "PMTS01")
  93. (string-equal (system-name) "PMTSNEU01"))
  94. "Is emacs running at work on the remote system?")
  95. #+END_SRC
  96. #+BEGIN_SRC emacs-lisp
  97. (defvar MY--PATH_USER_LOCAL (concat user-emacs-directory "user-local/"))
  98. (defvar MY--PATH_USER_GLOBAL (concat user-emacs-directory "user-global/"))
  99. (add-to-list 'custom-theme-load-path (concat MY--PATH_USER_GLOBAL "themes"))
  100. (when *sys/linux*
  101. (defconst MY--PATH_ORG_FILES (expand-file-name "~/Archiv/Organisieren/"))
  102. (defconst MY--PATH_ORG_FILES_MOBILE (expand-file-name "~/Archiv/Organisieren/mobile/"))
  103. (defconst MY--PATH_ORG_JOURNAl (expand-file-name "~/Archiv/Organisieren/Journal/"))
  104. (defconst MY--PATH_ORG_ROAM (file-truename "~/Archiv/Organisieren/")))
  105. (when *work_remote*
  106. (defconst MY--PATH_ORG_FILES "p:/Eigene Dateien/Notizen/")
  107. (defconst MY--PATH_ORG_FILES_MOBILE nil) ;; hacky way to prevent "free variable" compiler error
  108. (defconst MY--PATH_ORG_JOURNAL nil) ;; hacky way to prevent "free variable" compiler error
  109. (defconst MY--PATH_START "p:/Eigene Dateien/Notizen/")
  110. (defconst MY--PATH_ORG_ROAM (expand-file-name "p:/Eigene Dateien/Notizen/")))
  111. (setq custom-file (concat MY--PATH_USER_LOCAL "custom.el")) ;; don't spam init.e with saved customization settings
  112. (setq backup-directory-alist `((".*" . ,temporary-file-directory)))
  113. (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory)))
  114. (customize-set-variable 'auth-sources (list (concat MY--PATH_USER_LOCAL "authinfo")
  115. (concat MY--PATH_USER_LOCAL "authinfo.gpg")
  116. (concat MY--PATH_USER_LOCAL "netrc")))
  117. #+end_src
  118. ** Browser
  119. #+begin_src emacs-lisp
  120. (setq browse-url-function 'browse-url-generic
  121. browse-url-generic-program "firefox")
  122. #+end_src* Package Management
  123. ** Elpaca
  124. Boilerplate for Elpaca
  125. #+begin_src emacs-lisp
  126. (defvar elpaca-installer-version 0.7)
  127. (defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
  128. (defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
  129. (defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory))
  130. (defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
  131. :ref nil :depth 1
  132. :files (:defaults "elpaca-test.el" (:exclude "extensions"))
  133. :build (:not elpaca--activate-package)))
  134. (let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory))
  135. (build (expand-file-name "elpaca/" elpaca-builds-directory))
  136. (order (cdr elpaca-order))
  137. (default-directory repo))
  138. (add-to-list 'load-path (if (file-exists-p build) build repo))
  139. (unless (file-exists-p repo)
  140. (make-directory repo t)
  141. (when (< emacs-major-version 28) (require 'subr-x))
  142. (condition-case-unless-debug err
  143. (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
  144. ((zerop (apply #'call-process `("git" nil ,buffer t "clone"
  145. ,@(when-let ((depth (plist-get order :depth)))
  146. (list (format "--depth=%d" depth) "--no-single-branch"))
  147. ,(plist-get order :repo) ,repo))))
  148. ((zerop (call-process "git" nil buffer t "checkout"
  149. (or (plist-get order :ref) "--"))))
  150. (emacs (concat invocation-directory invocation-name))
  151. ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
  152. "--eval" "(byte-recompile-directory \".\" 0 'force)")))
  153. ((require 'elpaca))
  154. ((elpaca-generate-autoloads "elpaca" repo)))
  155. (progn (message "%s" (buffer-string)) (kill-buffer buffer))
  156. (error "%s" (with-current-buffer buffer (buffer-string))))
  157. ((error) (warn "%s" err) (delete-directory repo 'recursive))))
  158. (unless (require 'elpaca-autoloads nil t)
  159. (require 'elpaca)
  160. (elpaca-generate-autoloads "elpaca" repo)
  161. (load "./elpaca-autoloads")))
  162. (add-hook 'after-init-hook #'elpaca-process-queues)
  163. (elpaca `(,@elpaca-order))
  164. ;(setq use-package-always-ensure t)
  165. (elpaca elpaca-use-package
  166. ;; enable use-package :ensure support for elpaca
  167. (elpaca-use-package-mode))
  168. (elpaca-wait)
  169. #+end_src
  170. For Windows it might be necessary to disable symlink creations
  171. #+begin_src emacs-lisp
  172. (when *work_remote*
  173. (elpaca-no-symlink-mode))
  174. #+end_src
  175. * use-package keywords general / diminish
  176. Needs to be loaded before any other package which uses the :general keyword
  177. #+BEGIN_SRC emacs-lisp
  178. (use-package general
  179. :ensure t
  180. :demand t)
  181. (use-package diminish
  182. :ensure t
  183. :demand t)
  184. ;;wait for elpaca any time a use-package keyword is added
  185. (elpaca-wait)
  186. #+END_SRC
  187. * sane defaults
  188. #+begin_src emacs-lisp
  189. (setq-default create-lockfiles nil) ;; disable lock files, can cause trouble in e.g. lsp-mode
  190. (defalias 'yes-or-no-p 'y-or-n-p) ;; answer with y and n
  191. (setq custom-safe-themes t) ;; don't ask me if I want to load a theme
  192. (setq sentence-end-double-space nil) ;; don't coun two spaces after a period as the end of a sentence.
  193. (delete-selection-mode t) ;; delete selected region when typing
  194. (use-package saveplace
  195. :ensure nil
  196. :config
  197. (save-place-mode 1) ;; saves position in file when it's closed
  198. :custom
  199. (save-place-file (concat MY--PATH_USER_LOCAL "places")))
  200. (setq save-place-forget-unreadable-files nil) ;; checks if file is readable before saving position
  201. (global-set-key (kbd "RET") 'newline-and-indent) ;; indent after newline
  202. (setq save-interprogram-paste-before-kill t) ;; put replaced text into killring
  203. ;; https://emacs.stackexchange.com/questions/3673/how-to-make-vc-and-magit-treat-a-symbolic-link-to-a-real-file-in-git-repo-just
  204. (setq find-file-visit-truename t) ;; some programs like lsp have trouble following symlinks, maybe vc-follow-symlinks would be enough
  205. #+END_SRC
  206. * Performance Optimization
  207. ** Garbage Collection
  208. Make startup faster by reducing the frequency of garbage collection.
  209. Set gc-cons-threshold (default is 800kb) to maximum value available, to prevent any garbage collection from happening during load time.
  210. #+BEGIN_SRC emacs-lisp :tangle early-init.el
  211. (setq gc-cons-threshold most-positive-fixnum)
  212. #+END_SRC
  213. Restore it to reasonable value after init. Also stop garbage collection during minibuffer interaction (helm etc.)
  214. #+begin_src emacs-lisp
  215. (defconst 1mb 1048576)
  216. (defconst 20mb 20971520)
  217. (defconst 30mb 31457280)
  218. (defconst 50mb 52428800)
  219. (defun my--defer-garbage-collection ()
  220. (setq gc-cons-threshold most-positive-fixnum))
  221. (defun my--restore-garbage-collection ()
  222. (run-at-time 1 nil (lambda () (setq gc-cons-threshold 30mb))))
  223. (add-hook 'emacs-startup-hook 'my--restore-garbage-collection 100)
  224. (add-hook 'minibuffer-setup-hook 'my--defer-garbage-collection)
  225. (add-hook 'minibuffer-exit-hook 'my--restore-garbage-collection)
  226. (setq read-process-output-max 1mb) ;; lsp-mode's performance suggest
  227. #+end_src
  228. ** File Handler
  229. #+begin_src emacs-lisp :tangle early-init.el
  230. (defvar default-file-name-handler-alist file-name-handler-alist)
  231. (setq file-name-handler-alist nil)
  232. (add-hook 'emacs-startup-hook
  233. (lambda ()
  234. (setq file-name-handler-alist default-file-name-handler-alist)) 100)
  235. #+end_src
  236. ** Others
  237. #+begin_src emacs-lisp :tangle early-init.el
  238. ;; Resizing the emacs frame can be a terriblu expensive part of changing the font.
  239. ;; By inhibiting this, we easily hale startup times with fonts that are larger
  240. ;; than the system default.
  241. (setq package-enable-at-startup nil)
  242. (setq frame-inhibit-implied-resize t)
  243. #+end_src
  244. * Appearance
  245. ** Defaults
  246. #+begin_src emacs-lisp
  247. (set-charset-priority 'unicode)
  248. (setq-default locale-coding-system 'utf-8
  249. default-process-coding-system '(utf-8-unix . utf-8-unix))
  250. (set-terminal-coding-system 'utf-8)
  251. (set-keyboard-coding-system 'utf-8)
  252. (set-selection-coding-system 'utf-8)
  253. (if *sys/windows*
  254. (prefer-coding-system 'utf-8-dos)
  255. (prefer-coding-system 'utf-8))
  256. (setq-default bidi-paragraph-direction 'left-to-right
  257. bidi-inhibit-bpa t ;; both settings reduce line rescans
  258. uniquify-buffer-name-style 'forward
  259. indent-tabs-mode nil ;; avoid tabs in place of multiple spaces (they look bad in tex)
  260. indicate-empty-lines t ;; show empty lines
  261. scroll-margin 5 ;; smooth scrolling
  262. scroll-conservatively 10000
  263. scroll-preserve-screen-position 1
  264. scroll-step 1
  265. ring-bell-function 'ignore ;; disable pc speaker bell
  266. visible-bell t)
  267. (global-hl-line-mode t) ;; highlight current line
  268. (blink-cursor-mode -1) ;; turn off blinking cursor
  269. (column-number-mode t)
  270. #+end_src
  271. ** Remove redundant UI
  272. #+begin_src emacs-lisp :tangle early-init.el
  273. (menu-bar-mode -1) ;; disable menu bar
  274. (tool-bar-mode -1) ;; disable tool bar
  275. (scroll-bar-mode -1) ;; disable scroll bar
  276. #+end_src
  277. ** Font
  278. #+BEGIN_SRC emacs-lisp
  279. (when *sys/linux*
  280. (set-face-font 'default "Hack-10"))
  281. (when *work_remote*
  282. (set-face-font 'default "Lucida Sans Typewriter-11"))
  283. #+END_SRC
  284. ** Themes
  285. #+BEGIN_SRC emacs-lisp
  286. (defun my/toggle-theme ()
  287. (interactive)
  288. (when (or *sys/windows* *sys/linux*)
  289. (if (eq (car custom-enabled-themes) 'tango-dark)
  290. (progn (disable-theme 'tango-dark)
  291. (load-theme 'tango))
  292. (progn
  293. (disable-theme 'tango)
  294. (load-theme 'tango-dark)))))
  295. (bind-key "C-c t" 'my/toggle-theme)
  296. #+END_SRC
  297. Windows Theme:
  298. #+BEGIN_SRC emacs-lisp
  299. (when *sys/windows*
  300. (load-theme 'tango))
  301. (when *sys/linux*
  302. (load-theme 'plastic))
  303. #+END_SRC
  304. ** line wrappings
  305. #+BEGIN_SRC emacs-lisp
  306. (global-visual-line-mode)
  307. ;(diminish 'visual-line-mode)
  308. (use-package adaptive-wrap
  309. :ensure t
  310. :hook
  311. (visual-line-mode . adaptive-wrap-prefix-mode))
  312. ; :init
  313. ; (when (fboundp 'adaptive-wrap-prefix-mode)
  314. ; (defun me/activate-adaptive-wrap-prefix-mode ()
  315. ; "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously."
  316. ; (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1)))
  317. ; (add-hook 'visual-line-mode-hook 'me/activate-adaptive-wrap-prefix-mode)))
  318. #+END_SRC
  319. ** line numbers
  320. #+BEGIN_SRC emacs-lisp
  321. (use-package display-line-numbers
  322. :ensure nil
  323. :init
  324. :hook
  325. ((prog-mode
  326. org-src-mode) . display-line-numbers-mode)
  327. :config
  328. (setq-default display-line-numbers-type 'visual
  329. display-line-numbers-current-absolute t
  330. display-line-numbers-with 4
  331. display-line-numbers-widen t))
  332. #+END_SRC
  333. ** misc
  334. Delight can replace mode names with custom names ,
  335. e.g. python-mode with just "π ".
  336. #+BEGIN_SRC emacs-lisp
  337. (use-package rainbow-mode
  338. :ensure t
  339. :diminish
  340. :hook
  341. ((org-mode
  342. emacs-lisp-mode) . rainbow-mode))
  343. (use-package delight
  344. :if *sys/linux*
  345. :ensure t)
  346. (show-paren-mode t) ;; show other part of brackets
  347. (setq blink-matching-paren nil) ;; not necessary with show-paren-mode, bugs out on C-s counsel-line
  348. (use-package rainbow-delimiters
  349. :ensure t
  350. :hook
  351. (prog-mode . rainbow-delimiters-mode))
  352. #+END_SRC
  353. * Bookmarks
  354. Usage:
  355. - C-x r m (bookmark-set): add bookmark
  356. - C-x r l (list-bookmark): list bookmarks
  357. - C-x r b (bookmark-jump): open bookmark
  358. Edit bookmarks (while in bookmark file):
  359. - d: mark current item
  360. - x: delete marked items
  361. - r: rename current item
  362. - s: save changes
  363. #+begin_src emacs-lisp
  364. (use-package bookmark
  365. :ensure nil
  366. :custom
  367. (bookmark-default-file (concat MY--PATH_USER_LOCAL "bookmarks")))
  368. #+end_src
  369. Some windows specific stuff
  370. #+BEGIN_SRC emacs-lisp
  371. (when *sys/windows*
  372. (remove-hook 'find-file-hook 'vc-refresh-state)
  373. ; (progn
  374. ; (setq gc-cons-threshold (* 511 1024 1024)
  375. ; gc-cons-percentage 0.5
  376. ; garbage-collection-messages t
  377. ; (run-with-idle-timer 5 t #'garbage-collect))
  378. (when (boundp 'w32-pipe-read-delay)
  379. (setq w32-pipe-read-delay 0))
  380. (when (boundp 'w32-get-true-file-attributes)
  381. (setq w32-get-true-file-attributes nil)))
  382. #+END_SRC
  383. * recentf
  384. Exclude some dirs from spamming recentf
  385. #+begin_src emacs-lisp
  386. (use-package recentf
  387. :ensure nil
  388. ; :defer 1
  389. :config
  390. (recentf-mode)
  391. :custom
  392. (recentf-exclude '(".*-autoloads\\.el\\'"
  393. "[/\\]\\elpa/"
  394. "COMMIT_EDITMSG\\'"))
  395. (recentf-save-file (concat MY--PATH_USER_LOCAL "recentf"))
  396. (recentf-max-menu-items 600)
  397. (recentf-max-saved-items 600))
  398. #+end_src
  399. * savehist
  400. #+begin_src emacs-lisp
  401. (use-package savehist
  402. :ensure nil
  403. :config
  404. (savehist-mode)
  405. :custom
  406. (savehist-file (concat MY--PATH_USER_LOCAL "history")))
  407. #+end_src
  408. * undo
  409. #+BEGIN_SRC emacs-lisp
  410. (use-package undo-tree
  411. :ensure t
  412. :diminish undo-tree-mode
  413. :init
  414. (global-undo-tree-mode 1)
  415. :custom
  416. (undo-tree-auto-save-history nil))
  417. #+END_SRC
  418. * COMMENT ace-window (now avy)
  419. #+begin_src emacs-lisp
  420. (use-package ace-window
  421. :ensure t
  422. :bind
  423. (:map global-map
  424. ("C-x o" . ace-window)))
  425. #+end_src
  426. * which-key
  427. #+BEGIN_SRC emacs-lisp
  428. (use-package which-key
  429. :ensure t
  430. :diminish which-key-mode
  431. :defer t
  432. :hook
  433. (after-init . which-key-mode)
  434. :custom
  435. (which-key-idle-delay 0.5)
  436. (which-key-sort-order 'which-key-description-order)
  437. :config
  438. (which-key-setup-side-window-bottom))
  439. #+END_SRC
  440. * abbrev
  441. #+begin_src emacs-lisp
  442. (use-package abbrev
  443. :ensure nil
  444. :diminish abbrev-mode
  445. :hook
  446. ((text-mode org-mode) . abbrev-mode)
  447. :init
  448. (setq abbrev-file-name (concat MY--PATH_USER_GLOBAL "abbrev_tables.el"))
  449. :config
  450. (if (file-exists-p abbrev-file-name)
  451. (quietly-read-abbrev-file))
  452. (setq save-abbrevs 'silently)) ;; don't bother me with asking for abbrev saving
  453. #+end_src
  454. * imenu-list
  455. A minor mode to show imenu in a sidebar.
  456. Call imenu-list-smart-toggle.
  457. [[https://github.com/bmag/imenu-list][Source]]
  458. #+BEGIN_SRC emacs-lisp
  459. (use-package imenu-list
  460. :ensure t
  461. :demand t ; otherwise mode loads too late and won't work on first file it's being activated on
  462. :config
  463. (setq imenu-list-focus-after-activation t
  464. imenu-list-auto-resize t
  465. imenu-list-position 'right)
  466. :general
  467. ([f9] 'imenu-list-smart-toggle)
  468. (:states '(normal insert)
  469. :keymaps 'imenu-list-major-mode-map
  470. "RET" '(imenu-list-goto-entry :which-key "goto")
  471. "TAB" '(hs-toggle-hiding :which-key "collapse")
  472. "v" '(imenu-list-display-entry :which-key "show") ; also prevents visual mode
  473. "q" '(imenu-list-quit-window :which-key "quit"))
  474. :custom
  475. (org-imenu-depth 4))
  476. #+END_SRC
  477. * COMMENT Evil
  478. See also
  479. https://github.com/noctuid/evil-guide
  480. Use C-z (evil-toggle-key) to switch between evil and emacs keybindings,
  481. in case evil is messing something up.
  482. #+BEGIN_SRC emacs-lisp
  483. (use-package evil
  484. :ensure t
  485. :defer .1
  486. :custom
  487. (evil-want-C-i-jump nil) ;; prevent evil from blocking TAB in org tree expanding
  488. (evil-want-integration t)
  489. (evil-want-keybinding nil)
  490. :config
  491. ;; example for using emacs default key map in a certain mode
  492. ;; (evil-set-initial-state 'dired-mode 'emacs)
  493. (evil-mode 1))
  494. #+END_SRC
  495. * Eldoc
  496. use builtin version
  497. #+begin_src emacs-lisp
  498. (use-package eldoc
  499. :ensure nil
  500. :diminish eldoc-mode
  501. :defer t)
  502. #+end_src
  503. * COMMENT Eldoc Box
  504. Currently corfu-popupinfo displays eldoc in highlighted completion candidate. Maybe that's good enough.
  505. #+begin_src emacs-lisp
  506. (use-package eldoc-box
  507. :ensure t)
  508. #+end_src
  509. * Meow
  510. #+begin_src emacs-lisp
  511. (use-package meow
  512. :ensure t
  513. :config
  514. (setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty)
  515. (meow-motion-overwrite-define-key
  516. '("j" . meow-next)
  517. '("k" . meow-prev)
  518. '("<escape>" . ignore))
  519. (meow-leader-define-key
  520. ;; SPC j/k will run the original command in MOTION state.
  521. '("j" . "H-j")
  522. '("k" . "H-k")
  523. ;; Use SPC (0-9) for digit arguments.
  524. '("1" . meow-digit-argument)
  525. '("2" . meow-digit-argument)
  526. '("3" . meow-digit-argument)
  527. '("4" . meow-digit-argument)
  528. '("5" . meow-digit-argument)
  529. '("6" . meow-digit-argument)
  530. '("7" . meow-digit-argument)
  531. '("8" . meow-digit-argument)
  532. '("9" . meow-digit-argument)
  533. '("0" . meow-digit-argument)
  534. '("/" . meow-keypad-describe-key)
  535. '("?" . meow-cheatsheet))
  536. (meow-normal-define-key
  537. '("0" . meow-expand-0)
  538. '("9" . meow-expand-9)
  539. '("8" . meow-expand-8)
  540. '("7" . meow-expand-7)
  541. '("6" . meow-expand-6)
  542. '("5" . meow-expand-5)
  543. '("4" . meow-expand-4)
  544. '("3" . meow-expand-3)
  545. '("2" . meow-expand-2)
  546. '("1" . meow-expand-1)
  547. '("-" . negative-argument)
  548. '(";" . meow-reverse)
  549. '("," . meow-inner-of-thing)
  550. '("." . meow-bounds-of-thing)
  551. '("[" . meow-beginning-of-thing)
  552. '("]" . meow-end-of-thing)
  553. '("a" . meow-append)
  554. '("A" . meow-open-below)
  555. '("b" . meow-back-word)
  556. '("B" . meow-back-symbol)
  557. '("c" . meow-change)
  558. '("d" . meow-delete)
  559. '("D" . meow-backward-delete)
  560. '("e" . meow-next-word)
  561. '("E" . meow-next-symbol)
  562. '("f" . meow-find)
  563. '("g" . meow-cancel-selection)
  564. '("G" . meow-grab)
  565. '("h" . meow-left)
  566. '("H" . meow-left-expand)
  567. '("i" . meow-insert)
  568. '("I" . meow-open-above)
  569. '("j" . meow-next)
  570. '("J" . meow-next-expand)
  571. '("k" . meow-prev)
  572. '("K" . meow-prev-expand)
  573. '("l" . meow-right)
  574. '("L" . meow-right-expand)
  575. '("m" . meow-join)
  576. '("n" . meow-search)
  577. '("o" . meow-block)
  578. '("O" . meow-to-block)
  579. '("p" . meow-yank)
  580. '("q" . meow-quit)
  581. '("Q" . meow-goto-line)
  582. '("r" . meow-replace)
  583. '("R" . meow-swap-grab)
  584. '("s" . meow-kill)
  585. '("t" . meow-till)
  586. '("u" . meow-undo)
  587. '("U" . meow-undo-in-selection)
  588. '("v" . meow-visit)
  589. '("w" . meow-mark-word)
  590. '("W" . meow-mark-symbol)
  591. '("x" . meow-line)
  592. '("X" . meow-goto-line)
  593. '("y" . meow-save)
  594. '("Y" . meow-sync-grab)
  595. '("z" . meow-pop-selection)
  596. '("'" . repeat)
  597. '("<escape>" . ignore))
  598. ; :config
  599. (meow-global-mode t))
  600. #+end_src
  601. * avy
  602. Search, move, copy, delete text within all visible buffers.
  603. Also replaces ace-window for buffer switching.
  604. [[https://github.com/abo-abo/avy]]
  605. #+BEGIN_SRC emacs-lisp
  606. (use-package avy
  607. :ensure t
  608. :general
  609. (:prefix "M-s"
  610. "" '(:ignore t :which-key "avy")
  611. "w" '(avy-goto-char-2 :which-key "avy-jump")
  612. "c" '(:ignore t :which-key "avy copy")
  613. "c l" '(avy-copy-line :which-key "avy copy line")
  614. "c r" '(avy-copy-region :which-key "avy copy region")
  615. "m" '(:ignore t :which-key "avy move")
  616. "m l" '(avy-move-line :which-key "avy move line")
  617. "m r" '(avy-move-region :which-key "avy move region")))
  618. #+END_SRC
  619. * Vertico
  620. Vertico is a completion ui for the minibuffer and replaced selectrum.
  621. [[https://github.com/minad/vertico][Vertico Github]]
  622. #+begin_src emacs-lisp
  623. ;; completion ui
  624. (use-package vertico
  625. :ensure t
  626. :init
  627. (vertico-mode))
  628. #+end_src
  629. * Corfu
  630. Completion ui, replaces company.
  631. [[https://github.com/minad/corfu][Corfu Github]]
  632. #+begin_src emacs-lisp
  633. (use-package corfu
  634. :ensure t
  635. :after savehist
  636. :custom
  637. (corfu-popupinfo-delay t)
  638. (corfu-auto t)
  639. (corfu-cycle t)
  640. (corfu-auto-delay 0.3)
  641. (corfu-preselect-first nil)
  642. (corfu-popupinfo-delay '(1.0 . 0.0)) ;1s for first popup, instant for subsequent popups
  643. (corfu-popupinfo-max-width 70)
  644. (corfu-popupinfo-max-height 20)
  645. :init
  646. (global-corfu-mode)
  647. ; (corfu-popupinfo-mode) ; causes corfu window to stay
  648. (corfu-history-mode)
  649. ;; belongs to emacs
  650. (add-to-list 'savehist-additional-variables 'corfu-history)
  651. :hook
  652. (corfu-mode . corfu-popupinfo-mode))
  653. ; :bind
  654. ; (:map corfu-map
  655. ; ("TAB" . corfu-next)
  656. ; ("<C-return>" . corfu-insert)
  657. ; ("C-TAB" . corfu-popupinfo-toggle)))
  658. ;; (general-define-key
  659. ;; :states 'insert
  660. ;; :definer 'minor-mode
  661. ;; :keymaps 'completion-in-region-mode
  662. ;; :predicate 'corfu-mode
  663. ;; "C-d" 'corfu-info-documentation)
  664. (use-package emacs
  665. :ensure nil
  666. :init
  667. ;; hide commands in M-x which do not apply to current mode
  668. (setq read-extended-command-predicate #'command-completion-default-include-p)
  669. ;; enable indentation + completion using TAB
  670. (setq tab-always-indent 'complete))
  671. #+end_src
  672. * Cape
  673. Adds completions for corfu
  674. [[https://github.com/minad/cape][Cape Github]]
  675. Available functions:
  676. dabbrev, file, history, keyword, tex, sgml, rfc1345, abbrev, ispell, dict, symbol, line
  677. #+begin_src emacs-lisp
  678. (use-package cape
  679. :ensure t
  680. :bind
  681. (("C-c p p" . completion-at-point) ;; capf
  682. ("C-c p t" . complete-tag) ;; etags
  683. ("C-c p d" . cape-dabbrev)
  684. ("C-c p h" . cape-history)
  685. ("C-c p f" . cape-file))
  686. :init
  687. (advice-add #'lsp-completion-at-point :around #'cape-wrap-noninterruptible) ;; for performance issues with lsp
  688. (add-to-list 'completion-at-point-functions #'cape-dabbrev)
  689. (add-to-list 'completion-at-point-functions #'cape-file)
  690. (add-to-list 'completion-at-point-functions #'cape-history))
  691. #+end_src
  692. * kind-icon
  693. Make corfu pretty
  694. [[https://github.com/jdtsmith/kind-icon][kind-icon Github]]
  695. #+begin_src emacs-lisp
  696. (use-package kind-icon
  697. :ensure t
  698. :after corfu
  699. :custom
  700. (kind-icon-default-face 'corfu-default) ;; to compute blended backgrounds correctly
  701. :config
  702. (add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))
  703. #+end_src
  704. * Orderless
  705. [[https://github.com/oantolin/orderless][Orderless Github]]
  706. Orderless orders the suggestions by recency. The package prescient orders by frequency.
  707. #+begin_src emacs-lisp
  708. (use-package orderless
  709. :ensure t
  710. :init
  711. (setq completion-styles '(orderless partial-completion basic)
  712. completion-category-defaults nil
  713. completion-category-overrides nil))
  714. ; completion-category-overrides '((file (styles partial-completion)))))
  715. #+end_src
  716. * Consult
  717. [[https://github.com/minad/consult][Github]]
  718. #+begin_src emacs-lisp
  719. (use-package consult
  720. :ensure t
  721. :bind
  722. (("C-x C-r" . consult-recent-file)
  723. ("C-x b" . consult-buffer)
  724. ("C-s" . consult-line))
  725. :config
  726. ;; disable preview for some commands and buffers
  727. ;; and enable it by M-.
  728. ;; see https://github.com/minad/consult#use-package-example
  729. (consult-customize
  730. consult-theme
  731. :preview-key '(debounce 0.2 any)
  732. consult-ripgrep consult-git-grep consult-grep
  733. consult-bookmark consult-recent-file consult-xref
  734. consult--source-bookmark consult--source-file-register
  735. consult--source-recent-file consult--source-project-recent-file
  736. :preview-key "M-."))
  737. #+end_src
  738. * Marginalia
  739. [[https://github.com/minad/marginalia/][Github]]
  740. Adds additional information to the minibuffer
  741. #+begin_src emacs-lisp
  742. (use-package marginalia
  743. :ensure t
  744. :init
  745. (marginalia-mode)
  746. :bind
  747. (:map minibuffer-local-map
  748. ("M-A" . marginalia-cycle))
  749. :custom
  750. ;; switch by 'marginalia-cycle
  751. (marginalia-annotators '(marginalia-annotators-heavy
  752. marginalia-annotators-light
  753. nil)))
  754. #+end_src
  755. * Embark
  756. Does stuff in the minibuffer results
  757. #+begin_src emacs-lisp
  758. (use-package embark
  759. :ensure t
  760. :bind
  761. (("C-S-a" . embark-act)
  762. ("C-h B" . embark-bindings))
  763. :init
  764. (setq prefix-help-command #'embark-prefix-help-command)
  765. :config
  766. ;; hide modeline of the embark live/completions buffers
  767. (add-to-list 'display-buffer-alist
  768. '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
  769. nil
  770. (window-parameters (mode-line-format . none)))))
  771. (use-package embark-consult
  772. :ensure t
  773. :after (embark consult)
  774. :demand t
  775. :hook
  776. (embark-collect-mode . embark-consult-preview-minor-mode))
  777. #+end_src
  778. * Tree-sitter
  779. #+begin_src emacs-lisp
  780. (when *sys/linux*
  781. (use-package tree-sitter
  782. :ensure t
  783. :init
  784. (global-tree-sitter-mode t)
  785. :hook
  786. (tree-sitter-after-on . tree-sitter-hl-mode))
  787. (use-package tree-sitter-langs
  788. :ensure t
  789. :after tree-sitter)
  790. )
  791. #+end_src
  792. * Org-ql
  793. [[https://github.com/alphapapa/org-ql][org-ql]]
  794. Run queries on org files
  795. #+begin_src emacs-lisp
  796. (use-package org-ql
  797. :ensure t
  798. )
  799. #+end_src
  800. * COMMENT Xeft (needs xapian, not really windows compatible)
  801. Fast full text search for stuff org-ql cannot cover
  802. #+begin_src emacs-lisp
  803. (use-package xeft
  804. :ensure t
  805. :custom
  806. (xeft-recursive 'follow-symlinks))
  807. #+end_src
  808. * COMMENT Helm
  809. As an alternative if I'm not happy with selectrum & co
  810. #+begin_src emacs-lisp
  811. (use-package helm
  812. :ensure t
  813. :hook
  814. (helm-mode . helm-autoresize-mode)
  815. ;; :bind
  816. ;; (("M-x" . helm-M-x)
  817. ;; ("C-s" . helm-occur)
  818. ;; ("C-x C-f" . helm-find-files)
  819. ;; ("C-x C-b" . helm-buffers-list)
  820. ;; ("C-x b" . helm-buffers-list)
  821. ;; ("C-x C-r" . helm-recentf)
  822. ;; ("C-x C-i" . helm-imenu))
  823. :config
  824. (helm-mode)
  825. :custom
  826. (helm-split-window-inside-p t) ;; open helm buffer inside current window
  827. (helm-move-to-line-cycle-in-source t)
  828. (helm-echo-input-in-header-line t)
  829. (helm-autoresize-max-height 20)
  830. (helm-autoresize-min-height 5)
  831. )
  832. #+end_src
  833. * COMMENT ivy / counsel / swiper
  834. #+BEGIN_SRC emacs-lisp
  835. ; (require 'ivy)
  836. (use-package ivy
  837. :ensure t
  838. :diminish
  839. (ivy-mode . "")
  840. :defer t
  841. :init
  842. (ivy-mode 1)
  843. :bind
  844. ("C-r" . ivy-resume) ;; overrides isearch-backwards binding
  845. :config
  846. (setq ivy-use-virtual-buffers t ;; recent files and bookmarks in ivy-switch-buffer
  847. ivy-height 20 ;; height of ivy window
  848. ivy-count-format "%d/%d" ;; current and total number
  849. ivy-re-builders-alist ;; regex replaces spaces with *
  850. '((t . ivy--regex-plus))))
  851. ; make counsel-M-x more descriptive
  852. (use-package ivy-rich
  853. :ensure t
  854. :defer t
  855. :init
  856. (ivy-rich-mode 1))
  857. (use-package counsel
  858. :ensure t
  859. :defer t
  860. :bind
  861. (("M-x" . counsel-M-x)
  862. ("C-x C-f" . counsel-find-file)
  863. ("C-x C-r" . counsel-recentf)
  864. ("C-x b" . counsel-switch-buffer)
  865. ("C-c C-f" . counsel-git)
  866. ("C-c h f" . counsel-describe-function)
  867. ("C-c h v" . counsel-describe-variable)
  868. ("M-i" . counsel-imenu)))
  869. ; :map minibuffer-local-map ;;currently mapped to evil-redo
  870. ; ("C-r" . 'counsel-minibuffer-history)))
  871. (use-package swiper
  872. :ensure t
  873. :bind
  874. ("C-s" . swiper))
  875. (use-package ivy-hydra
  876. :ensure t)
  877. #+END_SRC
  878. * outlook
  879. In outlook a macro is necessary, also a reference to FM20.DLL
  880. (Microsoft Forms 2.0 Object Library, in c:\windows\syswow64\fm20.dll)
  881. The macro copies the GUID of the email to the clipboard
  882. Attention: the GUID changes when the email is moved to another folder!
  883. The macro:
  884. #+BEGIN_SRC
  885. Sub AddLinkToMessageInClipboard()
  886. 'Adds a link to the currently selected message to the clipboard
  887. Dim objMail As Outlook.MailItem
  888. Dim doClipboard As New DataObject
  889. 'One and ONLY one message muse be selected
  890. If Application.ActiveExplorer.Selection.Count <> 1 Then
  891. MsgBox ("Select one and ONLY one message.")
  892. Exit Sub
  893. End If
  894. Set objMail = Application.ActiveExplorer.Selection.Item(1)
  895. doClipboard.SetText "[[outlook:" + objMail.EntryID + "][MESSAGE: " + objMail.Subject + " (" + objMail.SenderName + ")]]"
  896. doClipboard.PutInClipboard
  897. End Sub
  898. #+END_SRC
  899. #+BEGIN_SRC emacs-lisp
  900. ;(org-add-link-type "outlook" 'my--org-outlook-open)
  901. (defun my--org-outlook-open (id)
  902. (w32-shell-execute "open" "outlook" (concat " /select outlook:" id)))
  903. (defun my/org-outlook-open-test ()
  904. (interactive)
  905. (w32-shell-execute "open" "outlook" " /select outlook:000000008A209C397CEF2C4FBA9E54AEB5B1F97F0700846D043B407C5B43A0C05AFC46DC5C630587BE5E020900006E48FF8F6027694BA6593777F542C19E0002A6434D000000"))'
  906. #+END_SRC
  907. * misc
  908. #+begin_src emacs-lisp
  909. (use-package autorevert
  910. :diminish auto-revert-mode)
  911. #+end_src
  912. * COMMENT company (now corfu)
  913. #+BEGIN_SRC emacs-lisp
  914. (use-package company
  915. :defer 1
  916. :diminish
  917. :defer t
  918. :bind
  919. (("C-<tab>" . company-complete)
  920. :map company-active-map
  921. ("RET" . nil)
  922. ([return] . nil)
  923. ("TAB" . company-complete-selection)
  924. ([tab] . company-complete-selection)
  925. ("<right>" . company-complete-common)
  926. ("<escape>" . company-abort))
  927. :hook
  928. (after-init . global-company-mode)
  929. (emacs-lisp-mode . my--company-elisp)
  930. (org-mode . my--company-org)
  931. :config
  932. (defun my--company-elisp ()
  933. (message "set up company for elisp")
  934. (set (make-local-variable 'company-backends)
  935. '(company-capf ;; capf needs to be before yasnippet, or lsp fucks up completion for elisp
  936. company-yasnippet
  937. company-dabbrev-code
  938. company-files)))
  939. (defun my--company-org ()
  940. (set (make-local-variable 'company-backends)
  941. '(company-capf company-files))
  942. ;; (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  943. (message "setup company for org"))
  944. (setq company-idle-delay .2
  945. company-minimum-prefix-length 1
  946. company-require-match nil
  947. company-show-numbers t
  948. company-tooltip-align-annotations t))
  949. (use-package company-statistics
  950. :ensure t
  951. :after company
  952. :defer t
  953. :init
  954. (setq company-statistics-file (concat MY--PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el")
  955. :config
  956. (company-statistics-mode 1))
  957. (use-package company-dabbrev
  958. :ensure nil
  959. :after company
  960. :defer t
  961. :config
  962. (setq-default company-dabbrev-downcase nil))
  963. ;; adds a info box right of the cursor with doc of the function
  964. (use-package company-box
  965. :ensure t
  966. :diminish
  967. :defer t
  968. :hook
  969. (company-mode . company-box-mode))
  970. ; :init
  971. ; (add-hook 'company-mode-hook 'company-box-mode))
  972. #+END_SRC
  973. * orgmode
  974. ** some notes
  975. *** copy file path within emacs
  976. Enter dired-other-window
  977. place cursor on the file
  978. M-0 w (copy absolute path)
  979. C-u w (copy relative path)
  980. *** Archiving
  981. C-c C-x C-a
  982. To keep the subheading structure when archiving, set the properties of the superheading.
  983. #+begin_src org :tangle no
  984. ,* FOO
  985. :PROPERTIES:
  986. :ARCHIVE: %s_archive::* FOO
  987. ,** DONE BAR
  988. ,** TODO BAZ
  989. #+end_src
  990. When moving BAR to archive, it will go to FILENAME.org_archive below the heading FOO.
  991. [[http://doc.endlessparentheses.com/Var/org-archive-location.html][Other examples]]
  992. ** org
  993. This seems necessary to prevent 'org is already installed' error
  994. https://github.com/jwiegley/use-package/issues/319
  995. #+begin_src emacs-lisp
  996. ;(assq-delete-all 'org package--builtins)'
  997. ;(assq-delete-all 'org package--builtin-versions)
  998. #+end_src
  999. #+BEGIN_SRC emacs-lisp
  1000. (defun my--buffer-prop-set (name value)
  1001. "Set a file property called NAME to VALUE in buffer file.
  1002. If the property is already set, replace its value."
  1003. (setq name (downcase name))
  1004. (org-with-point-at 1
  1005. (let ((case-fold-search t))
  1006. (if (re-search-forward (concat "^#\\+" name ":\\(.*\\)")
  1007. (point-max) t)
  1008. (replace-match (concat "#+" name ": " value) 'fixedcase)
  1009. (while (and (not (eobp))
  1010. (looking-at "^[#:]"))
  1011. (if (save-excursion (end-of-line) (eobp))
  1012. (progn
  1013. (end-of-line)
  1014. (insert "\n"))
  1015. (forward-line)
  1016. (beginning-of-line)))
  1017. (insert "#+" name ": " value "\n")))))
  1018. (defun my--buffer-prop-remove (name)
  1019. "Remove a buffer property called NAME."
  1020. (org-with-point-at 1
  1021. (when (re-search-forward (concat "\\(^#\\+" name ":.*\n?\\)")
  1022. (point-max) t)
  1023. (replace-match ""))))
  1024. (use-package org
  1025. :ensure t
  1026. ; :pin gnu
  1027. :mode (("\.org$" . org-mode))
  1028. :diminish org-indent-mode
  1029. :defer 1
  1030. :hook
  1031. (org-mode . org-indent-mode)
  1032. (org-source-mode . smartparens-mode)
  1033. :bind (("C-c l" . org-store-link)
  1034. ("C-c c" . org-capture)
  1035. ("C-c a" . org-agenda)
  1036. :map org-mode-map ("S-<right>" . org-shiftright)
  1037. ("S-<left>" . org-shiftleft))
  1038. :init
  1039. (defun my--org-agenda-files-set ()
  1040. "Sets default agenda files.
  1041. Necessary when updating roam agenda todos."
  1042. (setq org-agenda-files (list (concat MY--PATH_ORG_FILES "notes.org")
  1043. (concat MY--PATH_ORG_FILES "projects.org")
  1044. (concat MY--PATH_ORG_FILES "tasks.org")))
  1045. (when *sys/linux*
  1046. (nconc org-agenda-files
  1047. (directory-files-recursively MY--PATH_ORG_FILES_MOBILE "\\.org$"))))
  1048. (my--org-agenda-files-set)
  1049. (defun my--org-skip-subtree-if-priority (priority)
  1050. "Skip an agenda subtree if it has a priority of PRIORITY.
  1051. PRIORITY may be one of the characters ?A, ?B, or ?C."
  1052. (let ((subtree-end (save-excursion (org-end-of-subtree t)))
  1053. (pri-value (* 1000 (- org-lowest-priority priority)))
  1054. (pri-current (org-get-priority (thing-at-point 'line t))))
  1055. (if (= pri-value pri-current)
  1056. subtree-end
  1057. nil)))
  1058. :config
  1059. (when *work_remote*
  1060. (org-add-link-type "outlook" 'my--org-outlook-open)
  1061. (setq org-todo-keywords
  1062. '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE" "CANCELLED")))
  1063. (setq org-capture-templates
  1064. '(("t" "telephone call" entry
  1065. ; (file+olp+datetree (concat MY--PATH_ORG_FILES "phone_calls.org"))
  1066. (file+datetree "p:/Eigene Dateien/Notizen/phone_calls.org")
  1067. "* [%<%Y-%m-%d %H:%M>] %?"
  1068. :empty-lines 0 :jump-to-captured t))))
  1069. (when *sys/linux*
  1070. (setq org-pretty-entities t))
  1071. :custom
  1072. (org-startup-truncated t)
  1073. (org-startup-align-all-tables t)
  1074. (org-src-fontify-natively t) ;; use syntax highlighting in code blocks
  1075. (org-src-preserve-indentation t) ;; no extra indentation
  1076. (org-src-window-setup 'current-window) ;; C-c ' opens in current window
  1077. (org-modules (quote (org-id
  1078. org-habit
  1079. org-tempo))) ;; easy templates
  1080. (org-default-notes-file (concat MY--PATH_ORG_FILES "notes.org"))
  1081. (org-id-locations-file (concat MY--PATH_USER_LOCAL ".org-id-locations"))
  1082. (org-log-into-drawer "LOGBOOK")
  1083. (org-log-done 'time) ;; create timestamp when task is done
  1084. (org-blank-before-new-entry '((heading) (plain-list-item))) ;; prevent new line before new item
  1085. (org-src-tab-acts-natively t)
  1086. ;;Sort agenda by deadline and priority
  1087. (org-agenda-sorting-strategy
  1088. (quote
  1089. ((agenda deadline-up priority-down)
  1090. (todo priority-down category-keep)
  1091. (tags priority-down category-keep)
  1092. (search category-keep))))
  1093. (org-agenda-custom-commands
  1094. '(("c" "Simple agenda view"
  1095. ((tags "PRIORITY=\"A\""
  1096. ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
  1097. (org-agenda-overriding-header "Hohe Priorität:")))
  1098. (agenda ""
  1099. ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
  1100. (org-agenda-span 7)
  1101. (org-agenda-start-on-weekday nil)
  1102. (org-agenda-overriding-header "Nächste 7 Tage:")))
  1103. (alltodo ""
  1104. ((org-agenda-skip-function '(or (my--org-skip-subtree-if-priority ?A)
  1105. (org-agenda-skip-if nil '(scheduled deadline))))
  1106. (org-agenda-overriding-header "Sonstige Aufgaben:"))))))))
  1107. #+END_SRC
  1108. ** COMMENT languages
  1109. Set some languages and disable confirmation for evaluating code blocks C-c C-c
  1110. Elpaca cant find it, though it's built in org
  1111. #+begin_src emacs-lisp
  1112. (use-package ob-python
  1113. ; :ensure nil
  1114. :defer t
  1115. :after org
  1116. ; :ensure org-contrib
  1117. :commands
  1118. (org-babel-execute:python))
  1119. #+end_src
  1120. ** COMMENT habits
  1121. #+BEGIN_SRC emacs-lisp
  1122. (require 'org-habit) ;;TODO Lösung ohne require finden, scheint mir nicht ideal zu sein, nur um ein org-modul zu aktivieren
  1123. ;; (add-to-list 'org-modules "org-habit")
  1124. (setq org-habit-graph-column 80
  1125. org-habit-preceding-days 30
  1126. org-habit-following-days 7
  1127. org-habit-show-habits-only-for-today nil)
  1128. #+END_SRC
  1129. ** *TODO*
  1130. [[https://github.com/nobiot/org-transclusion][org-transclusion]]?
  1131. ** COMMENT journal
  1132. [[https://github.com/bastibe/org-journal][Source]]
  1133. Ggf. durch org-roam-journal ersetzen
  1134. #+BEGIN_SRC emacs-lisp
  1135. (use-package org-journal
  1136. :if *sys/linux*
  1137. :ensure t
  1138. :defer t
  1139. :config
  1140. ;; feels hacky, but this way compiler error "assignment to free variable" disappears
  1141. (when (and (boundp 'org-journal-dir)
  1142. (boundp 'org-journal-enable-agenda-integration))
  1143. (setq org-journal-dir MY--PATH_ORG_JOURNAl
  1144. org-journal-enable-agenda-integration t)))
  1145. #+END_SRC
  1146. ** org-roam
  1147. [[https://github.com/org-roam/org-roam][Github]]
  1148. Um Headings innerhalb einer Datei zu verlinken:
  1149. - org-id-get-create im Heading,
  1150. - org-roam-node-insert in der verweisenden Datei
  1151. Bei Problemen wie unique constraint
  1152. org-roam-db-clear-all
  1153. org-roam-db-sync
  1154. #+BEGIN_SRC emacs-lisp
  1155. (use-package emacsql-sqlite-builtin
  1156. :ensure t)
  1157. (use-package org-roam
  1158. :requires emacsql-sqlite-builtin
  1159. :ensure t
  1160. :defer 2
  1161. :after org
  1162. :init
  1163. (setq org-roam-v2-ack t)
  1164. (defun my--roamtodo-p ()
  1165. "Return non-nil if current buffer has any todo entry.
  1166. TODO entries marked as done are ignored, meaning this function
  1167. returns nil if current buffer contains only completed tasks."
  1168. (seq-find
  1169. (lambda (type)
  1170. (eq type 'todo))
  1171. (org-element-map
  1172. (org-element-parse-buffer 'headline)
  1173. 'headline
  1174. (lambda (h)
  1175. (org-element-property :todo-type h)))))
  1176. (defun my--roamtodo-update-tag ()
  1177. "Update ROAMTODO tag in the current buffer."
  1178. (when (and (not (active-minibuffer-window))
  1179. (my--buffer-roam-note-p))
  1180. (save-excursion
  1181. (goto-char (point-min))
  1182. (let* ((tags (my--buffer-tags-get))
  1183. (original-tags tags))
  1184. (if (my--roamtodo-p)
  1185. (setq tags (cons "roamtodo" tags))
  1186. (setq tags (remove "roamtodo" tags)))
  1187. ;;cleanup duplicates
  1188. (when (or (seq-difference tags original-tags)
  1189. (seq-difference original-tags tags))
  1190. (apply #'my--buffer-tags-set tags))))))
  1191. (defun my--buffer-tags-get ()
  1192. "Return filetags value in current buffer."
  1193. (my--buffer-prop-get-list "filetags" "[ :]"))
  1194. (defun my--buffer-tags-set (&rest tags)
  1195. "Set TAGS in current buffer.
  1196. If filetags value is already set, replace it."
  1197. (if tags
  1198. (my--buffer-prop-set
  1199. "filetags" (concat ":" (string-join tags ":") ":"))
  1200. (my--buffer-prop-remove "filetags")))
  1201. (defun my--buffer-tags-add (tag)
  1202. "Add a TAG to filetags in current buffer."
  1203. (let* ((tags (my--buffer-tags-get))
  1204. (tags (append tags (list tag))))
  1205. (apply #'my--buffer-tags-set tags)))
  1206. (defun my--buffer-tags-remove (tag)
  1207. "Remove a TAG from filetags in current buffer."
  1208. (let* ((tags (my--buffer-tags-get))
  1209. (tags (delete tag tags)))
  1210. (apply #'my--buffer-tags-set tags)))
  1211. (defun my--buffer-prop-set (name value)
  1212. "Set a file property called NAME to VALUE in buffer file.
  1213. If the property is already set, replace its value."
  1214. (setq name (downcase name))
  1215. (org-with-point-at 1
  1216. (let ((case-fold-search t))
  1217. (if (re-search-forward (concat "^#\\+" name ":\\(.*\\)")
  1218. (point-max) t)
  1219. (replace-match (concat "#+" name ": " value) 'fixedcase)
  1220. (while (and (not (eobp))
  1221. (looking-at "^[#:]"))
  1222. (if (save-excursion (end-of-line) (eobp))
  1223. (progn
  1224. (end-of-line)
  1225. (insert "\n"))
  1226. (forward-line)
  1227. (beginning-of-line)))
  1228. (insert "#+" name ": " value "\n")))))
  1229. (defun my--buffer-prop-set-list (name values &optional separators)
  1230. "Set a file property called NAME to VALUES in current buffer.
  1231. VALUES are quoted and combined into single string using
  1232. `combine-and-quote-strings'.
  1233. If SEPARATORS is non-nil, it should be a regular expression
  1234. matching text that separates, but is not part of, the substrings.
  1235. If nil it defaults to `split-string-and-unquote', normally
  1236. \"[ \f\t\n\r\v]+\", and OMIT-NULLS is forced to t.
  1237. If the property is already set, replace its value."
  1238. (my--buffer-prop-set
  1239. name (combine-and-quote-strings values separators)))
  1240. (defun my--buffer-prop-get (name)
  1241. "Get a buffer property called NAME as a string."
  1242. (org-with-point-at 1
  1243. (when (re-search-forward (concat "^#\\+" name ": \\(.*\\)")
  1244. (point-max) t)
  1245. (buffer-substring-no-properties
  1246. (match-beginning 1)
  1247. (match-end 1)))))
  1248. (defun my--buffer-prop-get-list (name &optional separators)
  1249. "Get a buffer property NAME as a list using SEPARATORS.
  1250. If SEPARATORS is non-nil, it should be a regular expression
  1251. matching text that separates, but is not part of, the substrings.
  1252. If nil it defaults to `split-string-default-separators', normally
  1253. \"[ \f\t\n\r\v]+\", and OMIT-NULLS is forced to t."
  1254. (let ((value (my--buffer-prop-get name)))
  1255. (when (and value (not (string-empty-p value)))
  1256. (split-string-and-unquote value separators))))
  1257. (defun my--buffer-prop-remove (name)
  1258. "Remove a buffer property called NAME."
  1259. (org-with-point-at 1
  1260. (when (re-search-forward (concat "\\(^#\\+" name ":.*\n?\\)")
  1261. (point-max) t)
  1262. (replace-match ""))))
  1263. (defun my--buffer-roam-note-p ()
  1264. "Return non-nil if the currently visited buffer is a note."
  1265. (and buffer-file-name
  1266. (string-prefix-p
  1267. (expand-file-name (file-name-as-directory MY--PATH_ORG_ROAM))
  1268. (file-name-directory buffer-file-name))))
  1269. (defun my--org-roam-filter-by-tag (tag-name)
  1270. (lambda (node)
  1271. (member tag-name (org-roam-node-tags node))))
  1272. (defun my--org-roam-list-notes-by-tag (tag-name)
  1273. (mapcar #'org-roam-node-file
  1274. (seq-filter
  1275. (my--org-roam-filter-by-tag tag-name)
  1276. (org-roam-node-list))))
  1277. (defun my/org-roam-refresh-agenda-list ()
  1278. "Add all org roam files with #+filetags: roamtodo"
  1279. (interactive)
  1280. (my--org-agenda-files-set)
  1281. (nconc org-agenda-files
  1282. (my--org-roam-list-notes-by-tag "roamtodo"))
  1283. (setq org-agenda-files (delete-dups org-agenda-files)))
  1284. (add-hook 'find-file-hook #'my--roamtodo-update-tag)
  1285. (add-hook 'before-save-hook #'my--roamtodo-update-tag)
  1286. (advice-add 'org-agenda :before #'my/org-roam-refresh-agenda-list)
  1287. (advice-add 'org-todo-list :before #'my/org-roam-refresh-agenda-list)
  1288. (add-to-list 'org-tags-exclude-from-inheritance "roamtodo")
  1289. :config
  1290. (require 'org-roam-dailies) ;; ensure the keymap is available
  1291. (org-roam-db-autosync-mode)
  1292. ;; build the agenda list the first ime for the session
  1293. (my/org-roam-refresh-agenda-list)
  1294. (when *work_remote*
  1295. (setq org-roam-capture-templates
  1296. '(("n" "note" plain
  1297. "%?"
  1298. :if-new (file+head "notes/%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
  1299. :unnarrowed t)
  1300. ("i" "idea" plain
  1301. "%?"
  1302. :if-new (file+head "ideas/%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
  1303. :unnarrowed t)
  1304. ("p" "project" plain
  1305. "%?"
  1306. :target (file+head "projects/${slug}.org" "#+title: ${title}\n#+filetags: :project:\n")
  1307. :unnarrowed t)
  1308. ("s" "Sicherheitenmeldung" plain
  1309. "*** TODO [#A] Sicherheitenmeldung ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n%u\n"
  1310. :target (file+olp "tasks.org" ("Todos" "Sicherheitenmeldungen")))
  1311. ("m" "Monatsbericht" plain
  1312. "*** TODO [#A] Monatsbericht ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n%u\n"
  1313. :target (file+olp "tasks.org" ("Todos" "Monatsberichte"))))))
  1314. :custom
  1315. (org-roam-database-connector 'sqlite-builtin)
  1316. (org-roam-directory MY--PATH_ORG_ROAM)
  1317. (org-roam-completion-everywhere t)
  1318. (org-roam-capture-templates
  1319. '(("n" "note" plain
  1320. "%?"
  1321. :if-new (file+head "notes/%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
  1322. :unnarrowed t)
  1323. ("i" "idea" plain
  1324. "%?"
  1325. :if-new (file+head "ideas/%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
  1326. :unnarrowed t)
  1327. ))
  1328. :bind (("C-c n l" . org-roam-buffer-toggle)
  1329. ("C-c n f" . org-roam-node-find)
  1330. ("C-c n i" . org-roam-node-insert)
  1331. :map org-mode-map
  1332. ("C-M-i" . completion-at-point)
  1333. :map org-roam-dailies-map
  1334. ("Y" . org-roam-dailies-capture-yesterday)
  1335. ("T" . org-roam-dailies-capture-tomorrow))
  1336. :bind-keymap
  1337. ("C-c n d" . org-roam-dailies-map))
  1338. #+END_SRC
  1339. *** TODO Verzeichnis außerhalb roam zum Archivieren (u.a. für erledigte Monatsmeldungen etc.)
  1340. * Programming
  1341. ** Magit / Git
  1342. Little crash course in magit:
  1343. - magit-init to init a git project
  1344. - magit-status (C-x g) to call the status window
  1345. In status buffer:
  1346. - s stage files
  1347. - u unstage files
  1348. - U unstage all files
  1349. - a apply changes to staging
  1350. - c c commit (type commit message, then C-c C-c to commit)
  1351. - b b switch to another branch
  1352. - P u git push
  1353. - F u git pull
  1354. #+BEGIN_SRC emacs-lisp
  1355. (use-package magit
  1356. :ensure t
  1357. ; :pin melpa-stable
  1358. :defer t
  1359. :init
  1360. ; set git-path in work environment
  1361. (if (string-equal user-login-name "POH")
  1362. (setq magit-git-executable "P:/Tools/Git/bin/git.exe")
  1363. )
  1364. :bind (("C-x g" . magit-status)))
  1365. #+END_SRC
  1366. ** COMMENT Eglot (can't do dap-mode, maybe dape?)
  1367. for python pyls (in env: pip install python-language-server) seems to work better than pyright (npm install -g pyright),
  1368. at least pandas couldnt be resolved in pyright
  1369. #+begin_src emacs-lisp
  1370. (use-package eglot
  1371. :ensure t
  1372. :init
  1373. (setq completion-category-overrides '((eglot (styles orderless))))
  1374. :config
  1375. (add-to-list 'eglot-server-programs '(python-mode . ("pyright-langserver" "--stdio")))
  1376. (with-eval-after-load 'eglot
  1377. (load-library "project"))
  1378. :hook
  1379. (python-mode . eglot-ensure)
  1380. :custom
  1381. (eglot-ignored-server-capabilities '(:documentHighlightProvider))
  1382. (eglot-autoshutdown t)
  1383. (eglot-events-buffer-size 0)
  1384. )
  1385. ;; performance stuff if necessary
  1386. ;(fset #'jsonrpc--log-event #'ignore)
  1387. #+end_src
  1388. ** LSP-Mode
  1389. #+begin_src emacs-lisp
  1390. (defun corfu-lsp-setup ()
  1391. (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
  1392. '(orderless)))
  1393. (use-package lsp-mode
  1394. :ensure t
  1395. ; :hook
  1396. ; ((python-mode . lsp))
  1397. :custom
  1398. (lsp-completion-provider :none)
  1399. (lsp-enable-suggest-server-download nil)
  1400. :hook
  1401. (lsp-completion-mode #'corfu-lsp-setup))
  1402. ;(use-package lsp-ui
  1403. ; :ensure t
  1404. ; :commands lsp-ui-mode)
  1405. (use-package lsp-pyright
  1406. :ensure t
  1407. :after (python lsp-mode)
  1408. :custom
  1409. (lsp-pyright-multi-root nil)
  1410. :hook
  1411. (python-mode-hook . (lambda ()
  1412. (require 'lsp-pyright) (lsp))))
  1413. #+end_src
  1414. ** flymake
  1415. python in venv: pip install pyflake (or ruff?)
  1416. TODO: if ruff active, sideline stops working
  1417. #+begin_src emacs-lisp
  1418. (setq python-flymake-command '("ruff" "--quiet" "--stdin-filename=stdin" "-"))
  1419. #+end_src
  1420. ** sideline
  1421. show flymake errors on the right of code window
  1422. #+begin_src emacs-lisp
  1423. (use-package sideline
  1424. :ensure t)
  1425. (use-package sideline-flymake
  1426. :ensure t
  1427. :requires sideline
  1428. :hook
  1429. (flymake-mode . sideline-mode)
  1430. :init
  1431. (setq sideline-flymake-display-mode 'line ; 'point or 'line
  1432. ; sideline-backends-left '(sideline-lsp)
  1433. sideline-backends-right '(sideline-flymake)))
  1434. #+end_src
  1435. ** yasnippet
  1436. For useful snippet either install yasnippet-snippets or get them from here
  1437. [[https://github.com/AndreaCrotti/yasnippet-snippets][Github]]
  1438. #+begin_src emacs-lisp
  1439. (use-package yasnippet
  1440. :ensure t
  1441. :defer t
  1442. :diminish yas-minor-mode
  1443. :config
  1444. (setq yas-snippet-dirs (list (concat MY--PATH_USER_GLOBAL "snippets")))
  1445. (yas-global-mode t)
  1446. (yas-reload-all)
  1447. (unbind-key "TAB" yas-minor-mode-map)
  1448. (unbind-key "<tab>" yas-minor-mode-map))
  1449. #+end_src
  1450. ** hippie expand
  1451. With hippie expand I am able to use yasnippet and emmet at the same time with the same key.
  1452. #+begin_src emacs-lisp
  1453. (use-package hippie-exp
  1454. :ensure nil
  1455. :defer t
  1456. :bind
  1457. ("C-<return>" . hippie-expand)
  1458. :config
  1459. (setq hippie-expand-try-functions-list
  1460. '(yas-hippie-try-expand emmet-expand-line)))
  1461. #+end_src
  1462. ** COMMENT flycheck (now flymake)
  1463. #+BEGIN_SRC emacs-lisp
  1464. (use-package flycheck
  1465. :ensure t
  1466. :hook
  1467. ((css-mode . flycheck-mode)
  1468. (emacs-lisp-mode . flycheck-mode)
  1469. (python-mode . flycheck-mode))
  1470. :defer 1.0
  1471. :init
  1472. (setq flycheck-emacs-lisp-load-path 'inherit)
  1473. :config
  1474. (setq-default
  1475. flycheck-check-synta-automatically '(save mode-enabled)
  1476. flycheck-disable-checkers '(emacs-lisp-checkdoc)
  1477. eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck
  1478. flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages
  1479. #+END_SRC
  1480. ** smartparens
  1481. #+BEGIN_SRC emacs-lisp
  1482. (use-package smartparens
  1483. :ensure t
  1484. :diminish smartparens-mode
  1485. :bind
  1486. (:map smartparens-mode-map
  1487. ("C-M-f" . sp-forward-sexp)
  1488. ("C-M-b" . sp-backward-sexp)
  1489. ("C-M-a" . sp-backward-down-sexp)
  1490. ("C-M-e" . sp-up-sexp)
  1491. ("C-M-w" . sp-copy-sexp)
  1492. ("M-k" . sp-kill-sexp)
  1493. ("C-M-<backspace>" . sp-slice-sexp-killing-backward)
  1494. ("C-S-<backspace>" . sp-slice-sexp-killing-around)
  1495. ("C-]" . sp-select-next-thing-exchange))
  1496. :config
  1497. (setq sp-show-pair-from-inside nil
  1498. sp-escape-quotes-after-insert nil)
  1499. (require 'smartparens-config))
  1500. #+END_SRC
  1501. ** lisp
  1502. #+BEGIN_SRC emacs-lisp
  1503. (use-package elisp-mode
  1504. :ensure nil
  1505. :defer t)
  1506. #+END_SRC
  1507. ** web
  1508. apt install npm
  1509. sudo npm install -g vscode-html-languageserver-bin
  1510. evtl alternativ typescript-language-server?
  1511. Unter Windows:
  1512. Hier runterladen: https://nodejs.org/dist/latest/
  1513. und in ein Verzeichnis entpacken.
  1514. Optional: PATH erweitern unter Windows (so kann exec-path-from-shell den Pfad ermitteln):
  1515. PATH=P:\path\to\node;%path%
  1516. *** web-mode
  1517. #+BEGIN_SRC emacs-lisp
  1518. (use-package web-mode
  1519. :ensure t
  1520. :defer t
  1521. :mode
  1522. ("\\.phtml\\'"
  1523. "\\.tpl\\.php\\'"
  1524. "\\.djhtml\\'"
  1525. "\\.[t]?html?\\'")
  1526. :hook
  1527. (web-mode . smartparens-mode)
  1528. :init
  1529. (if *work_remote*
  1530. (setq exec-path (append exec-path '("P:/Tools/node"))))
  1531. :config
  1532. (setq web-mode-enable-auto-closing t
  1533. web-mode-enable-auto-pairing t))
  1534. #+END_SRC
  1535. Emmet offers snippets, similar to yasnippet.
  1536. Default completion is C-j
  1537. [[https://github.com/smihica/emmet-mode#usage][Github]]
  1538. #+begin_src emacs-lisp
  1539. (use-package emmet-mode
  1540. :ensure t
  1541. :defer t
  1542. :hook
  1543. ((web-mode . emmet-mode)
  1544. (css-mode . emmet-mode))
  1545. :config
  1546. (unbind-key "C-<return>" emmet-mode-keymap))
  1547. #+end_src
  1548. *** JavaScript
  1549. npm install -g typescript-language-server typescript
  1550. maybe only typescript?
  1551. npm install -g prettier
  1552. #+begin_src emacs-lisp
  1553. (use-package rjsx-mode
  1554. :ensure t
  1555. :mode ("\\.js\\'"
  1556. "\\.jsx'"))
  1557. ; :config
  1558. ; (setq js2-mode-show-parse-errors nil
  1559. ; js2-mode-show-strict-warnings nil
  1560. ; js2-basic-offset 2
  1561. ; js-indent-level 2)
  1562. ; (setq-local flycheck-disabled-checkers (cl-union flycheck-disable-checkers
  1563. ; '(javascript-jshint)))) ; jshint doesn"t work for JSX
  1564. (use-package tide
  1565. :ensure t
  1566. :after (rjsx-mode company flycheck)
  1567. ; :hook (rjsx-mode . setup-tide-mode)
  1568. :config
  1569. (defun setup-tide-mode ()
  1570. "Setup function for tide."
  1571. (interactive)
  1572. (tide-setup)
  1573. (flycheck-mode t)
  1574. (setq flycheck-check-synta-automatically '(save mode-enabled))
  1575. (tide-hl-identifier-mode t)))
  1576. ;; needs npm install -g prettier
  1577. (use-package prettier-js
  1578. :ensure t
  1579. :after (rjsx-mode)
  1580. :defer t
  1581. :diminish prettier-js-mode
  1582. :hook ((js2-mode rsjx-mode) . prettier-js-mode))
  1583. #+end_src
  1584. ** YAML
  1585. #+begin_src emacs-lisp
  1586. (use-package yaml-mode
  1587. :if *sys/linux*
  1588. :ensure t
  1589. :defer t
  1590. :mode ("\\.yml$" . yaml-mode))
  1591. #+end_src
  1592. ** R
  1593. #+BEGIN_SRC emacs-lisp
  1594. (use-package ess
  1595. :ensure t
  1596. :defer t
  1597. :init
  1598. (if *work_remote*
  1599. (setq exec-path (append exec-path '("P:/Tools/R/bin/x64"))
  1600. org-babel-R-command "P:/Tools/R/bin/x64/R --slave --no-save")))
  1601. #+END_SRC
  1602. ** project.el
  1603. #+begin_src emacs-lisp
  1604. (use-package project
  1605. :custom
  1606. (project-vc-extra-root-markers '(".project.el" ".project" )))
  1607. #+end_src
  1608. ** Python
  1609. Preparations:
  1610. - Install language server in *each* projects venv
  1611. source ./bin/activate
  1612. pip install pyright
  1613. - in project root:
  1614. touch .project.el
  1615. echo "((nil . (pyvenv-activate . "/path/to/project/.env")))" >> .dir-locals.el
  1616. für andere language servers
  1617. https://github.com/emacs-lsp/lsp-mode#install-language-server
  1618. TODO if in a project, set venv automatically
  1619. (when-let ((project (project-current))) (project-root project))
  1620. returns project path from project.el
  1621. to recognize a project, either have git or
  1622. place a .project.el file in project root and
  1623. (setq project-vc-extra-root-markers '(".project.el" "..." ))
  1624. #+begin_src emacs-lisp
  1625. (use-package python
  1626. :if *sys/linux*
  1627. :delight "π "
  1628. :defer t
  1629. :bind (("M-[" . python-nav-backward-block)
  1630. ("M-]" . python-nav-forward-block))
  1631. :mode
  1632. (("\\.py\\'" . python-mode)))
  1633. (use-package pyvenv
  1634. ; :if *sys/linux*
  1635. :ensure t
  1636. :defer t
  1637. :after python
  1638. :hook
  1639. (python-mode . pyvenv-mode)
  1640. :custom
  1641. (pyvenv-default-virtual-env-name ".env")
  1642. (pyvenv-mode-line-indicator '(pyvenv-virtual-env-name ("[venv:" pyvenv-virtual-env-name "]"))))
  1643. ;; formatting to pep8
  1644. ;; requires pip install black
  1645. ;(use-package blacken
  1646. ; :ensure t)
  1647. #+end_src
  1648. TODO python mode hook:
  1649. - activate venv
  1650. - activate eglot with proper ls
  1651. - activate tree-sitter?
  1652. - have some fallback if activations fail
  1653. * beancount
  1654. ** Installation
  1655. #+BEGIN_SRC shell :tangle no
  1656. sudo su
  1657. cd /opt
  1658. python3 -m venv beancount
  1659. source ./beancount/bin/activate
  1660. pip3 install wheel
  1661. pip3 install beancount
  1662. sleep 100
  1663. echo "shell running!"
  1664. deactivate
  1665. #+END_SRC
  1666. #+begin_src emacs-lisp
  1667. (use-package beancount
  1668. :ensure nil
  1669. :if *sys/linux*
  1670. :load-path "user-global/elisp/"
  1671. ; :ensure t
  1672. :defer t
  1673. :mode
  1674. ("\\.beancount$" . beancount-mode)
  1675. :hook
  1676. (beancount-mode . my/beancount-company)
  1677. :config
  1678. (defun my/beancount-company ()
  1679. (setq-local completion-at-point-functions #'beancount-completion-at-point))
  1680. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount"))
  1681. #+end_src
  1682. +BEGIN_SRC emacs-lisp
  1683. (use-package beancount
  1684. :if *sys/linux*
  1685. :load-path "user-global/elisp"
  1686. ; :ensure t
  1687. :defer t
  1688. :mode
  1689. ("\\.beancount$" . beancount-mode)
  1690. ; :hook
  1691. ; (beancount-mode . my/beancount-company)
  1692. ; :init
  1693. ; (add-hook 'beancount-mode-hook 'company/beancount-mode-hook)
  1694. :config
  1695. (defun my/beancount-company ()
  1696. (setq-local completion-at-point-functions #'beancount-complete-at-point nil t))
  1697. ; (mapcar #'cape-company-to-capf
  1698. ; (list #'company-beancount #'company-dabbrev))))
  1699. (defun my--beancount-companyALT ()
  1700. (set (make-local-variable 'company-backends)
  1701. '(company-beancount)))
  1702. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount"))
  1703. +END_SRC
  1704. To support org-babel, check if it can find the symlink to ob-beancount.el
  1705. #+BEGIN_SRC shell :tangle no
  1706. orgpath=`find /home/marc/.emacs.d/elpa/ -type d -name "org-plus*" -print`
  1707. beansym="$orgpath/ob-beancount.el
  1708. bean="/home/marc/Archiv/Programmierprojekte/Lisp/beancount-mode/ob-beancount.el"
  1709. if [ -h "$beansym" ]
  1710. then
  1711. echo "$beansym found"
  1712. elif [ -e "$bean" ]
  1713. then
  1714. echo "creating symlink"
  1715. ln -s "$bean" "$beansym"
  1716. else
  1717. echo "$bean not found, symlink creation aborted"
  1718. fi
  1719. #+END_SRC
  1720. Fava is strongly recommended.
  1721. #+BEGIN_SRC shell :tangle no
  1722. cd /opt
  1723. python3 -m venv fava
  1724. source ./fava/bin/activate
  1725. pip3 install wheel
  1726. pip3 install fava
  1727. deactivate
  1728. #+END_SRC
  1729. Start fava with fava my_file.beancount
  1730. It is accessable on this URL: [[http://127.0.0.1:5000][Fava]]
  1731. Beancount-mode can start fava and open the URL right away.
  1732. * Stuff after everything else
  1733. Set garbage collector to a smaller value to let it kick in faster.
  1734. Maybe a problem on Windows?
  1735. #+begin_src emacs-lisp
  1736. ;(setq gc-cons-threshold (* 2 1000 1000))
  1737. #+end_src
  1738. Rest of early-init.el
  1739. #+begin_src emacs-lisp :tangle early-init.el
  1740. (defconst config-org (expand-file-name "config.org" user-emacs-directory))
  1741. (defconst init-el (expand-file-name "init.el" user-emacs-directory))
  1742. (unless (file-exists-p init-el)
  1743. (require 'org)
  1744. (org-babel-tangle-file config-org init-el))
  1745. #+end_src