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.

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