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.

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