From ae35cb41d959de89b4a3ece7cbf19a95e5d6dcdb Mon Sep 17 00:00:00 2001 From: Marc Date: Wed, 21 Apr 2021 10:06:19 +0200 Subject: [PATCH] restructured config --- config.org | 2863 +++++++++++++++++++---------------------------- create-init.bat | 9 - create-init.sh | 15 - init.org | 1362 ---------------------- 4 files changed, 1153 insertions(+), 3096 deletions(-) delete mode 100644 create-init.bat delete mode 100755 create-init.sh delete mode 100644 init.org diff --git a/config.org b/config.org index 327b25d..e3cba56 100644 --- a/config.org +++ b/config.org @@ -1,545 +1,356 @@ -#+TITLE: Emacs Configuration -#+AUTHOR: Marc Pohling +#+TITLE: Emacs configuration file +#+AUTHOR: Marc #+BABEL: :cache yes -#+PROPERTY: :header-args :tangle yes - -* Personal Information - -#+BEGIN_SRC emacs-lisp - (setq user-full-name "Marc Pohling" - user-mail-address "marc.pohling@googlemail.com") -#+END_SRC - -I need a function to know what computer emacs is running on. The display width of 1152 pixel is an oddity of hyper-v and for my usecase specific enough to tell the machine. - -#+BEGIN_SRC emacs-lisp - (defvar my/whoami - (if (string-equal user-login-name "POH") - "work_remote" - (if (equal (display-pixel-width) 1152) - "work_hyperv" - (if (string-equal system-type "gnu/linux") - "home")))) -#+END_SRC -* Stuff to add / to fix - - smartparens - a sane default configuration for navigation, manipulation etc. is still necessary - - Spaceline / Powerline or similar - I want a pretty status bar! - - Git gutter: - Do some configuration to make it useful (see given source link in the [[*Git][Section]] of gutter) - Maybe only enable it for modes where it is likely I use git? - - Some webmode stuff - - markdown: - add hooks for certain file extensions, maybe add a smart way to start gfm-mode if markdown-file is in a git-project - - move package dependend configurations inside the package configuration itself, like keymaps for magit - - get rid of user-local and user-global and work with git-ignore -* Update config in a running config - Two options: - - reload the open file: M-x load-file, then press twice to accept - the default filename, which is the currently opened - - Point at the end of any sexp and press C-x C-e -* Customize default settings - Keep the .emacs.d clean by moving user files into separate directories. - - user-local: directory for machine specific files - - user-global: directory for files which work on any machine - - the backup and auto-save files go right to /tmp - -#+BEGIN_SRC emacs-lisp -(defvar PATH_USER_LOCAL (expand-file-name "~/.emacs.d/user-local/")) -(defvar PATH_USER_GLOBAL (expand-file-name "~/.emacs.d/user-global/")) -(setq bookmark-default-file (concat PATH_USER_LOCAL "bookmarks")) -(setq recentf-save-file (concat PATH_USER_LOCAL "recentf")) -(setq custom-file (concat PATH_USER_LOCAL "custom.el")) ;don't spam init.el with saved customize settings -(setq abbrev-file-name (concat PATH_USER_GLOBAL "abbrev_defs")) -(setq backup-directory-alist `((".*" . ,temporary-file-directory))) -(setq auto-save-file-name-transforms `((".*" ,temporary-file-directory))) - -(setq save-abbrevs 'silently) ; don't bother me with asking if new abbrevs should be saved -#+END_SRC - - These functions are useful. Activate them. -#+BEGIN_SRC emacs-lisp - (put 'downcase-region 'disabled nil) - (put 'upcase-region 'disabled nil) - (put 'narrow-to-region 'disabled nil) - (put 'dired-find-alternate-file 'disabled nil) -#+END_SRC - - Disable lock files, which cause trouble in e.g. lsp-mode - -#+BEGIN_SRC emacs-lisp -(setq-default create-lockfiles nil) -#+END_SRC - - Answering just 'y' or 'n' should be enough. - -#+BEGIN_SRC emacs-lisp - (defalias 'yes-or-no-p 'y-or-n-p) -#+END_SRC - - Don't ask me if I want to load themes. -#+BEGIN_SRC emacs-lisp - (setq custom-safe-themes t) -#+END_SRC - - Don't count two spaces after a period as the end of a sentence. - Just one space is needed -#+BEGIN_SRC emacs-lisp - (setq sentence-end-double-space nil) -#+END_SRC - - Scroll to the end / beginning of buffer before you throw an error -#+BEGIN_SRC emacs-lisp - (setq scroll-error-top-bottom t) -#+END_SRC - - Delete the region when typing, just like as we expect nowadays. -#+BEGIN_SRC emacs-lisp - (delete-selection-mode t) +#+PROPERTY: header-args :tangle yes + +* TODOS +- early-init.el? What to outsource here? +- Paket exec-path-from-shell, um PATH aus Linux auch in emacs zu haben +- Smart mode line? +- Theme +- evil-collection or custom in init file? +- Hydra +- General +- (defalias 'list-buffers 'ibuffer) ;; change default to ibuffer +- ido? +- treemacs (for linux) +- treemacs-evil? +- treemacs-projectile + windmove? +- tramp (in linux) +- visual-regexp +- org configuration: paths +- org custom agenda +- org-ql (related to org agendas) +- org configuration: everything else +- beancount configuration from config.org +- CONTINUE TODO from config.org at Programming +- all-the-icons? +- lispy? [[https://github.com/abo-abo/lispy]] + +* Header + :PROPERTIES: + :ID: a14d7c89-24ea-41ae-b185-944bab49aa02 + :END: +Emacs variables are dynamically scoped. That's unusual for most languages, so disable it here, too +#+begin_src emacs-lisp +;;; init.el --- -*- lexical-binding: t -*- +#+end_src + +* First start +:PROPERTIES: +:ID: 1c24d48e-0124-4a0b-8e78-82e4c531e818 +:END: +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 + +#+BEGIN_SRC emacs-lisp :tangle no +(require 'org') +(find-file (concat user-emacs-directory "init.org")) +(org-babel-tangle) +(load-file (concat user-emacs-directory "init.el")) +(byte-compile-file (concat user-emacs-directory "init.el")) +#+END_SRC + +This function updates init.el whenever changes in init.org are made. The update will be active after saving. + +#+BEGIN_SRC emacs-lisp +(defun me/tangle-init () + "If the current buffer is 'init.org', the code blocks are tangled, and the tangled file is compiled." + (when (equal (buffer-file-name) + (expand-file-name (concat user-emacs-directory "init.org"))) + ;; avoid running hooks + (let ((prog-mode-hook nil)) + (org-babel-tangle) + (byte-compile-file (concat user-emacs-directory "init.el")) + (load-file user-init-file)))) +(add-hook 'after-save-hook 'me/tangle-init) +#+END_SRC + +A small function to measure start up time. +Compare that to +emacs -q --eval='(message "%s" (emacs-init-time))' +(roughly 0.27s) +https://blog.d46.us/advanced-emacs-startup/ +#+begin_src emacs-lisp +(add-hook 'emacs-startup-hook + (lambda () + (message "Emacs ready in %s with %d garbage collections." + (format "%.2f seconds" + (float-time + (time-subtract after-init-time before-init-time))) + gcs-done))) + +(setq gc-cons-threshold (* 50 1000 1000)) +#+end_src + +#+BEGIN_SRC emacs-lisp +(require 'package) + +(add-to-list 'package-archives '("elpa" . "https://elpa.gnu.org/packages/") t) +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) +(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t) +(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t) + +; fix for bug 34341 +(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3") + +(when (< emacs-major-version 27) + (package-initialize)) +#+END_SRC + +#+BEGIN_SRC emacs-lisp +(unless (package-installed-p 'use-package) + (package-refresh-contents) + (package-install 'use-package)) + +(eval-when-compile + (setq use-package-enable-imenu-support t) + (require 'use-package)) +(require 'bind-key) + +(setq use-package-verbose nil) + +(use-package diminish + :ensure t) #+END_SRC - Auto-indent when pressing RET, just new-line when C-j -#+BEGIN_SRC emacs-lisp - (define-key global-map (kbd "RET") 'newline-and-indent) - (define-key global-map (kbd "C-j") 'newline) -#+END_SRC +cl is deprecated in favor for cl-lib, some packages like emmet still depend on cl. +Shut off the compiler warning about it. +Maybe turn it on again at some point before the next major emacs upgrade +#+begin_src emacs-lisp +(setq byte-compile-warnings '(cl-functions)) +#+end_src - Set the default window size depending on the system emacs is running on. - ;; TODO: - ;; This size is only reasonable for linux@home - ;; hyperv is way smaller, use fullscreen here - ;; pm should be fullscreen, too - +* Default settings +:PROPERTIES: +:ID: 3512d679-d111-4ccd-8372-6fc2acbc0374 +:END: #+BEGIN_SRC emacs-lisp -(if (display-graphic-p) - (pcase my/whoami - ("home" (progn - (setq initial-frame-alist - '((width . 165) - (height . 70))) - (setq default-frame-alist - '((width . 165) - (height . 70))))) - ("work_remote" (add-to-list 'initial-frame-alist '(fullscreen . maximized))) - ("work_hyperv" (add-to-list 'initial-frame-alist '(fullscreen . maximized))))) -#+END_SRC - -* Windows specific stuff -** Performance - [[https://github.com/cbowdon/Config/blob/master/emacs/init.org][Got it from here]] -#+BEGIN_SRC emacs-lisp -(when (eq system-type 'windows-nt) - (if (>= emacs-major-version 25) - (remove-hook 'find-file-hooks 'vc-refresh-state) - (remove-hook 'find-file-hooks 'vc-find-file-hook)) - (progn - (setq gc-cons-threshold (* 511 1024 1024) - gc-cons-percentage 0.5 - garbage-collection-messages t - w32-get-true-file-attributes nil) - (run-with-idle-timer 5 t #'garbage-collect))) -#+END_SRC +(defconst *sys/gui* + (display-graphic-p) + "Is emacs running in a gui?") -#+RESULTS: -: [nil 0 5 0 t garbage-collect nil idle 0] +(defconst *sys/linux* + (string-equal system-type 'gnu/linux) + "Is the system running Linux?") - Hopefully this makes magit faster -#+BEGIN_SRC emacs-lisp -(when (eq system-type 'windows-nt) - (setq w32-pipe-read-delay 0) - (setq w32-get-true-file-attributes nil)) -#+END_SRC +(defconst *sys/windows* + (string-equal system-type 'windows-nt) + "Is the system running Windows?") -* Visuals -** Font - Don't add the font in the work environment, which I am logged in as POH +(defconst *home_desktop* + (string-equal (system-name) "marc") + "Is emacs running on my desktop?") -#+BEGIN_SRC emacs-lisp -; (set-face-attribute 'default nil -; :family "Hack Nerd Font Mono-14" -; :height 110 -; :weight 'normal -; :width 'normal) -(set-face-font 'default "Hack Nerd Font Mono-10") -; (pcase my/whoami -; ("home" (set-face-font 'default "Hack Nerd Font Mono-10")) - ;; ("home" (set-face-attribute 'default nil :font "Hack-10")) -; ("work_hyperv" (set-face-attribute 'default nil :font "Hack-12")) -; ) -#+END_SRC +(defconst *home_laptop* + (string-equal (system-name) "laptop") + "Is emacs running on my laptop?") -** Themes -*** Material Theme - The [[https://github.com/cpaulik/emacs-material-theme][Material Theme]] comes in a dark and a light variant. Not too dark - to be strenious though. - b -#+BEGIN_SRC emacs-lisp - (use-package material-theme - :if (window-system) - :defer t - :ensure t - ) -#+END_SRC -*** Apropospriate Theme - Variants dark and light +(defconst *work_local* + (string-equal (system-name) "PMPCNEU08") + "Is emacs running at work on the local system?") -#+BEGIN_SRC emacs-lisp - (use-package apropospriate-theme - :if (window-system) - :defer t - :ensure t - ) +(defconst *work_remote* + (string-equal (system-name) "PMTS01") + "Is emacs running at work on the remote system?") #+END_SRC -*** Ample Theme - Variants: - - ample - - ample-flat - - ample-light - #+BEGIN_SRC emacs-lisp -(use-package ample-theme - :if (window-system) - :defer t - :ensure t - :init - (load-theme 'ample-flat t) -) -#+END_SRC -** Prettier Line Wraps - By default there is no line wrapping. M-q actually modifies the buffer, which might not be wanted. - So: enable visual wrapping and keep indentation if there are any. +(defvar MY--PATH_USER_LOCAL (concat user-emacs-directory "user-local/")) +(defvar MY--PATH_USER_GLOBAL (concat user-emacs-directory "user-global/")) -#+BEGIN_SRC emacs-lisp - (global-visual-line-mode) - (diminish 'visual-line-mode) - (use-package adaptive-wrap - :ensure t - :init - (when (fboundp 'adaptive-wrap-prefix-mode) - (defun my-activate-adaptive-wrap-prefix-mode () - "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously." - (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1))) - (add-hook 'visual-line-mode-hook 'my-activate-adaptive-wrap-prefix-mode)) - ) -#+END_SRC +(add-to-list 'custom-theme-load-path (concat MY--PATH_USER_GLOBAL "themes")) -** Mode Line - Change the default mode line to something prettier. [[https://github.com/Malabarba/smart-mode-line][Source]] +(when *sys/linux* + (defconst MY--PATH_ORG_FILES (expand-file-name "~/Archiv/Organisieren/")) + (defconst MY--PATH_ORG_FILES_MOBILE (expand-file-name "~/Archiv/Organisieren/mobile/"))) + (defconst MY--PATH_ORG_JOURNAl (expand-file-name "~/Archiv/Organisieren/Journal/")) +(when *work_remote* + (defconst MY--PATH_ORG_FILES "p:/Eigene Dateien/Notizen/") + (defconst MY--PATH_ORG_FILES_MOBILE nil) ;; hacky way to prevent "free variable" compiler error + (defconst MY--PATH_ORG_JOURNAL nil) ;; hacky way to prevent "free variable" compiler error + (defconst MY--PATH_START "p:/Eigene Dateien/Notizen/")) +(setq recentf-save-file (concat MY--PATH_USER_LOCAL "recentf")) -#+BEGIN_SRC emacs-lisp -(use-package smart-mode-line - :ensure t +;; exclude some dirs from spamming recentf +(use-package recentf :config - (tool-bar-mode -1) - (setq sml/theme 'respectful) - (setq sml/name-width 40) - (setq sml/mode-width 'full) - (set-face-attribute 'mode-line nil - :box nil) - (sml/setup)) -#+END_SRC - -** Line numbers - -#+BEGIN_SRC emacs-lisp -(use-package linum - :ensure t - :init - (add-hook 'prog-mode-hook 'linum-mode)) -#+END_SRC + (recentf-mode) + (setq recentf-exclude '(".*-autoloads\\.el\\" + "[/\\]\\.elpa/"))) -** Misc - UTF-8 please, but don't mess with line endings. - -#+BEGIN_SRC emacs-lisp +(setq custom-file (concat MY--PATH_USER_LOCAL "custom.el")) ;; don't spam init.e with saved customization settings +(setq backup-directory-alist `((".*" . ,temporary-file-directory))) +(setq auto-save-file-name-transforms `((".*" ,temporary-file-directory))) +(setq-default create-lockfiles nil) ;; disable lock files, can cause trouble in e.g. lsp-mode +(defalias 'yes-or-no-p 'y-or-n-p) ;; answer with y and n +(setq custom-safe-themes t) ;; don't ask me if I want to load a theme +(setq sentence-end-double-space nil) ;; don't coun two spaces after a period as the end of a sentence. +(delete-selection-mode t) ;; delete selected region when typing +(save-place-mode 1) ;; saves position in file when it's closed +(setq save-place-forget-unreadable-files nil) ;; checks if file is readable before saving position + +(set-charset-priority 'unicode) (setq locale-coding-system 'utf-8) (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) (set-selection-coding-system 'utf-8) -(if (eq system-type 'windows-nt) +(setq default-process-coding-system '(utf-8-unix . utf-8-unix)) +(if *sys/windows* (prefer-coding-system 'utf-8-dos) (prefer-coding-system 'utf-8)) -#+END_SRC - - Turn off blinking cursor - -#+BEGIN_SRC emacs-lisp - (blink-cursor-mode -1) -#+END_SRC - -#+BEGIN_SRC emacs-lisp - (show-paren-mode t) - (column-number-mode t) - (setq uniquify-buffer-name-style 'forward) -#+END_SRC - - Avoid tabs in place of multiple spaces (they look bad in TeX) and show empty lines - -#+BEGIN_SRC emacs-lisp - (setq-default indent-tabs-mode nil) - (setq-default indicate-empty-lines t) -#+END_SRC - Smooth scrolling. Emacs tends to be jumpy, this should change it. - -#+BEGIN_SRC emacs-lisp -(setq scroll-margin 5 +(blink-cursor-mode -1) ;; turn off blinking cursor +(column-number-mode t) +(setq uniquify-buffer-name-style 'forward) +(setq-default indent-tabs-mode nil) ;; avoid tabs in place of multiple spaces (they look bad in tex) +(setq-default indicate-empty-lines t) ;; show empty lines +(setq scroll-margin 5 ;; smooth scrolling scroll-conservatively 10000 scroll-preserve-screen-position 1 scroll-step 1) +(global-hl-line-mode t) ;; highlight current line +(menu-bar-mode 0) ;; disable menu bar +(tool-bar-mode 0) ;; disable tool bar +(scroll-bar-mode 0) ;; disable scroll bar +(setq ring-bell-function 'ignore ;; disable pc speaker bell + visible-bell t) +#+END_SRC + +Bookmarks +Usage: +- C-x r m (bookmark-set): add bookmark +- C-x r l (list-bookmark): list bookmarks +- C-x r b (bookmark-jump): open bookmark + +Edit bookmarks (while in bookmark file): +- d: mark current item +- x: delete marked items +- r: rename current item +- s: save changes + +#+begin_src emacs-lisp +(use-package bookmark + :custom + (bookmark-default-file (concat MY--PATH_USER_LOCAL "bookmarks"))) +#+end_src + +Some windows specific stuff +#+BEGIN_SRC emacs-lisp +(when *sys/windows* + (remove-hook 'find-file-hook 'vc-refresh-state) + (progn + (setq gc-cons-threshold (* 511 1024 1024) + gc-cons-percentage 0.5 + garbage-collection-messages t) + (run-with-idle-timer 5 t #'garbage-collect)) + (when (boundp 'w32-pipe-read-delay) + (setq w32-pipe-read-delay 0)) + (when (boundp 'w32-get-true-file-attributes) + (setq w32-get-true-file-attributes nil))) #+END_SRC - Highlight current line - -#+BEGIN_SRC emacs-lisp -(global-hl-line-mode t) -#+END_SRC - -* Usability -** which-key - Greatly increases discovery of functions! - Click [[https://github.com/justbur/emacs-which-key][here]] for source and more info. - Info in Emacs: M-x customize-group which-key - +* visuals +** Font + :PROPERTIES: + :ID: dc8eb670-e6bb-4bfb-98f0-aae1860234fb + :END: #+BEGIN_SRC emacs-lisp - (use-package which-key - :ensure t - :diminish which-key-mode - :config - (which-key-mode) - (which-key-setup-side-window-right-bottom) - (which-key-setup-minibuffer) - (setq which-key-idle-delay 0.5) - ) +(when *sys/linux* + (set-face-font 'default "Hack-10")) +(when *work_remote* + (set-face-font 'default "Lucida Sans Typewriter-11")) #+END_SRC -** Recentf - Activate and configure recentf -#+BEGIN_SRC emacs-lisp - (recentf-mode t) - (setq recentf-max-saved-items 200) -#+END_SRC -** Hydra - Hydra allows grouping of commands +** Themes + :PROPERTIES: + :ID: 9ccf37c0-6837-43cb-bed8-5a353799d8b1 + :END: #+BEGIN_SRC emacs-lisp - (use-package hydra - :ensure t - :bind - ("C-c f" . hydra-flycheck/body) - ("C-c g" . hydra-git-gutter/body) - :config - (setq-default hydra-default-hint nil) - ) -#+END_SRC - -** Evil - So... Evil Mode might be worth a try +(defun my/toggle-theme () + (interactive) + (when (or *sys/windows* *sys/linux*) + (if (eq (car custom-enabled-themes) 'tango-dark) + (progn (disable-theme 'tango-dark) + (load-theme 'tango)) + (progn + (disable-theme 'tango) + (load-theme 'tango-dark))))) -#+BEGIN_SRC emacs-lisp - (use-package evil - :ensure t - :defer .1 ;; don't block emacs when starting, load evil immediately after startup - :init - (setq evil-want-integration nil) ;; required by evil-collection - :config - (evil-mode 1)) ;; for now deactivate per default +(bind-key "C-c t" 'my/toggle-theme) #+END_SRC - Evil-collection is a bundle of configs for different modes. - 2018-05-01: evil collection causes error - "Invalid function: with-helm-buffer" +Windows Theme: #+BEGIN_SRC emacs-lisp - ;(use-package evil-collection - ; :after evil - ; :ensure t - ; :config - ; (evil-collection-init)) +(when *sys/windows* + (load-theme 'tango)) +(when *sys/linux* + (load-theme 'plastic)) #+END_SRC - Evil-goggles give visual hints when editing texts, so it's more obvious what is actually happening. [[https://github.com/edkolev/evil-goggles][Source]] - +** line wrappings + :PROPERTIES: + :ID: 14ae933e-2941-4cc3-82de-38f90f91bfd3 + :END: #+BEGIN_SRC emacs-lisp -(use-package evil-goggles - :after evil +(global-visual-line-mode) +(diminish 'visual-line-mode) +(use-package adaptive-wrap :ensure t - :diminish evil-goggles-mode :config - (evil-goggles-mode) - (evil-goggles-use-diff-faces)) -#+END_SRC -** General (keymapper) - I just use general.el to define keys and keymaps. With it I can set leader keys and create keymaps for them. It also integrates well with which-key. - [[https://github.com/noctuid/general.el][Source]] - -#+BEGIN_SRC emacs-lisp - (use-package general - :ensure t - ) -#+END_SRC - -** Custom key mappings - Now some keymaps. - If there is no map defined, it is considered the global key map. - -#+BEGIN_SRC emacs-lisp -(general-define-key - :states '(normal visual insert emacs) - :prefix "SPC" - :non-normal-prefix "M-SPC" - "TAB" '(ivy-switch-buffer :which-key "prev buffer") - "SPC" '(counsel-M-x :which-key "M-x") - "g" '(:ignore t :which-key "Git") - "gs" '(magit-status :which-key "git-status") -) -#+END_SRC - - A map for org-mode - -#+BEGIN_SRC emacs-lisp - (general-define-key - :states '(normal visual insert emacs) - :keymaps 'org-mode-map - :prefix "SPC" - :non-normal-prefix "M-SPC" - "t" '(counsel-org-tag :which-key "org-tag")) -#+END_SRC - - A map for dired, based on [[https://github.com/emacs-evil/evil-collection/blob/master/evil-collection-dired.el][evil-collection]] -#+BEGIN_SRC emacs-lisp -(general-define-key - :states '(normal visual insert emacs) - :keymaps 'dired-mode-map - "q" '(quit-window :which-key "quit-window") - "j" '(dired-next-line :which-key "next line") - "k" '(dired-previous-line :which-key "previous line") - "D" '(dired-do-delete :which-key "delete") - "C" '(dired-do-copy :which-key "copy") - "t" '(:ignore t :which-key "dir navigation") - "td" '(dired-tree-down :which-key "tree down") - "tu" '(dired-tree-up :which-key "tree up") - "tn" '(dired-next-subdir :which-key "next subdir") - "tp" '(dired-prev-subdir :which-key "previous subdir") -) -#+END_SRC - -#+BEGIN_SRC emacs-lisp -(general-define-key - :states '(normal) - :keymaps 'lsp-ui-imenu-mode-map - (kbd "RET") '(lsp-ui-imenu--view :which-key "view") - (kbd "M-RET") '(lsp-ui-imenu--visit :which-key "visit") -) -#+END_SRC -** List buffers - Ibuffer is the improved version of list-buffers. - Make ibuffer the default buffer lister. [[http://ergoemacs.org/emacs/emacs_buffer_management.html][Source]] -#+BEGIN_SRC emacs-lisp - (defalias 'list-buffers 'ibuffer) -#+END_SRC - - Also auto refresh dired, but be quiet about it. [[http://whattheemacsd.com/sane-defaults.el-01.html][Source]] -#+BEGIN_SRC emacs-lisp - (add-hook 'dired-mode-hook 'auto-revert-mode) - (setq global-auto-revert-non-file-buffers t) - (setq auto-revert-verbose nil) -#+END_SRC -** ivy / counsel / swiper - Flx is required for fuzzy-matching - Is it really necessary? - BEGIN_SRC emacs-lisp - (use-package flx) - end_src - - Ivy displays a window with suggestions for hotkeys and M-x - -#+BEGIN_SRC emacs-lisp - (use-package ivy - :ensure t - :diminish - (ivy-mode . "") ;; does not display ivy in the mode line - :init - (ivy-mode 1) - :bind - ("C-c C-r" . ivy-resume) - :config - (setq ivy-use-virtual-buffers t) ;; recent files and bookmarks in ivy-switch-buffer - (setq ivy-height 20) ;; height of ivy window - (setq ivy-count-format "%d/%d") ;; current and total number - (setq ivy-re-builders-alist ;; regex replaces spaces with * - '((t . ivy--regex-plus))) - ) -#+END_SRC - - The find-file replacement is nicer to navigate - -#+BEGIN_SRC emacs-lisp - (use-package counsel - :ensure t - :bind* ;; load counsel when pressed - (("M-x" . counsel-M-x) - ("C-x C-f" . counsel-find-file) - ("C-x C-r" . counsel-recentf) - ("C-c C-f" . counsel-git) - ("C-c h f" . counsel-describe-function) - ("C-c h v" . counsel-describe-variable) - ("M-i" . counsel-imenu) - ) - ) + (add-hook 'visual-line-mode-hook #'adaptive-wrap-prefix-mode)) + ; :init + ; (when (fboundp 'adaptive-wrap-prefix-mode) + ; (defun my/activate-adaptive-wrap-prefix-mode () + ; "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously." + ; (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1))) + ; (add-hook 'visual-line-mode-hook 'my/activate-adaptive-wrap-prefix-mode))) #+END_SRC - Swiper ivy-enhances isearch - +** line numbers + :PROPERTIES: + :ID: 7b969436-98c9-4b61-ba7a-9fb22c9781ad + :END: #+BEGIN_SRC emacs-lisp - (use-package swiper - :ensure t - :bind - (("C-s" . swiper) - ("C-c C-r" . ivy-resume) - ) - ) +(use-package display-line-numbers + :init + (add-hook 'prog-mode-hook 'display-line-numbers-mode) + (add-hook 'org-src-mode-hook 'display-line-numbers-mode) + :config + (setq-default display-line-numbers-type 'visual + display-line-numbers-current-absolute t + display-line-numbers-with 4 + display-line-numbers-widen t)) + ; (add-hook 'emacs-lisp-mode-hook 'display-line-numbers-mode) #+END_SRC - Ivy-Hydra adds stuff in minibuffer when you press C-o - +** misc + :PROPERTIES: + :ID: a2873138-16ee-4990-89a2-26eab778ea74 + :END: #+BEGIN_SRC emacs-lisp - (use-package ivy-hydra - :ensure t) -#+END_SRC +(use-package rainbow-mode + :ensure t + :diminish + :hook + ((org-mode + emacs-lisp-mode) . rainbow-mode)) -** Helm - This is just a try to see how it works differently. +(use-package delight + :ensure t) -#+BEGIN_SRC emacs-lisp - (use-package helm - :ensure t - :init - (helm-mode 1) - :bind - ; (("M-x" . helm-M-x) - ; ("C-x C-f" . helm-find-files) - ; ("C-x C-r" . helm-recentf) - ; ("C-x b" . helm-buffers-list)) - :config - (setq helm-buffers-fuzzy-matching t) - ) - - (use-package helm-descbinds - :ensure t - :bind - ("C-h b" . helm-descbinds)) - - (use-package helm-projectile - :ensure t - :config - (helm-projectile-on)) +(show-paren-mode t) ;; show other part of brackets +(use-package rainbow-delimiters + :ensure t + :hook + (prog-mode . rainbow-delimiters-mode)) #+END_SRC -** Undo - Show an undo tree in a new buffer which can be navigated. - +* undo + :PROPERTIES: + :ID: d57621b2-5472-4c89-a520-b4133db0b9af + :END: #+BEGIN_SRC emacs-lisp (use-package undo-tree :ensure t @@ -548,26 +359,19 @@ I need a function to know what computer emacs is running on. The display width o (global-undo-tree-mode 1)) #+END_SRC -** Ido (currently inactive) - better completion - -#+BEGIN_SRC emacs-lisp - ;(use-package ido - ; :init - ; (setq ido-enable-flex-matching t) - ; (setq ido-everywhere t) - ; (ido-mode t) - ; (use-package ido-vertical-mode - ; :ensure t - ; :defer t - ; :init - ; (ido-vertical-mode 1) - ; (setq ido-vertical-define-keys 'C-n-and-C-p-only) - ; ) - ;) -#+END_SRC +* ace-window +#+begin_src emacs-lisp +(use-package ace-window + :ensure t + :bind + (:map global-map + ("C-x o" . ace-window))) +#+end_src -** imenu-list +* imenu-list + :PROPERTIES: + :ID: 0ae27ec9-5d77-43cf-ac76-5e12cc959046 + :END: A minor mode to show imenu in a sidebar. Call imenu-list-smart-toggle. [[https://github.com/bmag/imenu-list][Source]] @@ -575,6 +379,7 @@ I need a function to know what computer emacs is running on. The display width o #+BEGIN_SRC emacs-lisp (use-package imenu-list :ensure t + :defer t :config (setq imenu-list-focus-after-activation t imenu-list-auto-resize t @@ -582,1338 +387,976 @@ I need a function to know what computer emacs is running on. The display width o :bind (:map global-map ([f9] . imenu-list-smart-toggle)) - ) + :custom + (org-imenu-depth 4)) #+END_SRC -** Treemacs - A file manager comparable to neotree. - [[https://github.com/Alexander-Miller/treemacs][Github]] - - 2018-09-01: Treemacs needs emacs 25.2, debian stretch runs 25.1. Sucks. - - It has some requirements, which gets used here anyway: - - ace-window - - hydra - - projectile - - python - - I copied the configuration example from the github site. - No idea what this executable-find is about. - TODO check it out! - -BEGIN_SRC emacs-lisp - (use-package treemacs - :ensure t - :defer t - :config - (setq treemacs-collapse-dirs (if (executable-find "python") 3 0) - treemacs-file-event-delay 5000 - treemacs-follow-after-init t - treemacs-follow-recenter-distance 0.1 - treemacs-goto-tag-strategy 'refetch-index - treemacs-indentation 2 - treemacs-indentation-string " " - treemacs-is-never-other-window nil - treemacs-no-png-images nil - treemacs-project-follow-cleanup nil - treemacs-recenter-after-file-follow nil - treemacs-recenter-after-tag-follow nil - treemacs-show-hidden-files t - treemacs-silent-filewatch nil - treemacs-silent-refresh nil - treemacs-sorting 'alphabetic-desc - treemacs-tag-follow-cleanup t - treemacs-tag-follow-delay 1.5 - treemacs-width 35) - (treemacs-follow-mode t) - (treemacs-filewatch-mode t) - (pcase (cons (not (null (executable-find "git"))) - (not (null (executable-find "python3")))) - (`(t . t) - (treemacs-git-mode 'extended)) - (`(t . _) - (treemacs-git-mode 'simple))) - :bind - (:map global-map - ([f8] . treemacs)) - ) -END_SRC - - Treemacs-Evil is necessary when using evil -BEGIN_SRC emacs-lisp -(use-package treemacs-evil - :after treemacs evil - :ensure t) -END_SRC - Treemacs-projectile is useful for uhh.. TODO explain! - -BEGIN_SRC emacs-lisp -(use-package treemacs-projectile +* which-key + :PROPERTIES: + :ID: a880f079-b3a3-4706-bf1e-5f6c680101f1 + :END: +#+BEGIN_SRC emacs-lisp +(use-package which-key :ensure t - :after treemacs projectile + :diminish which-key-mode :defer t + :hook + (after-init . which-key-mode) :config - (setq treemacs-header-function #'treemacs-projectile-create-header) -) -END_SRC - - TODO - Hydrastuff or keybindings for functions: - - treemacs-projectile - - treemacs-projectile-toggle - - treemacs-toggle - - treemacs-bookmark - - treemacs-find-file - - treemacs-find-tag - -** Window Handling - Some tools to easen the navigation, creation and deletion of windows + (which-key-setup-side-window-bottom) + (setq which-key-idle-delay 0.5)) +#+END_SRC -*** Ace-Window +* abbrev +#+begin_src emacs-lisp +(use-package abbrev + :diminish abbrev-mode + :hook + ((text-mode org-mode) . abbrev-mode) + :init + (setq abbrev-file-name (concat MY--PATH_USER_GLOBAL "abbrev_tables.el")) + :config + (if (file-exists-p abbrev-file-name) + (quietly-read-abbrev-file)) + (setq save-abbrevs 'silently)) ;; don't bother me with asking for abbrev saving +#+end_src +* Evil + :PROPERTIES: + :ID: 80ca70e2-a146-46db-b581-418d655dc1fc + :END: #+BEGIN_SRC emacs-lisp - (use-package ace-window - :ensure t - :init - (global-set-key (kbd "C-x o") 'ace-window) - ) +(use-package evil + :ensure t + :defer .1 ;; don't block emacs when starting, load evil immediately after startup + :config + (evil-mode 1)) #+END_SRC -*** Windmove - Windmove easens the navigation between windows. - Here we are setting the default keybindings (shift+arrow) - - CURRENTLY NOT WORKING, defaults are blocked. - Also not sure if necessary when using ace-window. +* General (key mapper) + :PROPERTIES: + :ID: a20f183f-d41a-4dff-bc37-3bc4e25c8036 + :END: #+BEGIN_SRC emacs-lisp - (use-package windmove - :ensure t - :config - (windmove-default-keybindings) - ) +(use-package general + :ensure t) + +(general-define-key + :states 'normal + :keymaps 'imenu-list-major-mode-map + "RET" '(imenu-list-goto-entry :which-key "goto") + "TAB" '(hs-toggle-hiding :which-key "collapse") + "d" '(imenu-list-display-entry :which-key "show") + "q" '(imenu-list-quit-window :which-key "quit")) #+END_SRC -** Tramp - With tramp you can handle remote files like local files. - Usage example: - C-x C-f /ssh:name@server:/path - To open a file as sudo: - C-x C-f /ssh:/name@server|sudo:name@server:/path +* ivy / counsel / swiper + :PROPERTIES: + :ID: 55c74ba9-7761-4545-8ddd-087d6ee33e4b + :END: + #+BEGIN_SRC emacs-lisp -(use-package tramp +; (require 'ivy) +(use-package ivy :ensure t - ) -#+END_SRC -** misc - Visual feedback when using regexp on the buffer -#+BEGIN_SRC emacs-lisp -(use-package visual-regexp + :diminish + (ivy-mode . "") + :defer t + :init + (ivy-mode 1) + :bind + ("C-r" . ivy-resume) ;; overrides isearch-backwards binding + :config + (setq ivy-use-virtual-buffers t ;; recent files and bookmarks in ivy-switch-buffer + ivy-height 20 ;; height of ivy window + ivy-count-format "%d/%d" ;; current and total number + ivy-re-builders-alist ;; regex replaces spaces with * + '((t . ivy--regex-plus)))) + +; make counsel-M-x more descriptive +(use-package ivy-rich :ensure t :defer t - :bind (("C-c r s" . query-replace) - ("C-c r R" . vr/replace) - ("C-c r r" . vr/query-replace) - ("C-c r m" . vr/mc-mark))) -#+END_SRC - Newline at the end of file - -#+BEGIN_SRC emacs-lisp -(setq require-final-newline t) -#+END_SRC + :init + (ivy-rich-mode 1)) - Delete the selection with a keypress +(use-package counsel + :ensure t + :defer t + :bind + (("M-x" . counsel-M-x) + ("C-x C-f" . counsel-find-file) + ("C-x C-r" . counsel-recentf) + ("C-x b" . counsel-switch-buffer) + ("C-c C-f" . counsel-git) + ("C-c h f" . counsel-describe-function) + ("C-c h v" . counsel-describe-variable) + ("M-i" . counsel-imenu))) +; :map minibuffer-local-map ;;currently mapped to evil-redo +; ("C-r" . 'counsel-minibuffer-history))) + +(use-package swiper + :ensure t + :bind + ("C-s" . swiper)) -#+BEGIN_SRC emacs-lisp -(delete-selection-mode t) +(use-package ivy-hydra + :ensure t) #+END_SRC - Remember the current location in a file +* misc +#+begin_src emacs-lisp +(use-package autorevert + :diminish auto-revert-mode) +#+end_src +* company + :PROPERTIES: + :ID: 944563b6-b04a-44f2-9b21-a6a3e200867c + :END: #+BEGIN_SRC emacs-lisp -(use-package saveplace - :unless noninteractive +(use-package company + :defer 1 + :diminish + :defer t + :bind + (("C-" . company-complete) + :map company-active-map + ("RET" . nil) + ([return] . nil) + ("TAB" . company-complete-selection) + ([tab] . company-complete-selection) + ("" . company-complete-common) + ("" . company-abort)) + :hook + (after-init . global-company-mode) + (emacs-lisp-mode . my/company-elisp) + (org-mode . my/company-org) :config - (save-place-mode)) -#+END_SRC - -* Company Mode -Complete Anything! + (defun my/company-elisp () + (message "set up company for elisp") + (set (make-local-variable 'company-backends) + '(company-yasnippet + company-capf + company-dabbrev-code + company-files))) + (defun my/company-org () + (set (make-local-variable 'company-backends) + '(company-capf company-files)) + ;; (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t) + (message "setup company for org")) + (setq company-idle-delay .2 + company-minimum-prefix-length 1 + company-require-match nil + company-show-numbers t + company-tooltip-align-annotations t)) + +(use-package company-statistics + :ensure t + :after company + :defer t + :init + (setq company-statistics-file (concat MY--PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el") + :config + (company-statistics-mode 1)) -Activate company and make it react nearly instantly +(use-package company-dabbrev + :ensure nil + :after company + :defer t + :config + (setq-default company-dabbrev-downcase nil)) +;; adds a info box right of the cursor with doc of the function +(use-package company-box + :ensure t + :diminish + :defer t + :hook + (company-mode . company-box-mode)) +; :init +; (add-hook 'company-mode-hook 'company-box-mode)) +#+END_SRC + +* orgmode +** org + :PROPERTIES: + :ID: b89d7639-080c-4168-8884-bd5d8965f466 + :END: #+BEGIN_SRC emacs-lisp - (use-package company - :ensure t - :config - (setq-default company-minimum-prefix-length 1 - company-tooltip-align-annotation t - company-tooltop-flip-when-above t - company-show-numbers t - company-idle-delay 0.1) -; (define-key company-active-map (kbd "RET") nil) - (company-tng-configure-default) - :bind - (:map company-active-map - ("TAB" . company-complete-selection) - ("" . company-complete-selection)) - ) -#+END_SRC +(use-package org + :ensure org-plus-contrib + :mode (("\.org$" . org-mode)) + :diminish org-indent-mode + :defer t + :hook + (org-mode . org-indent-mode) + (org-source-mode . smartparens-mode) +; :init +; (add-hook 'org-mode-hook 'company/org-mode-hook) +; (add-hook 'org-src-mode-hook 'smartparens-mode) +; (add-hook 'org-mode-hook 'org-indent-mode) + :config + (defun my/org-company () + (set (make-local-variable 'company-backends) + '(company-capf company-files)) + (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t) + (message "company/org-mode-hook")) + (setq org-modules (quote (org-id + org-habit + org-tempo ;; easy templates + ))) + (setq org-default-notes-file (concat MY--PATH_ORG_FILES "notes.org") + org-agenda-files (list (concat MY--PATH_ORG_FILES "notes.org") + (concat MY--PATH_ORG_FILES "projects.org") + (concat MY--PATH_ORG_FILES "tasks.org"))) + (when *sys/linux* + (nconc org-agenda-files + (directory-files-recursively MY--PATH_ORG_FILES_MOBILE "\\.org$"))) + (setq org-id-locations-file (concat MY--PATH_USER_LOCAL ".org-id-locations") + org-log-into-drawer "LOGBOOK") + + ;; some display customizations + (setq org-pretty-entities t + org-startup-truncated t + org-startup-align-all-tables t) + + ;; some source code blocks customizations + (setq org-src-window-setup 'current-window ;; C-c ' opens in current window + org-src-fontify-natively t ;; use syntax highlighting in code blocks + org-src-preserve-indentation t ;; no extra indentation + org-src-tab-acts-natively t) + + (setq org-log-done 'time)) ;; create timestamp when task is done +#+END_SRC + +** languages + :PROPERTIES: + :ID: ad3af718-d0db-448c-9f75-eb9e250c2862 + :END: +Set some languages and disable confirmation for evaluating code blocks C-c C-c + ++BEGIN_SRC emacs-lisp +(org-babel-do-load-languages + 'org-babel-load-languages + '((emacs-lisp . t) + (gnuplot . t) + (js . t) + (latex . t) + (lisp . t) + (python . t) + (shell . t) + (sqlite . t) + (org . t) + (R . t) + (scheme . t))) + +(setq org-confirm-babel-evaluate nil) ++END_SRC +Another setup, because org-babel-do-load-languages requires eager loading +#+begin_src emacs-lisp +(use-package ob-org + :defer t + :ensure org-plus-contrib + :commands + (org-babel-execute:org + org-babel-expand-body:org)) -For a nicer suggestion box: company-box ([[https://github.com/sebastiencs/company-box][Source]]) -It is only available for emacs 26 and higher. +(use-package ob-python + :defer t + :ensure org-plus-contrib + :commands (org-babel-execute:python)) -#+BEGIN_SRC emacs-lisp -(when (> emacs-major-version 25) - (use-package company-box - :ensure t - :init - (add-hook 'company-mode-hook 'company-box-mode))) -#+END_SRC +(use-package ob-js + :defer t + :ensure org-plus-contrib + :commands (org-babel-execute:js)) +(use-package ob-shell + :defer t + :ensure org-plus-contrib + :commands + (org-babel-execute:sh + org-babel-expand-body:sh -* Org Mode -** Installation - Although org mode ships with Emacs, the latest version can be installed externally. The configuration here follows the [[http://orgmode.org/elpa.html][Org mode ELPA Installation instructions.]] - Added a hook to complete org functions, company-capf is necessary for this + org-babel-execute:bash + org-babel-expand-body:bash)) +(use-package ob-emacs-lisp + :defer t + :ensure org-plus-contrib + :commands + (org-babel-execute:emacs-lisp + org-babel-expand-body:emacs-lisp)) -#+BEGIN_SRC emacs-lisp -(use-package org - :ensure org-plus-contrib - :init - (add-hook 'org-mode-hook 'company/org-mode-hook) -) -(add-hook 'org-mode-hook 'company/org-mode-hook) +(use-package ob-lisp + :defer t + :ensure org-plus-contrib + :commands + (org-babel-execute:lisp + org-babel-expand-body:lisp)) -#+END_SRC +(use-package ob-gnuplot + :defer t + :ensure org-plus-contrib + :commands + (org-babel-execute:gnuplot + org-babel-expand-body:gnuplot)) - To avoid problems executing source blocks out of the box. [[https://emacs.stackexchange.com/a/28604][Others have the same problem, too]]. The solution is to remove the .elc files form the package directory: +(use-package ob-sqlite + :defer t + :ensure org-plus-contrib + :commands + (org-babel-execute:sqlite + org-babel-expand-body:sqlite)) -#+BEGIN_SRC shell -var ORG_DIR=(let* ((org-v (cadr (split-string (org-version nil t) "@"))) (len (length org-v))) (substring org-v 1 (- len 2))) -rm ${ORG_DIR}/*.elc -echo 'cleaned .elc from package directory' -#+END_SRC +(use-package ob-latex + :defer t + :ensure org-plus-contrib + :commands + (org-babel-execute:latex + org-babel-expand-body:latex)) -** Setup -*** Paths - Paths need to be different for work and home +(use-package ob-R + :defer t + :ensure org-plus-contrib + :commands + (org-babel-execute:R + org-babel-expand-body:R)) -#+BEGIN_SRC emacs-lisp -(pcase my/whoami - ("work_remote" - (progn - (defvar PATH_ORG_FILES "p:/Eigene Dateien/Notizen/") - (defvar PATH_ORG_JOURNAL "p:/Eigene Dateien/Notizen/Journal/") - (defvar PATH_START "p:/Eigene Dateien/Notizen/")) - (setq org-default-notes-file (concat PATH_ORG_FILES "notes.org")) - (setq org-agenda-files (list(concat PATH_ORG_FILES "notes.org") - (concat PATH_ORG_FILES "projects.org") - (concat PATH_ORG_FILES "todo.org")))) - ("home" - (progn - (defvar PATH_ORG_FILES_MOBILE "~/Archiv/Organisieren/mobile/") - (defvar PATH_ORG_JOURNAL "~/Archiv/Organisieren/Journal/") - (defvar PATH_ORG_FILES "~/Archiv/Organisieren/") - (setq org-default-notes-file (concat PATH_ORG_FILES "notes.org")) - ;; TODO: ignore notes.org, which shouldn't include any todos -;; (setq org-agenda-file-regexp "'\\`[^.].*\\.org\\'") - (setq org-agenda-files (list PATH_ORG_FILES PATH_ORG_FILES_MOBILE)))) -) -(setq org-id-locations-file (concat PATH_USER_LOCAL ".org-id-locations")) +(use-package ob-scheme + :defer t + :ensure org-plus-contrib + :commands + (org-babel-execute:scheme + org-babel-expand-body:scheme)) +#+end_src + +** habits + :PROPERTIES: + :ID: fcc91d0a-d040-4910-b2cf-3221496a3842 + :END: +#+BEGIN_SRC emacs-lisp +(require 'org-habit) ;;TODO Lösung ohne require finden, scheint mir nicht ideal zu sein, nur um ein org-modul zu aktivieren +;; (add-to-list 'org-modules "org-habit") +(setq org-habit-graph-column 80 + org-habit-preceding-days 30 + org-habit-following-days 7 + org-habit-show-habits-only-for-today nil) +#+END_SRC + +** org-id + :PROPERTIES: + :ID: c4017c45-d650-410c-8bd4-bc3cf42bbbb9 + :END: +Currently it causes some debugger errors "not a standard org time string", so it's disabled +#+BEGIN_SRC emacs-lisp +;; (use-package org-id +;; :config +;; (setq org-id-link-to-org-use-id t) +;; (org-id-update-id-locations)) ;; update id file .org-id-locations on startup +#+END_SRC + +** org-agenda + :PROPERTIES: + :ID: 03b67efb-4179-41e5-bc2e-c472b13f8be6 + :END: +Custom keywords, depending on environment +#+BEGIN_SRC emacs-lisp +(when *work_remote* + (setq org-todo-keywords + '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE" "CANCELLED")))) #+END_SRC -*** Settings - Speed commands are a nice and quick way to perform certain actions while at the beginning of a heading. It's not activated by default. - - See the doc for speed keys by checking out the documentation for speed keys in Org mode. - +Add some key bindings #+BEGIN_SRC emacs-lisp - (setq org-use-speed-commands t) - (setq org-image-actual-width 550) - (setq org-highlight-latex-and-related '(latex script entities)) +(bind-key "C-c l" 'org-store-link) +(bind-key "C-c c" 'org-capture) +(bind-key "C-c a" 'org-agenda) #+END_SRC - Hide emphasis markup (e.g. / ... / for italics, etc.) - +Sort agenda by deadline and priority #+BEGIN_SRC emacs-lisp - (setq org-hide-emphasis-markers t) +(setq org-agenda-sorting-strategy + (quote + ((agenda deadline-up priority-down) + (todo priority-down category-keep) + (tags priority-down category-keep) + (search category-keep)))) #+END_SRC - The default value for the org tag column is -77, which is weird for smaller width windows. I'd rather have the tags align horizontally with the header. - 45 is a good column number to do that. - +Customize the org agenda #+BEGIN_SRC emacs-lisp - (setq org-tags-column 45) -#+END_SRC +(defun me--org-skip-subtree-if-priority (priority) + "Skip an agenda subtree if it has a priority of PRIORITY. - Set the org-refile targets. - TODO: change maxlevel if necessary + PRIORITY may be one of the characters ?A, ?B, or ?C." + (let ((subtree-end (save-excursion (org-end-of-subtree t))) + (pri-value (* 1000 (- org-lowest-priority priority))) + (pri-current (org-get-priority (thing-at-point 'line t)))) + (if (= pri-value pri-current) + subtree-end + nil))) -#+BEGIN_SRC emacs-lisp -(setq org-refile-targets '((org-agenda-files . (:maxlevel . 1)))) +(setq org-agenda-custom-commands + '(("c" "Simple agenda view" + ((tags "PRIORITY=\"A\"" + ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done)) + (org-agenda-overriding-header "Hohe Priorität:"))) + (agenda "" + ((org-agenda-span 7) + (org-agenda-start-on-weekday nil) + (org-agenda-overriding-header "Nächste 7 Tage:"))) + (alltodo "" + ((org-agenda-skip-function '(or (me--org-skip-subtree-if-priority ?A) + (org-agenda-skip-if nil '(scheduled deadline)))) + (org-agenda-overriding-header "Sonstige Aufgaben:"))))))) #+END_SRC -*** Org key bindings - Set up some global key bindings that integrate with Org mode features -#+BEGIN_SRC emacs-lisp - (bind-key "C-c l" 'org-store-link) - (bind-key "C-c c" 'org-capture) - (bind-key "C-c a" 'org-agenda) -#+END_SRC +** *TODO* +org-super-agenda -Org overwrites RET and C-j, so I need to disable the rebinds +** org-caldav + :PROPERTIES: + :ID: 6bd24369-0d04-452f-85a0-99914dfb74ff + :END: +Vorerst deaktiviert, Nutzen evtl. nicht vorhanden #+BEGIN_SRC emacs-lisp - (define-key org-mode-map (kbd "RET") nil) ;;org-return - (define-key org-mode-map (kbd "C-j") nil) ;;org-return-indent +;;(use-package org-caldav +;; :ensure t +;; :config +;; (setq org-caldav-url "https://nextcloud.cloudsphere.duckdns.org/remote.php/dav/calendars/marc" +;; org-caldav-calendar-id "orgmode" +;; org-caldav-inbox (expand-file-name "~/Archiv/Organisieren/caldav-inbox") +;; org-caldav-files (concat MY--PATH_ORG_FILES "tasks"))) #+END_SRC -*** Org agenda - For a more detailed example [[https://github.com/sachac/.emacs.d/blob/83d21e473368adb1f63e582a6595450fcd0e787c/Sacha.org#org-agenda][see here]]. - - Custom todo-keywords, depending on environment +** journal + :PROPERTIES: + :ID: a1951e18-d862-4198-9652-016e979053c8 + :END: +[[https://github.com/bastibe/org-journal][Source]] #+BEGIN_SRC emacs-lisp -(pcase my/whoami - ("work_remote") - (setq org-todo-keywords - '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE"))) -) +(use-package org-journal + :if *sys/linux* + :ensure t + :defer t + :config + ;; feels hacky, but this way compiler error "assignment to free variable" disappears + (when (and (boundp 'org-journal-dir) + (boundp 'org-journal-enable-agenda-integration)) + (setq org-journal-dir MY--PATH_ORG_JOURNAl + org-journal-enable-agenda-integration t))) #+END_SRC - Sort org agenda by deadline and priority +* Programming +** misc +#+begin_src emacs-lisp +(use-package eldoc + :diminish eldoc-mode + :defer t) +#+end_src + +** Magit / Git + :PROPERTIES: + :ID: d3589460-317f-40f6-9056-053be9ba3217 + :END: +Little crash course in magit: +- magit-init to init a git project +- magit-status (C-x g) to call the status window +In status buffer: +- s stage files +- u unstage files +- U unstage all files +- a apply changes to staging +- c c commit (type commit message, then C-c C-c to commit) +- b b switch to another branch +- P u git push +- F u git pull #+BEGIN_SRC emacs-lisp - (setq org-agenda-sorting-strategy - (quote - ((agenda deadline-up priority-down) - (todo priority-down category-keep) - (tags priority-down category-keep) - (search category-keep))) - ) +(use-package magit + :ensure t + :defer t + :init + ; set git-path in work environment + (if (string-equal user-login-name "POH") + (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe") + ) + :bind (("C-x g" . magit-status))) #+END_SRC - Customize the org agenda +** LSP + :PROPERTIES: + :ID: 06ad00e0-44a6-4bfb-ba6f-b1672811e053 + :END: +Configuration for the language server protocol +*ACHTUNG* Dateipfad muss absolut sein, symlink im Pfad führt zumindest beim ersten Start zu Fehlern beim lsp +Sobald der lsp einmal lief, kann zukünftig der symlink-Pfad genommen werden. +Getestet wurde die funktionierende Datei selbst und neu erstellte Dateien im selben Pfad. +TODO Unterverzeichnisse wurden noch nicht getestet #+BEGIN_SRC emacs-lisp - (defun my-org-skip-subtree-if-priority (priority) - "Skip an agenda subtree if it has a priority of PRIORITY. - - PRIORITY may be one of the characters ?A, ?B, or ?C." - (let ((subtree-end (save-excursion (org-end-of-subtree t))) - (pri-value (* 1000 (- org-lowest-priority priority))) - (pri-current (org-get-priority (thing-at-point 'line t)))) - (if (= pri-value pri-current) - subtree-end - nil))) - - (setq org-agenda-custom-commands - '(("c" "Simple agenda view" - ((tags "PRIORITY=\"A\"" - ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done)) - (org-agenda-overriding-header "Hohe Priorität:"))) - (agenda "" - ((org-agenda-span 7) - (org-agenda-start-on-weekday nil) - (org-agenda-overriding-header "Nächsten 7 Tage:"))) - (alltodo "" - ((org-agenda-skip-function '(or (my-org-skip-subtree-if-priority ?A) - (org-agenda-skip-if nil '(scheduled deadline)))) - (org-agenda-overriding-header "Sonstige Aufgaben:")))))) - ) -#+END_SRC - -*** Org Capture - The basic format is: - hotkey - name - type - location - content - For todos a prompt for the title is demanded. This made it possible to place the cursor for the content to the right position. Just typing, C-c C-c, done! - -#+BEGIN_SRC emacs-lisp -(pcase my/whoami - ("home" - (setq org-capture-templates - `(("n" "note" entry (org-default-notes-file)) - ("t" "todo" entry (file+headline ,(concat PATH_ORG_FILES "tasks.org") "Tasks") - "* TODO %^{Title}\n %u\n %?\n") - ("c" "coding todo" entry (file+headline ,(concat PATH_ORG_FILES "tasks.org") "Tasks") - "* TODO %^{Title}\n %u %a\n %?\n") - ("p" "project" entry (file+headline ,(concat PATH_ORG_FILES "tasks.org") "Projects") - "* TODO %^{Title} %^g\n %u\n %?\n")))) - ("work_remote" - (setq org-capture-templates - `(("n" "note" entry (file org-default-notes-file)) - ("t" "todo" entry (file+headline ,(concat PATH_ORG_FILES "todo.org") "Todos") - "* TODO %^{Title}\n %u\n %?\n") - ("p" "project" entry (file+headline ,(concat PATH_ORG_FILES "projects.org") "Projekte") - "* OPEN %^{Title}\n %u\n** Beschreibung\n %?\n** Zu erledigen\n*** \n** Verlauf\n*** a\n")))) -) -#+END_SRC - -** Org babel languages - This code block is linux specific. Loading languages which aren't available seems to be a problem. - New: Load languages on demand. I need to test if this works as intended. -#+BEGIN_SRC emacs-lisp -(defadvice org-babel-execute-src-block (around load-language nil activate) - "Load language if needed" - (let ((language (org-element-property :language (org-element-at-point)))) - (unless (cdr (assoc (intern language) org-babel-load-languages)) - (add-to-list 'org-babel-load-languages (cons (intern language) t)) - (org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages)) - ad-do-it)) -#+END_SRC - -BEGIN_SRC emacs-lisp -(cond ((eq system-type 'gnu/linux) - (org-babel-do-load-languages -'org-babel-load-languages - '( - (C . t) - (calc . t) - (java . t) - (ipython . t) - (js . t) - (latex . t) - (ledger . t) - (beancount . t) - (lisp . t) - (python . t) - (R . t) - (ruby . t) - (scheme . t) - (shell . t) - (sqlite . t) - ) - )) -) -END_SRC - -#+BEGIN_SRC emacs-lisp -(defun my-org-confirm-babel-evaluate (lang body) - "Do not confirm evaluation for these languages." - (not (or (string= lang "beancount") - (string= lang "C") - (string= lang "emacs-lisp") - (string= lang "ipython") - (string= lang "java") - (string= lang "ledger") - (string= lang "python") - (string= lang "R") - (string= lang "sqlite")))) -(setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate) -#+END_SRC - -#+BEGIN_SRC emacs-lisp -(add-hook 'org-babel-after-execute-hook 'org-display-inline-images) -(add-hook 'org-mode-hook 'org-display-inline-images) -#+END_SRC - -** Org babel/source blocks - I like to have source blocks properly syntax highlighted and with the editing popup window staying within the same window so all the windows don't jump around. Also, having the top and bottom trailing lines in the block is a waste of space, so we can remove them - - I noticed that fontification doesn't work with markdown mode when the block is indented after editing it in the org src buffer - the leading #s for headers don't get fontified properly because they apppear as Org comments. Setting ~org-src-preserve-identation~ makes things consistent as it doesn't pad source blocks with leading spaces - -#+BEGIN_SRC emacs-lisp - (setq org-src-fontify-natively t - org-src-window-setup 'current-window - org-src-strip-leading-and-trailing-blank-lines t - org-src-preserve-indentation nil ; these two lines respect the indentation of - org-edit-src-content-indentation 0 ; the surrounding text around the source block - org-src-tab-acts-natively t) -#+END_SRC - - - -** Org babel helper functions - -* Pandoc - Convert between formats, like from org to html. - Pandoc needs to be installed on the system -#+BEGIN_EXAMPLE -sudo apt install pandoc -#+END_EXAMPLE - - Pandoc-mode is a minor mode to interact with pandoc -#+BEGIN_SRC emacs-lisp -(use-package pandoc-mode - :ensure t - :init - (add-hook 'markdown-mode-hook 'pandoc-mode)) -#+END_SRC - -* Emails - Currently following tools are required: - - notmuch (edit, read, tag, delete emails) - - isync /mbsync (fetch or sync emails) - - After setting up mbsync, notmuch must be configured. Execute "notmuch" from the command line to launch the setup wizard. After it, "notmuch new" to create a new database, which will index the available local e-mails. - - TODO: - - setup of mbsync on linux - - setup of notmuch on linux - - shell script for installation of isync and notmuch - - more config for notmuch? - - hydra for notmuch? - - maybe org-notmuch? - - some way to refresh the notmuch db before I run notmuch? - -#+BEGIN_SRC emacs-lisp -(unless (string-equal my/whoami "work_remote") - (use-package notmuch - :defer t - :ensure t - ) -) -#+END_SRC - -* Personal Finances - After trying ledger, I chose beancount. It is closer to real bookkeeping and has stricter rules. - Since there is no debian package, it is an option to install it via pip. - I picked /opt for the installation path - -#+BEGIN_EXAMPLE -sudo su -cd /opt -python3 -m venv beancount -source ./beancount/bin/activate -pip3 install wheel -pip3 install beancount -sleep 100 -echo "shell running!" -deactivate -#+END_EXAMPLE - - When using beancount, it will automatically pick the created virtual environment. - - Activate the beancount mode. ATTENTION: This mode is made by myself. - -#+BEGIN_SRC emacs-lisp -(unless (string-equal my/whoami "work_remote") - (load "/home/marc/.emacs.d/user-local/elisp/beancount-mode.el") ; somehow load-path in use-package doesn't work - (use-package beancount - :load-path "/home/marc/.emacs.d/elisp" - :defer t - :mode ("\\.beancount$" . beancount-mode) - :init - (add-hook 'beancount-mode-hook 'company/beancount-mode-hook) - (setenv "PATH" - (concat - "/opt/beancount/bin:" - (getenv "PATH")) - ) - :config - (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount") - ) -) -#+END_SRC - - To support org-babel, check if it can find the symlink to ob-beancount.el. - -#+BEGIN_SRC shell -orgpath=`find /home/marc/.emacs.d/elpa/ -type d -name "org-plus*" -print` -beansym="$orgpath/ob-beancount.el" -bean="/home/marc/Archiv/Programmierprojekte/Lisp/beancount-mode/ob-beancount.el" - -if [ -h "$beansym" ] -then - echo "$beansym found" -elif [ -e "$bean" ] -then - echo "creating symlink" - ln -s "$bean" "$beansym" -else - echo "$bean not found, symlink creation aborted" -fi -#+END_SRC - -#+RESULTS: -: /home/marc/.emacs.d/elpa/org-plus-contrib-20180521/ob-beancount.el found - - - Installing fava for reports is strongly recommended. - -#+BEGIN_EXAMPLE - cd /opt - python3 -m venv fava - source ./fava/bin/activate - pip3 install wheel - pip3 install fava - deactivate -#+END_EXAMPLE - - Start fava with -#+BEGIN_EXAMPLE - fava my_file.beancount -#+END_EXAMPLE - - It is accessable on this URL: [[http://127.0.0.1:5000][Fava]] - Beancount-mode can start fava and open the URL right away. - -* Programming -** Common things -List of plugins and settings which are shared between the language plugins - +(setq read-process-output-max (* 1024 1024)) ;; support reading large blobs of data for LSP's sake -Highlight whitespaces, tabs, empty lines. - -#+BEGIN_SRC emacs-lisp - (use-package whitespace - :demand t - :ensure nil - :diminish whitespace-mode;;mode shall be active, but not shown in mode line - :init - (dolist (hook '(prog-mode-hook - text-mode-hook - conf-mode-hook)) - (add-hook hook #'whitespace-mode)) -;; :hook ;;not working in use-package 2.3 -;; ((prog-mode . whitespace-turn-on) -;; (text-mode . whitespace-turn-on)) - :config - (setq-default whitespace-style '(face empty tab trailing)) - ) -#+END_SRC - -Disable Eldoc, it interferes with flycheck - -#+BEGIN_SRC emacs-lisp - (use-package eldoc - :ensure nil - :config - (global-eldoc-mode -1) - ) -#+END_SRC - -Colorize colors as text with their value -#+BEGIN_SRC emacs-lisp - (use-package rainbow-mode - :ensure t - :init - (add-hook 'prog-mode-hook 'rainbow-mode t) - :diminish rainbow-mode -;; :hook prog-mode ;; not working in use-package 2.3 - :config - (setq-default rainbow-x-colors-major-mode-list '()) - ) -#+END_SRC - -Highlight parens etc. for improved readability -#+BEGIN_SRC emacs-lisp -(use-package rainbow-delimiters - :ensure t - :config - (add-hook 'prog-mode-hook 'rainbow-delimiters-mode) -) -#+END_SRC - -Treat CamelCase combined words as individual words -#+BEGIN_SRC emacs-lisp -(use-package subword - :diminish subword-mode +(use-package lsp-mode + :defer t + :commands (lsp lsp-execute-code-action) + :custom + (lsp-auto-guess-root nil) + (lsp-prefer-flymake nil) ; use flycheck instead + (lsp-prefer-capf t) + (lsp-file-watch-threshold 5000) + (lsb-print-performance t) + (lsp-log-io nil) ; enable log only for debug + (lsp-enable-folding t) ; default, maybe evil-matchit instead for performance? + (lsp-diagnostics-modeline-scope :project) + (lsp-enable-file-watchers nil) + :bind (:map lsp-mode-map ("C-c C-f" . lsp-format-buffer)) + :hook + (((python-mode + js-mode + js2-mode + typescript-mode + web-mode + ) . lsp) + (lsp-mode . lsp-enable-which-key-integration) + (lsp-mode . lsp-diagnostics-modeline-mode)) :config - (add-hook 'python-mode-hook 'subword-mode)) -#+END_SRC + (setq lsp-diagnostics-package :none) ; disable flycheck-lsp for most modes + (add-hook 'web-mode-hook #'lsp-flycheck-enable)) ; enable flycheck-lsp for web-mode locally -** Smartparens - Smartparens is a beast on its own, so it's worth having a dedicated section for it -#+BEGIN_SRC emacs-lisp -(use-package smartparens +(use-package lsp-ui + :after lsp-mode :ensure t - :diminish smartparens-mode + :defer t + :diminish + :commands lsp-ui-mode :config - (add-hook 'prog-mode-hook 'smartparens-mode) -) -#+END_SRC -** Git -*** Magit - [[https://magit.vc/manual/magit/index.html][Link]] - I want to do git stuff here, not in a separate terminal window - - Little crashcourse in magit: - - magit-init to init a git project - - magit-status (C-x g) to call the status window - - in status buffer: - - s stage files - - u unstage files - - U unstage all files - - a apply changed to staging - - c c commit (type commit message, then C-c C-c to commit) - - b b switch to another branch - - P u git push - - F u git pull - -#+BEGIN_SRC emacs-lisp -(use-package magit + (setq lsp-ui-doc-enable t + lsp-ui-doc-header t + lsp-ui-doc-include-signature t + lsp-ui-doc-position 'top + lsp-ui-doc-border (face-foreground 'default) + lsp-ui-sideline-enable t + lsp-ui-sideline-ignore-duplicate t + lsp-ui-sideline-show-code-actions nil) + (when *sys/gui* + (setq lsp-ui-doc-use-webkit t)) + ;; workaround hide mode-line of lsp-ui-imenu buffer + (defadvice lsp-ui-imenu (after hide-lsp-ui-imenu-mode-line activate) + (setq mode-line-format nil))) + +;;NO LONGER SUPPORTED, USE company-capf / completion-at-point +;(use-package company-lsp +; :requires company +; :defer t +; :ensure t +; :config +; ;;disable client-side cache because lsp server does a better job +; (setq company-transformers nil +; company-lsp-async t +; company-lsp-cache-candidates nil)) +#+END_SRC + +** yasnippet + :PROPERTIES: + :ID: 935d89ef-645e-4e92-966f-2fe3bebb2880 + :END: +For useful snippet either install yasnippet-snippets or get them from here +[[https://github.com/AndreaCrotti/yasnippet-snippets][Github]] + +#+begin_src emacs-lisp +(use-package yasnippet :ensure t :defer t - :init - ;; set git-path in work environment - (if (string-equal user-login-name "POH") - (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe") - ) - :defer t - :bind (("C-x g" . magit-status)) -) -#+END_SRC -*** Git-gutter - Display line changes in gutter based on git history. Enable it everywhere - [[https://github.com/syohex/emacs-git-gutter][Source]] -#+BEGIN_SRC emacs-lisp -(use-package git-gutter - :ensure t + :diminish yas-minor-mode + :config + (setq yas-snippet-dirs (list (concat MY--PATH_USER_GLOBAL "snippets"))) + (yas-global-mode t) + (yas-reload-all) + (unbind-key "TAB" yas-minor-mode-map) + (unbind-key "" yas-minor-mode-map)) +#+end_src + +** hippie expand + :PROPERTIES: + :ID: c55245bc-813d-4816-a0ca-b4e2e793e28b + :END: +With hippie expand I am able to use yasnippet and emmet at the same time with the same key. +#+begin_src emacs-lisp +(use-package hippie-exp :defer t + :bind + ("C-" . hippie-expand) :config - (global-git-gutter-mode t) - :diminish git-gutter-mode -) -#+END_SRC - - Some persistent navigation in git-gutter is nice, so here's a hydra for it: - -#+BEGIN_SRC emacs-lisp - (defhydra hydra-git-gutter (:body-pre (git-gutter-mode 1) - :hint nil) - " -^Git Gutter^ ^Git^ ^misc^ -^──────────^────────^───^────────────────^────^────────────────────────── -_j_: next hunk _s_tage hunk _q_uit -_k_: previous hunk _r_evert hunk _g_ : call magit-status -_h_: first hunk _p_opup hunk -_l_: last hunk set start _R_evision -^^ ^^ ^^ -" - ("j" git-gutter:next-hunk) - ("k" git-gutter:previous-hunk) - ("h" (progn (goto-char (point-min)) - (git-gutter:next-hunk 1))) - ("l" (progn (goto-char (point-min)) - (git-gutter:previous-hunk 1))) - ("s" git-gutter:stage-hunk) - ("r" git-gutter:revert-hunk) - ("p" git-gutter:popup-hunk) - ("R" git-gutter:set-start-revision) - ("q" nil :color blue) - ("g" magit-status) -) -#+END_SRC + (setq hippie-expand-try-functions-list + '(yas-hippie-try-expand emmet-expand-line))) +#+end_src -*** Git-timemachine - Time machine lets me step through the history of a file as recorded in git. - [[https://github.com/pidu/git-timemachine][Source]] +** flycheck + :PROPERTIES: + :ID: 3d8f2547-c5b3-46d0-91b0-9667f9ee5c47 + :END: #+BEGIN_SRC emacs-lisp -(use-package git-timemachine +(use-package flycheck :ensure t - :defer t -) -#+END_SRC - -** Company backend hooks - - Backend configuration for python-mode - - Common backends are: - - company-files: files & directory - - company-keywords: keywords - - company-capf: ?? - - company-abbrev: ?? - - company-dabbrev: dynamic abbreviations - - company-ispell: ?? - - So far I cannot differenciate a true python mode and a source block of ipython in org-mode, so the python-mode-hook should include both completion backends. - -#+BEGIN_SRC emacs-lisp - (defun company/python-mode-hook() - (message "company/python-mode-hook activated") - (set (make-local-variable 'company-backends) - '(company-jedi)) -; '((company-jedi company-yasnippet company-dabbrev-code) company-dabbrev)) -; '((company-ob-ipython company-lsp))) -; '((company-ob-ipython company-jedi))) -; '((company-jedi company-dabbrev-code company-yasnippet) company-capf company-files)) -; '((company-lsp company-yasnippet) company-capf company-dabbrev company-files)) - (company-mode t) - ) -#+END_SRC - - I have yet to find the proper hook to call this. -#+BEGIN_SRC emacs-lisp - (defun company/ipython-mode-hook() - (message "company/ipython-mode-hook activated") - (set (make-local-variable 'company-backends) - '((company-ob-ipython))) - (company-mode t) - ) -#+END_SRC - -#+BEGIN_SRC emacs-lisp -(defun company/ess-mode-hook() - (message "company/ess-mode-hook activated") -; (set (make-local-variable 'company-backends) -; '((company-ess-backend company-R-args company-R-objects))) - (ess-indent-with-fancy-comments nil) - (company-mode t)) -#+END_SRC - - (defun add-pcomplete-to-capf () - (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)) -;; (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t) - (add-hook 'org-mode-hook #'add-pcomplete-to-capf) - -Backend for Orgmode -#+BEGIN_SRC emacs-lisp -(defun company/org-mode-hook() - (set (make-local-variable 'company-backends) - '(company-capf company-files)) - (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t) - (message "company/org-mode-hook") - (company-mode t) -) -#+END_SRC - -Backend configuration for lisp-mode - -#+BEGIN_SRC emacs-lisp - (defun company/elisp-mode-hook() - (set (make-local-variable 'company-backends) - '((company-elisp company-dabbrev) company-capf company-files)) - (company-mode t) - ) -#+END_SRC - -Backend configuration for beancount - -#+BEGIN_SRC emacs-lisp -(defun company/beancount-mode-hook() - (set (make-local-variable 'company-backends) - '(company-beancount)) -; '((company-beancount company-dabbrev) company-capf company-files)) - (company-mode t) -) -#+END_SRC - -Backend configuration for lua -#+BEGIN_SRC emacs-lisp -(defun company/lua-mode-hook() - (set (make-local-variable 'company-backends) - '(company-lua)) - (company-mode t) -) -#+END_SRC - -** Misc Company packages - -Addon to sort suggestions by usage - -#+BEGIN_SRC emacs-lisp - (use-package company-statistics - :ensure t - :after company - :init - (setq company-statistics-file (concat PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el") - :config - (company-statistics-mode 1) - ) -#+END_SRC - -Get a popup with documentation of the completion candidate. -For the popups the package pos-tip.el is used and automatically installed. -[[https://github.com/expez/company-quickhelp][Company Quickhelp]] -[[https://www.emacswiki.org/emacs/PosTip][See here for Pos-Tip details]] - -#+BEGIN_SRC emacs-lisp - (use-package company-quickhelp - :ensure t - :after company - :config - (company-quickhelp-mode 1) - ) -#+END_SRC - -Maybe add [[https://github.com/hlissner/emacs-company-dict][company-dict]]? It's a dictionary based on major modes, plus it has Yasnippet integration. - -** Flycheck - Show errors right away! -#+BEGIN_SRC emacs-lisp - (use-package flycheck - :ensure t - :diminish flycheck-mode " ✓" - :init - (setq flycheck-emacs-lisp-load-path 'inherit) - (add-hook 'after-init-hook #'global-flycheck-mode) -; (add-hook 'python-mode-hook (lambda () -; (semantic-mode 1) -; (flycheck-select-checker 'python-pylint))) - ) + :hook + ((css-mode . flycheck-mode) + (emacs-lisp-mode . flycheck-mode) + (python-mode . flycheck-mode)) + :defer 1.0 + :init + (setq flycheck-emacs-lisp-load-path 'inherit) + :config + (setq-default + flycheck-check-synta-automatically '(save mode-enabled) + flycheck-disable-checkers '(emacs-lisp-checkdoc) + eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck + flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages #+END_SRC ** Projectile - Brings search functions on project level - -#+BEGIN_SRC emacs-lisp + :PROPERTIES: + :ID: a90329fd-4d36-435f-8308-a2771ac4c320 + :END: +Manage projects and jump quickly between its files +#+BEGIN_SRC emacs-lisp + (defun set-workon_home() + (setenv "WORKON_HOME" (projectile-project-root)) + (message "set workon_home")) (use-package projectile :ensure t - :defer t - :bind - (("C-c p p" . projectile-switch-project) - ("C-c p s s" . projectile-ag)) +; :defer 1.0 + :diminish +; :hook (projectile-after-switch-project . (lambda () +; (set-workon_home) +; (message "set workon_home"))) ;; for pyvenv to auto activate environment +; :hook (projectile-after-switch-project #'set-workon_home) + :bind-keymap + ("C-c p" . projectile-command-map) + ;:preface :init - (setq-default - projectile-cache-file (concat PATH_USER_LOCAL ".projectile-cache") - projectile-known-projects-file (concat PATH_USER_LOCAL ".projectile-bookmarks")) + (setq-default projectile-cache-file (concat MY--PATH_USER_LOCAL ".projectile-cache") + projectile-known-projects-file (concat MY--PATH_USER_LOCAL ".projectile-bookmarks")) :config (projectile-mode t) - (setq-default - projectile-completion-system 'ivy - projectile-enable-caching t - projectile-mode-line '(:eval (projectile-project-name))) - ) -#+END_SRC - -** Yasnippet - Snippets! - TODO: yas-minor-mode? what's that? +; (add-hook 'projectile-after-switch-project-hook #'set-workon_home) + (setq-default projectile-completion-system 'ivy + projectile-enable-caching t + projectile-mode-line '(:eval (projectile-project-name)))) -#+BEGIN_SRC emacs-lisp -(use-package yasnippet +;; requires ripgrep on system for rg functions +(use-package counsel-projectile :ensure t - :defer t - :diminish yas-minor-mode - :init - (yas-global-mode t) -;; (setq yas-snippet-dirs '(concat PATH_USER_GLOBAL "snippets")) - :mode ("\\.yasnippet" . snippet-mode) - :config - (unless (string-equal my/whoami "work_remote") ; very hacky, but yas-reload-all throws a wrongp error at work - (yas-reload-all)) ;; ensure snippets are updated and available, necessary when not using global-mode -) + :config (counsel-projectile-mode)) #+END_SRC -#+RESULTS: - -** Lisp - - Not sure about this one, but dynamic binding gets some bad vibes. +** smartparens + :PROPERTIES: + :ID: 997ec416-33e6-41ed-8c7c-75a7bc47d285 + :END: #+BEGIN_SRC emacs-lisp -(setq lexical-binding t) +(use-package smartparens + :ensure t + :diminish smartparens-mode + :bind + (:map smartparens-mode-map + ("C-M-f" . sp-forward-sexp) + ("C-M-b" . sp-backward-sexp) + ("C-M-a" . sp-backward-down-sexp) + ("C-M-e" . sp-up-sexp) + ("C-M-w" . sp-copy-sexp) + ("M-k" . sp-kill-sexp) + ("C-M-" . sp-slice-sexp-killing-backward) + ("C-S-" . sp-slice-sexp-killing-around) + ("C-]" . sp-select-next-thing-exchange)) + :config + (setq sp-show-pair-from-inside nil + sp-escape-quotes-after-insert nil) + (require 'smartparens-config)) + #+END_SRC +** lisp + :PROPERTIES: + :ID: a2bc3e08-b203-49d3-b337-fb186a14eecb + :END: #+BEGIN_SRC emacs-lisp -(add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook) +(use-package elisp-mode + :defer t) #+END_SRC -Add some helpers to handle and understand macros -#+BEGIN_SRC emacs-lisp -(use-package macrostep +** web +:PROPERTIES: +:ID: c0b0b4e4-2162-429f-b80d-6e5334b1290e +:END: + +apt install npm +sudo npm install -g vscode-html-languageserver-bin +evtl alternativ typescript-language-server? + +Unter Windows: +Hier runterladen: https://nodejs.org/dist/latest/ +und in ein Verzeichnis entpacken. +Optional: PATH erweitern unter Windows (so kann exec-path-from-shell den Pfad ermitteln): +PATH=P:\path\to\node;%path% + + #+BEGIN_SRC emacs-lisp +(use-package web-mode :ensure t :defer t + :mode + ("\\.phtml\\'" + "\\.tpl\\.php\\'" + "\\.djhtml\\'" + "\\.[t]?html?\\'") :init - (define-key emacs-lisp-mode-map (kbd "C-c e") 'macrostep-expand) - (define-key emacs-lisp-mode-map (kbd "C-c c") 'macrostep-collapse)) -#+END_SRC + (if *work_remote* + (setq exec-path (append exec-path '("P:/Tools/node")))) + :config + (setq web-mode-enable-auto-closing t + web-mode-enable-auto-pairing t) + (add-hook 'web-mode-hook 'smartparens-mode)) + #+END_SRC -** LUA - #+BEGIN_SRC emacs-lisp - (use-package lua-mode - :ensure t - :mode (("\\.lua$" . lua-mode)) - :init - (add-hook 'lua-mode-hook 'company/lua-mode-hook) - ) - #+END_SRC -** R - TODO: test it - For now only enable ESS at home. Not sure if it is useful at work. - Also I got "locate-file" errors at work; the debugger listet random files not related to anything within the emacs configuraion -#+BEGIN_SRC emacs-lisp -(pcase my/whoami - ("home" - (use-package ess-r-mode ;ess-site lädt alle Sprachen (Julia, Stata, S, S+, SAS, BUGS/JAGS - :ensure ess -; :load-path "/usr/share/emacs/site-lisp/ess/" -; :load-path "/home/marc/.emacs.d/elpa/ess-20180825.900/" - :defer t - :mode (("\\.R$" . R-mode) - ("\\.r$" . R-mode)) -; :init (require 'ess-site) - :commands - (R-mode) - :config - (use-package ess-R-data-view :ensure t) -; (use-package ess-smart-equals :ensure t) ; requires julia-mode - (use-package ess-smart-underscore :ensure t) -; (use-package ess-view :ensure t) ; requires julia-mode - (setq ess-use-flymake nil - ess-use-ido nil ;;else ESS will use ido whenever possible - ess-eval-visibly 'nowait - ess-ask-for-ess-directory nil - ess-local-process-name "R" - ess-use-tracebug t - ess-indent-with-fancy-comments nil ; otherwise ess indents comments sometimes - ess-describe-at-point-method 'tooltip))) ; 'tooltip or nil (buffer) -) -#+END_SRC -** Lua - #+BEGIN_SRC emacs-lisp - (use-package lua-mode - :defer t - :ensure t - :mode "\\.lua\\'" - :config - (setq lua-indent-level 2)) - #+END_SRC -** Python -*** Intro - Systemwide following packages need to be installed: - - venv - - pylint / pylint3 (depending on default python version) - flycheck complains if no pylint is available and org tries to fontify python code natively. - - The virtual environments need to have following modules installed: - - wheel (for some reason it isn't pulled by other packages, yet they complain about missing wheel) - - jedi - - epc - - pylint -*** Python-Mode - Automatically start python-mode when opening a .py-file. - Not sure if python.el is better than python-mode.el. - See [[https://github.com/jorgenschaefer/elpy/issues/887][here]] for info about ~python-shell-completion-native-enable~. - The custom function is to run inferiour processes (do I really need that?), see [[https://emacs.stackexchange.com/questions/16361/how-to-automatically-run-inferior-process-when-loading-major-mode][here]]. - - Also limit the completion backends to those which make sense in Python. - -#+BEGIN_SRC emacs-lisp -(use-package python - :mode ("\\.py\\'" . python-mode) - :interpreter ("python" . python-mode) - :defer t - :after company-mode - :init - (message "python mode init") - (add-hook 'python-mode-hook (lambda () - (company/python-mode-hook) - (semantic-mode t) - (flycheck-select-checker 'python-pylint))) - :config - (setq python-shell-completion-native-enable nil) -) -#+END_SRC -*** IPython-Mode - Not sure if this configuraton will interfere with Python-Mode -#+BEGIN_SRC emacs-lisp -(use-package ob-ipython +Emmet offers snippets, similar to yasnippet. +Default completion is C-j +[[https://github.com/smihica/emmet-mode#usage][Github]] + +#+begin_src emacs-lisp +(use-package emmet-mode :ensure t :defer t - :init - (add-hook 'ob-ipython-mode-hook (lambda () - 'company/ipython-mode-hook - (semantic-mode t) - (flycheck-select-checker 'pylint)))) -#+END_SRC - -*** Jedi / Company - Jedi is a backend for python autocompletion and needs to be installed on the server: - - pip install jedi - Code checks need to be installed, too: - - pip install flake8 - - If jedi doesn't work, it might be a problem with jediepcserver.py. - See [[https://github.com/tkf/emacs-jedi/issues/293][here]] - To fix it: - - Figure out which jediepcserver is running (first guess is melpa/jedi-core../jediepcserver.py - - Change some code: - -#+BEGIN_SRC python -100 return dict( -101 # p.get_code(False) should do the job. But jedi-vim use replace. -102 # So follow what jedi.vim does... -103 - params=[p.get_code().replace('\n', '') for p in call_def.params], -103 + params=[p.name for p in call_def.params], -104 index=call-def.index, -105 - call_name=call_def.call_name, -105 + call_name=call_def.name, -106 ) -#+END_SRC - -#+BEGIN_SRC emacs-lisp - (use-package company-jedi - :defer t -;; :after company - :ensure t - :config - (setq jedi:environment-virtualenv (list (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))) - (setq jedi:python-environment-directory (list (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))) - (add-hook 'python-mode-hook 'jedi:setup) - (setq jedi:complete-on-dot t) - (setq jedi:use-shortcuts t) -;; (add-hook 'python-mode-hook 'company/python-mode-hook) - ) -#+END_SRC - -*** Virtual Environments - A wrapper to handle virtual environments. - I strongly recommend to install virtual environments on the terminal, not through this wrapper, but changing venvs is fine. - - TODO: automatically start an inferior python process or switch to it if already created - -#+BEGIN_SRC emacs-lisp - (use-package pyvenv - :ensure t - :defer t - :init - (setenv "WORKON_HOME" (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")) - :config - (pyvenv-mode t) - (defun my/pyvenv-post-activate-hook() -; (setq jedi:environment-root pyvenv-virtual-env) -; (setq jedi:environment-virtualenv pyvenv-virtual-env) -; (setq jedi:tooltip-method '(nil)) ;; variants: nil or pos-tip and/or popup - (setq python-shell-virtualenv-root pyvenv-virtual-env) - ;; default traceback, other option M-x jedi:toggle-log-traceback - ;; traceback is in jedi:pop-to-epc-buffer -; (jedi:setup) -;; (company/python-mode-hook) -; (setq jedi:server-args '("--log-traceback")) - (message "pyvenv-post-activate-hook activated")) - (add-hook 'pyvenv-post-activate-hooks 'my/pyvenv-post-activate-hook) - ) -#+END_SRC - - I want Emacs to automatically start the proper virtual environment. - Required is a .python-version file with, content in the first line being /path/to/virtualenv/ - [[https://github.com/marcwebbie/auto-virtualenv][Github source]] + :hook + ((web-mode . emmet-mode) + (css-mode . emmet-mode)) + :config + (unbind-key "C-" emmet-mode-keymap)) +#+end_src - Depends on pyvenv -#+BEGIN_SRC emacs-lisp - (use-package auto-virtualenv - :ensure t -;; :after pyvenv - :defer t - :init - (add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv) - ;; activate on changing buffers - ;; (add-hook 'window-configuration-change-hook 'auto-virtualenv-set-virtualenv) - ;; activate on focus in - ;; (add-hook 'focus-in-hook 'auto-virtualenv-set-virtualenv) - ) -#+END_SRC +*** JavaScript -*** Visuals - Highlight indentations +npm install -g typescript-language-server typescript +maybe only typescript? +npm install -g prettier -#+BEGIN_SRC emacs-lisp -(use-package highlight-indentation +#+begin_src emacs-lisp +(use-package rjsx-mode :ensure t - :init - (add-hook 'python-mode-hook 'highlight-indentation-current-column-mode) - (add-hook 'python-mode-hook 'highlight-indentation-mode) - :config - (set-face-background 'highlight-indentation-face "#454545") - (set-face-background 'highlight-indentation-current-column-face "#656565")) -#+END_SRC -*** Python language server (inactive) - On python side following needs to be installed: - - python-language-server[all] - - First test for lsp-python. - Some intro: [[https://vxlabs.com/2018/06/08/python-language-server-with-emacs-and-lsp-mode/][Intro]] - Source python language server: [[https://github.com/palantir/python-language-server][Link]] - Source lsp-mode: - Source lsp-python: [[https://github.com/emacs-lsp/lsp-python][Link]] - Source company-lsp: [[https://github.com/tigersoldier/company-lsp][Link]] - Source lsp-ui: [[https://github.com/emacs-lsp/lsp-ui][Link]] - -BEGIN_SRC emacs-lisp -(use-package lsp-mode + :mode ("\\.js\\'" + "\\.jsx'")) +; :config +; (setq js2-mode-show-parse-errors nil +; js2-mode-show-strict-warnings nil +; js2-basic-offset 2 +; js-indent-level 2) +; (setq-local flycheck-disabled-checkers (cl-union flycheck-disable-checkers +; '(javascript-jshint)))) ; jshint doesn"t work for JSX + +(use-package tide :ensure t + :after (rjsx-mode company flycheck) +; :hook (rjsx-mode . setup-tide-mode) :config - ;; make sure we have lsp-imenu everywhere we have lsp - (require 'lsp-imenu) - (add-hook 'lsp-after-open-hook 'lsp-enable-imenu) - ;; get lsp-python-enable defined - ;; nb: use either projectile-project-root or ffip-get-project-root-directory - ;; or any other function that can be used to find the root dir of a project - (lsp-define-stdio-client lsp-python "python" - #'projectile-project-root - '("pyls")) - ;; make sure this is activated when python-mode is activated - ;; lsp-python-enable is created by macro above - (add-hook 'python-mode-hook - (lambda () - (lsp-python-enable) - (company/python-mode-hook))) - ;; lsp extras - (use-package lsp-ui - :ensure t - :config - (setq lsp-ui-sideline-ignore-duplicate t) - (add-hook 'lsp-mode-hook 'lsp-ui-mode)) - - (use-package company-lsp - :ensure t) -; :config -; (push 'company-lsp company-backends)) - - ;; NB: only required if you prefer flake8 instead of the default - ;; send pyls config via lsp-after-initialize-hook -- harmless for - ;; other servers due to pyls key, but would prefer only sending this - ;; when pyls gets initialised (:initialize function in - ;; lsp-define-stdio-client is invoked too early (before server - ;; start)) - (defun lsp-set-cfg () - (let ((lsp-cfg `(:pyls (:configurationSources ("flake8"))))) - ;; TODO: check lsp--cur-workspace here to decide per server / project - (lsp--set-configuration lsp-cfg))) - - (add-hook 'lsp-after-initialize-hook 'lsp-set-cfg) -) -END_SRC -BEGIN_SRC emacs-lisp -(use-package lsp-mode + (defun setup-tide-mode () + "Setup function for tide." + (interactive) + (tide-setup) + (flycheck-mode t) + (setq flycheck-check-synta-automatically '(save mode-enabled)) + (tide-hl-identifier-mode t))) + +;; needs npm install -g prettier +(use-package prettier-js :ensure t - :defer t) - -(add-hook 'lsp-mode-hook #'(lambda () - (customize-set-variable 'lsp-enable-eldoc nil) - (flycheck-mode 1) - (company-mode 1))) - -(use-package lsp-ui + :after (rjsx-mode) + :defer t + :diminish prettier-js-mode + :hook ((js2-mode rsjx-mode) . prettier-js-mode)) +#+end_src + +** YAML + :PROPERTIES: + :ID: 95413247-04d5-4e02-8431-06c162ec8f3b + :END: +#+begin_src emacs-lisp +(use-package yaml-mode + :if *sys/linux* :ensure t - :defer t) + :defer t + :mode ("\\.yml$" . yaml-mode)) +#+end_src -(use-package company-lsp +** R +#+BEGIN_SRC emacs-lisp +(use-package ess :ensure t - :defer t) + :defer t + :init + (if *work_remote* + (setq exec-path (append exec-path '("P:/Tools/R/bin/x64")) + org-babel-R-command "P:/Tools/R/bin/x64/R --slave --no-save"))) +#+END_SRC -(use-package lsp-python +** Python + :PROPERTIES: + :ID: 8c76fcd1-c57c-48ab-8af0-aa782de6337f + :END: + Systemseitig muss python-language-server installiert sein: +apt install python3-pip python3-setuptools python3-wheel +apt install build-essential python3-dev + pip3 install 'python-language-server[all]' + + Statt obiges: npm install -g pyright + + für andere language servers + https://github.com/emacs-lsp/lsp-mode#install-language-server + + #+BEGIN_SRC emacs-lisp +;(use-package lsp-python-ms +; :if *sys/linux* +; :ensure t +; :defer t +; :custom (lsp-python-ms-auto-install-server t)) + +(use-package lsp-pyright :ensure t :after lsp-mode :defer t - :init - (add-hook 'python-mode-hook #'(lambda () - (lsp-python-enable) - (flycheck-select-checker 'python-flake8)))) - -END_SRC -** Latex - Requirements for Debian: - - texlive (texlive-base?) - - elpa-pdf-tools - - dh-autoreconf? - - Recommended: - - texlive-lang-german - - texlive-latex-extra - - The midnight mode hook is disabled for now, because CVs with my pic just look weird in this mode. - -#+BEGIN_SRC emacs-lisp -(unless (string-equal my/whoami "work_remote") - (use-package pdf-tools - :ensure t - :defer t - :mode (("\\.pdf\\'" . pdf-view-mode)) - :init -; (add-hook 'pdf-view-mode-hook 'pdf-view-midnight-minor-mode) - :config - (pdf-tools-install) - (setq pdf-view-resize-factor 1.1 ;; more finegraned zoom - pdf-view-midnight-colors '("#c6c6c6" . "#363636") - TeX-view-program-selection '((output-pdf "pdf-tools")) - TeX-view-program-list '(("pdf-tools" "Tex-pdf-tools-sync-view"))) +; :custom +; (lsp-pyright-auto-import-completions nil) +; (lsp-pyright-typechecking-mode "off") ) -) -#+END_SRC - - For latex-preview-pane a patch might be necessary (as of 2017-10), see the issue [[https://github.com/jsinglet/latex-preview-pane/issues/37][here]]. - Without it, the preview pane won't update, even when compiling works fine. -#+BEGIN_SRC - latex-preview-pane-update-p() - --- (doc-view-revert-buffer nil t) - +++ (revert-buffer nil t 'preserve-modes) +(use-package python + :if *sys/linux* + :delight "π " + :defer t + :bind (("M-[" . python-nav-backward-block) + ("M-]" . python-nav-forward-block))) + +(use-package pyvenv + :if *sys/linux* + :ensure t + :defer t + :after python + :hook ((python-mode . pyvenv-mode) + (python-mode . (lambda () + (if-let ((pyvenv-directory (find-pyvenv-directory (buffer-file-name)))) + (pyvenv-activate pyvenv-directory)) + (lsp)))) + :custom + (pyvenv-default-virtual-env-name "env") + (pyvenv-mode-line-indicator '(pyvenv-virtual-env-name ("[venv:" pyvenv-virtual-env-name "]"))) + :preface + (defun find-pyvenv-directory (path) + "Check if a pyvenv directory exists." + (cond + ((not path) nil) + ((file-regular-p path) (find-pyvenv-directory (file-name-directory path))) + ((file-directory-p path) + (or + (seq-find + (lambda (path) (file-regular-p (expand-file-name "pyvenv.cfg" path))) + (directory-files path t)) + (let ((parent (file-name-directory (directory-file-name path)))) + (unless (equal parent path) (find-pyvenv-directory parent)))))))) + + ;; manage multiple python version + ;; needs to be installed on system +; (use-package pyenv-mode +; :ensure t +; :after python +; :hook ((python-mode . pyenv-mode) +; (projectile-switch-project . projectile-pyenv-mode-set)) +; :custom (pyenv-mode-set "3.8.5") +; :preface +; (defun projectile-pyenv-mode-set () +; "Set pyenv version matching project name." +; (let ((project (projectile-project-name))) +; (if (member project (pyenv-mode-versions)) +; (pyenv-mode-set project) +; (pyenv-mode-unset))))) + + ;) + + + #+END_SRC +* beancount +** Installation + :PROPERTIES: + :ID: 2c329043-b7a9-437d-a5cf-f2ad6514be91 + :END: +#+BEGIN_SRC shell +sudo su +cd /opt +python3 -m venv beancount +source ./beancount/bin/activate +pip3 install wheel +pip3 install beancount +sleep 100 +echo "shell running!" +deactivate #+END_SRC - After that M-x byte-compile-file #+BEGIN_SRC emacs-lisp -(use-package latex-preview-pane - :ensure t +(use-package beancount + :if *sys/linux* + :load-path "user-global/elisp" +; :ensure t :defer t + :mode + ("\\.beancount$" . beancount-mode) + :hook + (beancount-mode . my/beancount-company) :init - ;; one of these works - (add-hook 'LaTeX-mode-hook 'latex-preview-pane-mode) - (add-hook 'latex-mode-hook 'latex-preview-pane-mode) - (setq auto-mode-alist - (append '(("\\.tex$" . latex-mode)) auto-mode-alist)) -) - -;; necessary, because linum-mode isn't compatible and prints errors -(add-hook 'pdf-view-mode-hook (lambda () (linum-mode -1))) + (add-hook 'beancount-mode-hook 'company/beancount-mode-hook) + :config + (defun my/beancount-company () + (set (make-local-variable 'company-backends) + '(company-beancount))) + (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount")) #+END_SRC -** Markdown - Major mode to edit markdown files. - For previews it needs markdown installed on the system. - For debian: -#+BEGIN_EXAMPLE - sudo apt install markdown -#+END_EXAMPLE +To support org-babel, check if it can find the symlink to ob-beancount.el -#+BEGIN_SRC emacs-lisp - (use-package markdown-mode - :ensure t - :defer t) -#+END_SRC - -** Config languages -#+BEGIN_SRC emacs-lisp -(use-package nginx-mode - :ensure t - :defer t) -#+END_SRC -** Hydra Flycheck -Flycheck is necessary, obviously +#+BEGIN_SRC shell +orgpath=`find /home/marc/.emacs.d/elpa/ -type d -name "org-plus*" -print` +beansym="$orgpath/ob-beancount.el + bean="/home/marc/Archiv/Programmierprojekte/Lisp/beancount-mode/ob-beancount.el" -#+BEGIN_SRC emacs-lisp - (defhydra hydra-flycheck (:color blue) - - " -^ -^Flycheck^ ^Errors^ ^Checker^ -^────────^──────────^──────^────────────^───────^─────────── -_q_ quit _<_ previous _?_ describe -_m_ manual _>_ next _d_ disable -_v_ verify setup _f_ check _s_ select -^^ ^^ ^^ -" - ("q" nil) - ("<" flycheck-previous-error :color red) - (">" flycheck-next-error :color red) - ("?" flycheck-describe-checker) - ("d" flycheck-disable-checker) - ("f" flycheck-buffer) - ("m" flycheck-manual) - ("s" flycheck-select-checker) - ("v" flycheck-verify-setup) - ) + if [ -h "$beansym" ] + then + echo "$beansym found" + elif [ -e "$bean" ] + then + echo "creating symlink" + ln -s "$bean" "$beansym" + else + echo "$bean not found, symlink creation aborted" + fi #+END_SRC +Fava is strongly recommended. +#+BEGIN_SRC shell +cd /opt +python3 -m venv fava +source ./fava/bin/activate +pip3 install wheel +pip3 install fava +deactivate +#+END_SRC -* Orchestrate the configuration - Some settings should be set for all systems, some need to be specific (like my job-emacs doesn't need development tools). - -** Common - -** Home - -** Work - I mainly only use org -** Work, Hyper-V - For testing purproses I keep a working emacs in a debian on hyper-v. The demands here are different to the other work-emacs +Start fava with fava my_file.beancount -* Finishing - Stuff which I want to run in the end +It is accessable on this URL: [[http://127.0.0.1:5000][Fava]] +Beancount-mode can start fava and open the URL right away. -#+BEGIN_SRC emacs-lisp -(message (emacs-init-time)) -#+END_SRC +* Stuff after everything else +Set garbage collector to a smaller value to let it kick in faster. +Maybe a problem on Windows? +#+begin_src emacs-lisp +(setq gc-cons-threshold (* 2 1000 1000)) +#+end_src diff --git a/create-init.bat b/create-init.bat deleted file mode 100644 index 4d2b108..0000000 --- a/create-init.bat +++ /dev/null @@ -1,9 +0,0 @@ -del init.el -del init.elc - -echo (require 'org) > init.el -echo (find-file (concat user-emacs-directory "init.org")) >> init.el -echo (org-babel-tangle) >> init.el -echo (load-file (concat user-emacs-directory "init.el")) >> init.el -echo (byte-compile-file (concat user-emacs-directory "init.el")) >> init.el - diff --git a/create-init.sh b/create-init.sh deleted file mode 100755 index dc7f0ac..0000000 --- a/create-init.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -rm ./init.el -rm ./init.elc - -# caused 'invalid byte-code object' -# when use-package already installed and running emacs after this script -rm -rf ./elpa/use-package* - -cat <./init.el -(require 'org) -(find-file (concat user-emacs-directory "init.org")) -(org-babel-tangle) -(load-file (concat user-emacs-directory "init.el")) -(byte-compile-file (concat user-emacs-directory "init.el")) -EOF diff --git a/init.org b/init.org deleted file mode 100644 index e3cba56..0000000 --- a/init.org +++ /dev/null @@ -1,1362 +0,0 @@ -#+TITLE: Emacs configuration file -#+AUTHOR: Marc -#+BABEL: :cache yes -#+PROPERTY: header-args :tangle yes - -* TODOS -- early-init.el? What to outsource here? -- Paket exec-path-from-shell, um PATH aus Linux auch in emacs zu haben -- Smart mode line? -- Theme -- evil-collection or custom in init file? -- Hydra -- General -- (defalias 'list-buffers 'ibuffer) ;; change default to ibuffer -- ido? -- treemacs (for linux) -- treemacs-evil? -- treemacs-projectile - windmove? -- tramp (in linux) -- visual-regexp -- org configuration: paths -- org custom agenda -- org-ql (related to org agendas) -- org configuration: everything else -- beancount configuration from config.org -- CONTINUE TODO from config.org at Programming -- all-the-icons? -- lispy? [[https://github.com/abo-abo/lispy]] - -* Header - :PROPERTIES: - :ID: a14d7c89-24ea-41ae-b185-944bab49aa02 - :END: -Emacs variables are dynamically scoped. That's unusual for most languages, so disable it here, too -#+begin_src emacs-lisp -;;; init.el --- -*- lexical-binding: t -*- -#+end_src - -* First start -:PROPERTIES: -:ID: 1c24d48e-0124-4a0b-8e78-82e4c531e818 -:END: -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 - -#+BEGIN_SRC emacs-lisp :tangle no -(require 'org') -(find-file (concat user-emacs-directory "init.org")) -(org-babel-tangle) -(load-file (concat user-emacs-directory "init.el")) -(byte-compile-file (concat user-emacs-directory "init.el")) -#+END_SRC - -This function updates init.el whenever changes in init.org are made. The update will be active after saving. - -#+BEGIN_SRC emacs-lisp -(defun me/tangle-init () - "If the current buffer is 'init.org', the code blocks are tangled, and the tangled file is compiled." - (when (equal (buffer-file-name) - (expand-file-name (concat user-emacs-directory "init.org"))) - ;; avoid running hooks - (let ((prog-mode-hook nil)) - (org-babel-tangle) - (byte-compile-file (concat user-emacs-directory "init.el")) - (load-file user-init-file)))) -(add-hook 'after-save-hook 'me/tangle-init) -#+END_SRC - -A small function to measure start up time. -Compare that to -emacs -q --eval='(message "%s" (emacs-init-time))' -(roughly 0.27s) -https://blog.d46.us/advanced-emacs-startup/ -#+begin_src emacs-lisp -(add-hook 'emacs-startup-hook - (lambda () - (message "Emacs ready in %s with %d garbage collections." - (format "%.2f seconds" - (float-time - (time-subtract after-init-time before-init-time))) - gcs-done))) - -(setq gc-cons-threshold (* 50 1000 1000)) -#+end_src - -#+BEGIN_SRC emacs-lisp -(require 'package) - -(add-to-list 'package-archives '("elpa" . "https://elpa.gnu.org/packages/") t) -(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) -(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t) -(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t) - -; fix for bug 34341 -(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3") - -(when (< emacs-major-version 27) - (package-initialize)) -#+END_SRC - -#+BEGIN_SRC emacs-lisp -(unless (package-installed-p 'use-package) - (package-refresh-contents) - (package-install 'use-package)) - -(eval-when-compile - (setq use-package-enable-imenu-support t) - (require 'use-package)) -(require 'bind-key) - -(setq use-package-verbose nil) - -(use-package diminish - :ensure t) -#+END_SRC - -cl is deprecated in favor for cl-lib, some packages like emmet still depend on cl. -Shut off the compiler warning about it. -Maybe turn it on again at some point before the next major emacs upgrade -#+begin_src emacs-lisp -(setq byte-compile-warnings '(cl-functions)) -#+end_src - -* Default settings -:PROPERTIES: -:ID: 3512d679-d111-4ccd-8372-6fc2acbc0374 -:END: -#+BEGIN_SRC emacs-lisp -(defconst *sys/gui* - (display-graphic-p) - "Is emacs running in a gui?") - -(defconst *sys/linux* - (string-equal system-type 'gnu/linux) - "Is the system running Linux?") - -(defconst *sys/windows* - (string-equal system-type 'windows-nt) - "Is the system running Windows?") - -(defconst *home_desktop* - (string-equal (system-name) "marc") - "Is emacs running on my desktop?") - -(defconst *home_laptop* - (string-equal (system-name) "laptop") - "Is emacs running on my laptop?") - -(defconst *work_local* - (string-equal (system-name) "PMPCNEU08") - "Is emacs running at work on the local system?") - -(defconst *work_remote* - (string-equal (system-name) "PMTS01") - "Is emacs running at work on the remote system?") -#+END_SRC - -#+BEGIN_SRC emacs-lisp -(defvar MY--PATH_USER_LOCAL (concat user-emacs-directory "user-local/")) -(defvar MY--PATH_USER_GLOBAL (concat user-emacs-directory "user-global/")) - -(add-to-list 'custom-theme-load-path (concat MY--PATH_USER_GLOBAL "themes")) - -(when *sys/linux* - (defconst MY--PATH_ORG_FILES (expand-file-name "~/Archiv/Organisieren/")) - (defconst MY--PATH_ORG_FILES_MOBILE (expand-file-name "~/Archiv/Organisieren/mobile/"))) - (defconst MY--PATH_ORG_JOURNAl (expand-file-name "~/Archiv/Organisieren/Journal/")) -(when *work_remote* - (defconst MY--PATH_ORG_FILES "p:/Eigene Dateien/Notizen/") - (defconst MY--PATH_ORG_FILES_MOBILE nil) ;; hacky way to prevent "free variable" compiler error - (defconst MY--PATH_ORG_JOURNAL nil) ;; hacky way to prevent "free variable" compiler error - (defconst MY--PATH_START "p:/Eigene Dateien/Notizen/")) -(setq recentf-save-file (concat MY--PATH_USER_LOCAL "recentf")) - -;; exclude some dirs from spamming recentf -(use-package recentf - :config - (recentf-mode) - (setq recentf-exclude '(".*-autoloads\\.el\\" - "[/\\]\\.elpa/"))) - -(setq custom-file (concat MY--PATH_USER_LOCAL "custom.el")) ;; don't spam init.e with saved customization settings -(setq backup-directory-alist `((".*" . ,temporary-file-directory))) -(setq auto-save-file-name-transforms `((".*" ,temporary-file-directory))) -(setq-default create-lockfiles nil) ;; disable lock files, can cause trouble in e.g. lsp-mode -(defalias 'yes-or-no-p 'y-or-n-p) ;; answer with y and n -(setq custom-safe-themes t) ;; don't ask me if I want to load a theme -(setq sentence-end-double-space nil) ;; don't coun two spaces after a period as the end of a sentence. -(delete-selection-mode t) ;; delete selected region when typing -(save-place-mode 1) ;; saves position in file when it's closed -(setq save-place-forget-unreadable-files nil) ;; checks if file is readable before saving position - -(set-charset-priority 'unicode) -(setq locale-coding-system 'utf-8) -(set-terminal-coding-system 'utf-8) -(set-keyboard-coding-system 'utf-8) -(set-selection-coding-system 'utf-8) -(setq default-process-coding-system '(utf-8-unix . utf-8-unix)) -(if *sys/windows* - (prefer-coding-system 'utf-8-dos) - (prefer-coding-system 'utf-8)) - -(blink-cursor-mode -1) ;; turn off blinking cursor -(column-number-mode t) -(setq uniquify-buffer-name-style 'forward) -(setq-default indent-tabs-mode nil) ;; avoid tabs in place of multiple spaces (they look bad in tex) -(setq-default indicate-empty-lines t) ;; show empty lines -(setq scroll-margin 5 ;; smooth scrolling - scroll-conservatively 10000 - scroll-preserve-screen-position 1 - scroll-step 1) -(global-hl-line-mode t) ;; highlight current line -(menu-bar-mode 0) ;; disable menu bar -(tool-bar-mode 0) ;; disable tool bar -(scroll-bar-mode 0) ;; disable scroll bar -(setq ring-bell-function 'ignore ;; disable pc speaker bell - visible-bell t) -#+END_SRC - -Bookmarks -Usage: -- C-x r m (bookmark-set): add bookmark -- C-x r l (list-bookmark): list bookmarks -- C-x r b (bookmark-jump): open bookmark - -Edit bookmarks (while in bookmark file): -- d: mark current item -- x: delete marked items -- r: rename current item -- s: save changes - -#+begin_src emacs-lisp -(use-package bookmark - :custom - (bookmark-default-file (concat MY--PATH_USER_LOCAL "bookmarks"))) -#+end_src - -Some windows specific stuff -#+BEGIN_SRC emacs-lisp -(when *sys/windows* - (remove-hook 'find-file-hook 'vc-refresh-state) - (progn - (setq gc-cons-threshold (* 511 1024 1024) - gc-cons-percentage 0.5 - garbage-collection-messages t) - (run-with-idle-timer 5 t #'garbage-collect)) - (when (boundp 'w32-pipe-read-delay) - (setq w32-pipe-read-delay 0)) - (when (boundp 'w32-get-true-file-attributes) - (setq w32-get-true-file-attributes nil))) -#+END_SRC - -* visuals -** Font - :PROPERTIES: - :ID: dc8eb670-e6bb-4bfb-98f0-aae1860234fb - :END: -#+BEGIN_SRC emacs-lisp -(when *sys/linux* - (set-face-font 'default "Hack-10")) -(when *work_remote* - (set-face-font 'default "Lucida Sans Typewriter-11")) -#+END_SRC - -** Themes - :PROPERTIES: - :ID: 9ccf37c0-6837-43cb-bed8-5a353799d8b1 - :END: - -#+BEGIN_SRC emacs-lisp -(defun my/toggle-theme () - (interactive) - (when (or *sys/windows* *sys/linux*) - (if (eq (car custom-enabled-themes) 'tango-dark) - (progn (disable-theme 'tango-dark) - (load-theme 'tango)) - (progn - (disable-theme 'tango) - (load-theme 'tango-dark))))) - -(bind-key "C-c t" 'my/toggle-theme) -#+END_SRC - -Windows Theme: -#+BEGIN_SRC emacs-lisp -(when *sys/windows* - (load-theme 'tango)) -(when *sys/linux* - (load-theme 'plastic)) -#+END_SRC - -** line wrappings - :PROPERTIES: - :ID: 14ae933e-2941-4cc3-82de-38f90f91bfd3 - :END: -#+BEGIN_SRC emacs-lisp -(global-visual-line-mode) -(diminish 'visual-line-mode) -(use-package adaptive-wrap - :ensure t - :config - (add-hook 'visual-line-mode-hook #'adaptive-wrap-prefix-mode)) - ; :init - ; (when (fboundp 'adaptive-wrap-prefix-mode) - ; (defun my/activate-adaptive-wrap-prefix-mode () - ; "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously." - ; (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1))) - ; (add-hook 'visual-line-mode-hook 'my/activate-adaptive-wrap-prefix-mode))) -#+END_SRC - -** line numbers - :PROPERTIES: - :ID: 7b969436-98c9-4b61-ba7a-9fb22c9781ad - :END: -#+BEGIN_SRC emacs-lisp -(use-package display-line-numbers - :init - (add-hook 'prog-mode-hook 'display-line-numbers-mode) - (add-hook 'org-src-mode-hook 'display-line-numbers-mode) - :config - (setq-default display-line-numbers-type 'visual - display-line-numbers-current-absolute t - display-line-numbers-with 4 - display-line-numbers-widen t)) - ; (add-hook 'emacs-lisp-mode-hook 'display-line-numbers-mode) -#+END_SRC - -** misc - :PROPERTIES: - :ID: a2873138-16ee-4990-89a2-26eab778ea74 - :END: -#+BEGIN_SRC emacs-lisp -(use-package rainbow-mode - :ensure t - :diminish - :hook - ((org-mode - emacs-lisp-mode) . rainbow-mode)) - -(use-package delight - :ensure t) - -(show-paren-mode t) ;; show other part of brackets -(use-package rainbow-delimiters - :ensure t - :hook - (prog-mode . rainbow-delimiters-mode)) -#+END_SRC - -* undo - :PROPERTIES: - :ID: d57621b2-5472-4c89-a520-b4133db0b9af - :END: -#+BEGIN_SRC emacs-lisp -(use-package undo-tree - :ensure t - :diminish undo-tree-mode - :init - (global-undo-tree-mode 1)) -#+END_SRC - -* ace-window -#+begin_src emacs-lisp -(use-package ace-window - :ensure t - :bind - (:map global-map - ("C-x o" . ace-window))) -#+end_src - -* imenu-list - :PROPERTIES: - :ID: 0ae27ec9-5d77-43cf-ac76-5e12cc959046 - :END: - A minor mode to show imenu in a sidebar. - Call imenu-list-smart-toggle. - [[https://github.com/bmag/imenu-list][Source]] - -#+BEGIN_SRC emacs-lisp -(use-package imenu-list - :ensure t - :defer t - :config - (setq imenu-list-focus-after-activation t - imenu-list-auto-resize t - imenu-list-position 'right) - :bind - (:map global-map - ([f9] . imenu-list-smart-toggle)) - :custom - (org-imenu-depth 4)) -#+END_SRC - -* which-key - :PROPERTIES: - :ID: a880f079-b3a3-4706-bf1e-5f6c680101f1 - :END: -#+BEGIN_SRC emacs-lisp -(use-package which-key - :ensure t - :diminish which-key-mode - :defer t - :hook - (after-init . which-key-mode) - :config - (which-key-setup-side-window-bottom) - (setq which-key-idle-delay 0.5)) -#+END_SRC - -* abbrev -#+begin_src emacs-lisp -(use-package abbrev - :diminish abbrev-mode - :hook - ((text-mode org-mode) . abbrev-mode) - :init - (setq abbrev-file-name (concat MY--PATH_USER_GLOBAL "abbrev_tables.el")) - :config - (if (file-exists-p abbrev-file-name) - (quietly-read-abbrev-file)) - (setq save-abbrevs 'silently)) ;; don't bother me with asking for abbrev saving -#+end_src -* Evil - :PROPERTIES: - :ID: 80ca70e2-a146-46db-b581-418d655dc1fc - :END: - -#+BEGIN_SRC emacs-lisp -(use-package evil - :ensure t - :defer .1 ;; don't block emacs when starting, load evil immediately after startup - :config - (evil-mode 1)) -#+END_SRC - -* General (key mapper) - :PROPERTIES: - :ID: a20f183f-d41a-4dff-bc37-3bc4e25c8036 - :END: -#+BEGIN_SRC emacs-lisp -(use-package general - :ensure t) - -(general-define-key - :states 'normal - :keymaps 'imenu-list-major-mode-map - "RET" '(imenu-list-goto-entry :which-key "goto") - "TAB" '(hs-toggle-hiding :which-key "collapse") - "d" '(imenu-list-display-entry :which-key "show") - "q" '(imenu-list-quit-window :which-key "quit")) -#+END_SRC - -* ivy / counsel / swiper - :PROPERTIES: - :ID: 55c74ba9-7761-4545-8ddd-087d6ee33e4b - :END: - -#+BEGIN_SRC emacs-lisp -; (require 'ivy) -(use-package ivy - :ensure t - :diminish - (ivy-mode . "") - :defer t - :init - (ivy-mode 1) - :bind - ("C-r" . ivy-resume) ;; overrides isearch-backwards binding - :config - (setq ivy-use-virtual-buffers t ;; recent files and bookmarks in ivy-switch-buffer - ivy-height 20 ;; height of ivy window - ivy-count-format "%d/%d" ;; current and total number - ivy-re-builders-alist ;; regex replaces spaces with * - '((t . ivy--regex-plus)))) - -; make counsel-M-x more descriptive -(use-package ivy-rich - :ensure t - :defer t - :init - (ivy-rich-mode 1)) - -(use-package counsel - :ensure t - :defer t - :bind - (("M-x" . counsel-M-x) - ("C-x C-f" . counsel-find-file) - ("C-x C-r" . counsel-recentf) - ("C-x b" . counsel-switch-buffer) - ("C-c C-f" . counsel-git) - ("C-c h f" . counsel-describe-function) - ("C-c h v" . counsel-describe-variable) - ("M-i" . counsel-imenu))) -; :map minibuffer-local-map ;;currently mapped to evil-redo -; ("C-r" . 'counsel-minibuffer-history))) - -(use-package swiper - :ensure t - :bind - ("C-s" . swiper)) - -(use-package ivy-hydra - :ensure t) -#+END_SRC - -* misc -#+begin_src emacs-lisp -(use-package autorevert - :diminish auto-revert-mode) -#+end_src - -* company - :PROPERTIES: - :ID: 944563b6-b04a-44f2-9b21-a6a3e200867c - :END: -#+BEGIN_SRC emacs-lisp -(use-package company - :defer 1 - :diminish - :defer t - :bind - (("C-" . company-complete) - :map company-active-map - ("RET" . nil) - ([return] . nil) - ("TAB" . company-complete-selection) - ([tab] . company-complete-selection) - ("" . company-complete-common) - ("" . company-abort)) - :hook - (after-init . global-company-mode) - (emacs-lisp-mode . my/company-elisp) - (org-mode . my/company-org) - :config - (defun my/company-elisp () - (message "set up company for elisp") - (set (make-local-variable 'company-backends) - '(company-yasnippet - company-capf - company-dabbrev-code - company-files))) - (defun my/company-org () - (set (make-local-variable 'company-backends) - '(company-capf company-files)) - ;; (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t) - (message "setup company for org")) - (setq company-idle-delay .2 - company-minimum-prefix-length 1 - company-require-match nil - company-show-numbers t - company-tooltip-align-annotations t)) - -(use-package company-statistics - :ensure t - :after company - :defer t - :init - (setq company-statistics-file (concat MY--PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el") - :config - (company-statistics-mode 1)) - -(use-package company-dabbrev - :ensure nil - :after company - :defer t - :config - (setq-default company-dabbrev-downcase nil)) - -;; adds a info box right of the cursor with doc of the function -(use-package company-box - :ensure t - :diminish - :defer t - :hook - (company-mode . company-box-mode)) -; :init -; (add-hook 'company-mode-hook 'company-box-mode)) -#+END_SRC - -* orgmode -** org - :PROPERTIES: - :ID: b89d7639-080c-4168-8884-bd5d8965f466 - :END: -#+BEGIN_SRC emacs-lisp -(use-package org - :ensure org-plus-contrib - :mode (("\.org$" . org-mode)) - :diminish org-indent-mode - :defer t - :hook - (org-mode . org-indent-mode) - (org-source-mode . smartparens-mode) -; :init -; (add-hook 'org-mode-hook 'company/org-mode-hook) -; (add-hook 'org-src-mode-hook 'smartparens-mode) -; (add-hook 'org-mode-hook 'org-indent-mode) - :config - (defun my/org-company () - (set (make-local-variable 'company-backends) - '(company-capf company-files)) - (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t) - (message "company/org-mode-hook")) - (setq org-modules (quote (org-id - org-habit - org-tempo ;; easy templates - ))) - (setq org-default-notes-file (concat MY--PATH_ORG_FILES "notes.org") - org-agenda-files (list (concat MY--PATH_ORG_FILES "notes.org") - (concat MY--PATH_ORG_FILES "projects.org") - (concat MY--PATH_ORG_FILES "tasks.org"))) - (when *sys/linux* - (nconc org-agenda-files - (directory-files-recursively MY--PATH_ORG_FILES_MOBILE "\\.org$"))) - (setq org-id-locations-file (concat MY--PATH_USER_LOCAL ".org-id-locations") - org-log-into-drawer "LOGBOOK") - - ;; some display customizations - (setq org-pretty-entities t - org-startup-truncated t - org-startup-align-all-tables t) - - ;; some source code blocks customizations - (setq org-src-window-setup 'current-window ;; C-c ' opens in current window - org-src-fontify-natively t ;; use syntax highlighting in code blocks - org-src-preserve-indentation t ;; no extra indentation - org-src-tab-acts-natively t) - - (setq org-log-done 'time)) ;; create timestamp when task is done -#+END_SRC - -** languages - :PROPERTIES: - :ID: ad3af718-d0db-448c-9f75-eb9e250c2862 - :END: -Set some languages and disable confirmation for evaluating code blocks C-c C-c - -+BEGIN_SRC emacs-lisp -(org-babel-do-load-languages - 'org-babel-load-languages - '((emacs-lisp . t) - (gnuplot . t) - (js . t) - (latex . t) - (lisp . t) - (python . t) - (shell . t) - (sqlite . t) - (org . t) - (R . t) - (scheme . t))) - -(setq org-confirm-babel-evaluate nil) -+END_SRC -Another setup, because org-babel-do-load-languages requires eager loading -#+begin_src emacs-lisp -(use-package ob-org - :defer t - :ensure org-plus-contrib - :commands - (org-babel-execute:org - org-babel-expand-body:org)) - -(use-package ob-python - :defer t - :ensure org-plus-contrib - :commands (org-babel-execute:python)) - -(use-package ob-js - :defer t - :ensure org-plus-contrib - :commands (org-babel-execute:js)) - -(use-package ob-shell - :defer t - :ensure org-plus-contrib - :commands - (org-babel-execute:sh - org-babel-expand-body:sh - - org-babel-execute:bash - org-babel-expand-body:bash)) - -(use-package ob-emacs-lisp - :defer t - :ensure org-plus-contrib - :commands - (org-babel-execute:emacs-lisp - org-babel-expand-body:emacs-lisp)) - -(use-package ob-lisp - :defer t - :ensure org-plus-contrib - :commands - (org-babel-execute:lisp - org-babel-expand-body:lisp)) - -(use-package ob-gnuplot - :defer t - :ensure org-plus-contrib - :commands - (org-babel-execute:gnuplot - org-babel-expand-body:gnuplot)) - -(use-package ob-sqlite - :defer t - :ensure org-plus-contrib - :commands - (org-babel-execute:sqlite - org-babel-expand-body:sqlite)) - -(use-package ob-latex - :defer t - :ensure org-plus-contrib - :commands - (org-babel-execute:latex - org-babel-expand-body:latex)) - -(use-package ob-R - :defer t - :ensure org-plus-contrib - :commands - (org-babel-execute:R - org-babel-expand-body:R)) - -(use-package ob-scheme - :defer t - :ensure org-plus-contrib - :commands - (org-babel-execute:scheme - org-babel-expand-body:scheme)) -#+end_src - -** habits - :PROPERTIES: - :ID: fcc91d0a-d040-4910-b2cf-3221496a3842 - :END: -#+BEGIN_SRC emacs-lisp -(require 'org-habit) ;;TODO Lösung ohne require finden, scheint mir nicht ideal zu sein, nur um ein org-modul zu aktivieren -;; (add-to-list 'org-modules "org-habit") -(setq org-habit-graph-column 80 - org-habit-preceding-days 30 - org-habit-following-days 7 - org-habit-show-habits-only-for-today nil) -#+END_SRC - -** org-id - :PROPERTIES: - :ID: c4017c45-d650-410c-8bd4-bc3cf42bbbb9 - :END: -Currently it causes some debugger errors "not a standard org time string", so it's disabled -#+BEGIN_SRC emacs-lisp -;; (use-package org-id -;; :config -;; (setq org-id-link-to-org-use-id t) -;; (org-id-update-id-locations)) ;; update id file .org-id-locations on startup -#+END_SRC - -** org-agenda - :PROPERTIES: - :ID: 03b67efb-4179-41e5-bc2e-c472b13f8be6 - :END: -Custom keywords, depending on environment -#+BEGIN_SRC emacs-lisp -(when *work_remote* - (setq org-todo-keywords - '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE" "CANCELLED")))) -#+END_SRC - -Add some key bindings -#+BEGIN_SRC emacs-lisp -(bind-key "C-c l" 'org-store-link) -(bind-key "C-c c" 'org-capture) -(bind-key "C-c a" 'org-agenda) -#+END_SRC - -Sort agenda by deadline and priority -#+BEGIN_SRC emacs-lisp -(setq org-agenda-sorting-strategy - (quote - ((agenda deadline-up priority-down) - (todo priority-down category-keep) - (tags priority-down category-keep) - (search category-keep)))) -#+END_SRC - -Customize the org agenda -#+BEGIN_SRC emacs-lisp -(defun me--org-skip-subtree-if-priority (priority) - "Skip an agenda subtree if it has a priority of PRIORITY. - - PRIORITY may be one of the characters ?A, ?B, or ?C." - (let ((subtree-end (save-excursion (org-end-of-subtree t))) - (pri-value (* 1000 (- org-lowest-priority priority))) - (pri-current (org-get-priority (thing-at-point 'line t)))) - (if (= pri-value pri-current) - subtree-end - nil))) - -(setq org-agenda-custom-commands - '(("c" "Simple agenda view" - ((tags "PRIORITY=\"A\"" - ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done)) - (org-agenda-overriding-header "Hohe Priorität:"))) - (agenda "" - ((org-agenda-span 7) - (org-agenda-start-on-weekday nil) - (org-agenda-overriding-header "Nächste 7 Tage:"))) - (alltodo "" - ((org-agenda-skip-function '(or (me--org-skip-subtree-if-priority ?A) - (org-agenda-skip-if nil '(scheduled deadline)))) - (org-agenda-overriding-header "Sonstige Aufgaben:"))))))) -#+END_SRC - -** *TODO* -org-super-agenda - -** org-caldav - :PROPERTIES: - :ID: 6bd24369-0d04-452f-85a0-99914dfb74ff - :END: -Vorerst deaktiviert, Nutzen evtl. nicht vorhanden -#+BEGIN_SRC emacs-lisp -;;(use-package org-caldav -;; :ensure t -;; :config -;; (setq org-caldav-url "https://nextcloud.cloudsphere.duckdns.org/remote.php/dav/calendars/marc" -;; org-caldav-calendar-id "orgmode" -;; org-caldav-inbox (expand-file-name "~/Archiv/Organisieren/caldav-inbox") -;; org-caldav-files (concat MY--PATH_ORG_FILES "tasks"))) -#+END_SRC - -** journal - :PROPERTIES: - :ID: a1951e18-d862-4198-9652-016e979053c8 - :END: -[[https://github.com/bastibe/org-journal][Source]] - -#+BEGIN_SRC emacs-lisp -(use-package org-journal - :if *sys/linux* - :ensure t - :defer t - :config - ;; feels hacky, but this way compiler error "assignment to free variable" disappears - (when (and (boundp 'org-journal-dir) - (boundp 'org-journal-enable-agenda-integration)) - (setq org-journal-dir MY--PATH_ORG_JOURNAl - org-journal-enable-agenda-integration t))) -#+END_SRC - -* Programming -** misc -#+begin_src emacs-lisp -(use-package eldoc - :diminish eldoc-mode - :defer t) -#+end_src - -** Magit / Git - :PROPERTIES: - :ID: d3589460-317f-40f6-9056-053be9ba3217 - :END: -Little crash course in magit: -- magit-init to init a git project -- magit-status (C-x g) to call the status window -In status buffer: -- s stage files -- u unstage files -- U unstage all files -- a apply changes to staging -- c c commit (type commit message, then C-c C-c to commit) -- b b switch to another branch -- P u git push -- F u git pull - -#+BEGIN_SRC emacs-lisp -(use-package magit - :ensure t - :defer t - :init - ; set git-path in work environment - (if (string-equal user-login-name "POH") - (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe") - ) - :bind (("C-x g" . magit-status))) -#+END_SRC - -** LSP - :PROPERTIES: - :ID: 06ad00e0-44a6-4bfb-ba6f-b1672811e053 - :END: -Configuration for the language server protocol -*ACHTUNG* Dateipfad muss absolut sein, symlink im Pfad führt zumindest beim ersten Start zu Fehlern beim lsp -Sobald der lsp einmal lief, kann zukünftig der symlink-Pfad genommen werden. -Getestet wurde die funktionierende Datei selbst und neu erstellte Dateien im selben Pfad. -TODO Unterverzeichnisse wurden noch nicht getestet - -#+BEGIN_SRC emacs-lisp -(setq read-process-output-max (* 1024 1024)) ;; support reading large blobs of data for LSP's sake - -(use-package lsp-mode - :defer t - :commands (lsp lsp-execute-code-action) - :custom - (lsp-auto-guess-root nil) - (lsp-prefer-flymake nil) ; use flycheck instead - (lsp-prefer-capf t) - (lsp-file-watch-threshold 5000) - (lsb-print-performance t) - (lsp-log-io nil) ; enable log only for debug - (lsp-enable-folding t) ; default, maybe evil-matchit instead for performance? - (lsp-diagnostics-modeline-scope :project) - (lsp-enable-file-watchers nil) - :bind (:map lsp-mode-map ("C-c C-f" . lsp-format-buffer)) - :hook - (((python-mode - js-mode - js2-mode - typescript-mode - web-mode - ) . lsp) - (lsp-mode . lsp-enable-which-key-integration) - (lsp-mode . lsp-diagnostics-modeline-mode)) - :config - (setq lsp-diagnostics-package :none) ; disable flycheck-lsp for most modes - (add-hook 'web-mode-hook #'lsp-flycheck-enable)) ; enable flycheck-lsp for web-mode locally - -(use-package lsp-ui - :after lsp-mode - :ensure t - :defer t - :diminish - :commands lsp-ui-mode - :config - (setq lsp-ui-doc-enable t - lsp-ui-doc-header t - lsp-ui-doc-include-signature t - lsp-ui-doc-position 'top - lsp-ui-doc-border (face-foreground 'default) - lsp-ui-sideline-enable t - lsp-ui-sideline-ignore-duplicate t - lsp-ui-sideline-show-code-actions nil) - (when *sys/gui* - (setq lsp-ui-doc-use-webkit t)) - ;; workaround hide mode-line of lsp-ui-imenu buffer - (defadvice lsp-ui-imenu (after hide-lsp-ui-imenu-mode-line activate) - (setq mode-line-format nil))) - -;;NO LONGER SUPPORTED, USE company-capf / completion-at-point -;(use-package company-lsp -; :requires company -; :defer t -; :ensure t -; :config -; ;;disable client-side cache because lsp server does a better job -; (setq company-transformers nil -; company-lsp-async t -; company-lsp-cache-candidates nil)) -#+END_SRC - -** yasnippet - :PROPERTIES: - :ID: 935d89ef-645e-4e92-966f-2fe3bebb2880 - :END: -For useful snippet either install yasnippet-snippets or get them from here -[[https://github.com/AndreaCrotti/yasnippet-snippets][Github]] - -#+begin_src emacs-lisp -(use-package yasnippet - :ensure t - :defer t - :diminish yas-minor-mode - :config - (setq yas-snippet-dirs (list (concat MY--PATH_USER_GLOBAL "snippets"))) - (yas-global-mode t) - (yas-reload-all) - (unbind-key "TAB" yas-minor-mode-map) - (unbind-key "" yas-minor-mode-map)) -#+end_src - -** hippie expand - :PROPERTIES: - :ID: c55245bc-813d-4816-a0ca-b4e2e793e28b - :END: -With hippie expand I am able to use yasnippet and emmet at the same time with the same key. -#+begin_src emacs-lisp -(use-package hippie-exp - :defer t - :bind - ("C-" . hippie-expand) - :config - (setq hippie-expand-try-functions-list - '(yas-hippie-try-expand emmet-expand-line))) -#+end_src - -** flycheck - :PROPERTIES: - :ID: 3d8f2547-c5b3-46d0-91b0-9667f9ee5c47 - :END: -#+BEGIN_SRC emacs-lisp -(use-package flycheck - :ensure t - :hook - ((css-mode . flycheck-mode) - (emacs-lisp-mode . flycheck-mode) - (python-mode . flycheck-mode)) - :defer 1.0 - :init - (setq flycheck-emacs-lisp-load-path 'inherit) - :config - (setq-default - flycheck-check-synta-automatically '(save mode-enabled) - flycheck-disable-checkers '(emacs-lisp-checkdoc) - eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck - flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages -#+END_SRC - -** Projectile - :PROPERTIES: - :ID: a90329fd-4d36-435f-8308-a2771ac4c320 - :END: -Manage projects and jump quickly between its files -#+BEGIN_SRC emacs-lisp - (defun set-workon_home() - (setenv "WORKON_HOME" (projectile-project-root)) - (message "set workon_home")) -(use-package projectile - :ensure t -; :defer 1.0 - :diminish -; :hook (projectile-after-switch-project . (lambda () -; (set-workon_home) -; (message "set workon_home"))) ;; for pyvenv to auto activate environment -; :hook (projectile-after-switch-project #'set-workon_home) - :bind-keymap - ("C-c p" . projectile-command-map) - ;:preface - :init - (setq-default projectile-cache-file (concat MY--PATH_USER_LOCAL ".projectile-cache") - projectile-known-projects-file (concat MY--PATH_USER_LOCAL ".projectile-bookmarks")) - :config - (projectile-mode t) -; (add-hook 'projectile-after-switch-project-hook #'set-workon_home) - (setq-default projectile-completion-system 'ivy - projectile-enable-caching t - projectile-mode-line '(:eval (projectile-project-name)))) - -;; requires ripgrep on system for rg functions -(use-package counsel-projectile - :ensure t - :config (counsel-projectile-mode)) -#+END_SRC - -** smartparens - :PROPERTIES: - :ID: 997ec416-33e6-41ed-8c7c-75a7bc47d285 - :END: -#+BEGIN_SRC emacs-lisp -(use-package smartparens - :ensure t - :diminish smartparens-mode - :bind - (:map smartparens-mode-map - ("C-M-f" . sp-forward-sexp) - ("C-M-b" . sp-backward-sexp) - ("C-M-a" . sp-backward-down-sexp) - ("C-M-e" . sp-up-sexp) - ("C-M-w" . sp-copy-sexp) - ("M-k" . sp-kill-sexp) - ("C-M-" . sp-slice-sexp-killing-backward) - ("C-S-" . sp-slice-sexp-killing-around) - ("C-]" . sp-select-next-thing-exchange)) - :config - (setq sp-show-pair-from-inside nil - sp-escape-quotes-after-insert nil) - (require 'smartparens-config)) - -#+END_SRC - -** lisp - :PROPERTIES: - :ID: a2bc3e08-b203-49d3-b337-fb186a14eecb - :END: -#+BEGIN_SRC emacs-lisp -(use-package elisp-mode - :defer t) -#+END_SRC - -** web -:PROPERTIES: -:ID: c0b0b4e4-2162-429f-b80d-6e5334b1290e -:END: - -apt install npm -sudo npm install -g vscode-html-languageserver-bin -evtl alternativ typescript-language-server? - -Unter Windows: -Hier runterladen: https://nodejs.org/dist/latest/ -und in ein Verzeichnis entpacken. -Optional: PATH erweitern unter Windows (so kann exec-path-from-shell den Pfad ermitteln): -PATH=P:\path\to\node;%path% - - #+BEGIN_SRC emacs-lisp -(use-package web-mode - :ensure t - :defer t - :mode - ("\\.phtml\\'" - "\\.tpl\\.php\\'" - "\\.djhtml\\'" - "\\.[t]?html?\\'") - :init - (if *work_remote* - (setq exec-path (append exec-path '("P:/Tools/node")))) - :config - (setq web-mode-enable-auto-closing t - web-mode-enable-auto-pairing t) - (add-hook 'web-mode-hook 'smartparens-mode)) - #+END_SRC - -Emmet offers snippets, similar to yasnippet. -Default completion is C-j -[[https://github.com/smihica/emmet-mode#usage][Github]] - -#+begin_src emacs-lisp -(use-package emmet-mode - :ensure t - :defer t - :hook - ((web-mode . emmet-mode) - (css-mode . emmet-mode)) - :config - (unbind-key "C-" emmet-mode-keymap)) -#+end_src - -*** JavaScript - -npm install -g typescript-language-server typescript -maybe only typescript? -npm install -g prettier - -#+begin_src emacs-lisp -(use-package rjsx-mode - :ensure t - :mode ("\\.js\\'" - "\\.jsx'")) -; :config -; (setq js2-mode-show-parse-errors nil -; js2-mode-show-strict-warnings nil -; js2-basic-offset 2 -; js-indent-level 2) -; (setq-local flycheck-disabled-checkers (cl-union flycheck-disable-checkers -; '(javascript-jshint)))) ; jshint doesn"t work for JSX - -(use-package tide - :ensure t - :after (rjsx-mode company flycheck) -; :hook (rjsx-mode . setup-tide-mode) - :config - (defun setup-tide-mode () - "Setup function for tide." - (interactive) - (tide-setup) - (flycheck-mode t) - (setq flycheck-check-synta-automatically '(save mode-enabled)) - (tide-hl-identifier-mode t))) - -;; needs npm install -g prettier -(use-package prettier-js - :ensure t - :after (rjsx-mode) - :defer t - :diminish prettier-js-mode - :hook ((js2-mode rsjx-mode) . prettier-js-mode)) -#+end_src - -** YAML - :PROPERTIES: - :ID: 95413247-04d5-4e02-8431-06c162ec8f3b - :END: -#+begin_src emacs-lisp -(use-package yaml-mode - :if *sys/linux* - :ensure t - :defer t - :mode ("\\.yml$" . yaml-mode)) -#+end_src - -** R -#+BEGIN_SRC emacs-lisp -(use-package ess - :ensure t - :defer t - :init - (if *work_remote* - (setq exec-path (append exec-path '("P:/Tools/R/bin/x64")) - org-babel-R-command "P:/Tools/R/bin/x64/R --slave --no-save"))) -#+END_SRC - -** Python - :PROPERTIES: - :ID: 8c76fcd1-c57c-48ab-8af0-aa782de6337f - :END: - Systemseitig muss python-language-server installiert sein: -apt install python3-pip python3-setuptools python3-wheel -apt install build-essential python3-dev - pip3 install 'python-language-server[all]' - - Statt obiges: npm install -g pyright - - für andere language servers - https://github.com/emacs-lsp/lsp-mode#install-language-server - - #+BEGIN_SRC emacs-lisp -;(use-package lsp-python-ms -; :if *sys/linux* -; :ensure t -; :defer t -; :custom (lsp-python-ms-auto-install-server t)) - -(use-package lsp-pyright - :ensure t - :after lsp-mode - :defer t -; :custom -; (lsp-pyright-auto-import-completions nil) -; (lsp-pyright-typechecking-mode "off") - ) -(use-package python - :if *sys/linux* - :delight "π " - :defer t - :bind (("M-[" . python-nav-backward-block) - ("M-]" . python-nav-forward-block))) - -(use-package pyvenv - :if *sys/linux* - :ensure t - :defer t - :after python - :hook ((python-mode . pyvenv-mode) - (python-mode . (lambda () - (if-let ((pyvenv-directory (find-pyvenv-directory (buffer-file-name)))) - (pyvenv-activate pyvenv-directory)) - (lsp)))) - :custom - (pyvenv-default-virtual-env-name "env") - (pyvenv-mode-line-indicator '(pyvenv-virtual-env-name ("[venv:" pyvenv-virtual-env-name "]"))) - :preface - (defun find-pyvenv-directory (path) - "Check if a pyvenv directory exists." - (cond - ((not path) nil) - ((file-regular-p path) (find-pyvenv-directory (file-name-directory path))) - ((file-directory-p path) - (or - (seq-find - (lambda (path) (file-regular-p (expand-file-name "pyvenv.cfg" path))) - (directory-files path t)) - (let ((parent (file-name-directory (directory-file-name path)))) - (unless (equal parent path) (find-pyvenv-directory parent)))))))) - - ;; manage multiple python version - ;; needs to be installed on system -; (use-package pyenv-mode -; :ensure t -; :after python -; :hook ((python-mode . pyenv-mode) -; (projectile-switch-project . projectile-pyenv-mode-set)) -; :custom (pyenv-mode-set "3.8.5") -; :preface -; (defun projectile-pyenv-mode-set () -; "Set pyenv version matching project name." -; (let ((project (projectile-project-name))) -; (if (member project (pyenv-mode-versions)) -; (pyenv-mode-set project) -; (pyenv-mode-unset))))) - - ;) - - - #+END_SRC -* beancount -** Installation - :PROPERTIES: - :ID: 2c329043-b7a9-437d-a5cf-f2ad6514be91 - :END: -#+BEGIN_SRC shell -sudo su -cd /opt -python3 -m venv beancount -source ./beancount/bin/activate -pip3 install wheel -pip3 install beancount -sleep 100 -echo "shell running!" -deactivate -#+END_SRC - -#+BEGIN_SRC emacs-lisp -(use-package beancount - :if *sys/linux* - :load-path "user-global/elisp" -; :ensure t - :defer t - :mode - ("\\.beancount$" . beancount-mode) - :hook - (beancount-mode . my/beancount-company) - :init - (add-hook 'beancount-mode-hook 'company/beancount-mode-hook) - :config - (defun my/beancount-company () - (set (make-local-variable 'company-backends) - '(company-beancount))) - (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount")) -#+END_SRC - -To support org-babel, check if it can find the symlink to ob-beancount.el - -#+BEGIN_SRC shell -orgpath=`find /home/marc/.emacs.d/elpa/ -type d -name "org-plus*" -print` -beansym="$orgpath/ob-beancount.el - bean="/home/marc/Archiv/Programmierprojekte/Lisp/beancount-mode/ob-beancount.el" - - if [ -h "$beansym" ] - then - echo "$beansym found" - elif [ -e "$bean" ] - then - echo "creating symlink" - ln -s "$bean" "$beansym" - else - echo "$bean not found, symlink creation aborted" - fi -#+END_SRC - -Fava is strongly recommended. - -#+BEGIN_SRC shell -cd /opt -python3 -m venv fava -source ./fava/bin/activate -pip3 install wheel -pip3 install fava -deactivate -#+END_SRC - -Start fava with fava my_file.beancount - -It is accessable on this URL: [[http://127.0.0.1:5000][Fava]] -Beancount-mode can start fava and open the URL right away. - -* Stuff after everything else -Set garbage collector to a smaller value to let it kick in faster. -Maybe a problem on Windows? -#+begin_src emacs-lisp -(setq gc-cons-threshold (* 2 1000 1000)) -#+end_src