You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1493 lines
42 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. #+TITLE: Emacs Configuration
  2. #+AUTHOR: Marc Pohling
  3. * Personal Information
  4. #+begin_src emacs-lisp
  5. (setq user-full-name "Marc Pohling"
  6. user-mail-address "marc.pohling@googlemail.com")
  7. #+end_src
  8. * Stuff to add / to fix
  9. - smartparens
  10. a sane default configuration for navigation, manipulation etc. is still necessary
  11. - Spaceline / Powerline or similar
  12. I want a pretty status bar!
  13. - Git gutter:
  14. Do some configuration to make it useful (see given source link in the [[*Git][Section]] of gutter)
  15. Maybe only enable it for modes where it is likely I use git?
  16. - Some webmode stuff
  17. - markdown:
  18. add hooks for certain file extensions, maybe add a smart way to start gfm-mode if markdown-file is in a git-project
  19. - move package dependend configurations inside the package configuration itself, like keymaps for magit
  20. * Update config in a running config
  21. Two options:
  22. - reload the open file: M-x load-file, then press twice to accept
  23. the default filename, which is the currently opened
  24. - Point at the end of any sexp and press C-x C-e
  25. * Customize default settings
  26. Keep the .emacs.d clean by moving user files into separate directories.
  27. - user-local: directory for machine specific files
  28. - user-global: directory for files which work on any machine
  29. - the backup and auto-save files go right to /tmp
  30. #+BEGIN_SRC emacs-lisp
  31. (defvar PATH_USER_LOCAL (expand-file-name "~/.emacs.d/user-local/"))
  32. (defvar PATH_USER_GLOBAL (expand-file-name "~/.emacs.d/user-global/"))
  33. (setq bookmark-default-file (concat PATH_USER_LOCAL "bookmarks"))
  34. (setq recentf-save-file (concat PATH_USER_LOCAL "recentf"))
  35. (setq custom-file (concat PATH_USER_LOCAL "custom.el")) ;don't spam init.el with saved customize settings
  36. (setq abbrev-file-name (concat PATH_USER_GLOBAL "abbrev_defs"))
  37. (setq backup-directory-alist `((".*" . ,temporary-file-directory)))
  38. (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory)))
  39. (setq save-abbrevs 'silently) ; don't bother me with asking if new abbrevs should be saved
  40. #+END_SRC
  41. These functions are useful. Activate them.
  42. #+begin_src emacs-lisp
  43. (put 'downcase-region 'disabled nil)
  44. (put 'upcase-region 'disabled nil)
  45. (put 'narrow-to-region 'disabled nil)
  46. (put 'dired-find-alternate-file 'disabled nil)
  47. #+end_src
  48. Answering just 'y' or 'n' should be enough.
  49. #+begin_src emacs-lisp
  50. (defalias 'yes-or-no-p 'y-or-n-p)
  51. #+end_src
  52. Don't count two spaces after a period as the end of a sentence.
  53. Just one space is needed
  54. #+begin_src emacs-lisp
  55. (setq sentence-end-double-space nil)
  56. #+end_src
  57. Delete the region when typing, just like as we expect nowadays.
  58. #+begin_src emacs-lisp
  59. (delete-selection-mode t)
  60. #+end_src
  61. Auto-indent when pressing RET, just new-line when C-j
  62. #+begin_src emacs-lisp
  63. (define-key global-map (kbd "RET") 'newline-and-indent)
  64. (define-key global-map (kbd "C-j") 'newline)
  65. #+end_src
  66. * Visuals
  67. ** Theme
  68. *** Font
  69. Don't add the font in the work environment, which I am logged in as POH
  70. #+begin_src emacs-lisp
  71. (unless (string-equal user-login-name "POH")
  72. (set-face-attribute 'default nil :font "Hack-12")
  73. )
  74. #+end_src
  75. *** Material Theme
  76. The [[https://github.com/cpaulik/emacs-material-theme][Material Theme]] comes in a dark and a light variant. Not too dark
  77. to be strenious though.
  78. b
  79. #+begin_src emacs-lisp
  80. (use-package material-theme
  81. :if (window-system)
  82. :defer t
  83. :ensure t
  84. ;; :init
  85. )
  86. #+end_src
  87. *** Apropospriate Theme
  88. Variants dark and light
  89. #+begin_src emacs-lisp
  90. (use-package apropospriate-theme
  91. :if (window-system)
  92. :defer t
  93. :ensure t
  94. :config
  95. )
  96. #+end_src
  97. *** Ample Theme
  98. Variants:
  99. - ample
  100. - ample-flat
  101. - ample-light
  102. #+begin_src emacs-lisp
  103. (use-package ample-theme
  104. :defer t
  105. :ensure t
  106. :init
  107. (load-theme 'ample-flat)
  108. )
  109. #+end_src
  110. ** Prettier Line Wraps
  111. By default there is no line wrapping. M-q actually modifies the buffer, which might not be wanted.
  112. So: enable visual wrapping and keep indentation if there are any.
  113. #+begin_src emacs-lisp
  114. (global-visual-line-mode)
  115. (diminish 'visual-line-mode)
  116. (use-package adaptive-wrap
  117. :ensure t
  118. :init
  119. (when (fboundp 'adaptive-wrap-prefix-mode)
  120. (defun my-activate-adaptive-wrap-prefix-mode ()
  121. "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously."
  122. (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1)))
  123. (add-hook 'visual-line-mode-hook 'my-activate-adaptive-wrap-prefix-mode))
  124. )
  125. #+end_src
  126. ** Mode Line
  127. Change the default mode line to something prettier. [[https://github.com/Malabarba/smart-mode-line][Source]]
  128. #+BEGIN_SRC emacs-lisp
  129. (use-package smart-mode-line
  130. :ensure t
  131. :config
  132. (tool-bar-mode -1)
  133. (setq sml/theme 'respectful)
  134. (setq sml/name-width 40)
  135. (setq sml/mode-width 'full)
  136. (set-face-attribute 'mode-line nil
  137. :box nil)
  138. (sml/setup))
  139. #+END_SRC
  140. ** Misc
  141. UTF-8 please
  142. #+begin_src emacs-lisp
  143. (setq locale-coding-system 'utf-8)
  144. (set-terminal-coding-system 'utf-8)
  145. (set-keyboard-coding-system 'utf-8)
  146. (set-selection-coding-system 'utf-8)
  147. (prefer-coding-system 'utf-8)
  148. #+end_src
  149. Turn off blinking cursor
  150. #+begin_src emacs-lisp
  151. (blink-cursor-mode -1)
  152. #+end_src
  153. #+begin_src emacs-lisp
  154. (show-paren-mode t)
  155. (column-number-mode t)
  156. (setq uniquify-buffer-name-style 'forward)
  157. #+end_src
  158. Avoid tabs in place of multiple spaces (they look bad in TeX)
  159. and show empty lines
  160. #+begin_src emacs-lisp
  161. (setq-default indent-tabs-mode nil)
  162. (setq-default indicate-empty-lines t)
  163. #+end_src
  164. Smooth scrolling. Emacs tends to be jumpy, this should change it.
  165. #+BEGIN_SRC emacs-lisp
  166. (setq scroll-margin 5
  167. scroll-conservatively 9999
  168. scroll-step 1)
  169. #+END_SRC
  170. * Usability
  171. Activate and configure recentf
  172. #+BEGIN_SRC emacs-lisp
  173. (recentf-mode t)
  174. (setq recentf-max-saved-items 200)
  175. #+END_SRC
  176. ** Hydra
  177. Hydra allows grouping of commands
  178. #+begin_src emacs-lisp
  179. (use-package hydra
  180. :ensure t
  181. :bind
  182. ("C-c f" . hydra-flycheck/body)
  183. ("C-c g" . hydra-git-gutter/body)
  184. :config
  185. (setq-default hydra-default-hint nil)
  186. )
  187. #+end_src
  188. ** Evil
  189. So... Evil Mode might be worth a try
  190. #+BEGIN_SRC emacs-lisp
  191. (use-package evil
  192. :ensure t
  193. :defer .1 ;; don't block emacs when starting, load evil immediately after startup
  194. :init
  195. (setq evil-want-integration nil) ;; required by evil-collection
  196. :config
  197. (evil-mode 1)) ;; for now deactivate per default
  198. #+END_SRC
  199. Evil-collection is a bundle of configs for different modes.
  200. 2018-05-01: evil collection causes error
  201. "Invalid function: with-helm-buffer"
  202. #+BEGIN_SRC emacs-lisp
  203. ;(use-package evil-collection
  204. ; :after evil
  205. ; :ensure t
  206. ; :config
  207. ; (evil-collection-init))
  208. #+END_SRC
  209. Evil-goggles give visual hints when editing texts, so it's more obvious what is actually happening. [[https://github.com/edkolev/evil-goggles][Source]]
  210. #+BEGIN_SRC emacs-lisp
  211. (use-package evil-goggles
  212. :after evil
  213. :ensure t
  214. :config
  215. (evil-goggles-mode)
  216. (evil-goggles-use-diff-faces))
  217. #+END_SRC
  218. ** List buffers
  219. Ibuffer is the improved version of list-buffers.
  220. Make ibuffer the default buffer lister. [[http://ergoemacs.org/emacs/emacs_buffer_management.html][Source]]
  221. #+begin_src emacs-lisp
  222. (defalias 'list-buffers 'ibuffer)
  223. #+end_src
  224. Also auto refresh dired, but be quiet about it. [[http://whattheemacsd.com/sane-defaults.el-01.html][Source]]
  225. #+begin_src emacs-lisp
  226. (add-hook 'dired-mode-hook 'auto-revert-mode)
  227. (setq global-auto-revert-non-file-buffers t)
  228. (setq auto-revert-verbose nil)
  229. #+end_src
  230. ** ivy / counsel / swiper
  231. Flx is required for fuzzy-matching
  232. Is it really necessary?
  233. begin_src emacs-lisp
  234. (use-package flx)
  235. end_src
  236. Ivy displays a window with suggestions for hotkeys and M-x
  237. #+begin_src emacs-lisp
  238. (use-package ivy
  239. :ensure t
  240. :diminish
  241. (ivy-mode . "") ;; does not display ivy in the mode line
  242. :init
  243. (ivy-mode 1)
  244. :bind
  245. ("C-c C-r" . ivy-resume)
  246. :config
  247. (setq ivy-use-virtual-buffers t) ;; recent files and bookmarks in ivy-switch-buffer
  248. (setq ivy-height 20) ;; height of ivy window
  249. (setq ivy-count-format "%d/%d") ;; current and total number
  250. (setq ivy-re-builders-alist ;; regex replaces spaces with *
  251. '((t . ivy--regex-plus)))
  252. )
  253. #+end_src
  254. The find-file replacement is nicer to navigate
  255. #+begin_src emacs-lisp
  256. (use-package counsel
  257. :ensure t
  258. :bind* ;; load counsel when pressed
  259. (("M-x" . counsel-M-x)
  260. ("C-x C-f" . counsel-find-file)
  261. ("C-x C-r" . counsel-recentf)
  262. ("C-c C-f" . counsel-git)
  263. ("C-c h f" . counsel-describe-function)
  264. ("C-c h v" . counsel-describe-variable)
  265. ("M-i" . counsel-imenu)
  266. )
  267. )
  268. #+end_src
  269. Swiper ivy-enhances isearch
  270. #+begin_src emacs-lisp
  271. (use-package swiper
  272. :ensure t
  273. :bind
  274. (("C-s" . swiper)
  275. ("C-c C-r" . ivy-resume)
  276. )
  277. )
  278. #+end_src
  279. Ivy-Hydra adds stuff in minibuffer when you press C-o
  280. #+BEGIN_SRC emacs-lisp
  281. (use-package ivy-hydra
  282. :ensure t)
  283. #+END_SRC
  284. ** which-key
  285. Greatly increases discovery of functions!
  286. Click [[https://github.com/justbur/emacs-which-key][here]] for source and more info.
  287. Info in Emacs: M-x customize-group which-key
  288. #+begin_src emacs-lisp
  289. (use-package which-key
  290. :ensure t
  291. :diminish which-key-mode
  292. :config
  293. (which-key-mode)
  294. (which-key-setup-side-window-right-bottom)
  295. (which-key-setup-minibuffer)
  296. (setq which-key-idle-delay 0.5)
  297. )
  298. #+end_src
  299. ** Undo
  300. Show an undo tree in a new buffer which can be navigated.
  301. #+BEGIN_SRC emacs-lisp
  302. (use-package undo-tree
  303. :ensure t
  304. :diminish undo-tree-mode
  305. :init
  306. (undo-tree-mode))
  307. #+END_SRC
  308. ** Ido (currently inactive)
  309. better completion
  310. begin_src emacs-lisp
  311. (use-package ido
  312. :init
  313. (setq ido-enable-flex-matching t)
  314. (setq ido-everywhere t)
  315. (ido-mode t)
  316. (use-package ido-vertical-mode
  317. :ensure t
  318. :defer t
  319. :init
  320. (ido-vertical-mode 1)
  321. (setq ido-vertical-define-keys 'C-n-and-C-p-only)
  322. )
  323. )
  324. end_src
  325. ** Treemacs
  326. A file manager comparable to neotree.
  327. [[https://github.com/Alexander-Miller/treemacs][Github]]
  328. It has some requirements, which gets used here anyway:
  329. - ace-window
  330. - hydra
  331. - projectile
  332. - python
  333. I copied the configuration example from the github site.
  334. No idea what this executable-find is about.
  335. TODO check it out!
  336. #+begin_src emacs-lisp
  337. (use-package treemacs
  338. :ensure t
  339. :defer t
  340. :config
  341. (setq treemacs-change-root-without-asking nil
  342. treemacs-collapse-dirs (if (executable-find "python") 3 0)
  343. treemacs-file-event-delay 5000
  344. treemacs-follow-after-init t
  345. treemacs-follow-recenter-distance 0.1
  346. treemacs-goto-tag-strategy 'refetch-index
  347. treemacs-indentation 2
  348. treemacs-indentation-string " "
  349. treemacs-is-never-other-window nil
  350. treemacs-never-persist nil
  351. treemacs-no-png-images nil
  352. treemacs-recenter-after-file-follow nil
  353. treemacs-recenter-after-tag-follow nil
  354. treemacs-show-hidden-files t
  355. treemacs-silent-filewatch nil
  356. treemacs-silent-refresh nil
  357. treemacs-sorting 'alphabetic-desc
  358. treemacs-tag-follow-cleanup t
  359. treemacs-tag-follow-delay 1.5
  360. treemacs-width 35)
  361. (treemacs-follow-mode t)
  362. (treemacs-filewatch-mode t)
  363. (pcase (cons (not (null (executable-find "git")))
  364. (not (null (executable-find "python3"))))
  365. (`(t . t)
  366. (treemacs-git-mode 'extended))
  367. (`(t . _)
  368. (treemacs-git-mode 'simple)))
  369. :bind
  370. (:map global-map
  371. ([f8] . treemacs-toggle))
  372. )
  373. #+end_src
  374. Treemacs-projectile is useful for uhh.. TODO explain!
  375. #+begin_src emacs-lisp
  376. (use-package treemacs-projectile
  377. :ensure t
  378. :defer t
  379. :config
  380. (setq treemacs-header-function #'treemacs-projectile-create-header)
  381. )
  382. #+end_src
  383. TODO
  384. Hydrastuff or keybindings for functions:
  385. - treemacs-projectile
  386. - treemacs-projectile-toggle
  387. - treemacs-toggle
  388. - treemacs-bookmark
  389. - treemacs-find-file
  390. - treemacs-find-tag
  391. ** Window Handling
  392. Some tools to easen the navigation, creation and deletion of windows
  393. *** Ace-Window
  394. #+begin_src emacs-lisp
  395. (use-package ace-window
  396. :ensure t
  397. :init
  398. (global-set-key (kbd "C-x o") 'ace-window)
  399. )
  400. #+end_src
  401. *** Windmove
  402. Windmove easens the navigation between windows.
  403. Here we are setting the default keybindings (shift+arrow)
  404. CURRENTLY NOT WORKING, defaults are blocked.
  405. Also not sure if necessary when using ace-window.
  406. #+begin_src emacs-lisp
  407. (use-package windmove
  408. :ensure t
  409. :config
  410. (windmove-default-keybindings)
  411. )
  412. #+end_src
  413. * Pandoc
  414. Convert between formats, like from org to html.
  415. Pandoc needs to be installed on the system
  416. #+BEGIN_SRC shell
  417. sudo apt install pandoc
  418. #+END_SRC
  419. Pandoc-mode is a minor mode to interact with pandoc
  420. #+BEGIN_SRC emacs-lisp
  421. (use-package pandoc-mode
  422. :ensure t
  423. :init
  424. (add-hook 'markdown-mode-hook 'pandoc-mode))
  425. #+END_SRC
  426. * Org Mode
  427. ** Installation
  428. 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.]]
  429. Added a hook to complete org functions, company-capf is necessary for this
  430. #+begin_src emacs-lisp
  431. (use-package org
  432. :ensure org-plus-contrib
  433. :init
  434. (add-hook 'org-mode-hook 'company/org-mode-hook)
  435. )
  436. #+end_src
  437. 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:
  438. #+begin_src sh:
  439. var ORG_DIR=(let* ((org-v (cadr (split-string (org-version nil t) "@"))) (len (length org-v))) (substring org-v 1 (- len 2)))
  440. rm ${ORG_DIR}/*.elc
  441. #+end_src
  442. *** Org key bindings
  443. Set up some global key bindings that integrate with Org mode features
  444. #+begin_src emacs-lisp
  445. (bind-key "C-c l" 'org-store-link)
  446. (bind-key "C-c c" 'org-capture)
  447. (bind-key "C-c a" 'org-agenda)
  448. #+end_src
  449. Org overwrites RET and C-j, so I need to disable the rebinds
  450. #+begin_src emacs-lisp
  451. (define-key org-mode-map (kbd "RET") nil) ;;org-return
  452. (define-key org-mode-map (kbd "C-j") nil) ;;org-return-indent
  453. #+end_src
  454. *** Org agenda
  455. For a more detailed example [[https://github.com/sachac/.emacs.d/blob/83d21e473368adb1f63e582a6595450fcd0e787c/Sacha.org#org-agenda][see here]].
  456. #+begin_src emacs-lisp
  457. (setq org-agenda-files
  458. (delq nil
  459. (mapcar (lambda (x) (and (file-exists-p x) x))
  460. '("~/Archiv/Dokumente/Agenda"))
  461. )
  462. )
  463. #+end_src
  464. *** Org capture
  465. #+begin_src emacs-lisp
  466. (bind-key "C-c c" 'org-capture)
  467. (setq org-default-notes-file "~/Archiv/Dokumente/Notizen/notes.org")
  468. #+end_src
  469. ** Org Setup
  470. 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.
  471. See the doc for speed keys by checking out the documentation for speed keys in Org mode.
  472. #+begin_src emacs-lisp
  473. (setq org-use-speed-commands t)
  474. (setq org-image-actual-width 550)
  475. (setq org-highlight-latex-and-related '(latex script entities))
  476. #+end_src
  477. Hide emphasis markup (e.g. / ... / for italics, etc.)
  478. #+begin_src emacs-lisp
  479. (setq org-hide-emphasis-markers t)
  480. #+end_src
  481. Setting some environment paths
  482. #+begin_src emacs-lisp
  483. (if (string-equal user-login-name "POH")
  484. (progn
  485. (defvar PATH_ORG_FILES "p:/Eigene Dateien/Notizen/")
  486. (defvar PATH_ORG_JOURNAL "p:/Eigene Dateien/Notizen/Journal/")
  487. (defvar PATH_START "p:/Eigene Dateien/Notizen/"))
  488. )
  489. #+end_src
  490. Sort org agenda by deadline and priority
  491. #+begin_src emacs-lisp
  492. (setq org-agenda-sorting-strategy
  493. (quote
  494. ((agenda deadline-up priority-down)
  495. (todo priority-down category-keep)
  496. (tags priority-down category-keep)
  497. (search category-keep)))
  498. )
  499. #+end_src
  500. Custom todo-keywords, depending on environment
  501. #+begin_src emacs-lisp
  502. (if (string-equal user-login-name "POH")
  503. (setq org-todo-keywords
  504. '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE")))
  505. )
  506. #+end_src
  507. Set locations of some org files
  508. #+begin_src emacs-lisp
  509. (if (string-equal user-login-name "POH")
  510. (progn
  511. (setq org-default-notes-file (concat PATH_ORG_FILES "notes.org"))
  512. (setq org-agenda-files (list(concat PATH_ORG_FILES "notes.org")
  513. (concat PATH_ORG_FILES "projects.org")
  514. (concat PATH_ORG_FILES "todo.org"))))
  515. )
  516. (setq org-id-locations-file (concat PATH_USER_LOCAL ".org-id-locations"))
  517. #+end_src
  518. Work specific org-capture-templates
  519. #+begin_src emacs-lisp
  520. (if (string-equal user-login-name "POH")
  521. (setq org-capture-templates
  522. '(("t" "todo" entry (file (concat PATH_ORG_FILES "todo.org"))
  523. "** TODO %\\n%u\n%a\n")
  524. ("n" "note" entry (file org-default-notes-file))
  525. ("p" "project" entry (file (concat PATH_ORG_FILES "projects.org"))
  526. "** OPEN %?\n%u\n** Beschreibung\n** Zu erledigen\n*** \n** Verlauf\n***" :clock-in t :clock-resume t)
  527. ("u" "Unterbrechung" entry (file org-default-notes-file)
  528. "* Unterbrechnung durch %? :Unterbrechung:\n%t" :clock-in t :clock-resume t)))
  529. )
  530. #+end_src
  531. Customize the org agenda
  532. #+begin_src emacs-lisp
  533. (defun my-org-skip-subtree-if-priority (priority)
  534. "Skip an agenda subtree if it has a priority of PRIORITY.
  535. PRIORITY may be one of the characters ?A, ?B, or ?C."
  536. (let ((subtree-end (save-excursion (org-end-of-subtree t)))
  537. (pri-value (* 1000 (- org-lowest-priority priority)))
  538. (pri-current (org-get-priority (thing-at-point 'line t))))
  539. (if (= pri-value pri-current)
  540. subtree-end
  541. nil)))
  542. (setq org-agenda-custom-commands
  543. '(("c" "Simple agenda view"
  544. ((tags "PRIORITY=\"A\""
  545. ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
  546. (org-agenda-overriding-header "Hohe Priorität:")))
  547. (agenda ""
  548. ((org-agenda-span 7)
  549. (org-agenda-start-on-weekday nil)
  550. (org-agenda-overriding-header "Nächsten 7 Tage:")))
  551. (alltodo ""
  552. ((org-agenda-skip-function '(or (my-org-skip-subtree-if-priority ?A)
  553. (org-agenda-skip-if nil '(scheduled deadline))))
  554. (org-agenda-overriding-header "Sonstige Aufgaben:"))))))
  555. )
  556. #+end_src
  557. ** Org tags
  558. The default value is -77, which is weird for smaller width windows. I'd rather have the tags align horizontally with the header.
  559. 45 is a good column number to do that.
  560. #+begin_src emacs-lisp
  561. (setq org-tags-column 45)
  562. #+end_src
  563. ** Org babel languages
  564. This code block is linux specific. Loading languages which aren't available seems to be a problem
  565. #+begin_src emacs-lisp
  566. (cond ((eq system-type 'gnu/linux)
  567. (org-babel-do-load-languages
  568. 'org-babel-load-languages
  569. '(
  570. (C . t)
  571. (calc . t)
  572. (java . t)
  573. (js . t)
  574. (latex . t)
  575. (ledger . t)
  576. (beancount . t)
  577. (lisp . t)
  578. (python . t)
  579. (R . t)
  580. (ruby . t)
  581. (scheme . t)
  582. (shell . t)
  583. (sqlite . t)
  584. )
  585. ))
  586. )
  587. #+end_src
  588. #+begin_src emacs-lisp
  589. (defun my-org-confirm-babel-evaluate (lang body)
  590. "Do not confirm evaluation for these languages."
  591. (not (or (string= lang "beancount")
  592. (string= lang "C")
  593. (string= lang "emacs-lisp")
  594. (string= lang "java")
  595. (string= lang "ledger")
  596. (string= lang "python")
  597. (string= lang "R")
  598. (string= lang "sqlite"))))
  599. (setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate)
  600. #+end_src
  601. I want plots!
  602. #+begin_src emacs-lisp
  603. (use-package ess
  604. :ensure t
  605. )
  606. (add-hook 'org-babel-after-execute-hook 'org-display-inline-images)
  607. (add-hook 'org-mode-hook 'org-display-inline-images)
  608. #+end_src
  609. ** Org babel/source blocks
  610. 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
  611. 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
  612. #+begin_src emacs-lisp
  613. (setq org-src-fontify-natively t
  614. org-src-window-setup 'current-window
  615. org-src-strip-leading-and-trailing-blank-lines t
  616. org-src-preserve-indentation nil ; these two lines respect the indentation of
  617. org-edit-src-content-indentation 0 ; the surrounding text around the source block
  618. org-src-tab-acts-natively t)
  619. #+end_src
  620. * Helm
  621. I placed it after ivy to override any configuration made by the former.
  622. This is just a try to see how it works differently.
  623. #+BEGIN_SRC emacs-lisp
  624. (use-package helm
  625. :ensure t
  626. :init
  627. (helm-mode 1)
  628. :bind
  629. ; (("M-x" . helm-M-x)
  630. ; ("C-x C-f" . helm-find-files)
  631. ; ("C-x C-r" . helm-recentf)
  632. ; ("C-x b" . helm-buffers-list))
  633. :config
  634. (setq helm-buffers-fuzzy-matching t)
  635. )
  636. (use-package helm-descbinds
  637. :ensure t
  638. :bind
  639. ("C-h b" . helm-descbinds))
  640. (use-package helm-projectile
  641. :ensure t
  642. :config
  643. (helm-projectile-on))
  644. #+END_SRC
  645. * Latex
  646. Requirements for Linux:
  647. - Latex
  648. - pdf-tools
  649. #+begin_src emacs-lisp
  650. (unless (string-equal user-login-name "POH")
  651. (use-package pdf-tools
  652. :ensure t
  653. :config
  654. (pdf-tools-install)
  655. (setq TeX-view-program-selection '((output-pdf "pdf-tools")))
  656. (setq TeX-view-program-list '(("pdf-tools" "Tex-pdf-tools-sync-view")))
  657. )
  658. )
  659. #+end_src
  660. 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]]
  661. Update 2018-03: It seems to work without this patch. I will keep it here in case something breaks again.
  662. #+begin_src
  663. latex-preview-pane-update-p()
  664. --- (doc-view-revert-buffer nil t)
  665. +++ (revert-buffer-nil t 'preserve-modes)
  666. #+end_src
  667. After that M-x byte-compile-file
  668. #+begin_src emacs-lisp
  669. (use-package latex-preview-pane
  670. :ensure t
  671. )
  672. (setq auto-mode-alist
  673. (append '(("\\.tex$" . latex-mode)) auto-mode-alist))
  674. ;; one of these works
  675. (add-hook 'LaTeX-mode-hook 'latex-preview-pane-mode)
  676. (add-hook 'latex-mode-hook 'latex-preview-pane-mode)
  677. ;; necessary, because linum-mode isn't compatible and prints errors
  678. (add-hook 'pdf-view-mode-hook (lambda () (linum-mode -1)))
  679. #+end_src
  680. * Markdown
  681. Major mode to edit markdown files.
  682. For previews it needs markdown installed on the system.
  683. For debian:
  684. #+BEGIN_SRC shell
  685. sudo apt install markdown
  686. #+END_SRC
  687. #+BEGIN_SRC emacs-lisp
  688. (use-package markdown-mode
  689. :ensure t)
  690. #+END_SRC
  691. * Emails
  692. Currently following tools are required:
  693. - notmuch (edit, read, tag, delete emails)
  694. - isync /mbsync (fetch or sync emails)
  695. 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.
  696. TODO:
  697. - setup of mbsync on linux
  698. - setup of notmuch on linux
  699. - shell script for installation of isync and notmuch
  700. - more config for notmuch?
  701. - hydra for notmuch?
  702. - maybe org-notmuch?
  703. - some way to refresh the notmuch db before I run notmuch?
  704. #+begin_src emacs-lisp
  705. (unless (string-equal user-login-name "POH")
  706. (use-package notmuch
  707. :ensure t
  708. )
  709. )
  710. #+end_src
  711. * Personal Finances
  712. I picked ledger for my personal accounting and will test if it's beneficial over gnucash.
  713. ..and don't activate the modules at work.
  714. #+begin_src emacs-lisp
  715. (unless (string-equal user-login-name "POH")
  716. (use-package ledger-mode
  717. :ensure t
  718. :mode ("\\.ledger$" . ledger-mode)
  719. :init
  720. (setq clear-whole-transactions t)
  721. )
  722. )
  723. #+end_src
  724. Ok, maybe beancount is better.
  725. Since there is no debian package, it is an option to install it via pip.
  726. I picked /opt for the installation path
  727. #+begin_src shell
  728. sudo su
  729. cd /opt
  730. python3 -m venv beancount
  731. source ./beancount/bin/activate
  732. pip3 install wheel
  733. pip3 install beancount
  734. deactivate
  735. #+end_src
  736. When using beancount, it will automatically pick the created virtual environment.
  737. Activate the beancount mode
  738. #+begin_src emacs-lisp
  739. (unless (string-equal user-login-name "POH")
  740. ;; (add-to-list 'package-archives
  741. ;; '("beancount" . "/opt/beancount/elisp") t)
  742. ; (use-package beancount
  743. ; :load-path "/opt/beancount/elisp/"
  744. ;; :ensure t
  745. ; :mode ("\\.beancount$" . beancount-mode)
  746. (load "/home/marc/.emacs.d/user-local/elisp/beancount-mode.el") ; somehow load-path in use-package doesn't work
  747. (use-package beancount
  748. :load-path "/home/marc/.emacs.d/elisp"
  749. :mode ("\\.beancount$" . beancount-mode)
  750. :init
  751. (add-hook 'beancount-mode-hook 'company/beancount-mode-hook)
  752. (setenv "PATH"
  753. (concat
  754. "/opt/beancount/bin:"
  755. (getenv "PATH"))
  756. )
  757. :config
  758. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/transactions.beancount")
  759. )
  760. )
  761. #+end_src
  762. For a nice frontend fava seems nice
  763. #+begin_src shell
  764. sudo su
  765. cd /opt
  766. python3 -m venv vava
  767. source ./vava/bin/activate
  768. pip3 install wheel
  769. pip3 install fava
  770. deactivate
  771. #+end_src
  772. Start fava with
  773. #+begin_src shell
  774. fava my_file.beancount
  775. #+end_src
  776. It is accessable on this URL: [[http://127.0.0.1:5000][Fava]]
  777. * Programming
  778. ** Common things
  779. List of plugins and settings which are shared between the language plugins
  780. Highlight whitespaces, tabs, empty lines.
  781. #+begin_src emacs-lisp
  782. (use-package whitespace
  783. :demand t
  784. :ensure nil
  785. :diminish whitespace-mode;;mode shall be active, but not shown in mode line
  786. :init
  787. (dolist (hook '(prog-mode-hook
  788. text-mode-hook
  789. conf-mode-hook))
  790. (add-hook hook #'whitespace-mode))
  791. ;; :hook ;;not working in use-package 2.3
  792. ;; ((prog-mode . whitespace-turn-on)
  793. ;; (text-mode . whitespace-turn-on))
  794. :config
  795. (setq-default whitespace-style '(face empty tab trailing))
  796. )
  797. #+end_src
  798. Disable Eldoc, it interferes with flycheck
  799. #+begin_src emacs-lisp
  800. (use-package eldoc
  801. :ensure nil
  802. :config
  803. (global-eldoc-mode -1)
  804. )
  805. #+end_src
  806. Colorize colors as text with their value
  807. #+begin_src emacs-lisp
  808. (use-package rainbow-mode
  809. :ensure t
  810. :init
  811. (add-hook 'prog-mode-hook 'rainbow-mode t)
  812. :diminish rainbow-mode
  813. ;; :hook prog-mode ;; not working in use-package 2.3
  814. :config
  815. (setq-default rainbow-x-colors-major-mode-list '())
  816. )
  817. #+end_src
  818. Highlight parens etc. for improved readability
  819. #+begin_src emacs-lisp
  820. (use-package rainbow-delimiters
  821. :ensure t
  822. :config
  823. (add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
  824. )
  825. #+end_src
  826. ** Smartparens
  827. Smartparens is a beast on its own, so it's worth having a dedicated section for it
  828. #+begin_src emacs-lisp
  829. (use-package smartparens
  830. :ensure t
  831. :diminish smartparens-mode
  832. :config
  833. (add-hook 'prog-mode-hook 'smartparens-mode)
  834. )
  835. #+end_src
  836. ** Git
  837. *** Magit
  838. [[https://magit.vc/manual/magit/index.html][Link]]
  839. I want to do git stuff here, not in a separate terminal window
  840. Little crashcourse in magit:
  841. - magit-init to init a git project
  842. - magit-status (C-x g) to call the status window
  843. in status buffer:
  844. - s stage files
  845. - u unstage files
  846. - U unstage all files
  847. - a apply changed to staging
  848. - c c commit (type commit message, then C-c C-c to commit)
  849. - b b switch to another branch
  850. - P u git push
  851. - F u git pull
  852. #+begin_src emacs-lisp
  853. (use-package magit
  854. :ensure t
  855. :init
  856. ;; set git-path in work environment
  857. (if (string-equal user-login-name "POH")
  858. (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe")
  859. )
  860. :defer t
  861. :bind (("C-x g" . magit-status))
  862. )
  863. #+end_src
  864. *** Git-gutter
  865. Display line changes in gutter based on git history. Enable it everywhere
  866. [[https://github.com/syohex/emacs-git-gutter][Source]]
  867. #+begin_src emacs-lisp
  868. (use-package git-gutter
  869. :ensure t
  870. :config
  871. (global-git-gutter-mode t)
  872. :diminish git-gutter-mode
  873. )
  874. #+end_src
  875. Some persistent navigation in git-gutter is nice, so here's a hydra for it:
  876. #+BEGIN_SRC emacs-lisp
  877. (defhydra hydra-git-gutter (:body-pre (git-gutter-mode 1)
  878. :hint nil)
  879. "
  880. ^Git Gutter^ ^Git^ ^misc^
  881. ^──────────^────────^───^────────────────^────^──────────────────────────
  882. _j_: next hunk _s_tage hunk _q_uit
  883. _k_: previous hunk _r_evert hunk _g_ : call magit-status
  884. _h_: first hunk _p_opup hunk
  885. _l_: last hunk set start _R_evision
  886. ^^ ^^ ^^
  887. "
  888. ("j" git-gutter:next-hunk)
  889. ("k" git-gutter:previous-hunk)
  890. ("h" (progn (goto-char (point-min))
  891. (git-gutter:next-hunk 1)))
  892. ("l" (progn (goto-char (point-min))
  893. (git-gutter:previous-hunk 1)))
  894. ("s" git-gutter:stage-hunk)
  895. ("r" git-gutter:revert-hunk)
  896. ("p" git-gutter:popup-hunk)
  897. ("R" git-gutter:set-start-revision)
  898. ("q" nil :color blue)
  899. ("g" magit-status)
  900. )
  901. #+END_SRC
  902. *** Git-timemachine
  903. Time machine lets me step through the history of a file as recorded in git.
  904. [[https://github.com/pidu/git-timemachine][Source]]
  905. #+begin_src emacs-lisp
  906. (use-package git-timemachine
  907. :ensure t
  908. )
  909. #+end_src
  910. ** Company Mode
  911. Complete Anything!
  912. Activate company and make it react nearly instantly
  913. #+begin_src emacs-lisp
  914. (use-package company
  915. :ensure t
  916. :config
  917. (setq-default company-minimum-prefix-length 1
  918. company-tooltip-align-annotation t
  919. company-tooltop-flip-when-above t
  920. company-show-numbers t
  921. company-idle-delay 0.1)
  922. ;; (define-key company-active-map (kbd "TAB") #'company-complete-selection)
  923. ;; (define-key company-active-map (kbd "RET") nil)
  924. (company-tng-configure-default)
  925. )
  926. #+end_src
  927. For a nicer suggestion box: company-box ([[https://github.com/sebastiencs/company-box][Source]])
  928. It is only available for emacs 26 and higher.
  929. #+begin_src emacs-lisp
  930. (when (> emacs-major-version 25)
  931. (use-package company-box
  932. :ensure t
  933. :init
  934. (add-hook 'company-mode-hook 'company-box-mode)))
  935. #+end_src
  936. *** Company backend hooks
  937. Backend configuration for python-mode
  938. Common backends are:
  939. - company-files: files & directory
  940. - company-keywords: keywords
  941. - company-capf: ??
  942. - company-abbrev: ??
  943. - company-dabbrev: dynamic abbreviations
  944. - company-ispell: ??
  945. #+begin_src emacs-lisp
  946. (defun company/python-mode-hook()
  947. (set (make-local-variable 'company-backends)
  948. '((company-jedi company-dabbrev company-yasnippet) company-capf company-files))
  949. ;; '((company-jedi company-dabbrev) company-capf company-files))
  950. (company-mode t)
  951. )
  952. #+end_src
  953. (defun add-pcomplete-to-capf ()
  954. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t))
  955. ;; (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  956. (add-hook 'org-mode-hook #'add-pcomplete-to-capf)
  957. Backend for Orgmode
  958. #+begin_src emacs-lisp
  959. (defun company/org-mode-hook()
  960. (set (make-local-variable 'company-backends)
  961. '(company-capf company-files))
  962. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  963. (company-mode t)
  964. )
  965. #+end_src
  966. Backend configuration for lisp-mode
  967. #+begin_src emacs-lisp
  968. (defun company/elisp-mode-hook()
  969. (set (make-local-variable 'company-backends)
  970. '((company-elisp company-dabbrev) company-capf company-files))
  971. (company-mode t)
  972. )
  973. #+end_src
  974. Backend configuration for beancount
  975. #+begin_src emacs-lisp
  976. (defun company/beancount-mode-hook()
  977. (set (make-local-variable 'company-backends)
  978. '(company-beancount))
  979. ; '((company-beancount company-dabbrev) company-capf company-files))
  980. (company-mode t)
  981. )
  982. #+end_src
  983. *** Misc Company packages
  984. Addon to sort suggestions by usage
  985. #+begin_src emacs-lisp
  986. (use-package company-statistics
  987. :ensure t
  988. :after company
  989. :init
  990. (setq company-statistics-file (concat PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el")
  991. :config
  992. (company-statistics-mode 1)
  993. )
  994. #+end_src
  995. Get a popup with documentation of the completion candidate.
  996. For the popups the package pos-tip.el is used and automatically installed.
  997. [[https://github.com/expez/company-quickhelp][Company Quickhelp]]
  998. [[https://www.emacswiki.org/emacs/PosTip][See here for Pos-Tip details]]
  999. #+begin_src emacs-lisp
  1000. (use-package company-quickhelp
  1001. :ensure t
  1002. :after company
  1003. :config
  1004. (company-quickhelp-mode 1)
  1005. )
  1006. #+end_src
  1007. Maybe add [[https://github.com/hlissner/emacs-company-dict][company-dict]]? It's a dictionary based on major modes, plus it has Yasnippet integration.
  1008. ** Projectile
  1009. Brings search functions on project level
  1010. #+begin_src emacs-lisp
  1011. (use-package projectile
  1012. :ensure t
  1013. :defer t
  1014. :bind
  1015. (("C-c p p" . projectile-switch-project)
  1016. ("C-c p s s" . projectile-ag))
  1017. :init
  1018. (setq-default
  1019. projectile-cache-file (concat PATH_USER_LOCAL ".projectile-cache")
  1020. projectile-known-projects-file (concat PATH_USER_LOCAL ".projectile-bookmarks"))
  1021. :config
  1022. (projectile-mode t)
  1023. (setq-default
  1024. projectile-completion-system 'ivy
  1025. projectile-enable-caching t
  1026. projectile-mode-line '(:eval (projectile-project-name)))
  1027. )
  1028. #+end_src
  1029. ** Yasnippet
  1030. Snippets!
  1031. TODO: yas-minor-mode? what's that?
  1032. #+begin_src emacs-lisp
  1033. (use-package yasnippet
  1034. :ensure t
  1035. :diminish yas-minor-mode
  1036. :init
  1037. (setq yas-snippet-dirs (concat PATH_USER_GLOBAL "snippets"))
  1038. (yas-global-mode t)
  1039. :mode ("\\.yasnippet" . snippet-mode)
  1040. ; :config
  1041. ; (yas-reload-all) ;; ensure snippets are updated and available, necessary when not using global-mode
  1042. )
  1043. #+end_src
  1044. ** Lisp
  1045. #+begin_src emacs-lisp
  1046. (add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook)
  1047. #+end_src
  1048. Add some helpers to handle and understand macros
  1049. #+begin_src emacs-lisp
  1050. (use-package macrostep
  1051. :ensure t
  1052. :init
  1053. (define-key emacs-lisp-mode-map (kbd "C-c e") 'macrostep-expand)
  1054. (define-key emacs-lisp-mode-map (kbd "C-c c") 'macrostep-collapse))
  1055. #+end_src
  1056. ** Python
  1057. Systemwide following packages need to be installed:
  1058. - venv
  1059. The virtual environments need to have following modules installed:
  1060. - jedi
  1061. - epc
  1062. - pylint
  1063. #+begin_src emacs-lisp
  1064. (use-package flycheck
  1065. :ensure t
  1066. :diminish flycheck-mode " ✓"
  1067. :init
  1068. (setq flycheck-emacs-lisp-load-path 'inherit)
  1069. (add-hook 'after-init-hook #'global-flycheck-mode)
  1070. (add-hook 'python-mode-hook (lambda ()
  1071. (semantic-mode 1)
  1072. (flycheck-select-checker 'python-pylint)))
  1073. )
  1074. #+end_src
  1075. Automatically start python-mode when opening a .py-file.
  1076. Not sure if python.el is better than python-mode.el.
  1077. See [[https://github.com/jorgenschaefer/elpy/issues/887][here]] for info about ~python-shell-completion-native-enable~.
  1078. 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]].
  1079. Also limit the completion backends to those which make sense in Python.
  1080. #+begin_src emacs-lisp
  1081. (use-package python
  1082. :mode ("\\.py\\'" . python-mode)
  1083. :interpreter ("python" . python-mode)
  1084. :init
  1085. (add-hook 'python-mode-hook 'company/python-mode-hook)
  1086. :config
  1087. (setq python-shell-completion-native-enable nil)
  1088. )
  1089. #+end_src
  1090. Jedi is a backend for python autocompletion and needs to be installed on the server:
  1091. - pip install jedi
  1092. Code checks need to be installed, too:
  1093. - pip install flake8
  1094. #+begin_src emacs-lisp
  1095. (use-package company-jedi
  1096. :defer t
  1097. ;; :after company
  1098. :ensure t
  1099. :config
  1100. (setq jedi:environment-virtualenv (list (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
  1101. (setq jedi:python-environment-directory (list (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
  1102. (add-hook 'python-mode-hook 'jedi:setup)
  1103. (setq jedi:complete-on-dot t)
  1104. (setq jedi:use-shortcuts t)
  1105. ;; (add-hook 'python-mode-hook 'company/python-mode-hook)
  1106. )
  1107. #+end_src
  1108. A wrapper to handle virtual environments.
  1109. I strongly recommend to install virtual environments on the terminal, not through this wrapper, but changing venvs is fine.
  1110. TODO: automatically start an inferior python process or switch to it if already created
  1111. #+begin_src emacs-lisp
  1112. (use-package pyvenv
  1113. :ensure t
  1114. :init
  1115. (setenv "WORKON_HOME" (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))
  1116. :config
  1117. (pyvenv-mode t)
  1118. (defun my/post-activate-hook()
  1119. (setq jedi:environment-root pyvenv-virtual-env)
  1120. (setq jedi:environment-virtualenv pyvenv-virtual-env)
  1121. (setq jedi:tooltip-method '(nil)) ;; variants: nil or pos-tip and/or popup
  1122. (setq python-shell-virtualenv-root pyvenv-virtual-env)
  1123. ;; default traceback, other option M-x jedi:toggle-log-traceback
  1124. ;; traceback is in jedi:pop-to-epc-buffer
  1125. (jedi:setup)
  1126. (company/python-mode-hook)
  1127. (setq jedi:server-args '("--log-traceback")))
  1128. ;; (add-to-list 'company-backends 'company-jedi)
  1129. ;; (add-to-list 'company-backends 'company-anaconda)
  1130. ;; (lambda ()
  1131. ;; (set (make-local-variable 'company-backends)
  1132. ;; '((company-jedi company-dabbrev) company-capf company-files)))
  1133. ;; (setq flycheck-checker 'python-pylint))
  1134. ;; (flycheck-select-checker 'python-pylint))
  1135. ;; (setq flycheck-checker 'python-flake8)
  1136. (add-hook 'pyvenv-post-activate-hooks 'my/post-activate-hook)
  1137. )
  1138. #+end_src
  1139. I want Emacs to automatically start the proper virtual environment.
  1140. Required is a .python-version file with, content in the first line being /path/to/virtualenv/
  1141. [[https://github.com/marcwebbie/auto-virtualenv][Github source]]
  1142. Depends on pyvenv
  1143. #+begin_src emacs-lisp
  1144. (use-package auto-virtualenv
  1145. :ensure t
  1146. ;; :after pyvenv
  1147. ;; :defer t
  1148. :init
  1149. (add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv)
  1150. ;; activate on changing buffers
  1151. ;; (add-hook 'window-configuration-change-hook 'auto-virtualenv-set-virtualenv)
  1152. ;; activate on focus in
  1153. ;; (add-hook 'focus-in-hook 'auto-virtualenv-set-virtualenv)
  1154. )
  1155. #+end_src
  1156. Anaconda test
  1157. begin_src emacs-lisp
  1158. (use-package anaconda-mode
  1159. :ensure t
  1160. :defer t
  1161. :init
  1162. (add-hook 'python-mode-hook 'anaconda-mode)
  1163. ;; (add-hook 'python-mode-hook 'anaconda-eldoc-mode)
  1164. :config
  1165. (setq anaconda-eldoc-mode 1)
  1166. )
  1167. end_src
  1168. begin_src emacs-lisp
  1169. (use-package company-anaconda
  1170. :ensure t
  1171. :defer t
  1172. :init
  1173. (defun my/company-anaconda-hook()
  1174. (add-to-list 'company-backends 'company-anaconda))
  1175. (add-hook 'python-mode-hook 'my/company-anaconda-hook)
  1176. )
  1177. end_src
  1178. ** Hydra Flycheck
  1179. Flycheck is necessary, obviously
  1180. #+begin_src emacs-lisp
  1181. (defhydra hydra-flycheck (:color blue)
  1182. "
  1183. ^
  1184. ^Flycheck^ ^Errors^ ^Checker^
  1185. ^────────^──────────^──────^────────────^───────^───────────
  1186. _q_ quit _<_ previous _?_ describe
  1187. _m_ manual _>_ next _d_ disable
  1188. _v_ verify setup _f_ check _s_ select
  1189. ^^ ^^ ^^
  1190. "
  1191. ("q" nil)
  1192. ("<" flycheck-previous-error :color red)
  1193. (">" flycheck-next-error :color red)
  1194. ("?" flycheck-describe-checker)
  1195. ("d" flycheck-disable-checker)
  1196. ("f" flycheck-buffer)
  1197. ("m" flycheck-manual)
  1198. ("s" flycheck-select-checker)
  1199. ("v" flycheck-verify-setup)
  1200. )
  1201. #+end_src
  1202. * Custom key mappings
  1203. I just use general.el to define keys and keymaps.
  1204. #+BEGIN_SRC emacs-lisp
  1205. (use-package general
  1206. :ensure t
  1207. )
  1208. #+END_SRC
  1209. Now some keymaps.
  1210. If there is no map defined, it is considered the global key map.
  1211. #+BEGIN_SRC emacs-lisp
  1212. (general-define-key
  1213. :states '(normal visual insert emacs)
  1214. :prefix "SPC"
  1215. :non-normal-prefix "M-SPC"
  1216. "TAB" '(ivy-switch-buffer :which-key "prev buffer")
  1217. "SPC" '(counsel-M-x :which-key "M-x"))
  1218. #+END_SRC
  1219. A map for org-mode
  1220. #+BEGIN_SRC emacs-lisp
  1221. (general-define-key
  1222. :states '(normal visual insert emacs)
  1223. :keymaps 'org-mode-map
  1224. :prefix "SPC"
  1225. :non-normal-prefix "M-SPC"
  1226. "t" '(counsel-org-tag :which-key "org-tag"))
  1227. #+END_SRC
  1228. * Quality of Life
  1229. ** Default Window Size
  1230. ;; TODO:
  1231. ;; This size is only reasonable for linux@home
  1232. ;; hyperv is way smaller, use fullscreen here
  1233. ;; pm should be fullscreen, too
  1234. #+BEGIN_SRC emacs-lisp
  1235. (if (display-graphic-p)
  1236. (progn
  1237. (setq initial-frame-alist
  1238. '(
  1239. (width . 165)
  1240. (height . 70)))
  1241. (setq default-frame-alist
  1242. '(
  1243. (width . 165)
  1244. (height . 70))))
  1245. )
  1246. #+END_SRC
  1247. ** Line numbers
  1248. #+BEGIN_SRC emacs-lisp
  1249. (use-package linum
  1250. :ensure t
  1251. :init
  1252. (add-hook 'prog-mode-hook 'linum-mode))
  1253. #+END_SRC
  1254. * Orchestrate the configuration
  1255. Some settings should be set for all systems, some need to be specific (like my job-emacs doesn't need development tools).
  1256. ** Common
  1257. ** Home
  1258. ** Work
  1259. I mainly only use org
  1260. ** Work, Hyper-V
  1261. For testing purproses I keep a working emacs in a debian on hyper-v. The demands here are different to the other work-emacs