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.

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