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.

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