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.

1907 lines
56 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
  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. I need a function to know what computer emacs is running on. The display width of 1152 pixel is an oddity of hyper-v and for my usecase specific enough to tell the machine.
  9. #+BEGIN_SRC emacs-lisp
  10. (defvar my/whoami
  11. (if (string-equal user-login-name "POH")
  12. "work_remote"
  13. (if (equal (display-pixel-width) 1152)
  14. "work_hyperv"
  15. (if (string-equal system-type "gnu/linux")
  16. "home"))))
  17. #+END_SRC
  18. * Stuff to add / to fix
  19. - smartparens
  20. a sane default configuration for navigation, manipulation etc. is still necessary
  21. - Spaceline / Powerline or similar
  22. I want a pretty status bar!
  23. - Git gutter:
  24. Do some configuration to make it useful (see given source link in the [[*Git][Section]] of gutter)
  25. Maybe only enable it for modes where it is likely I use git?
  26. - Some webmode stuff
  27. - markdown:
  28. add hooks for certain file extensions, maybe add a smart way to start gfm-mode if markdown-file is in a git-project
  29. - move package dependend configurations inside the package configuration itself, like keymaps for magit
  30. * Update config in a running config
  31. Two options:
  32. - reload the open file: M-x load-file, then press twice to accept
  33. the default filename, which is the currently opened
  34. - Point at the end of any sexp and press C-x C-e
  35. * Customize default settings
  36. Keep the .emacs.d clean by moving user files into separate directories.
  37. - user-local: directory for machine specific files
  38. - user-global: directory for files which work on any machine
  39. - the backup and auto-save files go right to /tmp
  40. #+BEGIN_SRC emacs-lisp
  41. (defvar PATH_USER_LOCAL (expand-file-name "~/.emacs.d/user-local/"))
  42. (defvar PATH_USER_GLOBAL (expand-file-name "~/.emacs.d/user-global/"))
  43. (setq bookmark-default-file (concat PATH_USER_LOCAL "bookmarks"))
  44. (setq recentf-save-file (concat PATH_USER_LOCAL "recentf"))
  45. (setq custom-file (concat PATH_USER_LOCAL "custom.el")) ;don't spam init.el with saved customize settings
  46. (setq abbrev-file-name (concat PATH_USER_GLOBAL "abbrev_defs"))
  47. (setq backup-directory-alist `((".*" . ,temporary-file-directory)))
  48. (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory)))
  49. (setq save-abbrevs 'silently) ; don't bother me with asking if new abbrevs should be saved
  50. #+END_SRC
  51. These functions are useful. Activate them.
  52. #+BEGIN_SRC emacs-lisp
  53. (put 'downcase-region 'disabled nil)
  54. (put 'upcase-region 'disabled nil)
  55. (put 'narrow-to-region 'disabled nil)
  56. (put 'dired-find-alternate-file 'disabled nil)
  57. #+END_SRC
  58. Disable lock files, which cause trouble in e.g. lsp-mode
  59. #+BEGIN_SRC emacs-lisp
  60. (setq-default create-lockfiles nil)
  61. #+END_SRC
  62. Answering just 'y' or 'n' should be enough.
  63. #+BEGIN_SRC emacs-lisp
  64. (defalias 'yes-or-no-p 'y-or-n-p)
  65. #+END_SRC
  66. Don't ask me if I want to load themes.
  67. #+BEGIN_SRC emacs-lisp
  68. (setq custom-safe-themes t)
  69. #+END_SRC
  70. Don't count two spaces after a period as the end of a sentence.
  71. Just one space is needed
  72. #+BEGIN_SRC emacs-lisp
  73. (setq sentence-end-double-space nil)
  74. #+END_SRC
  75. Scroll to the end / beginning of buffer before you throw an error
  76. #+BEGIN_SRC emacs-lisp
  77. (setq scroll-error-top-bottom t)
  78. #+END_SRC
  79. Delete the region when typing, just like as we expect nowadays.
  80. #+BEGIN_SRC emacs-lisp
  81. (delete-selection-mode t)
  82. #+END_SRC
  83. Auto-indent when pressing RET, just new-line when C-j
  84. #+BEGIN_SRC emacs-lisp
  85. (define-key global-map (kbd "RET") 'newline-and-indent)
  86. (define-key global-map (kbd "C-j") 'newline)
  87. #+END_SRC
  88. Set the default window size depending on the system emacs is running on.
  89. ;; TODO:
  90. ;; This size is only reasonable for linux@home
  91. ;; hyperv is way smaller, use fullscreen here
  92. ;; pm should be fullscreen, too
  93. #+BEGIN_SRC emacs-lisp
  94. (if (display-graphic-p)
  95. (pcase my/whoami
  96. ("home" (progn
  97. (setq initial-frame-alist
  98. '((width . 165)
  99. (height . 70)))
  100. (setq default-frame-alist
  101. '((width . 165)
  102. (height . 70)))))
  103. ("work_remote" (add-to-list 'initial-frame-alist '(fullscreen . maximized)))
  104. ("work_hyperv" (add-to-list 'initial-frame-alist '(fullscreen . maximized)))))
  105. #+END_SRC
  106. * Windows specific stuff
  107. ** Performance
  108. [[https://github.com/cbowdon/Config/blob/master/emacs/init.org][Got it from here]]
  109. #+BEGIN_SRC emacs-lisp
  110. (when (eq system-type 'windows-nt)
  111. (if (>= emacs-major-version 25)
  112. (remove-hook 'find-file-hooks 'vc-refresh-state)
  113. (remove-hook 'find-file-hooks 'vc-find-file-hook))
  114. (progn
  115. (setq gc-cons-threshold (* 511 1024 1024)
  116. gc-cons-percentage 0.5
  117. garbage-collection-messages t)
  118. (run-with-idle-timer 5 t #'garbage-collect)))
  119. #+END_SRC
  120. Hopefully this makes magit faster
  121. #+BEGIN_SRC emacs-lisp
  122. (when (eq system-type 'windows-nt)
  123. (setq w32-pipe-read-delay 0)
  124. (setq w32-get-true-file-attributes nil))
  125. #+END_SRC
  126. * Visuals
  127. ** Font
  128. Don't add the font in the work environment, which I am logged in as POH
  129. #+BEGIN_SRC emacs-lisp
  130. (pcase my/whoami
  131. ("home" (set-face-attribute 'default nil :font "Hack-10"))
  132. ("work_hyperv" (set-face-attribute 'default nil :font "Hack-12"))
  133. )
  134. #+END_SRC
  135. ** Themes
  136. *** Material Theme
  137. The [[https://github.com/cpaulik/emacs-material-theme][Material Theme]] comes in a dark and a light variant. Not too dark
  138. to be strenious though.
  139. b
  140. #+BEGIN_SRC emacs-lisp
  141. (use-package material-theme
  142. :if (window-system)
  143. :defer t
  144. :ensure t
  145. )
  146. #+END_SRC
  147. *** Apropospriate Theme
  148. Variants dark and light
  149. #+BEGIN_SRC emacs-lisp
  150. (use-package apropospriate-theme
  151. :if (window-system)
  152. :defer t
  153. :ensure t
  154. )
  155. #+END_SRC
  156. *** Ample Theme
  157. Variants:
  158. - ample
  159. - ample-flat
  160. - ample-light
  161. #+BEGIN_SRC emacs-lisp
  162. (use-package ample-theme
  163. :if (window-system)
  164. :defer t
  165. :ensure t
  166. :init
  167. (load-theme 'ample-flat t)
  168. )
  169. #+END_SRC
  170. ** Prettier Line Wraps
  171. By default there is no line wrapping. M-q actually modifies the buffer, which might not be wanted.
  172. So: enable visual wrapping and keep indentation if there are any.
  173. #+BEGIN_SRC emacs-lisp
  174. (global-visual-line-mode)
  175. (diminish 'visual-line-mode)
  176. (use-package adaptive-wrap
  177. :ensure t
  178. :init
  179. (when (fboundp 'adaptive-wrap-prefix-mode)
  180. (defun my-activate-adaptive-wrap-prefix-mode ()
  181. "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously."
  182. (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1)))
  183. (add-hook 'visual-line-mode-hook 'my-activate-adaptive-wrap-prefix-mode))
  184. )
  185. #+END_SRC
  186. ** Mode Line
  187. Change the default mode line to something prettier. [[https://github.com/Malabarba/smart-mode-line][Source]]
  188. #+BEGIN_SRC emacs-lisp
  189. (use-package smart-mode-line
  190. :ensure t
  191. :config
  192. (tool-bar-mode -1)
  193. (setq sml/theme 'respectful)
  194. (setq sml/name-width 40)
  195. (setq sml/mode-width 'full)
  196. (set-face-attribute 'mode-line nil
  197. :box nil)
  198. (sml/setup))
  199. #+END_SRC
  200. ** Line numbers
  201. #+BEGIN_SRC emacs-lisp
  202. (use-package linum
  203. :ensure t
  204. :init
  205. (add-hook 'prog-mode-hook 'linum-mode))
  206. #+END_SRC
  207. ** Misc
  208. UTF-8 please, but don't mess with line endings.
  209. #+BEGIN_SRC emacs-lisp
  210. (setq locale-coding-system 'utf-8)
  211. (set-terminal-coding-system 'utf-8)
  212. (set-keyboard-coding-system 'utf-8)
  213. (set-selection-coding-system 'utf-8)
  214. (if (eq system-type 'windows-nt)
  215. (prefer-coding-system 'utf-8-dos)
  216. (prefer-coding-system 'utf-8))
  217. #+END_SRC
  218. Turn off blinking cursor
  219. #+BEGIN_SRC emacs-lisp
  220. (blink-cursor-mode -1)
  221. #+END_SRC
  222. #+BEGIN_SRC emacs-lisp
  223. (show-paren-mode t)
  224. (column-number-mode t)
  225. (setq uniquify-buffer-name-style 'forward)
  226. #+END_SRC
  227. Avoid tabs in place of multiple spaces (they look bad in TeX) and show empty lines
  228. #+BEGIN_SRC emacs-lisp
  229. (setq-default indent-tabs-mode nil)
  230. (setq-default indicate-empty-lines t)
  231. #+END_SRC
  232. Smooth scrolling. Emacs tends to be jumpy, this should change it.
  233. #+BEGIN_SRC emacs-lisp
  234. (setq scroll-margin 5
  235. scroll-conservatively 10000
  236. scroll-preserve-screen-position 1
  237. scroll-step 1)
  238. #+END_SRC
  239. Highlight current line
  240. #+BEGIN_SRC emacs-lisp
  241. (global-hl-line-mode t)
  242. #+END_SRC
  243. * Usability
  244. ** which-key
  245. Greatly increases discovery of functions!
  246. Click [[https://github.com/justbur/emacs-which-key][here]] for source and more info.
  247. Info in Emacs: M-x customize-group which-key
  248. #+BEGIN_SRC emacs-lisp
  249. (use-package which-key
  250. :ensure t
  251. :diminish which-key-mode
  252. :config
  253. (which-key-mode)
  254. (which-key-setup-side-window-right-bottom)
  255. (which-key-setup-minibuffer)
  256. (setq which-key-idle-delay 0.5)
  257. )
  258. #+END_SRC
  259. ** Recentf
  260. Activate and configure recentf
  261. #+BEGIN_SRC emacs-lisp
  262. (recentf-mode t)
  263. (setq recentf-max-saved-items 200)
  264. #+END_SRC
  265. ** Hydra
  266. Hydra allows grouping of commands
  267. #+BEGIN_SRC emacs-lisp
  268. (use-package hydra
  269. :ensure t
  270. :bind
  271. ("C-c f" . hydra-flycheck/body)
  272. ("C-c g" . hydra-git-gutter/body)
  273. :config
  274. (setq-default hydra-default-hint nil)
  275. )
  276. #+END_SRC
  277. ** Evil
  278. So... Evil Mode might be worth a try
  279. #+BEGIN_SRC emacs-lisp
  280. (use-package evil
  281. :ensure t
  282. :defer .1 ;; don't block emacs when starting, load evil immediately after startup
  283. :init
  284. (setq evil-want-integration nil) ;; required by evil-collection
  285. :config
  286. (evil-mode 1)) ;; for now deactivate per default
  287. #+END_SRC
  288. Evil-collection is a bundle of configs for different modes.
  289. 2018-05-01: evil collection causes error
  290. "Invalid function: with-helm-buffer"
  291. #+BEGIN_SRC emacs-lisp
  292. ;(use-package evil-collection
  293. ; :after evil
  294. ; :ensure t
  295. ; :config
  296. ; (evil-collection-init))
  297. #+END_SRC
  298. Evil-goggles give visual hints when editing texts, so it's more obvious what is actually happening. [[https://github.com/edkolev/evil-goggles][Source]]
  299. #+BEGIN_SRC emacs-lisp
  300. (use-package evil-goggles
  301. :after evil
  302. :ensure t
  303. :diminish evil-goggles-mode
  304. :config
  305. (evil-goggles-mode)
  306. (evil-goggles-use-diff-faces))
  307. #+END_SRC
  308. ** General (keymapper)
  309. 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.
  310. [[https://github.com/noctuid/general.el][Source]]
  311. #+BEGIN_SRC emacs-lisp
  312. (use-package general
  313. :ensure t
  314. )
  315. #+END_SRC
  316. ** Custom key mappings
  317. Now some keymaps.
  318. If there is no map defined, it is considered the global key map.
  319. #+BEGIN_SRC emacs-lisp
  320. (general-define-key
  321. :states '(normal visual insert emacs)
  322. :prefix "SPC"
  323. :non-normal-prefix "M-SPC"
  324. "TAB" '(ivy-switch-buffer :which-key "prev buffer")
  325. "SPC" '(counsel-M-x :which-key "M-x")
  326. "g" '(:ignore t :which-key "Git")
  327. "gs" '(magit-status :which-key "git-status")
  328. )
  329. #+END_SRC
  330. A map for org-mode
  331. #+BEGIN_SRC emacs-lisp
  332. (general-define-key
  333. :states '(normal visual insert emacs)
  334. :keymaps 'org-mode-map
  335. :prefix "SPC"
  336. :non-normal-prefix "M-SPC"
  337. "t" '(counsel-org-tag :which-key "org-tag"))
  338. #+END_SRC
  339. A map for dired, based on [[https://github.com/emacs-evil/evil-collection/blob/master/evil-collection-dired.el][evil-collection]]
  340. #+BEGIN_SRC emacs-lisp
  341. (general-define-key
  342. :states '(normal visual insert emacs)
  343. :keymaps 'dired-mode-map
  344. "q" '(quit-window :which-key "quit-window")
  345. "j" '(dired-next-line :which-key "next line")
  346. "k" '(dired-previous-line :which-key "previous line")
  347. "D" '(dired-do-delete :which-key "delete")
  348. "C" '(dired-do-copy :which-key "copy")
  349. "t" '(:ignore t :which-key "dir navigation")
  350. "td" '(dired-tree-down :which-key "tree down")
  351. "tu" '(dired-tree-up :which-key "tree up")
  352. "tn" '(dired-next-subdir :which-key "next subdir")
  353. "tp" '(dired-prev-subdir :which-key "previous subdir")
  354. )
  355. #+END_SRC
  356. #+BEGIN_SRC emacs-lisp
  357. (general-define-key
  358. :states '(normal)
  359. :keymaps 'lsp-ui-imenu-mode-map
  360. (kbd "RET") '(lsp-ui-imenu--view :which-key "view")
  361. (kbd "M-RET") '(lsp-ui-imenu--visit :which-key "visit")
  362. )
  363. #+END_SRC
  364. ** List buffers
  365. Ibuffer is the improved version of list-buffers.
  366. Make ibuffer the default buffer lister. [[http://ergoemacs.org/emacs/emacs_buffer_management.html][Source]]
  367. #+BEGIN_SRC emacs-lisp
  368. (defalias 'list-buffers 'ibuffer)
  369. #+END_SRC
  370. Also auto refresh dired, but be quiet about it. [[http://whattheemacsd.com/sane-defaults.el-01.html][Source]]
  371. #+BEGIN_SRC emacs-lisp
  372. (add-hook 'dired-mode-hook 'auto-revert-mode)
  373. (setq global-auto-revert-non-file-buffers t)
  374. (setq auto-revert-verbose nil)
  375. #+END_SRC
  376. ** ivy / counsel / swiper
  377. Flx is required for fuzzy-matching
  378. Is it really necessary?
  379. BEGIN_SRC emacs-lisp
  380. (use-package flx)
  381. end_src
  382. Ivy displays a window with suggestions for hotkeys and M-x
  383. #+BEGIN_SRC emacs-lisp
  384. (use-package ivy
  385. :ensure t
  386. :diminish
  387. (ivy-mode . "") ;; does not display ivy in the mode line
  388. :init
  389. (ivy-mode 1)
  390. :bind
  391. ("C-c C-r" . ivy-resume)
  392. :config
  393. (setq ivy-use-virtual-buffers t) ;; recent files and bookmarks in ivy-switch-buffer
  394. (setq ivy-height 20) ;; height of ivy window
  395. (setq ivy-count-format "%d/%d") ;; current and total number
  396. (setq ivy-re-builders-alist ;; regex replaces spaces with *
  397. '((t . ivy--regex-plus)))
  398. )
  399. #+END_SRC
  400. The find-file replacement is nicer to navigate
  401. #+BEGIN_SRC emacs-lisp
  402. (use-package counsel
  403. :ensure t
  404. :bind* ;; load counsel when pressed
  405. (("M-x" . counsel-M-x)
  406. ("C-x C-f" . counsel-find-file)
  407. ("C-x C-r" . counsel-recentf)
  408. ("C-c C-f" . counsel-git)
  409. ("C-c h f" . counsel-describe-function)
  410. ("C-c h v" . counsel-describe-variable)
  411. ("M-i" . counsel-imenu)
  412. )
  413. )
  414. #+END_SRC
  415. Swiper ivy-enhances isearch
  416. #+BEGIN_SRC emacs-lisp
  417. (use-package swiper
  418. :ensure t
  419. :bind
  420. (("C-s" . swiper)
  421. ("C-c C-r" . ivy-resume)
  422. )
  423. )
  424. #+END_SRC
  425. Ivy-Hydra adds stuff in minibuffer when you press C-o
  426. #+BEGIN_SRC emacs-lisp
  427. (use-package ivy-hydra
  428. :ensure t)
  429. #+END_SRC
  430. ** Helm
  431. This is just a try to see how it works differently.
  432. #+BEGIN_SRC emacs-lisp
  433. (use-package helm
  434. :ensure t
  435. :init
  436. (helm-mode 1)
  437. :bind
  438. ; (("M-x" . helm-M-x)
  439. ; ("C-x C-f" . helm-find-files)
  440. ; ("C-x C-r" . helm-recentf)
  441. ; ("C-x b" . helm-buffers-list))
  442. :config
  443. (setq helm-buffers-fuzzy-matching t)
  444. )
  445. (use-package helm-descbinds
  446. :ensure t
  447. :bind
  448. ("C-h b" . helm-descbinds))
  449. (use-package helm-projectile
  450. :ensure t
  451. :config
  452. (helm-projectile-on))
  453. #+END_SRC
  454. ** Undo
  455. Show an undo tree in a new buffer which can be navigated.
  456. #+BEGIN_SRC emacs-lisp
  457. (use-package undo-tree
  458. :ensure t
  459. :diminish undo-tree-mode
  460. :init
  461. (global-undo-tree-mode 1))
  462. #+END_SRC
  463. ** Ido (currently inactive)
  464. better completion
  465. #+BEGIN_SRC emacs-lisp
  466. ;(use-package ido
  467. ; :init
  468. ; (setq ido-enable-flex-matching t)
  469. ; (setq ido-everywhere t)
  470. ; (ido-mode t)
  471. ; (use-package ido-vertical-mode
  472. ; :ensure t
  473. ; :defer t
  474. ; :init
  475. ; (ido-vertical-mode 1)
  476. ; (setq ido-vertical-define-keys 'C-n-and-C-p-only)
  477. ; )
  478. ;)
  479. #+END_SRC
  480. ** imenu-list
  481. A minor mode to show imenu in a sidebar.
  482. Call imenu-list-smart-toggle.
  483. [[https://github.com/bmag/imenu-list][Source]]
  484. #+BEGIN_SRC emacs-lisp
  485. (use-package imenu-list
  486. :ensure t
  487. :config
  488. (setq imenu-list-focus-after-activation t
  489. imenu-list-auto-resize t
  490. imenu-list-position 'right)
  491. :bind
  492. (:map global-map
  493. ([f9] . imenu-list-smart-toggle))
  494. )
  495. #+END_SRC
  496. ** Treemacs
  497. A file manager comparable to neotree.
  498. [[https://github.com/Alexander-Miller/treemacs][Github]]
  499. It has some requirements, which gets used here anyway:
  500. - ace-window
  501. - hydra
  502. - projectile
  503. - python
  504. I copied the configuration example from the github site.
  505. No idea what this executable-find is about.
  506. TODO check it out!
  507. #+BEGIN_SRC emacs-lisp
  508. (use-package treemacs
  509. :ensure t
  510. :defer t
  511. :config
  512. (setq treemacs-collapse-dirs (if (executable-find "python") 3 0)
  513. treemacs-file-event-delay 5000
  514. treemacs-follow-after-init t
  515. treemacs-follow-recenter-distance 0.1
  516. treemacs-goto-tag-strategy 'refetch-index
  517. treemacs-indentation 2
  518. treemacs-indentation-string " "
  519. treemacs-is-never-other-window nil
  520. treemacs-no-png-images nil
  521. treemacs-project-follow-cleanup nil
  522. treemacs-recenter-after-file-follow nil
  523. treemacs-recenter-after-tag-follow nil
  524. treemacs-show-hidden-files t
  525. treemacs-silent-filewatch nil
  526. treemacs-silent-refresh nil
  527. treemacs-sorting 'alphabetic-desc
  528. treemacs-tag-follow-cleanup t
  529. treemacs-tag-follow-delay 1.5
  530. treemacs-width 35)
  531. (treemacs-follow-mode t)
  532. (treemacs-filewatch-mode t)
  533. (pcase (cons (not (null (executable-find "git")))
  534. (not (null (executable-find "python3"))))
  535. (`(t . t)
  536. (treemacs-git-mode 'extended))
  537. (`(t . _)
  538. (treemacs-git-mode 'simple)))
  539. :bind
  540. (:map global-map
  541. ([f8] . treemacs))
  542. )
  543. #+END_SRC
  544. Treemacs-Evil is necessary when using evil
  545. #+BEGIN_SRC emacs-lisp
  546. (use-package treemacs-evil
  547. :after treemacs evil
  548. :ensure t)
  549. #+END_SRC
  550. Treemacs-projectile is useful for uhh.. TODO explain!
  551. #+BEGIN_SRC emacs-lisp
  552. (use-package treemacs-projectile
  553. :ensure t
  554. :after treemacs projectile
  555. :defer t
  556. :config
  557. (setq treemacs-header-function #'treemacs-projectile-create-header)
  558. )
  559. #+END_SRC
  560. TODO
  561. Hydrastuff or keybindings for functions:
  562. - treemacs-projectile
  563. - treemacs-projectile-toggle
  564. - treemacs-toggle
  565. - treemacs-bookmark
  566. - treemacs-find-file
  567. - treemacs-find-tag
  568. ** Window Handling
  569. Some tools to easen the navigation, creation and deletion of windows
  570. *** Ace-Window
  571. #+BEGIN_SRC emacs-lisp
  572. (use-package ace-window
  573. :ensure t
  574. :init
  575. (global-set-key (kbd "C-x o") 'ace-window)
  576. )
  577. #+END_SRC
  578. *** Windmove
  579. Windmove easens the navigation between windows.
  580. Here we are setting the default keybindings (shift+arrow)
  581. CURRENTLY NOT WORKING, defaults are blocked.
  582. Also not sure if necessary when using ace-window.
  583. #+BEGIN_SRC emacs-lisp
  584. (use-package windmove
  585. :ensure t
  586. :config
  587. (windmove-default-keybindings)
  588. )
  589. #+END_SRC
  590. ** Tramp
  591. With tramp you can handle remote files like local files.
  592. Usage example:
  593. C-x C-f /ssh:name@server:/path
  594. To open a file as sudo:
  595. C-x C-f /ssh:/name@server|sudo:name@server:/path
  596. #+BEGIN_SRC emacs-lisp
  597. (use-package tramp
  598. :ensure t
  599. )
  600. #+END_SRC
  601. ** misc
  602. Visual feedback when using regexp on the buffer
  603. #+BEGIN_SRC emacs-lisp
  604. (use-package visual-regexp
  605. :ensure t
  606. :defer t
  607. :bind (("C-c r s" . query-replace)
  608. ("C-c r R" . vr/replace)
  609. ("C-c r r" . vr/query-replace)
  610. ("C-c r m" . vr/mc-mark)))
  611. #+END_SRC
  612. Newline at the end of file
  613. #+BEGIN_SRC emacs-lisp
  614. (setq require-final-newline t)
  615. #+END_SRC
  616. Delete the selection with a keypress
  617. #+BEGIN_SRC emacs-lisp
  618. (delete-selection-mode t)
  619. #+END_SRC
  620. Remember the current location in a file
  621. #+BEGIN_SRC emacs-lisp
  622. (use-package saveplace
  623. :unless noninteractive
  624. :config
  625. (save-place-mode))
  626. #+END_SRC
  627. * Org Mode
  628. ** Installation
  629. 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.]]
  630. Added a hook to complete org functions, company-capf is necessary for this
  631. #+BEGIN_SRC emacs-lisp
  632. (use-package org-plus-contrib
  633. :ensure t
  634. :init
  635. (add-hook 'org-mode-hook 'company/org-mode-hook)
  636. )
  637. (add-hook 'org-mode-hook 'company/org-mode-hook)
  638. #+END_SRC
  639. 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:
  640. #+BEGIN_SRC shell
  641. var ORG_DIR=(let* ((org-v (cadr (split-string (org-version nil t) "@"))) (len (length org-v))) (substring org-v 1 (- len 2)))
  642. rm ${ORG_DIR}/*.elc
  643. echo 'cleaned .elc from package directory'
  644. #+END_SRC
  645. ** Setup
  646. *** Paths
  647. Paths need to be different for work and home
  648. #+BEGIN_SRC emacs-lisp
  649. (pcase my/whoami
  650. ("work_remote"
  651. (progn
  652. (defvar PATH_ORG_FILES "p:/Eigene Dateien/Notizen/")
  653. (defvar PATH_ORG_JOURNAL "p:/Eigene Dateien/Notizen/Journal/")
  654. (defvar PATH_START "p:/Eigene Dateien/Notizen/"))
  655. (setq org-default-notes-file (concat PATH_ORG_FILES "notes.org"))
  656. (setq org-agenda-files (list(concat PATH_ORG_FILES "notes.org")
  657. (concat PATH_ORG_FILES "projects.org")
  658. (concat PATH_ORG_FILES "todo.org"))))
  659. ("home"
  660. (progn
  661. (defvar PATH_ORG_FILES_MOBILE "~/Archiv/Organisieren/mobile/")
  662. (defvar PATH_ORG_JOURNAL "~/Archiv/Organisieren/Journal/")
  663. (defvar PATH_ORG_FILES "~/Archiv/Organisieren/")
  664. (setq org-default-notes-file (concat PATH_ORG_FILES "notes.org"))
  665. ;; TODO: ignore notes.org, which shouldn't include any todos
  666. ;; (setq org-agenda-file-regexp "'\\`[^.].*\\.org\\'")
  667. (setq org-agenda-files (list PATH_ORG_FILES PATH_ORG_FILES_MOBILE))))
  668. )
  669. (setq org-id-locations-file (concat PATH_USER_LOCAL ".org-id-locations"))
  670. #+END_SRC
  671. *** Settings
  672. 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.
  673. See the doc for speed keys by checking out the documentation for speed keys in Org mode.
  674. #+BEGIN_SRC emacs-lisp
  675. (setq org-use-speed-commands t)
  676. (setq org-image-actual-width 550)
  677. (setq org-highlight-latex-and-related '(latex script entities))
  678. #+END_SRC
  679. Hide emphasis markup (e.g. / ... / for italics, etc.)
  680. #+BEGIN_SRC emacs-lisp
  681. (setq org-hide-emphasis-markers t)
  682. #+END_SRC
  683. The default value for the org tag column is -77, which is weird for smaller width windows. I'd rather have the tags align horizontally with the header.
  684. 45 is a good column number to do that.
  685. #+BEGIN_SRC emacs-lisp
  686. (setq org-tags-column 45)
  687. #+END_SRC
  688. Set the org-refile targets.
  689. TODO: change maxlevel if necessary
  690. #+BEGIN_SRC emacs-lisp
  691. (setq org-refile-targets '((org-agenda-files . (:maxlevel . 1))))
  692. #+END_SRC
  693. *** Org key bindings
  694. Set up some global key bindings that integrate with Org mode features
  695. #+BEGIN_SRC emacs-lisp
  696. (bind-key "C-c l" 'org-store-link)
  697. (bind-key "C-c c" 'org-capture)
  698. (bind-key "C-c a" 'org-agenda)
  699. #+END_SRC
  700. Org overwrites RET and C-j, so I need to disable the rebinds
  701. #+BEGIN_SRC emacs-lisp
  702. (define-key org-mode-map (kbd "RET") nil) ;;org-return
  703. (define-key org-mode-map (kbd "C-j") nil) ;;org-return-indent
  704. #+END_SRC
  705. *** Org agenda
  706. For a more detailed example [[https://github.com/sachac/.emacs.d/blob/83d21e473368adb1f63e582a6595450fcd0e787c/Sacha.org#org-agenda][see here]].
  707. Custom todo-keywords, depending on environment
  708. #+BEGIN_SRC emacs-lisp
  709. (pcase my/whoami
  710. ("work_remote")
  711. (setq org-todo-keywords
  712. '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE")))
  713. )
  714. #+END_SRC
  715. Sort org agenda by deadline and priority
  716. #+BEGIN_SRC emacs-lisp
  717. (setq org-agenda-sorting-strategy
  718. (quote
  719. ((agenda deadline-up priority-down)
  720. (todo priority-down category-keep)
  721. (tags priority-down category-keep)
  722. (search category-keep)))
  723. )
  724. #+END_SRC
  725. Customize the org agenda
  726. #+BEGIN_SRC emacs-lisp
  727. (defun my-org-skip-subtree-if-priority (priority)
  728. "Skip an agenda subtree if it has a priority of PRIORITY.
  729. PRIORITY may be one of the characters ?A, ?B, or ?C."
  730. (let ((subtree-end (save-excursion (org-end-of-subtree t)))
  731. (pri-value (* 1000 (- org-lowest-priority priority)))
  732. (pri-current (org-get-priority (thing-at-point 'line t))))
  733. (if (= pri-value pri-current)
  734. subtree-end
  735. nil)))
  736. (setq org-agenda-custom-commands
  737. '(("c" "Simple agenda view"
  738. ((tags "PRIORITY=\"A\""
  739. ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
  740. (org-agenda-overriding-header "Hohe Priorität:")))
  741. (agenda ""
  742. ((org-agenda-span 7)
  743. (org-agenda-start-on-weekday nil)
  744. (org-agenda-overriding-header "Nächsten 7 Tage:")))
  745. (alltodo ""
  746. ((org-agenda-skip-function '(or (my-org-skip-subtree-if-priority ?A)
  747. (org-agenda-skip-if nil '(scheduled deadline))))
  748. (org-agenda-overriding-header "Sonstige Aufgaben:"))))))
  749. )
  750. #+END_SRC
  751. *** Org Capture
  752. The basic format is:
  753. hotkey - name - type - location - content
  754. For todos a prompt for the title is demanded. This made it possible to place the cursor for the content to the right position. Just typing, C-c C-c, done!
  755. #+BEGIN_SRC emacs-lisp
  756. (pcase my/whoami
  757. ("home"
  758. (setq org-capture-templates
  759. `(("n" "note" entry (org-default-notes-file))
  760. ("t" "todo" entry (file+headline ,(concat PATH_ORG_FILES "tasks.org") "Tasks")
  761. "* TODO %^{Title}\n %u\n %?\n")
  762. ("c" "coding todo" entry (file+headline ,(concat PATH_ORG_FILES "tasks.org") "Tasks")
  763. "* TODO %^{Title}\n %u %a\n %?\n")
  764. ("p" "project" entry (file+headline ,(concat PATH_ORG_FILES "tasks.org") "Projects")
  765. "* TODO %^{Title} %^g\n %u\n %?\n"))))
  766. ("work_remote"
  767. (setq org-capture-templates
  768. `(("n" "note" entry (file org-default-notes-file))
  769. ("t" "todo" entry (file+headline ,(concat PATH_ORG_FILES "todo.org") "Todos")
  770. "* TODO %^{Title}\n %u\n %?\n")
  771. ("p" "project" entry (file+headline ,(concat PATH_ORG_FILES "projects.org") "Projekte")
  772. "* OPEN %^{Title}\n %u\n** Beschreibung\n %?\n** Zu erledigen\n*** \n** Verlauf\n*** a\n"))))
  773. )
  774. #+END_SRC
  775. ** Org babel languages
  776. This code block is linux specific. Loading languages which aren't available seems to be a problem.
  777. New: Load languages on demand. I need to test if this works as intended.
  778. #+BEGIN_SRC emacs-lisp
  779. (defadvice org-babel-execute-src-block (around load-language nil activate)
  780. "Load language if needed"
  781. (let ((language (org-element-property :language (org-element-at-point))))
  782. (unless (cdr (assoc (intern language) org-babel-load-languages))
  783. (add-to-list 'org-babel-load-languages (cons (intern language) t))
  784. (org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages))
  785. ad-do-it))
  786. #+END_SRC
  787. BEGIN_SRC emacs-lisp
  788. (cond ((eq system-type 'gnu/linux)
  789. (org-babel-do-load-languages
  790. 'org-babel-load-languages
  791. '(
  792. (C . t)
  793. (calc . t)
  794. (java . t)
  795. (ipython . t)
  796. (js . t)
  797. (latex . t)
  798. (ledger . t)
  799. (beancount . t)
  800. (lisp . t)
  801. (python . t)
  802. (R . t)
  803. (ruby . t)
  804. (scheme . t)
  805. (shell . t)
  806. (sqlite . t)
  807. )
  808. ))
  809. )
  810. END_SRC
  811. #+BEGIN_SRC emacs-lisp
  812. (defun my-org-confirm-babel-evaluate (lang body)
  813. "Do not confirm evaluation for these languages."
  814. (not (or (string= lang "beancount")
  815. (string= lang "C")
  816. (string= lang "emacs-lisp")
  817. (string= lang "ipython")
  818. (string= lang "java")
  819. (string= lang "ledger")
  820. (string= lang "python")
  821. (string= lang "R")
  822. (string= lang "sqlite"))))
  823. (setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate)
  824. #+END_SRC
  825. TODO: ess belongs to programming languages
  826. to start an ess instance C-c C-s
  827. #+BEGIN_SRC emacs-lisp
  828. (use-package ess
  829. :ensure t
  830. :init
  831. (add-hook 'ess-mode-hook 'company/ess-mode-hook)
  832. )
  833. (add-hook 'org-babel-after-execute-hook 'org-display-inline-images)
  834. (add-hook 'org-mode-hook 'org-display-inline-images)
  835. #+END_SRC
  836. ** Org babel/source blocks
  837. 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
  838. 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
  839. #+BEGIN_SRC emacs-lisp
  840. (setq org-src-fontify-natively t
  841. org-src-window-setup 'current-window
  842. org-src-strip-leading-and-trailing-blank-lines t
  843. org-src-preserve-indentation nil ; these two lines respect the indentation of
  844. org-edit-src-content-indentation 0 ; the surrounding text around the source block
  845. org-src-tab-acts-natively t)
  846. #+END_SRC
  847. ** Org babel helper functions
  848. * Pandoc
  849. Convert between formats, like from org to html.
  850. Pandoc needs to be installed on the system
  851. #+BEGIN_EXAMPLE
  852. sudo apt install pandoc
  853. #+END_EXAMPLE
  854. Pandoc-mode is a minor mode to interact with pandoc
  855. #+BEGIN_SRC emacs-lisp
  856. (use-package pandoc-mode
  857. :ensure t
  858. :init
  859. (add-hook 'markdown-mode-hook 'pandoc-mode))
  860. #+END_SRC
  861. * Emails
  862. Currently following tools are required:
  863. - notmuch (edit, read, tag, delete emails)
  864. - isync /mbsync (fetch or sync emails)
  865. 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.
  866. TODO:
  867. - setup of mbsync on linux
  868. - setup of notmuch on linux
  869. - shell script for installation of isync and notmuch
  870. - more config for notmuch?
  871. - hydra for notmuch?
  872. - maybe org-notmuch?
  873. - some way to refresh the notmuch db before I run notmuch?
  874. #+BEGIN_SRC emacs-lisp
  875. (unless (string-equal my/whoami "work_remote")
  876. (use-package notmuch
  877. :defer t
  878. :ensure t
  879. )
  880. )
  881. #+END_SRC
  882. * Personal Finances
  883. After trying ledger, I chose beancount. It is closer to real bookkeeping and has stricter rules.
  884. Since there is no debian package, it is an option to install it via pip.
  885. I picked /opt for the installation path
  886. #+BEGIN_EXAMPLE
  887. sudo su
  888. cd /opt
  889. python3 -m venv beancount
  890. source ./beancount/bin/activate
  891. pip3 install wheel
  892. pip3 install beancount
  893. sleep 100
  894. echo "shell running!"
  895. deactivate
  896. #+END_EXAMPLE
  897. When using beancount, it will automatically pick the created virtual environment.
  898. Activate the beancount mode. ATTENTION: This mode is made by myself.
  899. #+BEGIN_SRC emacs-lisp
  900. (unless (string-equal my/whoami "work_remote")
  901. (load "/home/marc/.emacs.d/user-local/elisp/beancount-mode.el") ; somehow load-path in use-package doesn't work
  902. (use-package beancount
  903. :load-path "/home/marc/.emacs.d/elisp"
  904. :defer t
  905. :mode ("\\.beancount$" . beancount-mode)
  906. :init
  907. (add-hook 'beancount-mode-hook 'company/beancount-mode-hook)
  908. (setenv "PATH"
  909. (concat
  910. "/opt/beancount/bin:"
  911. (getenv "PATH"))
  912. )
  913. :config
  914. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount")
  915. )
  916. )
  917. #+END_SRC
  918. To support org-babel, check if it can find the symlink to ob-beancount.el.
  919. #+BEGIN_SRC shell
  920. orgpath=`find /home/marc/.emacs.d/elpa/ -type d -name "org-plus*" -print`
  921. beansym="$orgpath/ob-beancount.el"
  922. bean="/home/marc/Archiv/Programmierprojekte/Lisp/beancount-mode/ob-beancount.el"
  923. if [ -h "$beansym" ]
  924. then
  925. echo "$beansym found"
  926. elif [ -e "$bean" ]
  927. then
  928. echo "creating symlink"
  929. ln -s "$bean" "$beansym"
  930. else
  931. echo "$bean not found, symlink creation aborted"
  932. fi
  933. #+END_SRC
  934. #+RESULTS:
  935. : /home/marc/.emacs.d/elpa/org-plus-contrib-20180521/ob-beancount.el found
  936. Installing fava for reports is strongly recommended.
  937. #+BEGIN_EXAMPLE
  938. cd /opt
  939. python3 -m venv vava
  940. source ./vava/bin/activate
  941. pip3 install wheel
  942. pip3 install fava
  943. deactivate
  944. #+END_EXAMPLE
  945. Start fava with
  946. #+BEGIN_EXAMPLE
  947. fava my_file.beancount
  948. #+END_EXAMPLE
  949. It is accessable on this URL: [[http://127.0.0.1:5000][Fava]]
  950. Beancount-mode can start fava and open the URL right away.
  951. * Programming
  952. ** Common things
  953. List of plugins and settings which are shared between the language plugins
  954. Highlight whitespaces, tabs, empty lines.
  955. #+BEGIN_SRC emacs-lisp
  956. (use-package whitespace
  957. :demand t
  958. :ensure nil
  959. :diminish whitespace-mode;;mode shall be active, but not shown in mode line
  960. :init
  961. (dolist (hook '(prog-mode-hook
  962. text-mode-hook
  963. conf-mode-hook))
  964. (add-hook hook #'whitespace-mode))
  965. ;; :hook ;;not working in use-package 2.3
  966. ;; ((prog-mode . whitespace-turn-on)
  967. ;; (text-mode . whitespace-turn-on))
  968. :config
  969. (setq-default whitespace-style '(face empty tab trailing))
  970. )
  971. #+END_SRC
  972. Disable Eldoc, it interferes with flycheck
  973. #+BEGIN_SRC emacs-lisp
  974. (use-package eldoc
  975. :ensure nil
  976. :config
  977. (global-eldoc-mode -1)
  978. )
  979. #+END_SRC
  980. Colorize colors as text with their value
  981. #+BEGIN_SRC emacs-lisp
  982. (use-package rainbow-mode
  983. :ensure t
  984. :init
  985. (add-hook 'prog-mode-hook 'rainbow-mode t)
  986. :diminish rainbow-mode
  987. ;; :hook prog-mode ;; not working in use-package 2.3
  988. :config
  989. (setq-default rainbow-x-colors-major-mode-list '())
  990. )
  991. #+END_SRC
  992. Highlight parens etc. for improved readability
  993. #+BEGIN_SRC emacs-lisp
  994. (use-package rainbow-delimiters
  995. :ensure t
  996. :config
  997. (add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
  998. )
  999. #+END_SRC
  1000. Treat CamelCase combined words as individual words
  1001. #+BEGIN_SRC emacs-lisp
  1002. (use-package subword
  1003. :diminish subword-mode
  1004. :config
  1005. (add-hook 'python-mode-hook 'subword-mode))
  1006. #+END_SRC
  1007. ** Smartparens
  1008. Smartparens is a beast on its own, so it's worth having a dedicated section for it
  1009. #+BEGIN_SRC emacs-lisp
  1010. (use-package smartparens
  1011. :ensure t
  1012. :diminish smartparens-mode
  1013. :config
  1014. (add-hook 'prog-mode-hook 'smartparens-mode)
  1015. )
  1016. #+END_SRC
  1017. ** Git
  1018. *** Magit
  1019. [[https://magit.vc/manual/magit/index.html][Link]]
  1020. I want to do git stuff here, not in a separate terminal window
  1021. Little crashcourse in magit:
  1022. - magit-init to init a git project
  1023. - magit-status (C-x g) to call the status window
  1024. in status buffer:
  1025. - s stage files
  1026. - u unstage files
  1027. - U unstage all files
  1028. - a apply changed to staging
  1029. - c c commit (type commit message, then C-c C-c to commit)
  1030. - b b switch to another branch
  1031. - P u git push
  1032. - F u git pull
  1033. #+BEGIN_SRC emacs-lisp
  1034. (use-package magit
  1035. :ensure t
  1036. :defer t
  1037. :init
  1038. ;; set git-path in work environment
  1039. (if (string-equal user-login-name "POH")
  1040. (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe")
  1041. )
  1042. :defer t
  1043. :bind (("C-x g" . magit-status))
  1044. )
  1045. #+END_SRC
  1046. *** Git-gutter
  1047. Display line changes in gutter based on git history. Enable it everywhere
  1048. [[https://github.com/syohex/emacs-git-gutter][Source]]
  1049. #+BEGIN_SRC emacs-lisp
  1050. (use-package git-gutter
  1051. :ensure t
  1052. :defer t
  1053. :config
  1054. (global-git-gutter-mode t)
  1055. :diminish git-gutter-mode
  1056. )
  1057. #+END_SRC
  1058. Some persistent navigation in git-gutter is nice, so here's a hydra for it:
  1059. #+BEGIN_SRC emacs-lisp
  1060. (defhydra hydra-git-gutter (:body-pre (git-gutter-mode 1)
  1061. :hint nil)
  1062. "
  1063. ^Git Gutter^ ^Git^ ^misc^
  1064. ^──────────^────────^───^────────────────^────^──────────────────────────
  1065. _j_: next hunk _s_tage hunk _q_uit
  1066. _k_: previous hunk _r_evert hunk _g_ : call magit-status
  1067. _h_: first hunk _p_opup hunk
  1068. _l_: last hunk set start _R_evision
  1069. ^^ ^^ ^^
  1070. "
  1071. ("j" git-gutter:next-hunk)
  1072. ("k" git-gutter:previous-hunk)
  1073. ("h" (progn (goto-char (point-min))
  1074. (git-gutter:next-hunk 1)))
  1075. ("l" (progn (goto-char (point-min))
  1076. (git-gutter:previous-hunk 1)))
  1077. ("s" git-gutter:stage-hunk)
  1078. ("r" git-gutter:revert-hunk)
  1079. ("p" git-gutter:popup-hunk)
  1080. ("R" git-gutter:set-start-revision)
  1081. ("q" nil :color blue)
  1082. ("g" magit-status)
  1083. )
  1084. #+END_SRC
  1085. *** Git-timemachine
  1086. Time machine lets me step through the history of a file as recorded in git.
  1087. [[https://github.com/pidu/git-timemachine][Source]]
  1088. #+BEGIN_SRC emacs-lisp
  1089. (use-package git-timemachine
  1090. :ensure t
  1091. :defer t
  1092. )
  1093. #+END_SRC
  1094. ** Company Mode
  1095. Complete Anything!
  1096. Activate company and make it react nearly instantly
  1097. #+BEGIN_SRC emacs-lisp
  1098. (use-package company
  1099. :ensure t
  1100. :config
  1101. (setq-default company-minimum-prefix-length 1
  1102. company-tooltip-align-annotation t
  1103. company-tooltop-flip-when-above t
  1104. company-show-numbers t
  1105. company-idle-delay 0.1)
  1106. ;; (define-key company-active-map (kbd "TAB") #'company-complete-selection)
  1107. ;; (define-key company-active-map (kbd "RET") nil)
  1108. (company-tng-configure-default)
  1109. )
  1110. #+END_SRC
  1111. For a nicer suggestion box: company-box ([[https://github.com/sebastiencs/company-box][Source]])
  1112. It is only available for emacs 26 and higher.
  1113. #+BEGIN_SRC emacs-lisp
  1114. (when (> emacs-major-version 25)
  1115. (use-package company-box
  1116. :ensure t
  1117. :init
  1118. (add-hook 'company-mode-hook 'company-box-mode)))
  1119. #+END_SRC
  1120. *** Company backend hooks
  1121. Backend configuration for python-mode
  1122. Common backends are:
  1123. - company-files: files & directory
  1124. - company-keywords: keywords
  1125. - company-capf: ??
  1126. - company-abbrev: ??
  1127. - company-dabbrev: dynamic abbreviations
  1128. - company-ispell: ??
  1129. So far I cannot differenciate a true python mode and a source block of ipython in org-mode, so the python-mode-hook should include both completion backends.
  1130. #+BEGIN_SRC emacs-lisp
  1131. (defun company/python-mode-hook()
  1132. (message "company/python-mode-hook activated")
  1133. (set (make-local-variable 'company-backends)
  1134. '((company-ob-ipython company-lsp)))
  1135. ; '((company-ob-ipython company-jedi)))
  1136. ; '((company-jedi company-dabbrev-code company-yasnippet) company-capf company-files))
  1137. ; '((company-lsp company-yasnippet) company-capf company-dabbrev company-files))
  1138. (company-mode t)
  1139. )
  1140. #+END_SRC
  1141. I have yet to find the proper hook to call this.
  1142. #+BEGIN_SRC emacs-lisp
  1143. (defun company/ipython-mode-hook()
  1144. (message "company/ipython-mode-hook activated")
  1145. (set (make-local-variable 'company-backends)
  1146. '((company-ob-ipython)))
  1147. (company-mode t)
  1148. )
  1149. #+END_SRC
  1150. #+BEGIN_SRC emacs-lisp
  1151. (defun company/ess-mode-hook()
  1152. (message "company/ess-mode-hook activated")
  1153. ; (set (make-local-variable 'company-backends)
  1154. ; '((company-ess-backend company-R-args company-R-objects)))
  1155. (company-mode t))
  1156. #+END_SRC
  1157. (defun add-pcomplete-to-capf ()
  1158. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t))
  1159. ;; (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  1160. (add-hook 'org-mode-hook #'add-pcomplete-to-capf)
  1161. Backend for Orgmode
  1162. #+BEGIN_SRC emacs-lisp
  1163. (defun company/org-mode-hook()
  1164. (set (make-local-variable 'company-backends)
  1165. '(company-capf company-files))
  1166. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  1167. (message "company/org-mode-hook")
  1168. (company-mode t)
  1169. )
  1170. #+END_SRC
  1171. Backend configuration for lisp-mode
  1172. #+BEGIN_SRC emacs-lisp
  1173. (defun company/elisp-mode-hook()
  1174. (set (make-local-variable 'company-backends)
  1175. '((company-elisp company-dabbrev) company-capf company-files))
  1176. (company-mode t)
  1177. )
  1178. #+END_SRC
  1179. Backend configuration for beancount
  1180. #+BEGIN_SRC emacs-lisp
  1181. (defun company/beancount-mode-hook()
  1182. (set (make-local-variable 'company-backends)
  1183. '(company-beancount))
  1184. ; '((company-beancount company-dabbrev) company-capf company-files))
  1185. (company-mode t)
  1186. )
  1187. #+END_SRC
  1188. *** Misc Company packages
  1189. Addon to sort suggestions by usage
  1190. #+BEGIN_SRC emacs-lisp
  1191. (use-package company-statistics
  1192. :ensure t
  1193. :after company
  1194. :init
  1195. (setq company-statistics-file (concat PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el")
  1196. :config
  1197. (company-statistics-mode 1)
  1198. )
  1199. #+END_SRC
  1200. Get a popup with documentation of the completion candidate.
  1201. For the popups the package pos-tip.el is used and automatically installed.
  1202. [[https://github.com/expez/company-quickhelp][Company Quickhelp]]
  1203. [[https://www.emacswiki.org/emacs/PosTip][See here for Pos-Tip details]]
  1204. #+BEGIN_SRC emacs-lisp
  1205. (use-package company-quickhelp
  1206. :ensure t
  1207. :after company
  1208. :config
  1209. (company-quickhelp-mode 1)
  1210. )
  1211. #+END_SRC
  1212. Maybe add [[https://github.com/hlissner/emacs-company-dict][company-dict]]? It's a dictionary based on major modes, plus it has Yasnippet integration.
  1213. ** Flycheck
  1214. Show errors right away!
  1215. #+BEGIN_SRC emacs-lisp
  1216. (use-package flycheck
  1217. :ensure t
  1218. :diminish flycheck-mode " ✓"
  1219. :init
  1220. (setq flycheck-emacs-lisp-load-path 'inherit)
  1221. (add-hook 'after-init-hook #'global-flycheck-mode)
  1222. ; (add-hook 'python-mode-hook (lambda ()
  1223. ; (semantic-mode 1)
  1224. ; (flycheck-select-checker 'python-pylint)))
  1225. )
  1226. #+END_SRC
  1227. ** Projectile
  1228. Brings search functions on project level
  1229. #+BEGIN_SRC emacs-lisp
  1230. (use-package projectile
  1231. :ensure t
  1232. :defer t
  1233. :bind
  1234. (("C-c p p" . projectile-switch-project)
  1235. ("C-c p s s" . projectile-ag))
  1236. :init
  1237. (setq-default
  1238. projectile-cache-file (concat PATH_USER_LOCAL ".projectile-cache")
  1239. projectile-known-projects-file (concat PATH_USER_LOCAL ".projectile-bookmarks"))
  1240. :config
  1241. (projectile-mode t)
  1242. (setq-default
  1243. projectile-completion-system 'ivy
  1244. projectile-enable-caching t
  1245. projectile-mode-line '(:eval (projectile-project-name)))
  1246. )
  1247. #+END_SRC
  1248. ** Yasnippet
  1249. Snippets!
  1250. TODO: yas-minor-mode? what's that?
  1251. #+BEGIN_SRC emacs-lisp
  1252. (use-package yasnippet
  1253. :ensure t
  1254. :defer t
  1255. :diminish yas-minor-mode
  1256. :init
  1257. (yas-global-mode t)
  1258. (setq yas-snippet-dirs (concat PATH_USER_GLOBAL "snippets"))
  1259. :mode ("\\.yasnippet" . snippet-mode)
  1260. ; :config
  1261. ; (yas-reload-all) ;; ensure snippets are updated and available, necessary when not using global-mode
  1262. )
  1263. #+END_SRC
  1264. ** Lisp
  1265. Not sure about this one, but dynamic binding gets some bad vibes.
  1266. #+BEGIN_SRC emacs-lisp
  1267. (setq lexical-binding t)
  1268. #+END_SRC
  1269. #+BEGIN_SRC emacs-lisp
  1270. (add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook)
  1271. #+END_SRC
  1272. Add some helpers to handle and understand macros
  1273. #+BEGIN_SRC emacs-lisp
  1274. (use-package macrostep
  1275. :ensure t
  1276. :defer t
  1277. :init
  1278. (define-key emacs-lisp-mode-map (kbd "C-c e") 'macrostep-expand)
  1279. (define-key emacs-lisp-mode-map (kbd "C-c c") 'macrostep-collapse))
  1280. #+END_SRC
  1281. ** R
  1282. TODO: test it
  1283. For now only enable ESS at home. Not sure if it is useful at work.
  1284. Also I got "locate-file" errors at work; the debugger listet random files not related to anything within the emacs configuraion
  1285. #+BEGIN_SRC emacs-lisp
  1286. (pcase my/whoami
  1287. ("home"
  1288. (use-package ess-site
  1289. :ensure ess
  1290. :defer t
  1291. :mode (("\\.R\\'" . r-mode))
  1292. :init (require 'ess-site)
  1293. :config
  1294. (use-package ess-R-data-view :ensure t)
  1295. (use-package ess-smart-equals :ensure t)
  1296. (use-package ess-smart-underscore :ensure t)
  1297. (use-package ess-view :ensure t)
  1298. (setq ess-use-flymake nil
  1299. ess-use-ido nil ;;else ESS will use ido whenever possible
  1300. ess-eval-visibly 'nowait
  1301. ess-ask-for-ess-directory nil
  1302. ess-local-process-name "R"
  1303. ess-use-tracebug t
  1304. ess-describe-at-point-method 'tooltip))) ; 'tooltip or nil (buffer)
  1305. )
  1306. #+END_SRC
  1307. ** Lua
  1308. #+BEGIN_SRC emacs-lisp
  1309. (use-package lua-mode
  1310. :defer t
  1311. :ensure t
  1312. :mode "\\.lua\\'"
  1313. :config
  1314. (setq lua-indent-level 2))
  1315. #+END_SRC
  1316. ** Python
  1317. *** Intro
  1318. Systemwide following packages need to be installed:
  1319. - venv
  1320. - pylint / pylint3 (depending on default python version)
  1321. flycheck complains if no pylint is available and org tries to fontify python code natively.
  1322. The virtual environments need to have following modules installed:
  1323. - wheel (for some reason it isn't pulled by other packages, yet they complain about missing wheel)
  1324. - jedi
  1325. - epc
  1326. - pylint
  1327. *** Python-Mode
  1328. Automatically start python-mode when opening a .py-file.
  1329. Not sure if python.el is better than python-mode.el.
  1330. See [[https://github.com/jorgenschaefer/elpy/issues/887][here]] for info about ~python-shell-completion-native-enable~.
  1331. 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]].
  1332. Also limit the completion backends to those which make sense in Python.
  1333. #+BEGIN_SRC emacs-lisp
  1334. (use-package python
  1335. :mode ("\\.py\\'" . python-mode)
  1336. :interpreter ("python" . python-mode)
  1337. :defer t
  1338. :init
  1339. (add-hook 'python-mode-hook (lambda ()
  1340. 'company/python-mode-hook
  1341. (semantic-mode t)
  1342. (flycheck-select-checker 'python-pylint)))
  1343. :config
  1344. (setq python-shell-completion-native-enable nil)
  1345. )
  1346. #+END_SRC
  1347. *** IPython-Mode
  1348. Not sure if this configuraton will interfere with Python-Mode
  1349. #+BEGIN_SRC emacs-lisp
  1350. (use-package ob-ipython
  1351. :ensure t
  1352. :defer t
  1353. :init
  1354. (add-hook 'ob-ipython-mode-hook (lambda ()
  1355. 'company/ipython-mode-hook
  1356. (semantic-mode t)
  1357. (flycheck-select-checker 'pylint))))
  1358. #+END_SRC
  1359. *** Python language server (inactive)
  1360. On python side following needs to be installed:
  1361. - python-language-server[all]
  1362. First test for lsp-python.
  1363. Some intro: [[https://vxlabs.com/2018/06/08/python-language-server-with-emacs-and-lsp-mode/][Intro]]
  1364. Source python language server: [[https://github.com/palantir/python-language-server][Link]]
  1365. Source lsp-mode:
  1366. Source lsp-python: [[https://github.com/emacs-lsp/lsp-python][Link]]
  1367. Source company-lsp: [[https://github.com/tigersoldier/company-lsp][Link]]
  1368. Source lsp-ui: [[https://github.com/emacs-lsp/lsp-ui][Link]]
  1369. #+BEGIN_SRC emacs-lisp
  1370. (use-package lsp-mode
  1371. :ensure t
  1372. :config
  1373. ;; make sure we have lsp-imenu everywhere we have lsp
  1374. (require 'lsp-imenu)
  1375. (add-hook 'lsp-after-open-hook 'lsp-enable-imenu)
  1376. ;; get lsp-python-enable defined
  1377. ;; nb: use either projectile-project-root or ffip-get-project-root-directory
  1378. ;; or any other function that can be used to find the root dir of a project
  1379. (lsp-define-stdio-client lsp-python "python"
  1380. #'projectile-project-root
  1381. '("pyls"))
  1382. ;; make sure this is activated when python-mode is activated
  1383. ;; lsp-python-enable is created by macro above
  1384. (add-hook 'python-mode-hook
  1385. (lambda ()
  1386. (lsp-python-enable)
  1387. (company/python-mode-hook)))
  1388. ;; lsp extras
  1389. (use-package lsp-ui
  1390. :ensure t
  1391. :config
  1392. (setq lsp-ui-sideline-ignore-duplicate t)
  1393. (add-hook 'lsp-mode-hook 'lsp-ui-mode))
  1394. (use-package company-lsp
  1395. :ensure t)
  1396. ; :config
  1397. ; (push 'company-lsp company-backends))
  1398. ;; NB: only required if you prefer flake8 instead of the default
  1399. ;; send pyls config via lsp-after-initialize-hook -- harmless for
  1400. ;; other servers due to pyls key, but would prefer only sending this
  1401. ;; when pyls gets initialised (:initialize function in
  1402. ;; lsp-define-stdio-client is invoked too early (before server
  1403. ;; start))
  1404. (defun lsp-set-cfg ()
  1405. (let ((lsp-cfg `(:pyls (:configurationSources ("flake8")))))
  1406. ;; TODO: check lsp--cur-workspace here to decide per server / project
  1407. (lsp--set-configuration lsp-cfg)))
  1408. (add-hook 'lsp-after-initialize-hook 'lsp-set-cfg)
  1409. )
  1410. #+END_SRC
  1411. BEGIN_SRC emacs-lisp
  1412. (use-package lsp-mode
  1413. :ensure t
  1414. :defer t)
  1415. (add-hook 'lsp-mode-hook #'(lambda ()
  1416. (customize-set-variable 'lsp-enable-eldoc nil)
  1417. (flycheck-mode 1)
  1418. (company-mode 1)))
  1419. (use-package lsp-ui
  1420. :ensure t
  1421. :defer t)
  1422. (use-package company-lsp
  1423. :ensure t
  1424. :defer t)
  1425. (use-package lsp-python
  1426. :ensure t
  1427. :after lsp-mode
  1428. :defer t
  1429. :init
  1430. (add-hook 'python-mode-hook #'(lambda ()
  1431. (lsp-python-enable)
  1432. (flycheck-select-checker 'python-flake8))))
  1433. END_SRC
  1434. *** Jedi / Company
  1435. Jedi is a backend for python autocompletion and needs to be installed on the server:
  1436. - pip install jedi
  1437. Code checks need to be installed, too:
  1438. - pip install flake8
  1439. If jedi doesn't work, it might be a problem with jediepcserver.py.
  1440. See [[https://github.com/tkf/emacs-jedi/issues/293][here]]
  1441. To fix it:
  1442. - Figure out which jediepcserver is running (first guess is melpa/jedi-core../jediepcserver.py
  1443. - Change some code:
  1444. #+BEGIN_SRC python
  1445. 100 return dict(
  1446. 101 # p.get_code(False) should do the job. But jedi-vim use replace.
  1447. 102 # So follow what jedi.vim does...
  1448. 103 - params=[p.get_code().replace('\n', '') for p in call_def.params],
  1449. 103 + params=[p.name for p in call_def.params],
  1450. 104 index=call-def.index,
  1451. 105 - call_name=call_def.call_name,
  1452. 105 + call_name=call_def.name,
  1453. 106 )
  1454. #+END_SRC
  1455. BEGIN_SRC emacs-lisp
  1456. (use-package company-jedi
  1457. :defer t
  1458. ;; :after company
  1459. :ensure t
  1460. :config
  1461. (setq jedi:environment-virtualenv (list (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
  1462. (setq jedi:python-environment-directory (list (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
  1463. (add-hook 'python-mode-hook 'jedi:setup)
  1464. (setq jedi:complete-on-dot t)
  1465. (setq jedi:use-shortcuts t)
  1466. ;; (add-hook 'python-mode-hook 'company/python-mode-hook)
  1467. )
  1468. END_SRC
  1469. *** Virtual Environments
  1470. A wrapper to handle virtual environments.
  1471. I strongly recommend to install virtual environments on the terminal, not through this wrapper, but changing venvs is fine.
  1472. TODO: automatically start an inferior python process or switch to it if already created
  1473. #+BEGIN_SRC emacs-lisp
  1474. (use-package pyvenv
  1475. :ensure t
  1476. :defer t
  1477. :init
  1478. (setenv "WORKON_HOME" (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))
  1479. :config
  1480. (pyvenv-mode t)
  1481. (defun my/pyvenv-post-activate-hook()
  1482. ; (setq jedi:environment-root pyvenv-virtual-env)
  1483. ; (setq jedi:environment-virtualenv pyvenv-virtual-env)
  1484. ; (setq jedi:tooltip-method '(nil)) ;; variants: nil or pos-tip and/or popup
  1485. (setq python-shell-virtualenv-root pyvenv-virtual-env)
  1486. ;; default traceback, other option M-x jedi:toggle-log-traceback
  1487. ;; traceback is in jedi:pop-to-epc-buffer
  1488. ; (jedi:setup)
  1489. ;; (company/python-mode-hook)
  1490. ; (setq jedi:server-args '("--log-traceback"))
  1491. (message "pyvenv-post-activate-hook activated"))
  1492. (add-hook 'pyvenv-post-activate-hooks 'my/pyvenv-post-activate-hook)
  1493. )
  1494. #+END_SRC
  1495. I want Emacs to automatically start the proper virtual environment.
  1496. Required is a .python-version file with, content in the first line being /path/to/virtualenv/
  1497. [[https://github.com/marcwebbie/auto-virtualenv][Github source]]
  1498. Depends on pyvenv
  1499. #+BEGIN_SRC emacs-lisp
  1500. (use-package auto-virtualenv
  1501. :ensure t
  1502. ;; :after pyvenv
  1503. :defer t
  1504. :init
  1505. (add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv)
  1506. ;; activate on changing buffers
  1507. ;; (add-hook 'window-configuration-change-hook 'auto-virtualenv-set-virtualenv)
  1508. ;; activate on focus in
  1509. ;; (add-hook 'focus-in-hook 'auto-virtualenv-set-virtualenv)
  1510. )
  1511. #+END_SRC
  1512. *** Visuals
  1513. Highlight indentations
  1514. #+BEGIN_SRC emacs-lisp
  1515. (use-package highlight-indentation
  1516. :init
  1517. (add-hook 'python-mode-hook 'highlight-indentation-current-column-mode)
  1518. (add-hook 'python-mode-hook 'highlight-indentation-mode)
  1519. :config
  1520. (set-face-background 'highlight-indentation-face "#454545")
  1521. (set-face-background 'highlight-indentation-current-column-face "#656565"))
  1522. #+END_SRC
  1523. BEGIN_SRC emacs-lisp
  1524. (use-package highlight-indent-guides
  1525. :ensure t
  1526. :defer t
  1527. :init
  1528. (add-hook 'python-mode-hook 'highlight-indent-guides-mode)
  1529. :config
  1530. (setq highlight-indent-guides-method 'column ;'character
  1531. ;highlight-indent-guides-character ?\|
  1532. highlight-indent-guides-auto-odd-face-perc 15
  1533. highlight-indent-guides-auto-even-face-perc 15
  1534. highlight-indent-guides-auto-character-face-perc 20))
  1535. END_SRC
  1536. *** Anaconda (inactive)
  1537. Anaconda test
  1538. #+BEGIN_SRC emacs-lisp
  1539. ; (use-package anaconda-mode
  1540. ; :ensure t
  1541. ; :defer t
  1542. ; :init
  1543. ; (add-hook 'python-mode-hook 'anaconda-mode)
  1544. ;; (add-hook 'python-mode-hook 'anaconda-eldoc-mode)
  1545. ; :config
  1546. ; (setq anaconda-eldoc-mode 1)
  1547. ; )
  1548. #+END_SRC
  1549. #+BEGIN_SRC emacs-lisp
  1550. ; (use-package company-anaconda
  1551. ; :ensure t
  1552. ; :defer t
  1553. ; :init
  1554. ; (defun my/company-anaconda-hook()
  1555. ; (add-to-list 'company-backends 'company-anaconda))
  1556. ; (add-hook 'python-mode-hook 'my/company-anaconda-hook)
  1557. ; )
  1558. #+END_SRC
  1559. ** Latex
  1560. Requirements for Linux:
  1561. - Latex
  1562. - pdf-tools
  1563. The midnight mode hook is disabled for now, because CVs with my pic just look weird in this mode.
  1564. #+BEGIN_SRC emacs-lisp
  1565. (unless (string-equal my/whoami "work_remote")
  1566. (use-package pdf-tools
  1567. :ensure t
  1568. :defer t
  1569. :mode (("\\.pdf\\'" . pdf-view-mode))
  1570. :init
  1571. ; (add-hook 'pdf-view-mode-hook 'pdf-view-midnight-minor-mode)
  1572. :config
  1573. (pdf-tools-install)
  1574. (setq pdf-view-resize-factor 1.1 ;; more finegraned zoom
  1575. pdf-view-midnight-colors '("#c6c6c6" . "#363636")
  1576. TeX-view-program-selection '((output-pdf "pdf-tools"))
  1577. TeX-view-program-list '(("pdf-tools" "Tex-pdf-tools-sync-view")))
  1578. )
  1579. )
  1580. #+END_SRC
  1581. 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]]
  1582. Update 2018-03: It seems to work without this patch. I will keep it here in case something breaks again.
  1583. #+BEGIN_SRC
  1584. latex-preview-pane-update-p()
  1585. --- (doc-view-revert-buffer nil t)
  1586. +++ (revert-buffer-nil t 'preserve-modes)
  1587. #+END_SRC
  1588. After that M-x byte-compile-file
  1589. #+BEGIN_SRC emacs-lisp
  1590. (use-package latex-preview-pane
  1591. :ensure t
  1592. :defer t
  1593. :init
  1594. ;; one of these works
  1595. (add-hook 'LaTeX-mode-hook 'latex-preview-pane-mode)
  1596. (add-hook 'latex-mode-hook 'latex-preview-pane-mode)
  1597. (setq auto-mode-alist
  1598. (append '(("\\.tex$" . latex-mode)) auto-mode-alist))
  1599. )
  1600. ;; necessary, because linum-mode isn't compatible and prints errors
  1601. (add-hook 'pdf-view-mode-hook (lambda () (linum-mode -1)))
  1602. #+END_SRC
  1603. ** Markdown
  1604. Major mode to edit markdown files.
  1605. For previews it needs markdown installed on the system.
  1606. For debian:
  1607. #+BEGIN_EXAMPLE
  1608. sudo apt install markdown
  1609. #+END_EXAMPLE
  1610. #+BEGIN_SRC emacs-lisp
  1611. (use-package markdown-mode
  1612. :ensure t
  1613. :defer t)
  1614. #+END_SRC
  1615. ** Config languages
  1616. #+BEGIN_SRC emacs-lisp
  1617. (use-package nginx-mode
  1618. :ensure t
  1619. :defer t)
  1620. #+END_SRC
  1621. ** Hydra Flycheck
  1622. Flycheck is necessary, obviously
  1623. #+BEGIN_SRC emacs-lisp
  1624. (defhydra hydra-flycheck (:color blue)
  1625. "
  1626. ^
  1627. ^Flycheck^ ^Errors^ ^Checker^
  1628. ^────────^──────────^──────^────────────^───────^───────────
  1629. _q_ quit _<_ previous _?_ describe
  1630. _m_ manual _>_ next _d_ disable
  1631. _v_ verify setup _f_ check _s_ select
  1632. ^^ ^^ ^^
  1633. "
  1634. ("q" nil)
  1635. ("<" flycheck-previous-error :color red)
  1636. (">" flycheck-next-error :color red)
  1637. ("?" flycheck-describe-checker)
  1638. ("d" flycheck-disable-checker)
  1639. ("f" flycheck-buffer)
  1640. ("m" flycheck-manual)
  1641. ("s" flycheck-select-checker)
  1642. ("v" flycheck-verify-setup)
  1643. )
  1644. #+END_SRC
  1645. * Orchestrate the configuration
  1646. Some settings should be set for all systems, some need to be specific (like my job-emacs doesn't need development tools).
  1647. ** Common
  1648. ** Home
  1649. ** Work
  1650. I mainly only use org
  1651. ** Work, Hyper-V
  1652. For testing purproses I keep a working emacs in a debian on hyper-v. The demands here are different to the other work-emacs
  1653. * Finishing
  1654. Stuff which I want to run in the end
  1655. #+BEGIN_SRC emacs-lisp
  1656. (message (emacs-init-time))
  1657. #+END_SRC