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.

1476 lines
42 KiB

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