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.

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