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.

1472 lines
41 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 _g_ : call magit-status
  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. ("g" magit-status)
  437. )
  438. #+END_SRC
  439. * Undo
  440. #+BEGIN_SRC emacs-lisp
  441. (use-package undo-tree
  442. :ensure t
  443. :diminish undo-tree-mode
  444. :init
  445. (undo-tree-mode))
  446. #+END_SRC
  447. * Ido (currently inactive)
  448. better completion
  449. begin_src emacs-lisp
  450. (use-package ido
  451. :init
  452. (setq ido-enable-flex-matching t)
  453. (setq ido-everywhere t)
  454. (ido-mode t)
  455. (use-package ido-vertical-mode
  456. :ensure t
  457. :defer t
  458. :init
  459. (ido-vertical-mode 1)
  460. (setq ido-vertical-define-keys 'C-n-and-C-p-only)
  461. )
  462. )
  463. end_src
  464. * Recentf
  465. #+begin_src emacs-lisp
  466. (use-package recentf
  467. :init
  468. (setq recentf-save-file (concat PATH_USER_LOCAL "recentf"))
  469. :config
  470. (recentf-mode t)
  471. (setq recentf-max-saved-items 200)
  472. )
  473. #+end_src
  474. * ivy / counsel / swiper
  475. Flx is required for fuzzy-matching
  476. Is it really necessary?
  477. begin_src emacs-lisp
  478. (use-package flx)
  479. end_src
  480. Ivy displays a window with suggestions for hotkeys and M-x
  481. #+begin_src emacs-lisp
  482. (use-package ivy
  483. :ensure t
  484. :diminish
  485. (ivy-mode . "") ;; does not display ivy in the mode line
  486. :init
  487. (ivy-mode 1)
  488. :bind
  489. ("C-c C-r" . ivy-resume)
  490. :config
  491. (setq ivy-use-virtual-buffers t) ;; recent files and bookmarks in ivy-switch-buffer
  492. (setq ivy-height 20) ;; height of ivy window
  493. (setq ivy-count-format "%d/%d") ;; current and total number
  494. (setq ivy-re-builders-alist ;; regex replaces spaces with *
  495. '((t . ivy--regex-plus)))
  496. )
  497. #+end_src
  498. The find-file replacement is nicer to navigate
  499. #+begin_src emacs-lisp
  500. (use-package counsel
  501. :ensure t
  502. :bind* ;; load counsel when pressed
  503. (("M-x" . counsel-M-x)
  504. ("C-x C-f" . counsel-find-file)
  505. ("C-x C-r" . counsel-recentf)
  506. ("C-c C-f" . counsel-git)
  507. ("C-c h f" . counsel-describe-function)
  508. ("C-c h v" . counsel-describe-variable)
  509. ("M-i" . counsel-imenu)
  510. )
  511. )
  512. #+end_src
  513. Swiper ivy-enhances isearch
  514. #+begin_src emacs-lisp
  515. (use-package swiper
  516. :ensure t
  517. :bind
  518. (("C-s" . swiper)
  519. ("C-c C-r" . ivy-resume)
  520. )
  521. )
  522. #+end_src
  523. Ivy-Hydra adds stuff in minibuffer when you press C-o
  524. #+BEGIN_SRC emacs-lisp
  525. (use-package ivy-hydra
  526. :ensure t)
  527. #+END_SRC
  528. * Helm
  529. I placed it after ivy to override any configuration made by the former.
  530. This is just a try to see how it works differently.
  531. #+BEGIN_SRC emacs-lisp
  532. (use-package helm
  533. :ensure t
  534. :init
  535. (helm-mode 1)
  536. :bind
  537. ; (("M-x" . helm-M-x)
  538. ; ("C-x C-f" . helm-find-files)
  539. ; ("C-x C-r" . helm-recentf)
  540. ; ("C-x b" . helm-buffers-list))
  541. :config
  542. (setq helm-buffers-fuzzy-matching t)
  543. )
  544. (use-package helm-descbinds
  545. :ensure t
  546. :bind
  547. ("C-h b" . helm-descbinds))
  548. (use-package helm-projectile
  549. :ensure t
  550. :config
  551. (helm-projectile-on))
  552. #+END_SRC
  553. * Latex
  554. Requirements for Linux:
  555. - Latex
  556. - pdf-tools
  557. #+begin_src emacs-lisp
  558. (unless (string-equal user-login-name "POH")
  559. (use-package pdf-tools
  560. :ensure t
  561. :config
  562. (pdf-tools-install)
  563. (setq TeX-view-program-selection '((output-pdf "pdf-tools")))
  564. (setq TeX-view-program-list '(("pdf-tools" "Tex-pdf-tools-sync-view")))
  565. )
  566. )
  567. #+end_src
  568. 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]]
  569. Update 2018-03: It seems to work without this patch. I will keep it here in case something breaks again.
  570. #+begin_src
  571. latex-preview-pane-update-p()
  572. --- (doc-view-revert-buffer nil t)
  573. +++ (revert-buffer-nil t 'preserve-modes)
  574. #+end_src
  575. After that M-x byte-compile-file
  576. #+begin_src emacs-lisp
  577. (use-package latex-preview-pane
  578. :ensure t
  579. )
  580. (setq auto-mode-alist
  581. (append '(("\\.tex$" . latex-mode)) auto-mode-alist))
  582. ;; one of these works
  583. (add-hook 'LaTeX-mode-hook 'latex-preview-pane-mode)
  584. (add-hook 'latex-mode-hook 'latex-preview-pane-mode)
  585. ;; necessary, because linum-mode isn't compatible and prints errors
  586. (add-hook 'pdf-view-mode-hook (lambda () (linum-mode -1)))
  587. #+end_src
  588. * Markdown
  589. Major mode to edit markdown files.
  590. For previews it needs markdown installed on the system.
  591. For debian:
  592. #+BEGIN_SRC shell
  593. sudo apt install markdown
  594. #+END_SRC
  595. #+BEGIN_SRC emacs-lisp
  596. (use-package markdown-mode
  597. :ensure t)
  598. #+END_SRC
  599. * Emails
  600. Currently following tools are required:
  601. - notmuch (edit, read, tag, delete emails)
  602. - isync /mbsync (fetch or sync emails)
  603. 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.
  604. TODO:
  605. - setup of mbsync on linux
  606. - setup of notmuch on linux
  607. - shell script for installation of isync and notmuch
  608. - more config for notmuch?
  609. - hydra for notmuch?
  610. - maybe org-notmuch?
  611. - some way to refresh the notmuch db before I run notmuch?
  612. #+begin_src emacs-lisp
  613. (unless (string-equal user-login-name "POH")
  614. (use-package notmuch
  615. :ensure t
  616. )
  617. )
  618. #+end_src
  619. * Personal Finances
  620. I picked ledger for my personal accounting and will test if it's beneficial over gnucash.
  621. ..and don't activate the modules at work.
  622. #+begin_src emacs-lisp
  623. (unless (string-equal user-login-name "POH")
  624. (use-package ledger-mode
  625. :ensure t
  626. :mode ("\\.ledger$" . ledger-mode)
  627. :init
  628. (setq clear-whole-transactions t)
  629. )
  630. )
  631. #+end_src
  632. Ok, maybe beancount is better.
  633. Since there is no debian package, it is an option to install it via pip.
  634. I picked /opt for the installation path
  635. #+begin_src shell
  636. sudo su
  637. cd /opt
  638. python3 -m venv beancount
  639. source ./beancount/bin/activate
  640. pip3 install wheel
  641. pip3 install beancount
  642. deactivate
  643. #+end_src
  644. When using beancount, it will automatically pick the created virtual environment.
  645. Activate the beancount mode
  646. #+begin_src emacs-lisp
  647. (unless (string-equal user-login-name "POH")
  648. ;; (add-to-list 'package-archives
  649. ;; '("beancount" . "/opt/beancount/elisp") t)
  650. ; (use-package beancount
  651. ; :load-path "/opt/beancount/elisp/"
  652. ;; :ensure t
  653. ; :mode ("\\.beancount$" . beancount-mode)
  654. (load "/home/marc/.emacs.d/user-local/elisp/beancount-mode.el") ; somehow load-path in use-package doesn't work
  655. (use-package beancount
  656. :load-path "/home/marc/.emacs.d/elisp"
  657. :mode ("\\.beancount$" . beancount-mode)
  658. :init
  659. (add-hook 'beancount-mode-hook 'company/beancount-mode-hook)
  660. (setenv "PATH"
  661. (concat
  662. "/opt/beancount/bin:"
  663. (getenv "PATH"))
  664. )
  665. :config
  666. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/transactions.beancount")
  667. )
  668. )
  669. #+end_src
  670. For a nice frontend fava seems nice
  671. #+begin_src shell
  672. sudo su
  673. cd /opt
  674. python3 -m venv vava
  675. source ./vava/bin/activate
  676. pip3 install wheel
  677. pip3 install fava
  678. deactivate
  679. #+end_src
  680. Start fava with
  681. #+begin_src shell
  682. fava my_file.beancount
  683. #+end_src
  684. It is accessable on this URL: [[http://127.0.0.1:5000][Fava]]
  685. * Programming
  686. ** Common things
  687. List of plugins and settings which are shared between the language plugins
  688. Highlight whitespaces, tabs, empty lines.
  689. #+begin_src emacs-lisp
  690. (use-package whitespace
  691. :demand t
  692. :ensure nil
  693. :diminish whitespace-mode;;mode shall be active, but not shown in mode line
  694. :init
  695. (dolist (hook '(prog-mode-hook
  696. text-mode-hook
  697. conf-mode-hook))
  698. (add-hook hook #'whitespace-mode))
  699. ;; :hook ;;not working in use-package 2.3
  700. ;; ((prog-mode . whitespace-turn-on)
  701. ;; (text-mode . whitespace-turn-on))
  702. :config
  703. (setq-default whitespace-style '(face empty tab trailing))
  704. )
  705. #+end_src
  706. Disable Eldoc, it interferes with flycheck
  707. #+begin_src emacs-lisp
  708. (use-package eldoc
  709. :ensure nil
  710. :config
  711. (global-eldoc-mode -1)
  712. )
  713. #+end_src
  714. Colorize colors as text with their value
  715. #+begin_src emacs-lisp
  716. (use-package rainbow-mode
  717. :ensure t
  718. :init
  719. (add-hook 'prog-mode-hook 'rainbow-mode t)
  720. :diminish rainbow-mode
  721. ;; :hook prog-mode ;; not working in use-package 2.3
  722. :config
  723. (setq-default rainbow-x-colors-major-mode-list '())
  724. )
  725. #+end_src
  726. Highlight parens etc. for improved readability
  727. #+begin_src emacs-lisp
  728. (use-package rainbow-delimiters
  729. :ensure t
  730. :config
  731. (add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
  732. )
  733. #+end_src
  734. ** Smartparens
  735. Smartparens is a beast on its own, so it's worth having a dedicated section for it
  736. #+begin_src emacs-lisp
  737. (use-package smartparens
  738. :ensure t
  739. :diminish smartparens-mode
  740. :config
  741. (add-hook 'prog-mode-hook 'smartparens-mode)
  742. )
  743. #+end_src
  744. ** Git
  745. [[https://magit.vc/manual/magit/index.html][Link]]
  746. I want to do git stuff here, not in a separate terminal window
  747. Little crashcourse in magit:
  748. - magit-init to init a git project
  749. - magit-status (C-x g) to call the status window
  750. in status buffer:
  751. - s stage files
  752. - u unstage files
  753. - U unstage all files
  754. - a apply changed to staging
  755. - c c commit (type commit message, then C-c C-c to commit)
  756. - b b switch to another branch
  757. - P u git push
  758. - F u git pull
  759. #+begin_src emacs-lisp
  760. (use-package magit
  761. :ensure t
  762. :init
  763. ;; set git-path in work environment
  764. (if (string-equal user-login-name "POH")
  765. (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe")
  766. )
  767. :defer t
  768. :bind (("C-x g" . magit-status))
  769. )
  770. #+end_src
  771. Display line changes in gutter based on git history. Enable it everywhere
  772. [[https://github.com/syohex/emacs-git-gutter][Source]]
  773. #+begin_src emacs-lisp
  774. (use-package git-gutter
  775. :ensure t
  776. :config
  777. (global-git-gutter-mode t)
  778. :diminish git-gutter-mode
  779. )
  780. #+end_src
  781. Time machine lets me step through the history of a file as recorded in git.
  782. [[https://github.com/pidu/git-timemachine][Source]]
  783. #+begin_src emacs-lisp
  784. (use-package git-timemachine
  785. :ensure t
  786. )
  787. #+end_src
  788. ** Company Mode
  789. Complete Anything!
  790. Activate company and make it react nearly instantly
  791. #+begin_src emacs-lisp
  792. (use-package company
  793. :ensure t
  794. :config
  795. (setq-default company-minimum-prefix-length 1
  796. company-tooltip-align-annotation t
  797. company-tooltop-flip-when-above t
  798. company-show-numbers t
  799. company-idle-delay 0.1)
  800. ;; (define-key company-active-map (kbd "TAB") #'company-complete-selection)
  801. ;; (define-key company-active-map (kbd "RET") nil)
  802. (company-tng-configure-default)
  803. )
  804. #+end_src
  805. For a nicer suggestion box: company-box ([[https://github.com/sebastiencs/company-box][Source]])
  806. It is only available for emacs 26 and higher.
  807. #+begin_src emacs-lisp
  808. (when (> emacs-major-version 25)
  809. (use-package company-box
  810. :ensure t
  811. :init
  812. (add-hook 'company-mode-hook 'company-box-mode)))
  813. #+end_src
  814. *** Company backend hooks
  815. Backend configuration for python-mode
  816. Common backends are:
  817. - company-files: files & directory
  818. - company-keywords: keywords
  819. - company-capf: ??
  820. - company-abbrev: ??
  821. - company-dabbrev: dynamic abbreviations
  822. - company-ispell: ??
  823. #+begin_src emacs-lisp
  824. (defun company/python-mode-hook()
  825. (set (make-local-variable 'company-backends)
  826. '((company-jedi company-dabbrev company-yasnippet) company-capf company-files))
  827. ;; '((company-jedi company-dabbrev) company-capf company-files))
  828. (company-mode t)
  829. )
  830. #+end_src
  831. (defun add-pcomplete-to-capf ()
  832. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t))
  833. ;; (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  834. (add-hook 'org-mode-hook #'add-pcomplete-to-capf)
  835. Backend for Orgmode
  836. #+begin_src emacs-lisp
  837. (defun company/org-mode-hook()
  838. (set (make-local-variable 'company-backends)
  839. '(company-capf company-files))
  840. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  841. (company-mode t)
  842. )
  843. #+end_src
  844. Backend configuration for lisp-mode
  845. #+begin_src emacs-lisp
  846. (defun company/elisp-mode-hook()
  847. (set (make-local-variable 'company-backends)
  848. '((company-elisp company-dabbrev) company-capf company-files))
  849. (company-mode t)
  850. )
  851. #+end_src
  852. Backend configuration for beancount
  853. #+begin_src emacs-lisp
  854. (defun company/beancount-mode-hook()
  855. (set (make-local-variable 'company-backends)
  856. '(company-beancount))
  857. ; '((company-beancount company-dabbrev) company-capf company-files))
  858. (company-mode t)
  859. )
  860. #+end_src
  861. *** Misc Company packages
  862. Addon to sort suggestions by usage
  863. #+begin_src emacs-lisp
  864. (use-package company-statistics
  865. :ensure t
  866. :after company
  867. :init
  868. (setq company-statistics-file (concat PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el")
  869. :config
  870. (company-statistics-mode 1)
  871. )
  872. #+end_src
  873. Get a popup with documentation of the completion candidate.
  874. For the popups the package pos-tip.el is used and automatically installed.
  875. [[https://github.com/expez/company-quickhelp][Company Quickhelp]]
  876. [[https://www.emacswiki.org/emacs/PosTip][See here for Pos-Tip details]]
  877. #+begin_src emacs-lisp
  878. (use-package company-quickhelp
  879. :ensure t
  880. :after company
  881. :config
  882. (company-quickhelp-mode 1)
  883. )
  884. #+end_src
  885. Maybe add [[https://github.com/hlissner/emacs-company-dict][company-dict]]? It's a dictionary based on major modes, plus it has Yasnippet integration.
  886. ** Projectile
  887. Brings search functions on project level
  888. #+begin_src emacs-lisp
  889. (use-package projectile
  890. :ensure t
  891. :defer t
  892. :bind
  893. (("C-c p p" . projectile-switch-project)
  894. ("C-c p s s" . projectile-ag))
  895. :init
  896. (setq-default
  897. projectile-cache-file (concat PATH_USER_LOCAL ".projectile-cache")
  898. projectile-known-projects-file (concat PATH_USER_LOCAL ".projectile-bookmarks"))
  899. :config
  900. (projectile-mode t)
  901. (setq-default
  902. projectile-completion-system 'ivy
  903. projectile-enable-caching t
  904. projectile-mode-line '(:eval (projectile-project-name)))
  905. )
  906. #+end_src
  907. ** Yasnippet
  908. Snippets!
  909. TODO: yas-minor-mode? what's that?
  910. #+begin_src emacs-lisp
  911. (use-package yasnippet
  912. :ensure t
  913. :diminish yas-minor-mode
  914. :init
  915. (setq yas-snippet-dirs (concat PATH_USER_GLOBAL "snippets"))
  916. (yas-global-mode t)
  917. :mode ("\\.yasnippet" . snippet-mode)
  918. ; :config
  919. ; (yas-reload-all) ;; ensure snippets are updated and available, necessary when not using global-mode
  920. )
  921. #+end_src
  922. ** Lisp
  923. #+begin_src emacs-lisp
  924. (add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook)
  925. #+end_src
  926. Add some helpers to handle and understand macros
  927. #+begin_src emacs-lisp
  928. (use-package macrostep
  929. :ensure t
  930. :init
  931. (define-key emacs-lisp-mode-map (kbd "C-c e") 'macrostep-expand)
  932. (define-key emacs-lisp-mode-map (kbd "C-c c") 'macrostep-collapse))
  933. #+end_src
  934. ** Python
  935. Systemwide following packages need to be installed:
  936. - venv
  937. The virtual environments need to have following modules installed:
  938. - jedi
  939. - epc
  940. - pylint
  941. #+begin_src emacs-lisp
  942. (use-package flycheck
  943. :ensure t
  944. :diminish flycheck-mode " ✓"
  945. :init
  946. (setq flycheck-emacs-lisp-load-path 'inherit)
  947. (add-hook 'after-init-hook #'global-flycheck-mode)
  948. (add-hook 'python-mode-hook (lambda ()
  949. (semantic-mode 1)
  950. (flycheck-select-checker 'python-pylint)))
  951. )
  952. #+end_src
  953. Automatically start python-mode when opening a .py-file.
  954. Not sure if python.el is better than python-mode.el.
  955. See [[https://github.com/jorgenschaefer/elpy/issues/887][here]] for info about ~python-shell-completion-native-enable~.
  956. 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]].
  957. Also limit the completion backends to those which make sense in Python.
  958. #+begin_src emacs-lisp
  959. (use-package python
  960. :mode ("\\.py\\'" . python-mode)
  961. :interpreter ("python" . python-mode)
  962. :init
  963. (add-hook 'python-mode-hook 'company/python-mode-hook)
  964. :config
  965. (setq python-shell-completion-native-enable nil)
  966. )
  967. #+end_src
  968. Jedi is a backend for python autocompletion and needs to be installed on the server:
  969. - pip install jedi
  970. Code checks need to be installed, too:
  971. - pip install flake8
  972. #+begin_src emacs-lisp
  973. (use-package company-jedi
  974. :defer t
  975. ;; :after company
  976. :ensure t
  977. :config
  978. (setq jedi:environment-virtualenv (list (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
  979. (setq jedi:python-environment-directory (list (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
  980. (add-hook 'python-mode-hook 'jedi:setup)
  981. (setq jedi:complete-on-dot t)
  982. (setq jedi:use-shortcuts t)
  983. ;; (add-hook 'python-mode-hook 'company/python-mode-hook)
  984. )
  985. #+end_src
  986. A wrapper to handle virtual environments.
  987. I strongly recommend to install virtual environments on the terminal, not through this wrapper, but changing venvs is fine.
  988. TODO: automatically start an inferior python process or switch to it if already created
  989. #+begin_src emacs-lisp
  990. (use-package pyvenv
  991. :ensure t
  992. :init
  993. (setenv "WORKON_HOME" (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))
  994. :config
  995. (pyvenv-mode t)
  996. (defun my/post-activate-hook()
  997. (setq jedi:environment-root pyvenv-virtual-env)
  998. (setq jedi:environment-virtualenv pyvenv-virtual-env)
  999. (setq jedi:tooltip-method '(nil)) ;; variants: nil or pos-tip and/or popup
  1000. (setq python-shell-virtualenv-root pyvenv-virtual-env)
  1001. ;; default traceback, other option M-x jedi:toggle-log-traceback
  1002. ;; traceback is in jedi:pop-to-epc-buffer
  1003. (jedi:setup)
  1004. (company/python-mode-hook)
  1005. (setq jedi:server-args '("--log-traceback")))
  1006. ;; (add-to-list 'company-backends 'company-jedi)
  1007. ;; (add-to-list 'company-backends 'company-anaconda)
  1008. ;; (lambda ()
  1009. ;; (set (make-local-variable 'company-backends)
  1010. ;; '((company-jedi company-dabbrev) company-capf company-files)))
  1011. ;; (setq flycheck-checker 'python-pylint))
  1012. ;; (flycheck-select-checker 'python-pylint))
  1013. ;; (setq flycheck-checker 'python-flake8)
  1014. (add-hook 'pyvenv-post-activate-hooks 'my/post-activate-hook)
  1015. )
  1016. #+end_src
  1017. I want Emacs to automatically start the proper virtual environment.
  1018. Required is a .python-version file with, content in the first line being /path/to/virtualenv/
  1019. [[https://github.com/marcwebbie/auto-virtualenv][Github source]]
  1020. Depends on pyvenv
  1021. #+begin_src emacs-lisp
  1022. (use-package auto-virtualenv
  1023. :ensure t
  1024. ;; :after pyvenv
  1025. ;; :defer t
  1026. :init
  1027. (add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv)
  1028. ;; activate on changing buffers
  1029. ;; (add-hook 'window-configuration-change-hook 'auto-virtualenv-set-virtualenv)
  1030. ;; activate on focus in
  1031. ;; (add-hook 'focus-in-hook 'auto-virtualenv-set-virtualenv)
  1032. )
  1033. #+end_src
  1034. Anaconda test
  1035. begin_src emacs-lisp
  1036. (use-package anaconda-mode
  1037. :ensure t
  1038. :defer t
  1039. :init
  1040. (add-hook 'python-mode-hook 'anaconda-mode)
  1041. ;; (add-hook 'python-mode-hook 'anaconda-eldoc-mode)
  1042. :config
  1043. (setq anaconda-eldoc-mode 1)
  1044. )
  1045. end_src
  1046. begin_src emacs-lisp
  1047. (use-package company-anaconda
  1048. :ensure t
  1049. :defer t
  1050. :init
  1051. (defun my/company-anaconda-hook()
  1052. (add-to-list 'company-backends 'company-anaconda))
  1053. (add-hook 'python-mode-hook 'my/company-anaconda-hook)
  1054. )
  1055. end_src
  1056. ** Hydra Flycheck
  1057. Flycheck is necessary, obviously
  1058. #+begin_src emacs-lisp
  1059. (defhydra hydra-flycheck (:color blue)
  1060. "
  1061. ^
  1062. ^Flycheck^ ^Errors^ ^Checker^
  1063. ^────────^──────────^──────^────────────^───────^───────────
  1064. _q_ quit _<_ previous _?_ describe
  1065. _m_ manual _>_ next _d_ disable
  1066. _v_ verify setup _f_ check _s_ select
  1067. ^^ ^^ ^^
  1068. "
  1069. ("q" nil)
  1070. ("<" flycheck-previous-error :color red)
  1071. (">" flycheck-next-error :color red)
  1072. ("?" flycheck-describe-checker)
  1073. ("d" flycheck-disable-checker)
  1074. ("f" flycheck-buffer)
  1075. ("m" flycheck-manual)
  1076. ("s" flycheck-select-checker)
  1077. ("v" flycheck-verify-setup)
  1078. )
  1079. #+end_src
  1080. * Treemacs
  1081. A file manager comparable to neotree.
  1082. [[https://github.com/Alexander-Miller/treemacs][Github]]
  1083. It has some requirements, which gets used here anyway:
  1084. - ace-window
  1085. - hydra
  1086. - projectile
  1087. - python
  1088. I copied the configuration example from the github site.
  1089. No idea what this executable-find is about.
  1090. TODO check it out!
  1091. #+begin_src emacs-lisp
  1092. (use-package treemacs
  1093. :ensure t
  1094. :defer t
  1095. :config
  1096. (setq treemacs-change-root-without-asking nil
  1097. treemacs-collapse-dirs (if (executable-find "python") 3 0)
  1098. treemacs-file-event-delay 5000
  1099. treemacs-follow-after-init t
  1100. treemacs-follow-recenter-distance 0.1
  1101. treemacs-goto-tag-strategy 'refetch-index
  1102. treemacs-indentation 2
  1103. treemacs-indentation-string " "
  1104. treemacs-is-never-other-window nil
  1105. treemacs-never-persist nil
  1106. treemacs-no-png-images nil
  1107. treemacs-recenter-after-file-follow nil
  1108. treemacs-recenter-after-tag-follow nil
  1109. treemacs-show-hidden-files t
  1110. treemacs-silent-filewatch nil
  1111. treemacs-silent-refresh nil
  1112. treemacs-sorting 'alphabetic-desc
  1113. treemacs-tag-follow-cleanup t
  1114. treemacs-tag-follow-delay 1.5
  1115. treemacs-width 35)
  1116. (treemacs-follow-mode t)
  1117. (treemacs-filewatch-mode t)
  1118. (pcase (cons (not (null (executable-find "git")))
  1119. (not (null (executable-find "python3"))))
  1120. (`(t . t)
  1121. (treemacs-git-mode 'extended))
  1122. (`(t . _)
  1123. (treemacs-git-mode 'simple)))
  1124. :bind
  1125. (:map global-map
  1126. ([f8] . treemacs-toggle))
  1127. )
  1128. #+end_src
  1129. Treemacs-projectile is useful for uhh.. TODO explain!
  1130. #+begin_src emacs-lisp
  1131. (use-package treemacs-projectile
  1132. :ensure t
  1133. :defer t
  1134. :config
  1135. (setq treemacs-header-function #'treemacs-projectile-create-header)
  1136. )
  1137. #+end_src
  1138. TODO
  1139. Hydrastuff or keybindings for functions:
  1140. - treemacs-projectile
  1141. - treemacs-projectile-toggle
  1142. - treemacs-toggle
  1143. - treemacs-bookmark
  1144. - treemacs-find-file
  1145. - treemacs-find-tag
  1146. * Evil
  1147. So... Evil Mode might be worth a try
  1148. #+BEGIN_SRC emacs-lisp
  1149. (use-package evil
  1150. :ensure t
  1151. :defer .1 ;; don't block emacs when starting, load evil immediately after startup
  1152. :init
  1153. (setq evil-want-integration nil) ;; required by evil-collection
  1154. :config
  1155. (evil-mode 1)) ;; for now deactivate per default
  1156. #+END_SRC
  1157. Evil-collection is a bundle of configs for different modes.
  1158. 2018-05-01: evil collection causes error
  1159. "Invalid function: with-helm-buffer"
  1160. #+BEGIN_SRC emacs-lisp
  1161. ;(use-package evil-collection
  1162. ; :after evil
  1163. ; :ensure t
  1164. ; :config
  1165. ; (evil-collection-init))
  1166. #+END_SRC
  1167. Evil-goggles give visual hints when editing texts, so it's more obvious what is actually happening. [[https://github.com/edkolev/evil-goggles][Source]]
  1168. #+BEGIN_SRC emacs-lisp
  1169. (use-package evil-goggles
  1170. :after evil
  1171. :ensure t
  1172. :config
  1173. (evil-goggles-mode)
  1174. (evil-goggles-use-diff-faces))
  1175. #+END_SRC
  1176. * Window Handling
  1177. Some tools to easen the navigation, creation and deletion of windows
  1178. ** Ace-Window
  1179. #+begin_src emacs-lisp
  1180. (use-package ace-window
  1181. :ensure t
  1182. :init
  1183. (global-set-key (kbd "C-x o") 'ace-window)
  1184. )
  1185. #+end_src
  1186. ** Windmove
  1187. Windmove easens the navigation between windows.
  1188. Here we are setting the default keybindings (shift+arrow)
  1189. CURRENTLY NOT WORKING, defaults are blocked.
  1190. Also not sure if necessary when using ace-window.
  1191. #+begin_src emacs-lisp
  1192. (use-package windmove
  1193. :ensure t
  1194. :config
  1195. (windmove-default-keybindings)
  1196. )
  1197. #+end_src
  1198. * Custom key mappings
  1199. ** Escape stuff
  1200. Standard is C-g to exit. But with the coming introduction of evil, ESC should be the default key for escaping stuff.
  1201. #+BEGIN_SRC emacs-lisp
  1202. (defun minibuffer-keyboard-quit ()
  1203. "Abort recursive edit.
  1204. In Delete Selection mode, if the mark is active, just deactivate it;
  1205. then it takes a second \\[keyboard-quit] to abort the minibuffer."
  1206. (interactive)
  1207. (if (and delete-selection-mode transient-mark-mode mark-active)
  1208. (setq deactivate-mark t)
  1209. (when (get-buffer "*Completions*") (delete-windows-on "*Completions*"))
  1210. (abort-recursive-edit)))
  1211. (with-eval-after-load 'evil-maps
  1212. (define-key evil-normal-state-map [escape] 'keyboard-quit)
  1213. (define-key evil-visual-state-map [escape] 'keyboard-quit))
  1214. ;(with-eval-after-load 'swiper-map
  1215. ; (define-key ivy-minibuffer-map [escape] 'keyboard-quit)
  1216. ; (define-key swiper-map [escape] 'keyboard-quit)
  1217. ;)
  1218. (define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit)
  1219. (define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit)
  1220. (define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit)
  1221. (define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit)
  1222. (define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit)
  1223. (global-set-key [escape] 'evil-exit-emacs-state)
  1224. #+END_SRC
  1225. * Quality of Life
  1226. ** Default Window Size
  1227. #+BEGIN_SRC emacs-lisp
  1228. (if (display-graphic-p)
  1229. (progn
  1230. (setq initial-frame-alist
  1231. '(
  1232. (width . 165)
  1233. (height . 70)))
  1234. (setq default-frame-alist
  1235. '(
  1236. (width . 165)
  1237. (height . 70))))
  1238. )
  1239. #+END_SRC